From 838a4ea5928da4bc771d917338cbf63f0d9573f7 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 18 Nov 2020 14:57:09 +0100 Subject: [PATCH] [skip ci] fix for scalar values --- python/damask/_result.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/python/damask/_result.py b/python/damask/_result.py index 0452cebe6..7ed2310d9 100644 --- a/python/damask/_result.py +++ b/python/damask/_result.py @@ -1198,17 +1198,18 @@ class Result: dtype = f[name].dtype prec = f[name].dtype.itemsize - if (shape not in [(1,), (3,), (3,3)]) or dtype != np.float64: continue + if (shape not in [(), (3,), (3,3)]) or dtype != np.float64: continue attributes.append(ET.SubElement(grid, 'Attribute')) attributes[-1].attrib={'Name': name.split('/',2)[2], 'Center': 'Cell', - 'AttributeType': 'Tensor'} + 'AttributeType': {():'Scalar',(3):'Vector',(3,3):'Tensor'}[shape]} data_items.append(ET.SubElement(attributes[-1], 'DataItem')) data_items[-1].attrib={'Format': 'HDF', 'NumberType': 'Float', 'Precision': f'{prec}', - 'Dimensions': '{} {} {} {}'.format(*self.grid,np.prod(shape))} + 'Dimensions': '{} {} {} {}'.format(*self.grid,1 if shape == () else + np.prod(shape))} data_items[-1].text=f'{os.path.split(self.fname)[1]}:{name}' with open(self.fname.with_suffix('.xdmf').name,'w') as f: