Merge remote-tracking branch 'origin/development' into vector-mechanics
This commit is contained in:
commit
cbe8160e13
2
PRIVATE
2
PRIVATE
|
@ -1 +1 @@
|
||||||
Subproject commit 5b2a0eb3e5ea0991d54ed9753804f45947cf61b4
|
Subproject commit 8bd09b5511d1e0e0ea288b47d16ce4924d75adcd
|
|
@ -20,9 +20,9 @@ parser.add_argument('filenames', nargs='+',
|
||||||
parser.add_argument('-d','--dir', dest='dir',default='postProc',metavar='string',
|
parser.add_argument('-d','--dir', dest='dir',default='postProc',metavar='string',
|
||||||
help='name of subdirectory relative to the location of the DADF5 file to hold output')
|
help='name of subdirectory relative to the location of the DADF5 file to hold output')
|
||||||
parser.add_argument('--mat', nargs='+',
|
parser.add_argument('--mat', nargs='+',
|
||||||
help='labels for materialpoint',dest='mat')
|
help='labels for homogenization',dest='mat')
|
||||||
parser.add_argument('--con', nargs='+',
|
parser.add_argument('--con', nargs='+',
|
||||||
help='labels for constituent',dest='con')
|
help='labels for phase',dest='con')
|
||||||
|
|
||||||
options = parser.parse_args()
|
options = parser.parse_args()
|
||||||
|
|
||||||
|
@ -41,15 +41,15 @@ for filename in options.filenames:
|
||||||
table = damask.Table(np.ones(np.product(results.grid),dtype=int)*int(inc[3:]),{'inc':(1,)})\
|
table = damask.Table(np.ones(np.product(results.grid),dtype=int)*int(inc[3:]),{'inc':(1,)})\
|
||||||
.add('pos',coords.reshape(-1,3))
|
.add('pos',coords.reshape(-1,3))
|
||||||
|
|
||||||
results.pick('materialpoints',False)
|
results.pick('homogenizations',False)
|
||||||
results.pick('constituents', True)
|
results.pick('phases',True)
|
||||||
for label in options.con:
|
for label in options.con:
|
||||||
x = results.get_dataset_location(label)
|
x = results.get_dataset_location(label)
|
||||||
if len(x) != 0:
|
if len(x) != 0:
|
||||||
table = table.add(label,results.read_dataset(x,0,plain=True).reshape(results.grid.prod(),-1))
|
table = table.add(label,results.read_dataset(x,0,plain=True).reshape(results.grid.prod(),-1))
|
||||||
|
|
||||||
results.pick('constituents', False)
|
results.pick('phases',False)
|
||||||
results.pick('materialpoints',True)
|
results.pick('homogenizations',True)
|
||||||
for label in options.mat:
|
for label in options.mat:
|
||||||
x = results.get_dataset_location(label)
|
x = results.get_dataset_location(label)
|
||||||
if len(x) != 0:
|
if len(x) != 0:
|
||||||
|
|
|
@ -42,14 +42,10 @@ class Result:
|
||||||
"""
|
"""
|
||||||
with h5py.File(fname,'r') as f:
|
with h5py.File(fname,'r') as f:
|
||||||
|
|
||||||
try:
|
self.version_major = f.attrs['DADF5_version_major']
|
||||||
self.version_major = f.attrs['DADF5_version_major']
|
self.version_minor = f.attrs['DADF5_version_minor']
|
||||||
self.version_minor = f.attrs['DADF5_version_minor']
|
|
||||||
except KeyError:
|
|
||||||
self.version_major = f.attrs['DADF5-major']
|
|
||||||
self.version_minor = f.attrs['DADF5-minor']
|
|
||||||
|
|
||||||
if self.version_major != 0 or not 2 <= self.version_minor <= 7:
|
if self.version_major != 0 or not 7 <= self.version_minor <= 8:
|
||||||
raise TypeError(f'Unsupported DADF5 version {self.version_major}.{self.version_minor}')
|
raise TypeError(f'Unsupported DADF5 version {self.version_major}.{self.version_minor}')
|
||||||
|
|
||||||
self.structured = 'grid' in f['geometry'].attrs.keys()
|
self.structured = 'grid' in f['geometry'].attrs.keys()
|
||||||
|
@ -57,35 +53,33 @@ class Result:
|
||||||
if self.structured:
|
if self.structured:
|
||||||
self.grid = f['geometry'].attrs['grid']
|
self.grid = f['geometry'].attrs['grid']
|
||||||
self.size = f['geometry'].attrs['size']
|
self.size = f['geometry'].attrs['size']
|
||||||
self.origin = f['geometry'].attrs['origin'] if self.version_major == 0 and self.version_minor >= 5 else \
|
self.origin = f['geometry'].attrs['origin']
|
||||||
np.zeros(3)
|
|
||||||
|
|
||||||
r=re.compile('inc[0-9]+')
|
r=re.compile('inc[0-9]+')
|
||||||
increments_unsorted = {int(i[3:]):i for i in f.keys() if r.match(i)}
|
increments_unsorted = {int(i[3:]):i for i in f.keys() if r.match(i)}
|
||||||
self.increments = [increments_unsorted[i] for i in sorted(increments_unsorted)]
|
self.increments = [increments_unsorted[i] for i in sorted(increments_unsorted)]
|
||||||
self.times = [round(f[i].attrs['time/s'],12) for i in self.increments]
|
self.times = [round(f[i].attrs['time/s'],12) for i in self.increments]
|
||||||
|
|
||||||
self.Nmaterialpoints, self.Nconstituents = np.shape(f['mapping/cellResults/constituent'])
|
self.N_materialpoints, self.N_constituents = np.shape(f['mapping/phase'])
|
||||||
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'])]
|
|
||||||
|
|
||||||
# faster, but does not work with (deprecated) DADF5_postResults
|
self.homogenizations = [m.decode() for m in np.unique(f['mapping/homogenization']['Name'])]
|
||||||
#self.materialpoints = [m for m in f['inc0/materialpoint']]
|
self.phases = [c.decode() for c in np.unique(f['mapping/phase']['Name'])]
|
||||||
#self.constituents = [c for c in f['inc0/constituent']]
|
|
||||||
|
|
||||||
self.con_physics = []
|
self.out_type_ph = []
|
||||||
for c in self.constituents:
|
for c in self.phases:
|
||||||
self.con_physics += f['/'.join([self.increments[0],'constituent',c])].keys()
|
self.out_type_ph += f['/'.join([self.increments[0],'phase',c])].keys()
|
||||||
self.con_physics = list(set(self.con_physics)) # make unique
|
self.out_type_ph = list(set(self.out_type_ph)) # make unique
|
||||||
|
|
||||||
self.mat_physics = []
|
self.out_type_ho = []
|
||||||
for m in self.materialpoints:
|
for m in self.homogenizations:
|
||||||
self.mat_physics += f['/'.join([self.increments[0],'materialpoint',m])].keys()
|
self.out_type_ho += f['/'.join([self.increments[0],'homogenization',m])].keys()
|
||||||
self.mat_physics = list(set(self.mat_physics)) # make unique
|
self.out_type_ho = list(set(self.out_type_ho)) # make unique
|
||||||
|
|
||||||
self.selection = {'increments': self.increments,
|
self.selection = {'increments': self.increments,
|
||||||
'constituents': self.constituents,'materialpoints': self.materialpoints,
|
'phases': self.phases,
|
||||||
'con_physics': self.con_physics, 'mat_physics': self.mat_physics
|
'homogenizations': self.homogenizations,
|
||||||
|
'out_type_ph': self.out_type_ph,
|
||||||
|
'out_type_ho': self.out_type_ho
|
||||||
}
|
}
|
||||||
|
|
||||||
self.fname = Path(fname).absolute()
|
self.fname = Path(fname).absolute()
|
||||||
|
@ -289,34 +283,34 @@ class Result:
|
||||||
# def datamerger(regular expression to filter groups into one copy)
|
# def datamerger(regular expression to filter groups into one copy)
|
||||||
|
|
||||||
|
|
||||||
def place(self,datasets,component=0,tagged=False,split=True):
|
def place(self,datasets,constituent=0,tagged=False,split=True):
|
||||||
"""
|
"""
|
||||||
Distribute datasets onto geometry and return Table or (split) dictionary of Tables.
|
Distribute datasets onto geometry and return Table or (split) dictionary of Tables.
|
||||||
|
|
||||||
Must not mix nodal end cell data.
|
Must not mix nodal end cell data.
|
||||||
|
|
||||||
Only data within
|
Only data within
|
||||||
- inc?????/constituent/*_*/*
|
- inc*/phase/*/*
|
||||||
- inc?????/materialpoint/*_*/*
|
- inc*/homogenization/*/*
|
||||||
- inc?????/geometry/*
|
- inc*/geometry/*
|
||||||
are considered.
|
are considered.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
datasets : iterable or str
|
datasets : iterable or str
|
||||||
component : int
|
constituent : int
|
||||||
homogenization component to consider for constituent data
|
Constituent to consider for phase data
|
||||||
tagged : bool
|
tagged : bool
|
||||||
tag Table.column name with '#component'
|
tag Table.column name with '#constituent'
|
||||||
defaults to False
|
defaults to False
|
||||||
split : bool
|
split : bool
|
||||||
split Table by increment and return dictionary of Tables
|
split Table by increment and return dictionary of Tables
|
||||||
defaults to True
|
defaults to True
|
||||||
|
|
||||||
"""
|
"""
|
||||||
sets = datasets if hasattr(datasets,'__iter__') and not isinstance(datasets,str) \
|
sets = datasets if hasattr(datasets,'__iter__') and not isinstance(datasets,str) else \
|
||||||
else [datasets]
|
[datasets]
|
||||||
tag = f'#{component}' if tagged else ''
|
tag = f'#{constituent}' if tagged else ''
|
||||||
tbl = {} if split else None
|
tbl = {} if split else None
|
||||||
inGeom = {}
|
inGeom = {}
|
||||||
inData = {}
|
inData = {}
|
||||||
|
@ -328,15 +322,15 @@ class Result:
|
||||||
key = '/'.join([prop,name+tag])
|
key = '/'.join([prop,name+tag])
|
||||||
if key not in inGeom:
|
if key not in inGeom:
|
||||||
if prop == 'geometry':
|
if prop == 'geometry':
|
||||||
inGeom[key] = inData[key] = np.arange(self.Nmaterialpoints)
|
inGeom[key] = inData[key] = np.arange(self.N_materialpoints)
|
||||||
elif prop == 'constituent':
|
elif prop == 'phase':
|
||||||
inGeom[key] = np.where(f['mapping/cellResults/constituent'][:,component]['Name'] == str.encode(name))[0]
|
inGeom[key] = np.where(f['mapping/phase'][:,constituent]['Name'] == str.encode(name))[0]
|
||||||
inData[key] = f['mapping/cellResults/constituent'][inGeom[key],component]['Position']
|
inData[key] = f['mapping/phase'][inGeom[key],constituent]['Position']
|
||||||
else:
|
elif prop == 'homogenization':
|
||||||
inGeom[key] = np.where(f['mapping/cellResults/materialpoint']['Name'] == str.encode(name))[0]
|
inGeom[key] = np.where(f['mapping/homogenization']['Name'] == str.encode(name))[0]
|
||||||
inData[key] = f['mapping/cellResults/materialpoint'][inGeom[key].tolist()]['Position']
|
inData[key] = f['mapping/homogenization'][inGeom[key].tolist()]['Position']
|
||||||
shape = np.shape(f[path])
|
shape = np.shape(f[path])
|
||||||
data = np.full((self.Nmaterialpoints,) + (shape[1:] if len(shape)>1 else (1,)),
|
data = np.full((self.N_materialpoints,) + (shape[1:] if len(shape)>1 else (1,)),
|
||||||
np.nan,
|
np.nan,
|
||||||
dtype=np.dtype(f[path]))
|
dtype=np.dtype(f[path]))
|
||||||
data[inGeom[key]] = (f[path] if len(shape)>1 else np.expand_dims(f[path],1))[inData[key]]
|
data[inGeom[key]] = (f[path] if len(shape)>1 else np.expand_dims(f[path],1))[inData[key]]
|
||||||
|
@ -345,12 +339,12 @@ class Result:
|
||||||
try:
|
try:
|
||||||
tbl[inc].add(path,data)
|
tbl[inc].add(path,data)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
tbl[inc] = Table(data.reshape(self.Nmaterialpoints,-1),{path:data.shape[1:]})
|
tbl[inc] = Table(data.reshape(self.N_materialpoints,-1),{path:data.shape[1:]})
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
tbl.add(path,data)
|
tbl.add(path,data)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
tbl = Table(data.reshape(self.Nmaterialpoints,-1),{path:data.shape[1:]})
|
tbl = Table(data.reshape(self.N_materialpoints,-1),{path:data.shape[1:]})
|
||||||
|
|
||||||
return tbl
|
return tbl
|
||||||
|
|
||||||
|
@ -360,8 +354,8 @@ class Result:
|
||||||
Return groups that contain all requested datasets.
|
Return groups that contain all requested datasets.
|
||||||
|
|
||||||
Only groups within
|
Only groups within
|
||||||
- inc*/constituent/*/*
|
- inc*/phase/*/*
|
||||||
- inc*/materialpoint/*/*
|
- inc*/homogenization/*/*
|
||||||
- inc*/geometry/*
|
- inc*/geometry/*
|
||||||
|
|
||||||
are considered as they contain user-relevant data.
|
are considered as they contain user-relevant data.
|
||||||
|
@ -393,7 +387,7 @@ class Result:
|
||||||
|
|
||||||
with h5py.File(self.fname,'r') as f:
|
with h5py.File(self.fname,'r') as f:
|
||||||
for i in self.iterate('increments'):
|
for i in self.iterate('increments'):
|
||||||
for o,p in zip(['constituents','materialpoints'],['con_physics','mat_physics']):
|
for o,p in zip(['phases','homogenizations'],['out_type_ph','out_type_ho']):
|
||||||
for oo in self.iterate(o):
|
for oo in self.iterate(o):
|
||||||
for pp in self.iterate(p):
|
for pp in self.iterate(p):
|
||||||
group = '/'.join([i,o[:-1],oo,pp]) # o[:-1]: plural/singular issue
|
group = '/'.join([i,o[:-1],oo,pp]) # o[:-1]: plural/singular issue
|
||||||
|
@ -412,7 +406,7 @@ class Result:
|
||||||
with h5py.File(self.fname,'r') as f:
|
with h5py.File(self.fname,'r') as f:
|
||||||
for i in self.iterate('increments'):
|
for i in self.iterate('increments'):
|
||||||
message += f'\n{i} ({self.times[self.increments.index(i)]}s)\n'
|
message += f'\n{i} ({self.times[self.increments.index(i)]}s)\n'
|
||||||
for o,p in zip(['constituents','materialpoints'],['con_physics','mat_physics']):
|
for o,p in zip(['phases','homogenizations'],['out_type_ph','out_type_ho']):
|
||||||
message += f' {o[:-1]}\n'
|
message += f' {o[:-1]}\n'
|
||||||
for oo in self.iterate(o):
|
for oo in self.iterate(o):
|
||||||
message += f' {oo}\n'
|
message += f' {oo}\n'
|
||||||
|
@ -446,7 +440,7 @@ class Result:
|
||||||
path.append(k)
|
path.append(k)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
for o,p in zip(['constituents','materialpoints'],['con_physics','mat_physics']):
|
for o,p in zip(['phases','homogenizations'],['out_type_ph','out_type_ho']):
|
||||||
for oo in self.iterate(o):
|
for oo in self.iterate(o):
|
||||||
for pp in self.iterate(p):
|
for pp in self.iterate(p):
|
||||||
k = '/'.join([i,o[:-1],oo,pp,label])
|
k = '/'.join([i,o[:-1],oo,pp,label])
|
||||||
|
@ -461,7 +455,7 @@ class Result:
|
||||||
def get_constituent_ID(self,c=0):
|
def get_constituent_ID(self,c=0):
|
||||||
"""Pointwise constituent ID."""
|
"""Pointwise constituent ID."""
|
||||||
with h5py.File(self.fname,'r') as f:
|
with h5py.File(self.fname,'r') as f:
|
||||||
names = f['/mapping/cellResults/constituent']['Name'][:,c].astype('str')
|
names = f['/mapping/phase']['Name'][:,c].astype('str')
|
||||||
return np.array([int(n.split('_')[0]) for n in names.tolist()],dtype=np.int32)
|
return np.array([int(n.split('_')[0]) for n in names.tolist()],dtype=np.int32)
|
||||||
|
|
||||||
|
|
||||||
|
@ -484,7 +478,7 @@ class Result:
|
||||||
If more than one path is given, the dataset is composed of the individual contributions.
|
If more than one path is given, the dataset is composed of the individual contributions.
|
||||||
"""
|
"""
|
||||||
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.N_materialpoints,) + np.shape(f[path[0]])[1:]
|
||||||
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]]))
|
||||||
for pa in path:
|
for pa in path:
|
||||||
|
@ -494,17 +488,17 @@ class Result:
|
||||||
dataset = np.array(f[pa])
|
dataset = np.array(f[pa])
|
||||||
continue
|
continue
|
||||||
|
|
||||||
p = np.where(f['mapping/cellResults/constituent'][:,c]['Name'] == str.encode(label))[0]
|
p = np.where(f['mapping/phase'][:,c]['Name'] == str.encode(label))[0]
|
||||||
if len(p)>0:
|
if len(p)>0:
|
||||||
u = (f['mapping/cellResults/constituent']['Position'][p,c])
|
u = (f['mapping/phase']['Position'][p,c])
|
||||||
a = np.array(f[pa])
|
a = np.array(f[pa])
|
||||||
if len(a.shape) == 1:
|
if len(a.shape) == 1:
|
||||||
a=a.reshape([a.shape[0],1])
|
a=a.reshape([a.shape[0],1])
|
||||||
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/homogenization']['Name'] == str.encode(label))[0]
|
||||||
if len(p)>0:
|
if len(p)>0:
|
||||||
u = (f['mapping/cellResults/materialpoint']['Position'][p.tolist()])
|
u = (f['mapping/homogenization']['Position'][p.tolist()])
|
||||||
a = np.array(f[pa])
|
a = np.array(f[pa])
|
||||||
if len(a.shape) == 1:
|
if len(a.shape) == 1:
|
||||||
a=a.reshape([a.shape[0],1])
|
a=a.reshape([a.shape[0],1])
|
||||||
|
@ -1134,7 +1128,7 @@ class Result:
|
||||||
This works only for scalar, 3-vector and 3x3-tensor data.
|
This works only for scalar, 3-vector and 3x3-tensor data.
|
||||||
Selection is not taken into account.
|
Selection is not taken into account.
|
||||||
"""
|
"""
|
||||||
if len(self.constituents) != 1 or not self.structured:
|
if self.N_constituents != 1 or not self.structured:
|
||||||
raise NotImplementedError('XDMF only available for grid results with 1 constituent.')
|
raise NotImplementedError('XDMF only available for grid results with 1 constituent.')
|
||||||
|
|
||||||
xdmf=ET.Element('Xdmf')
|
xdmf=ET.Element('Xdmf')
|
||||||
|
@ -1196,7 +1190,7 @@ class Result:
|
||||||
'Dimensions': '{} {} {} 3'.format(*(self.grid+1))}
|
'Dimensions': '{} {} {} 3'.format(*(self.grid+1))}
|
||||||
data_items[-1].text=f'{os.path.split(self.fname)[1]}:/{inc}/geometry/u_n'
|
data_items[-1].text=f'{os.path.split(self.fname)[1]}:/{inc}/geometry/u_n'
|
||||||
|
|
||||||
for o,p in zip(['constituents','materialpoints'],['con_physics','mat_physics']):
|
for o,p in zip(['phases','homogenizations'],['out_type_ph','out_type_ho']):
|
||||||
for oo in getattr(self,o):
|
for oo in getattr(self,o):
|
||||||
for pp in getattr(self,p):
|
for pp in getattr(self,p):
|
||||||
g = '/'.join([inc,o[:-1],oo,pp])
|
g = '/'.join([inc,o[:-1],oo,pp])
|
||||||
|
@ -1206,17 +1200,18 @@ class Result:
|
||||||
dtype = f[name].dtype
|
dtype = f[name].dtype
|
||||||
prec = f[name].dtype.itemsize
|
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.append(ET.SubElement(grid, 'Attribute'))
|
||||||
attributes[-1].attrib={'Name': name.split('/',2)[2],
|
attributes[-1].attrib={'Name': name.split('/',2)[2],
|
||||||
'Center': 'Cell',
|
'Center': 'Cell',
|
||||||
'AttributeType': 'Tensor'}
|
'AttributeType': {():'Scalar',(3):'Vector',(3,3):'Tensor'}[shape]}
|
||||||
data_items.append(ET.SubElement(attributes[-1], 'DataItem'))
|
data_items.append(ET.SubElement(attributes[-1], 'DataItem'))
|
||||||
data_items[-1].attrib={'Format': 'HDF',
|
data_items[-1].attrib={'Format': 'HDF',
|
||||||
'NumberType': 'Float',
|
'NumberType': 'Float',
|
||||||
'Precision': f'{prec}',
|
'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}'
|
data_items[-1].text=f'{os.path.split(self.fname)[1]}:{name}'
|
||||||
|
|
||||||
with open(self.fname.with_suffix('.xdmf').name,'w') as f:
|
with open(self.fname.with_suffix('.xdmf').name,'w') as f:
|
||||||
|
@ -1244,6 +1239,7 @@ class Result:
|
||||||
with h5py.File(self.fname,'r') as f:
|
with h5py.File(self.fname,'r') as f:
|
||||||
v = VTK.from_unstructured_grid(f['/geometry/x_n'][()],
|
v = VTK.from_unstructured_grid(f['/geometry/x_n'][()],
|
||||||
f['/geometry/T_c'][()]-1,
|
f['/geometry/T_c'][()]-1,
|
||||||
|
f['/geometry/T_c'].attrs['VTK_TYPE'] if h5py3 else \
|
||||||
f['/geometry/T_c'].attrs['VTK_TYPE'].decode())
|
f['/geometry/T_c'].attrs['VTK_TYPE'].decode())
|
||||||
elif mode.lower()=='point':
|
elif mode.lower()=='point':
|
||||||
v = VTK.from_poly_data(self.cell_coordinates)
|
v = VTK.from_poly_data(self.cell_coordinates)
|
||||||
|
@ -1252,45 +1248,39 @@ class Result:
|
||||||
|
|
||||||
for inc in util.show_progress(self.iterate('increments'),len(self.selection['increments'])):
|
for inc in util.show_progress(self.iterate('increments'),len(self.selection['increments'])):
|
||||||
|
|
||||||
materialpoints_backup = self.selection['materialpoints'].copy()
|
picked_backup_ho = self.selection['homogenizations'].copy()
|
||||||
self.pick('materialpoints',False)
|
self.pick('homogenizations',False)
|
||||||
for label in (labels if isinstance(labels,list) else [labels]):
|
for label in (labels if isinstance(labels,list) else [labels]):
|
||||||
for p in self.iterate('con_physics'):
|
for o in self.iterate('out_type_ph'):
|
||||||
if p != 'generic':
|
for c in range(self.N_constituents):
|
||||||
for c in self.iterate('constituents'):
|
prefix = '' if self.N_constituents == 1 else f'constituent{c}/'
|
||||||
x = self.get_dataset_location(label)
|
if o != 'mechanics':
|
||||||
if len(x) == 0:
|
for _ in self.iterate('phases'):
|
||||||
|
path = self.get_dataset_location(label)
|
||||||
|
if len(path) == 0:
|
||||||
|
continue
|
||||||
|
array = self.read_dataset(path,c)
|
||||||
|
v.add(array,prefix+path[0].split('/',1)[1])
|
||||||
|
else:
|
||||||
|
paths = self.get_dataset_location(label)
|
||||||
|
if len(paths) == 0:
|
||||||
continue
|
continue
|
||||||
array = self.read_dataset(x,0)
|
array = self.read_dataset(paths,c)
|
||||||
v.add(array,'1_'+x[0].split('/',1)[1]) #ToDo: hard coded 1!
|
ph_name = re.compile(r'(?<=(phase\/))(.*?)(?=(mechanics))') # identify phase name
|
||||||
else:
|
dset_name = prefix+re.sub(ph_name,r'',paths[0].split('/',1)[1]) # remove phase name
|
||||||
x = self.get_dataset_location(label)
|
v.add(array,dset_name)
|
||||||
if len(x) == 0:
|
self.pick('homogenizations',picked_backup_ho)
|
||||||
continue
|
|
||||||
array = self.read_dataset(x,0)
|
|
||||||
ph_name = re.compile(r'(?<=(constituent\/))(.*?)(?=(generic))') # identify phase name
|
|
||||||
dset_name = '1_' + re.sub(ph_name,r'',x[0].split('/',1)[1]) # removing phase name
|
|
||||||
v.add(array,dset_name)
|
|
||||||
self.pick('materialpoints',materialpoints_backup)
|
|
||||||
|
|
||||||
constituents_backup = self.selection['constituents'].copy()
|
picked_backup_ph = self.selection['phases'].copy()
|
||||||
self.pick('constituents',False)
|
self.pick('phases',False)
|
||||||
for label in (labels if isinstance(labels,list) else [labels]):
|
for label in (labels if isinstance(labels,list) else [labels]):
|
||||||
for p in self.iterate('mat_physics'):
|
for _ in self.iterate('out_type_ho'):
|
||||||
if p != 'generic':
|
paths = self.get_dataset_location(label)
|
||||||
for m in self.iterate('materialpoints'):
|
if len(paths) == 0:
|
||||||
x = self.get_dataset_location(label)
|
continue
|
||||||
if len(x) == 0:
|
array = self.read_dataset(paths)
|
||||||
continue
|
v.add(array,paths[0].split('/',1)[1])
|
||||||
array = self.read_dataset(x,0)
|
self.pick('phases',picked_backup_ph)
|
||||||
v.add(array,'1_'+x[0].split('/',1)[1]) #ToDo: why 1_?
|
|
||||||
else:
|
|
||||||
x = self.get_dataset_location(label)
|
|
||||||
if len(x) == 0:
|
|
||||||
continue
|
|
||||||
array = self.read_dataset(x,0)
|
|
||||||
v.add(array,'1_'+x[0].split('/',1)[1])
|
|
||||||
self.pick('constituents',constituents_backup)
|
|
||||||
|
|
||||||
u = self.read_dataset(self.get_dataset_location('u_n' if mode.lower() == 'cell' else 'u_p'))
|
u = self.read_dataset(self.get_dataset_location('u_n' if mode.lower() == 'cell' else 'u_p'))
|
||||||
v.add(u,'u')
|
v.add(u,'u')
|
||||||
|
|
|
@ -59,7 +59,7 @@ class TestResult:
|
||||||
f = default.get_dataset_location('F')
|
f = default.get_dataset_location('F')
|
||||||
assert a == b == c == d == e ==f
|
assert a == b == c == d == e ==f
|
||||||
|
|
||||||
@pytest.mark.parametrize('what',['increments','times','constituents']) # ToDo: discuss materialpoints
|
@pytest.mark.parametrize('what',['increments','times','phases']) # ToDo: discuss homogenizations
|
||||||
def test_pick_none(self,default,what):
|
def test_pick_none(self,default,what):
|
||||||
default.pick(what,False)
|
default.pick(what,False)
|
||||||
a = default.get_dataset_location('F')
|
a = default.get_dataset_location('F')
|
||||||
|
@ -68,7 +68,7 @@ class TestResult:
|
||||||
|
|
||||||
assert a == b == []
|
assert a == b == []
|
||||||
|
|
||||||
@pytest.mark.parametrize('what',['increments','times','constituents']) # ToDo: discuss materialpoints
|
@pytest.mark.parametrize('what',['increments','times','phases']) # ToDo: discuss homogenizations
|
||||||
def test_pick_more(self,default,what):
|
def test_pick_more(self,default,what):
|
||||||
default.pick(what,False)
|
default.pick(what,False)
|
||||||
default.pick_more(what,'*')
|
default.pick_more(what,'*')
|
||||||
|
@ -79,7 +79,7 @@ class TestResult:
|
||||||
|
|
||||||
assert a == b
|
assert a == b
|
||||||
|
|
||||||
@pytest.mark.parametrize('what',['increments','times','constituents']) # ToDo: discuss materialpoints
|
@pytest.mark.parametrize('what',['increments','times','phases']) # ToDo: discuss homogenizations
|
||||||
def test_pick_less(self,default,what):
|
def test_pick_less(self,default,what):
|
||||||
default.pick(what,True)
|
default.pick(what,True)
|
||||||
default.pick_less(what,'*')
|
default.pick_less(what,'*')
|
||||||
|
|
|
@ -225,7 +225,7 @@ module subroutine damage_results
|
||||||
do p = 1, size(material_name_phase)
|
do p = 1, size(material_name_phase)
|
||||||
|
|
||||||
sourceLoop: do i = 1, phase_Nsources(p)
|
sourceLoop: do i = 1, phase_Nsources(p)
|
||||||
group = trim('current/constituent')//'/'//trim(material_name_phase(p))
|
group = trim('current/phase')//'/'//trim(material_name_phase(p))
|
||||||
group = trim(group)//'/sources'
|
group = trim(group)//'/sources'
|
||||||
call results_closeGroup(results_addGroup(group))
|
call results_closeGroup(results_addGroup(group))
|
||||||
|
|
||||||
|
|
|
@ -457,7 +457,7 @@ module subroutine plastic_results
|
||||||
character(len=pStringLen) :: group
|
character(len=pStringLen) :: group
|
||||||
|
|
||||||
plasticityLoop: do p=1,size(material_name_phase)
|
plasticityLoop: do p=1,size(material_name_phase)
|
||||||
group = trim('current/constituent')//'/'//trim(material_name_phase(p))
|
group = trim('current/phase')//'/'//trim(material_name_phase(p))
|
||||||
call results_closeGroup(results_addGroup(group))
|
call results_closeGroup(results_addGroup(group))
|
||||||
|
|
||||||
group = trim(group)//'/plastic'
|
group = trim(group)//'/plastic'
|
||||||
|
|
|
@ -739,7 +739,7 @@ subroutine crystallite_results
|
||||||
character(len=:), allocatable :: group,structureLabel
|
character(len=:), allocatable :: group,structureLabel
|
||||||
|
|
||||||
do p=1,size(material_name_phase)
|
do p=1,size(material_name_phase)
|
||||||
group = trim('current/constituent')//'/'//trim(material_name_phase(p))//'/mechanics'
|
group = trim('current/phase')//'/'//trim(material_name_phase(p))//'/mechanics'
|
||||||
|
|
||||||
call results_closeGroup(results_addGroup(group))
|
call results_closeGroup(results_addGroup(group))
|
||||||
|
|
||||||
|
@ -772,11 +772,11 @@ subroutine crystallite_results
|
||||||
case('P')
|
case('P')
|
||||||
selected_tensors = select_tensors(crystallite_P,p)
|
selected_tensors = select_tensors(crystallite_P,p)
|
||||||
call results_writeDataset(group,selected_tensors,output_constituent(p)%label(o),&
|
call results_writeDataset(group,selected_tensors,output_constituent(p)%label(o),&
|
||||||
'First Piola-Kirchoff stress','Pa')
|
'First Piola-Kirchhoff stress','Pa')
|
||||||
case('S')
|
case('S')
|
||||||
selected_tensors = select_tensors(crystallite_S,p)
|
selected_tensors = select_tensors(crystallite_S,p)
|
||||||
call results_writeDataset(group,selected_tensors,output_constituent(p)%label(o),&
|
call results_writeDataset(group,selected_tensors,output_constituent(p)%label(o),&
|
||||||
'Second Piola-Kirchoff stress','Pa')
|
'Second Piola-Kirchhoff stress','Pa')
|
||||||
case('O')
|
case('O')
|
||||||
select case(lattice_structure(p))
|
select case(lattice_structure(p))
|
||||||
case(lattice_ISO_ID)
|
case(lattice_ISO_ID)
|
||||||
|
@ -1553,16 +1553,16 @@ subroutine crystallite_restartWrite
|
||||||
call HDF5_write(fileHandle,crystallite_Li, 'L_i')
|
call HDF5_write(fileHandle,crystallite_Li, 'L_i')
|
||||||
call HDF5_write(fileHandle,crystallite_S, 'S')
|
call HDF5_write(fileHandle,crystallite_S, 'S')
|
||||||
|
|
||||||
groupHandle = HDF5_addGroup(fileHandle,'constituent')
|
groupHandle = HDF5_addGroup(fileHandle,'phase')
|
||||||
do i = 1,size(material_name_phase)
|
do i = 1,size(material_name_phase)
|
||||||
write(datasetName,'(i0,a)') i,'_omega_plastic'
|
write(datasetName,'(i0,a)') i,'_omega'
|
||||||
call HDF5_write(groupHandle,plasticState(i)%state,datasetName)
|
call HDF5_write(groupHandle,plasticState(i)%state,datasetName)
|
||||||
enddo
|
enddo
|
||||||
call HDF5_closeGroup(groupHandle)
|
call HDF5_closeGroup(groupHandle)
|
||||||
|
|
||||||
groupHandle = HDF5_addGroup(fileHandle,'materialpoint')
|
groupHandle = HDF5_addGroup(fileHandle,'homogenization')
|
||||||
do i = 1, size(material_name_homogenization)
|
do i = 1, size(material_name_homogenization)
|
||||||
write(datasetName,'(i0,a)') i,'_omega_homogenization'
|
write(datasetName,'(i0,a)') i,'_omega'
|
||||||
call HDF5_write(groupHandle,homogState(i)%state,datasetName)
|
call HDF5_write(groupHandle,homogState(i)%state,datasetName)
|
||||||
enddo
|
enddo
|
||||||
call HDF5_closeGroup(groupHandle)
|
call HDF5_closeGroup(groupHandle)
|
||||||
|
@ -1594,16 +1594,16 @@ subroutine crystallite_restartRead
|
||||||
call HDF5_read(fileHandle,crystallite_Li0,'L_i')
|
call HDF5_read(fileHandle,crystallite_Li0,'L_i')
|
||||||
call HDF5_read(fileHandle,crystallite_S0, 'S')
|
call HDF5_read(fileHandle,crystallite_S0, 'S')
|
||||||
|
|
||||||
groupHandle = HDF5_openGroup(fileHandle,'constituent')
|
groupHandle = HDF5_openGroup(fileHandle,'phase')
|
||||||
do i = 1,size(material_name_phase)
|
do i = 1,size(material_name_phase)
|
||||||
write(datasetName,'(i0,a)') i,'_omega_plastic'
|
write(datasetName,'(i0,a)') i,'_omega'
|
||||||
call HDF5_read(groupHandle,plasticState(i)%state0,datasetName)
|
call HDF5_read(groupHandle,plasticState(i)%state0,datasetName)
|
||||||
enddo
|
enddo
|
||||||
call HDF5_closeGroup(groupHandle)
|
call HDF5_closeGroup(groupHandle)
|
||||||
|
|
||||||
groupHandle = HDF5_openGroup(fileHandle,'materialpoint')
|
groupHandle = HDF5_openGroup(fileHandle,'homogenization')
|
||||||
do i = 1,size(material_name_homogenization)
|
do i = 1,size(material_name_homogenization)
|
||||||
write(datasetName,'(i0,a)') i,'_omega_homogenization'
|
write(datasetName,'(i0,a)') i,'_omega'
|
||||||
call HDF5_read(groupHandle,homogState(i)%state0,datasetName)
|
call HDF5_read(groupHandle,homogState(i)%state0,datasetName)
|
||||||
enddo
|
enddo
|
||||||
call HDF5_closeGroup(groupHandle)
|
call HDF5_closeGroup(groupHandle)
|
||||||
|
|
|
@ -534,7 +534,7 @@ subroutine homogenization_results
|
||||||
!real(pReal), dimension(:,:,:), allocatable :: temp
|
!real(pReal), dimension(:,:,:), allocatable :: temp
|
||||||
|
|
||||||
do p=1,size(material_name_homogenization)
|
do p=1,size(material_name_homogenization)
|
||||||
group_base = 'current/materialpoint/'//trim(material_name_homogenization(p))
|
group_base = 'current/homogenization/'//trim(material_name_homogenization(p))
|
||||||
call results_closeGroup(results_addGroup(group_base))
|
call results_closeGroup(results_addGroup(group_base))
|
||||||
|
|
||||||
group = trim(group_base)//'/generic'
|
group = trim(group_base)//'/generic'
|
||||||
|
|
|
@ -387,7 +387,7 @@ end subroutine sanityCheck
|
||||||
|
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
!> @brief Get all keys from a dictionary (currently with #_ prefix)
|
!> @brief Get all keys from a dictionary
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
function getKeys(dict)
|
function getKeys(dict)
|
||||||
|
|
||||||
|
@ -395,12 +395,10 @@ function getKeys(dict)
|
||||||
character(len=pStringLen), dimension(:), allocatable :: getKeys
|
character(len=pStringLen), dimension(:), allocatable :: getKeys
|
||||||
|
|
||||||
integer :: i
|
integer :: i
|
||||||
character(len=pStringLen) :: sectionName
|
|
||||||
|
|
||||||
allocate(getKeys(dict%length))
|
allocate(getKeys(dict%length))
|
||||||
do i=1, dict%length
|
do i=1, dict%length
|
||||||
write(sectionName,'(i0,a)') i,'_'
|
getKeys(i) = dict%getKey(i)
|
||||||
getKeys(i) = trim(adjustl(sectionName))//dict%getKey(i) !ToDo: remove prefix
|
|
||||||
enddo
|
enddo
|
||||||
|
|
||||||
end function getKeys
|
end function getKeys
|
||||||
|
|
|
@ -74,12 +74,11 @@ subroutine results_init(restart)
|
||||||
if(.not. restart) then
|
if(.not. restart) then
|
||||||
resultsFile = HDF5_openFile(trim(getSolverJobName())//'.hdf5','w',.true.)
|
resultsFile = HDF5_openFile(trim(getSolverJobName())//'.hdf5','w',.true.)
|
||||||
call results_addAttribute('DADF5_version_major',0)
|
call results_addAttribute('DADF5_version_major',0)
|
||||||
call results_addAttribute('DADF5_version_minor',7)
|
call results_addAttribute('DADF5_version_minor',8)
|
||||||
call results_addAttribute('DAMASK_version',DAMASKVERSION)
|
call results_addAttribute('DAMASK_version',DAMASKVERSION)
|
||||||
call get_command(commandLine)
|
call get_command(commandLine)
|
||||||
call results_addAttribute('call',trim(commandLine))
|
call results_addAttribute('call',trim(commandLine))
|
||||||
call results_closeGroup(results_addGroup('mapping'))
|
call results_closeGroup(results_addGroup('mapping'))
|
||||||
call results_closeGroup(results_addGroup('mapping/cellResults'))
|
|
||||||
call results_closeJobFile
|
call results_closeJobFile
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -122,12 +121,6 @@ subroutine results_addIncrement(inc,time)
|
||||||
call results_closeGroup(results_addGroup('current/phase'))
|
call results_closeGroup(results_addGroup('current/phase'))
|
||||||
call results_closeGroup(results_addGroup('current/homogenization'))
|
call results_closeGroup(results_addGroup('current/homogenization'))
|
||||||
|
|
||||||
! for backward compatibility
|
|
||||||
call results_setLink(trim('/inc'//trim(adjustl(incChar)))//'/phase',&
|
|
||||||
trim('/inc'//trim(adjustl(incChar)))//'/constituent')
|
|
||||||
call results_setLink(trim('/inc'//trim(adjustl(incChar)))//'/homogenization',&
|
|
||||||
trim('/inc'//trim(adjustl(incChar)))//'/materialpoint')
|
|
||||||
|
|
||||||
end subroutine results_addIncrement
|
end subroutine results_addIncrement
|
||||||
|
|
||||||
|
|
||||||
|
@ -656,9 +649,6 @@ subroutine results_mapping_constituent(phaseAt,memberAtLocal,label)
|
||||||
if(hdferr < 0) error stop 'HDF5 error'
|
if(hdferr < 0) error stop 'HDF5 error'
|
||||||
call h5tclose_f(position_id, hdferr)
|
call h5tclose_f(position_id, hdferr)
|
||||||
|
|
||||||
! for backward compatibility
|
|
||||||
call results_setLink('/mapping/phase','/mapping/cellResults/constituent')
|
|
||||||
|
|
||||||
end subroutine results_mapping_constituent
|
end subroutine results_mapping_constituent
|
||||||
|
|
||||||
|
|
||||||
|
@ -814,9 +804,6 @@ subroutine results_mapping_homogenization(homogenizationAt,memberAtLocal,label)
|
||||||
call h5tclose_f(position_id, hdferr)
|
call h5tclose_f(position_id, hdferr)
|
||||||
if(hdferr < 0) error stop 'HDF5 error'
|
if(hdferr < 0) error stop 'HDF5 error'
|
||||||
|
|
||||||
! for backward compatibility
|
|
||||||
call results_setLink('/mapping/homogenization','/mapping/cellResults/materialpoint')
|
|
||||||
|
|
||||||
end subroutine results_mapping_homogenization
|
end subroutine results_mapping_homogenization
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue