polishing

This commit is contained in:
Martin Diehl 2021-03-12 08:43:57 +01:00
parent 3b27c64709
commit ec28fd8a73
2 changed files with 16 additions and 20 deletions

View File

@ -98,8 +98,8 @@ class ConfigMaterial(Config):
@staticmethod @staticmethod
def load_from_Dream3D(fname,base_group,data_group,ori_data,phase_id,phase_name): def load_DREAM3D(fname,base_group,data_group,ori_data,phase_id,phase_name):
r""" """
Load material data from DREAM3D file. Load material data from DREAM3D file.
The parts of homogenization and phase need to be added by the user. The parts of homogenization and phase need to be added by the user.
@ -128,37 +128,34 @@ class ConfigMaterial(Config):
for grain based data with single phase for grain based data with single phase
>>> import damask >>> import damask
>>> import damask.ConfigMaterial as cm >>> import damask.ConfigMaterial as cm
>>> cm.load_from_Dream3D('20grains16x16x16.dream3D','SyntheticVolumeDataContainer', 'Grain Data'\ >>> cm.load_from_Dream3D('20grains16x16x16.dream3D','SyntheticVolumeDataContainer', 'Grain Data',
'EulerAngles','Phases',['Ferrite']) ... 'EulerAngles','Phases',['Ferrite'])
for point based data with single phase for point based data with single phase
>>> import damask >>> import damask
>>> import damask.ConfigMaterial as cm >>> import damask.ConfigMaterial as cm
>>> cm.load_from_Dream3D('20grains16x16x16.dream3D','SyntheticVolumeDataContainer', 'CellData'\ >>> cm.load_from_Dream3D('20grains16x16x16.dream3D','SyntheticVolumeDataContainer', 'CellData',
'EulerAngles','Phases',['Ferrite']) ... 'EulerAngles','Phases',['Ferrite'])
for grain based data with dual phase for grain based data with dual phase
>>> import damask >>> import damask
>>> import damask.ConfigMaterial as cm >>> import damask.ConfigMaterial as cm
>>> cm.load_from_Dream3D('20grains16x16x16.dream3D','SyntheticVolumeDataContainer', 'Grain Data'\ >>> cm.load_from_Dream3D('20grains16x16x16.dream3D','SyntheticVolumeDataContainer', 'Grain Data',
'EulerAngles','Phases',['Ferrite','Martensite']) ... 'EulerAngles','Phases',['Ferrite','Martensite'])
for point based data with dual phase for point based data with dual phase
>>> import damask >>> import damask
>>> import damask.ConfigMaterial as cm >>> import damask.ConfigMaterial as cm
>>> cm.load_from_Dream3D('20grains16x16x16.dream3D','SyntheticVolumeDataContainer', 'CellData'\ >>> cm.load_from_Dream3D('20grains16x16x16.dream3D','SyntheticVolumeDataContainer', 'CellData',
'EulerAngles','Phases',['Ferrite','Martensite']) ... 'EulerAngles','Phases',['Ferrite','Martensite'])
""" """
root_dir = 'DataContainers' root_dir = 'DataContainers'
hdf = h5py.File(fname,'r') hdf = h5py.File(fname,'r')
cells = hdf[path.join(root_dir,base_group,'_SIMPL_GEOMETRY/DIMENSIONS')][()]
config_info = ConfigMaterial() # empty yaml dictionary
orientation_path = path.join(root_dir,base_group,data_group,ori_data) orientation_path = path.join(root_dir,base_group,data_group,ori_data)
if hdf[orientation_path].attrs['TupleDimensions'].shape == (3,): if hdf[orientation_path].attrs['TupleDimensions'].shape == (3,):
grain_orientations = np.array(hdf[orientation_path]).reshape(cells.prod(),3,order='F') grain_orientations = np.array(hdf[orientation_path]).reshape(-1,3,order='F')
else: else:
grain_orientations = np.array(hdf[orientation_path])[1:] grain_orientations = np.array(hdf[orientation_path])[1:]
@ -166,15 +163,15 @@ class ConfigMaterial(Config):
phase_path = path.join(root_dir,base_group,data_group,phase_id) phase_path = path.join(root_dir,base_group,data_group,phase_id)
if hdf[phase_path].attrs['TupleDimensions'].shape == (3,): if hdf[phase_path].attrs['TupleDimensions'].shape == (3,):
grain_phase = np.array(hdf[phase_path]).reshape(cells.prod(),order='F') grain_phase = np.array(hdf[phase_path]).reshape(-1,order='F')
else: else:
grain_phase = np.array(hdf[phase_path])[1:] grain_phase = np.array(hdf[phase_path])[1:]
grain_phase = grain_phase.reshape(len(grain_phase),) grain_phase = grain_phase.reshape(len(grain_phase),)
phase_name_list = [phase_name[i - 1] for i in grain_phase] phase_name_list = [phase_name[i - 1] for i in grain_phase]
material_dict = config_info.material_add(constituents={'phase':phase_name_list,'O':grain_quats},homogenization='SX') return ConfigMaterial().material_add(phase=phase_name_list, O = grain_quats) # noqa
material_dict.save()
@property @property
def is_complete(self): def is_complete(self):

View File

@ -275,16 +275,15 @@ class Grid:
Defaults to 'FeatureIds'. Defaults to 'FeatureIds'.
""" """
root_dir ='DataContainers'
f = h5py.File(fname, 'r') f = h5py.File(fname, 'r')
g = os.path.join(root_dir,base_group,'_SIMPL_GEOMETRY') g = os.path.join('DataContainers',base_group,'_SIMPL_GEOMETRY')
cells = f[os.path.join(g,'DIMENSIONS')][()] cells = f[os.path.join(g,'DIMENSIONS')][()]
size = f[os.path.join(g,'SPACING')][()] * cells size = f[os.path.join(g,'SPACING')][()] * cells
origin = f[os.path.join(g,'ORIGIN')][()] origin = f[os.path.join(g,'ORIGIN')][()]
ma = np.arange(cells.prod(),dtype=int) \ ma = np.arange(cells.prod(),dtype=int) \
if point_data is None else \ if point_data is None else \
np.reshape(f[os.path.join(root_dir,base_group,point_data,material)],cells.prod()) np.reshape(f[os.path.join('DataContainers',base_group,point_data,material)],cells.prod())
return Grid(ma.reshape(cells,order='F'),size,origin,util.execution_stamp('Grid','load_DREAM3D')) return Grid(ma.reshape(cells,order='F'),size,origin,util.execution_stamp('Grid','load_DREAM3D'))