forgotten debug statements

+ polishing of XDMF output
This commit is contained in:
Martin Diehl 2020-05-07 19:12:05 +02:00
parent c2b4f5516e
commit b75e98ca3f
1 changed files with 6 additions and 13 deletions

View File

@ -66,7 +66,7 @@ class Result:
self.Nmaterialpoints, self.Nconstituents = np.shape(f['mapping/cellResults/constituent']) self.Nmaterialpoints, self.Nconstituents = np.shape(f['mapping/cellResults/constituent'])
self.materialpoints = [m.decode() for m in np.unique(f['mapping/cellResults/materialpoint']['Name'])] self.materialpoints = [m.decode() for m in np.unique(f['mapping/cellResults/materialpoint']['Name'])]
self.constituents = [c.decode() for c in np.unique(f['mapping/cellResults/constituent'] ['Name'])] self.constituents = [c.decode() for c in np.unique(f['mapping/cellResults/constituent'] ['Name'])]
# faster, but does not work with (deprecated) DADF5_postResults # faster, but does not work with (deprecated) DADF5_postResults
#self.materialpoints = [m for m in f['inc0/materialpoint']] #self.materialpoints = [m for m in f['inc0/materialpoint']]
#self.constituents = [c for c in f['inc0/constituent']] #self.constituents = [c for c in f['inc0/constituent']]
@ -432,10 +432,8 @@ class Result:
""" """
with h5py.File(self.fname,'r') as f: with h5py.File(self.fname,'r') as f:
shape = (self.Nmaterialpoints,) + np.shape(f[path[0]])[1:] shape = (self.Nmaterialpoints,) + np.shape(f[path[0]])[1:]
print(path[0])
if len(shape) == 1: shape = shape +(1,) if len(shape) == 1: shape = shape +(1,)
dataset = np.full(shape,np.nan,dtype=np.dtype(f[path[0]])) dataset = np.full(shape,np.nan,dtype=np.dtype(f[path[0]]))
print('dataset shape', dataset.shape)
for pa in path: for pa in path:
label = pa.split('/')[2] label = pa.split('/')[2]
@ -443,19 +441,12 @@ class Result:
dataset = np.array(f[pa]) dataset = np.array(f[pa])
continue continue
print(label)
p = np.where(f['mapping/cellResults/constituent'][:,c]['Name'] == str.encode(label))[0] p = np.where(f['mapping/cellResults/constituent'][:,c]['Name'] == str.encode(label))[0]
print(len(p))
if len(p)>0: if len(p)>0:
u = (f['mapping/cellResults/constituent']['Position'][p,c]) u = (f['mapping/cellResults/constituent']['Position'][p,c])
print('pa',pa)
a = np.array(f[pa]) a = np.array(f[pa])
print(a.shape)
if len(a.shape) == 1: if len(a.shape) == 1:
a=a.reshape([a.shape[0],1]) a=a.reshape([a.shape[0],1])
print('u',u)
print('a[u]',a[u,:].shape)
print('dataset[p]',dataset[p,:].shape)
dataset[p,:] = a[u,:] dataset[p,:] = a[u,:]
p = np.where(f['mapping/cellResults/materialpoint']['Name'] == str.encode(label))[0] p = np.where(f['mapping/cellResults/materialpoint']['Name'] == str.encode(label))[0]
@ -1061,7 +1052,7 @@ class Result:
raise NotImplementedError raise NotImplementedError
xdmf=ET.Element('Xdmf') xdmf=ET.Element('Xdmf')
xdmf.attrib={'Version': '3.0', xdmf.attrib={'Version': '2.0',
'xmlns:xi': 'http://www.w3.org/2001/XInclude'} 'xmlns:xi': 'http://www.w3.org/2001/XInclude'}
domain=ET.SubElement(xdmf, 'Domain') domain=ET.SubElement(xdmf, 'Domain')
@ -1074,7 +1065,9 @@ class Result:
time.attrib={'TimeType': 'List'} time.attrib={'TimeType': 'List'}
time_data = ET.SubElement(time, 'DataItem') time_data = ET.SubElement(time, 'DataItem')
time_data.attrib={'Dimensions': '{}'.format(len(self.times))} time_data.attrib={'Format': 'XML',
'NumberType': 'Float',
'Dimensions': '{}'.format(len(self.times))}
time_data.text = ' '.join(map(str,self.times)) time_data.text = ' '.join(map(str,self.times))
attributes = [] attributes = []
@ -1087,7 +1080,7 @@ class Result:
'Name': inc} 'Name': inc}
topology=ET.SubElement(grid, 'Topology') topology=ET.SubElement(grid, 'Topology')
topology.attrib={'TopologyType': '3DCORECTMESH', topology.attrib={'TopologyType': '3DCoRectMesh',
'Dimensions': '{} {} {}'.format(*self.grid+1)} 'Dimensions': '{} {} {}'.format(*self.grid+1)}
geometry=ET.SubElement(grid, 'Geometry') geometry=ET.SubElement(grid, 'Geometry')