From 885aeb62e58f954c57c0772b7fd08b76df889b49 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 3 Apr 2021 08:58:22 +0200 Subject: [PATCH] geometry0 itself is useful can be combined with 'place' if in-memory VTK is required for spatial operations --- python/damask/_result.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/python/damask/_result.py b/python/damask/_result.py index b3e803972..fcf178f44 100644 --- a/python/damask/_result.py +++ b/python/damask/_result.py @@ -530,6 +530,17 @@ class Result: with h5py.File(self.fname,'r') as f: return f['geometry/x_n'][()] + @property + def geometry0(self): + if self.structured: + return VTK.from_rectilinear_grid(self.cells,self.size,self.origin) + else: + with h5py.File(self.fname,'r') as f: + return VTK.from_unstructured_grid(f['/geometry/x_n'][()], + f['/geometry/T_c'][()]-1, + f['/geometry/T_c'].attrs['VTK_TYPE'] if h5py3 else \ + f['/geometry/T_c'].attrs['VTK_TYPE'].decode()) + @staticmethod def _add_absolute(x): @@ -1267,15 +1278,7 @@ class Result: """ if mode.lower()=='cell': - - if self.structured: - v = VTK.from_rectilinear_grid(self.cells,self.size,self.origin) - else: - with h5py.File(self.fname,'r') as f: - v = VTK.from_unstructured_grid(f['/geometry/x_n'][()], - f['/geometry/T_c'][()]-1, - f['/geometry/T_c'].attrs['VTK_TYPE'] if h5py3 else \ - f['/geometry/T_c'].attrs['VTK_TYPE'].decode()) + v = self.geometry0 elif mode.lower()=='point': v = VTK.from_poly_data(self.coordinates0_point)