From 2751cdb6afb4c0c9adcdd8308682d65214448bb4 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 25 Aug 2020 00:40:14 +0200 Subject: [PATCH] support comments also in vtr --- python/damask/_geom.py | 4 +++- python/damask/_vtk.py | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/python/damask/_geom.py b/python/damask/_geom.py index 8d98700c4..7185f0963 100644 --- a/python/damask/_geom.py +++ b/python/damask/_geom.py @@ -359,11 +359,12 @@ class Geom: """ v = VTK.from_file(fname if str(fname).endswith('.vtr') else str(fname)+'.vtr') + comments = v.get_comments() grid = np.array(v.geom.GetDimensions())-1 bbox = np.array(v.geom.GetBounds()).reshape(3,2).T size = bbox[1] - bbox[0] - return Geom(v.get('materialpoint').reshape(grid,order='F'),size,bbox[0]) + return Geom(v.get('materialpoint').reshape(grid,order='F'),size,bbox[0],comments=comments) @staticmethod @@ -527,6 +528,7 @@ class Geom: """ v = VTK.from_rectilinearGrid(self.grid,self.size,self.origin) v.add(self.microstructure.flatten(order='F'),'materialpoint') + v.add_comments(self.comments) if fname: v.write(fname if str(fname).endswith('.vtr') else str(fname)+'.vtr') diff --git a/python/damask/_vtk.py b/python/damask/_vtk.py index 15a571f4f..cccfc5524 100644 --- a/python/damask/_vtk.py +++ b/python/damask/_vtk.py @@ -284,7 +284,7 @@ class VTK: def set_comments(self,comments): """ - Set Comments. + Set comments. Parameters ---------- @@ -301,7 +301,7 @@ class VTK: def add_comments(self,comments): """ - Add Comments. + Add comments. Parameters ---------- @@ -309,7 +309,7 @@ class VTK: Comments to add. """ - self.set_comments(self.get_comments + ([comments] if isinstance(comments,str) else comments)) + self.set_comments(self.get_comments() + ([comments] if isinstance(comments,str) else comments)) def __repr__(self):