Merge branch 'config_from_dream3D' into 'development'

Config from DREAM.3D

See merge request damask/DAMASK!358
This commit is contained in:
Francisco Jose Gallardo Basile 2021-03-24 13:02:51 +00:00
commit ee8015cd55
20 changed files with 68015 additions and 28 deletions

@ -1 +1 @@
Subproject commit a4fed7a4b285496f547a7b940f6b6d54419f2384
Subproject commit ba046ace284515cb82020b3930206eab84ff3121

View File

@ -65,7 +65,7 @@ if filenames == []: parser.error('no input file specified.')
for name in filenames:
damask.util.report(scriptName,name)
geom = damask.Grid.load_DREAM3D(name,options.basegroup,options.pointwise)
geom = damask.Grid.load_DREAM3D(name,'FeatureIds')
damask.util.croak(geom)
geom.save_ASCII(os.path.splitext(name)[0]+'.geom')

View File

@ -1,4 +1,7 @@
import os.path
import numpy as np
import h5py
from . import Config
from . import Rotation
@ -49,7 +52,7 @@ class ConfigMaterial(Config):
@staticmethod
def from_table(table,**kwargs):
"""
Load from an ASCII table.
Generate from an ASCII table.
Parameters
----------
@ -85,7 +88,7 @@ class ConfigMaterial(Config):
phase: {}
"""
kwargs_ = {k:table.get(v) for k,v in kwargs.items()}
kwargs_ = {k:table.get(v) for k,v in kwargs.items()}
_,idx = np.unique(np.hstack(list(kwargs_.values())),return_index=True,axis=0)
idx = np.sort(idx)
@ -94,6 +97,79 @@ class ConfigMaterial(Config):
return ConfigMaterial().material_add(**kwargs_)
@staticmethod
def load_DREAM3D(fname,
grain_data=None,cell_data=None,cell_ensemble_data='CellEnsembleData',
phases='Phases',Euler_angles='EulerAngles',phase_names='PhaseName',
base_group=None):
"""
Load DREAM.3D (HDF5) file.
Data in DREAM.3D files can be stored per cell ('CellData')
and/or per grain ('Grain Data'). Per default, cell-wise data
is assumed.
damask.Grid.load_DREAM3D allows to get the corresponding geometry
for the grid solver.
Parameters
----------
fname : str
Filename of the DREAM.3D (HDF5) file.
grain_data : str
Name of the group (folder) containing grain-wise data. Defaults
to None, in which case cell-wise data is used.
cell_data : str
Name of the group (folder) containing cell-wise data. Defaults to
None in wich case it is automatically detected.
cell_ensemble_data : str
Name of the group (folder) containing data of cell ensembles. This
group is used to inquire the name of the phases. Phases will get
numeric IDs if this group is not found. Defaults to 'CellEnsembleData'.
phases : str
Name of the dataset containing the phase ID (cell-wise or grain-wise).
Defaults to 'Phases'.
Euler_angles : str
Name of the dataset containing the crystallographic orientation as
Euler angles in radians (cell-wise or grain-wise). Defaults to 'EulerAngles'.
phase_names : str
Name of the dataset containing the phase names. Phases will get
numeric IDs if this dataset is not found. Defaults to 'PhaseName'.
base_group : str
Path to the group (folder) that contains geometry (_SIMPL_GEOMETRY),
and grain- or cell-wise data. Defaults to None, in which case
it is set as the path that contains _SIMPL_GEOMETRY/SPACING.
"""
b = util.DREAM3D_base_group(fname) if base_group is None else base_group
c = util.DREAM3D_cell_data_group(fname) if cell_data is None else cell_data
f = h5py.File(fname,'r')
if grain_data is None:
phase = f[os.path.join(b,c,phases)][()].flatten()
O = Rotation.from_Euler_angles(f[os.path.join(b,c,Euler_angles)]).as_quaternion().reshape(-1,4) # noqa
_,idx = np.unique(np.hstack([O,phase.reshape(-1,1)]),return_index=True,axis=0)
idx = np.sort(idx)
else:
phase = f[os.path.join(b,grain_data,phases)][()]
O = Rotation.from_Euler_angles(f[os.path.join(b,grain_data,Euler_angles)]).as_quaternion() # noqa
idx = np.arange(phase.size)
if cell_ensemble_data is not None and phase_names is not None:
try:
names = np.array([s.decode() for s in f[os.path.join(b,cell_ensemble_data,phase_names)]])
phase = names[phase]
except KeyError:
pass
base_config = ConfigMaterial({'phase':{k if isinstance(k,int) else str(k):'t.b.d.' for k in np.unique(phase)},
'homogenization':{'direct':{'N_constituents':1}}})
constituent = {k:np.atleast_1d(v[idx].squeeze()) for k,v in zip(['O','phase'],[O,phase])}
return base_config.material_add(**constituent,homogenization='direct')
@property
def is_complete(self):
"""Check for completeness."""

View File

@ -256,35 +256,62 @@ class Grid:
@staticmethod
def load_DREAM3D(fname,base_group,point_data=None,material='FeatureIds'):
def load_DREAM3D(fname,
feature_IDs=None,cell_data=None,
phases='Phases',Euler_angles='EulerAngles',
base_group=None):
"""
Load from DREAM.3D file.
Load DREAM.3D (HDF5) file.
Data in DREAM.3D files can be stored per cell ('CellData')
and/or per grain ('Grain Data'). Per default, cell-wise data
is assumed.
damask.ConfigMaterial.load_DREAM3D allows to get the
corresponding material definition.
Parameters
----------
fname : str
Filename of the DREAM.3D file
Filename of the DREAM.3D (HDF5) file.
feature_IDs : str
Name of the dataset containing the mapping between cells and
grain-wise data. Defaults to 'None', in which case cell-wise
data is used.
cell_data : str
Name of the group (folder) containing cell-wise data. Defaults to
None in wich case it is automatically detected.
phases : str
Name of the dataset containing the phase ID. It is not used for
grain-wise data, i.e. when feature_IDs is not None.
Defaults to 'Phases'.
Euler_angles : str
Name of the dataset containing the crystallographic orientation as
Euler angles in radians It is not used for grain-wise data, i.e.
when feature_IDs is not None. Defaults to 'EulerAngles'.
base_group : str
Name of the group (folder) below 'DataContainers',
for example 'SyntheticVolumeDataContainer'.
point_data : str, optional
Name of the group (folder) containing the pointwise material data,
for example 'CellData'. Defaults to None, in which case points are consecutively numbered.
material : str, optional
Name of the dataset containing the material ID.
Defaults to 'FeatureIds'.
Path to the group (folder) that contains geometry (_SIMPL_GEOMETRY),
and grain- or cell-wise data. Defaults to None, in which case
it is set as the path that contains _SIMPL_GEOMETRY/SPACING.
"""
root_dir ='DataContainers'
b = util.DREAM3D_base_group(fname) if base_group is None else base_group
c = util.DREAM3D_cell_data_group(fname) if cell_data is None else cell_data
f = h5py.File(fname, 'r')
g = os.path.join(root_dir,base_group,'_SIMPL_GEOMETRY')
cells = f[os.path.join(g,'DIMENSIONS')][()]
size = f[os.path.join(g,'SPACING')][()] * cells
origin = f[os.path.join(g,'ORIGIN')][()]
ma = np.arange(cells.prod(),dtype=int) \
if point_data is None else \
np.reshape(f[os.path.join(root_dir,base_group,point_data,material)],cells.prod())
cells = f[os.path.join(b,'_SIMPL_GEOMETRY','DIMENSIONS')][()]
size = f[os.path.join(b,'_SIMPL_GEOMETRY','SPACING')] * cells
origin = f[os.path.join(b,'_SIMPL_GEOMETRY','ORIGIN')][()]
if feature_IDs is None:
phase = f[os.path.join(b,c,phases)][()].reshape(-1,1)
O = Rotation.from_Euler_angles(f[os.path.join(b,c,Euler_angles)]).as_quaternion().reshape(-1,4) # noqa
unique,unique_inverse = np.unique(np.hstack([O,phase]),return_inverse=True,axis=0)
ma = np.arange(cells.prod()) if len(unique) == cells.prod() else \
np.arange(unique.size)[np.argsort(pd.unique(unique_inverse))][unique_inverse]
else:
ma = f[os.path.join(b,c,feature_IDs)][()].flatten()
return Grid(ma.reshape(cells,order='F'),size,origin,util.execution_stamp('Grid','load_DREAM3D'))

View File

@ -9,6 +9,7 @@ from functools import reduce
from optparse import Option
import numpy as np
import h5py
from . import version
@ -27,7 +28,8 @@ __all__=[
'extendableOption',
'execution_stamp',
'shapeshifter', 'shapeblender',
'extend_docstring', 'extended_docstring'
'extend_docstring', 'extended_docstring',
'DREAM3D_base_group', 'DREAM3D_cell_data_group'
]
####################################################################################################
@ -376,6 +378,53 @@ def extended_docstring(f,extra_docstring):
return _decorator
def DREAM3D_base_group(fname):
"""
Determine the base group of a DREAM.3D file.
The base group is defined as the group (folder) that contains
a 'SPACING' dataset in a '_SIMPL_GEOMETRY' group.
Parameters
----------
fname : str
Filename of the DREAM.3D (HDF5) file.
"""
with h5py.File(fname,'r') as f:
base_group = f.visit(lambda path: path.rsplit('/',2)[0] if '_SIMPL_GEOMETRY/SPACING' in path else None)
if base_group is None:
raise ValueError(f'Could not determine base group in file {fname}.')
return base_group
def DREAM3D_cell_data_group(fname):
"""
Determine the cell data group of a DREAM.3D file.
The cell data group is defined as the group (folder) that contains
a dataset in the base group whose length matches the total number
of points as specified in '_SIMPL_GEOMETRY/DIMENSIONS'.
Parameters
----------
fname : str
Filename of the DREAM.3D (HDF5) file.
"""
base_group = DREAM3D_base_group(fname)
with h5py.File(fname,'r') as f:
cells = tuple(f[os.path.join(base_group,'_SIMPL_GEOMETRY','DIMENSIONS')][()][::-1])
cell_data_group = f[base_group].visititems(lambda path,obj: path.split('/')[0] \
if isinstance(obj,h5py._hl.dataset.Dataset) and np.shape(obj)[:-1] == cells \
else None)
if cell_data_group is None:
raise ValueError(f'Could not determine cell data group in file {fname}/{base_group}.')
return cell_data_group
####################################################################################################
# Classes
####################################################################################################

View File

@ -0,0 +1 @@
../Grid/2phase_irregularGrid.dream3d

View File

@ -0,0 +1 @@
../Grid/2phase_irregularGrid.json

View File

@ -0,0 +1 @@
../Grid/2phase_irregularGrid.xdmf

View File

@ -0,0 +1 @@
../Grid/measured.dream3d

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
../Grid/measured.xdmf

View File

@ -0,0 +1,764 @@
{
"0": {
"CellEnsembleAttributeMatrixName": "CellEnsembleData",
"CrystalStructuresArrayName": "CrystalStructures",
"Filter_Enabled": true,
"Filter_Human_Label": "StatsGenerator",
"Filter_Name": "StatsGeneratorFilter",
"Filter_Uuid": "{f642e217-4722-5dd8-9df9-cee71e7b26ba}",
"PhaseNamesArrayName": "PhaseName",
"PhaseTypesArrayName": "PhaseTypes",
"StatsDataArray": {
"1": {
"AxisODF-Weights": {
},
"Bin Count": 34,
"BinNumber": [
0.03019738383591175,
1.031197428703308,
2.0321974754333496,
3.0331974029541016,
4.0341973304748535,
5.0351972579956055,
6.036197185516357,
7.037197113037109,
8.03819751739502,
9.03919792175293,
10.04019832611084,
11.04119873046875,
12.04219913482666,
13.04319953918457,
14.04419994354248,
15.04520034790039,
16.046199798583984,
17.047199249267578,
18.048198699951172,
19.049198150634766,
20.05019760131836,
21.051197052001953,
22.052196502685547,
23.05319595336914,
24.054195404052734,
25.055194854736328,
26.056194305419922,
27.057193756103516,
28.05819320678711,
29.059192657470703,
30.060192108154297,
31.06119155883789,
32.062191009521484,
33.06319046020508
],
"BoundaryArea": 0,
"Crystal Symmetry": 1,
"FeatureSize Distribution": {
"Average": 0.5,
"Standard Deviation": 1
},
"FeatureSize Vs B Over A Distributions": {
"Alpha": [
15.845513343811035,
15.281289100646973,
15.406131744384766,
15.695631980895996
],
"Beta": [
1.5363599061965942,
1.3575199842453003,
1.2908644676208496,
1.6510697603225708
],
"Distribution Type": "Beta Distribution"
},
"FeatureSize Vs C Over A Distributions": {
"Alpha": [
15.83090591430664,
15.119057655334473,
15.210259437561035,
15.403964042663574
],
"Beta": [
1.4798208475112915,
1.439164638519287,
1.6361048221588135,
1.3149876594543457
],
"Distribution Type": "Beta Distribution"
},
"FeatureSize Vs Neighbors Distributions": {
"Average": [
2.3025851249694824,
2.4849066734313965,
2.6390573978424072,
2.7725887298583984
],
"Distribution Type": "Log Normal Distribution",
"Standard Deviation": [
0.4000000059604645,
0.3499999940395355,
0.30000001192092896,
0.25
]
},
"FeatureSize Vs Omega3 Distributions": {
"Alpha": [
10.906224250793457,
10.030556678771973,
10.367804527282715,
10.777519226074219
],
"Beta": [
1.7305665016174316,
1.638364553451538,
1.6687047481536865,
1.6839183568954468
],
"Distribution Type": "Beta Distribution"
},
"Feature_Diameter_Info": [
1.0010000467300415,
33.11545181274414,
0.03019738383591175
],
"MDF-Weights": {
},
"Name": "Primary",
"ODF-Weights": {
},
"PhaseFraction": 0.8999999761581421,
"PhaseType": "Primary"
},
"2": {
"AxisODF-Weights": {
},
"Bin Count": 34,
"BinNumber": [
0.03019738383591175,
1.031197428703308,
2.0321974754333496,
3.0331974029541016,
4.0341973304748535,
5.0351972579956055,
6.036197185516357,
7.037197113037109,
8.03819751739502,
9.03919792175293,
10.04019832611084,
11.04119873046875,
12.04219913482666,
13.04319953918457,
14.04419994354248,
15.04520034790039,
16.046199798583984,
17.047199249267578,
18.048198699951172,
19.049198150634766,
20.05019760131836,
21.051197052001953,
22.052196502685547,
23.05319595336914,
24.054195404052734,
25.055194854736328,
26.056194305419922,
27.057193756103516,
28.05819320678711,
29.059192657470703,
30.060192108154297,
31.06119155883789,
32.062191009521484,
33.06319046020508
],
"BoundaryArea": 0,
"Crystal Symmetry": 0,
"FeatureSize Distribution": {
"Average": 0.5,
"Standard Deviation": 1
},
"FeatureSize Vs B Over A Distributions": {
"Alpha": [
15.447705268859863,
15.033297538757324,
15.445094108581543,
15.426791191101074,
15.61402702331543,
15.366107940673828,
15.525880813598633,
15.943540573120117,
15.176913261413574,
15.9615478515625,
15.254341125488281,
15.919609069824219,
15.170331954956055,
15.80831527709961,
15.88097095489502,
15.6745023727417,
15.72781753540039,
15.8475980758667,
15.314001083374023,
15.855002403259277,
15.942434310913086,
15.40106201171875,
15.478381156921387,
15.788527488708496,
15.045133590698242,
15.81428050994873,
15.582372665405273,
15.878610610961914,
15.554070472717285,
15.576101303100586,
15.961583137512207,
15.629712104797363,
15.71079158782959,
15.126718521118164
],
"Beta": [
1.6585813760757446,
1.5793683528900146,
1.3637349605560303,
1.3487848043441772,
1.2599012851715088,
1.6920716762542725,
1.4974967241287231,
1.2616045475006104,
1.4897079467773438,
1.7281248569488525,
1.427177906036377,
1.6394929885864258,
1.533599853515625,
1.4850311279296875,
1.4161322116851807,
1.4839515686035156,
1.619403600692749,
1.3563393354415894,
1.7409964799880981,
1.7253544330596924,
1.3933753967285156,
1.7071460485458374,
1.4746366739273071,
1.3466795682907104,
1.5836750268936157,
1.2904614210128784,
1.4404902458190918,
1.7157742977142334,
1.3197978734970093,
1.2591632604599,
1.387762188911438,
1.5591365098953247,
1.3606828451156616,
1.4381128549575806
],
"Distribution Type": "Beta Distribution"
},
"FeatureSize Vs C Over A Distributions": {
"Alpha": [
15.365218162536621,
15.545299530029297,
15.212627410888672,
15.400262832641602,
15.938212394714355,
15.722898483276367,
15.016470909118652,
15.900740623474121,
15.425718307495117,
15.16152572631836,
15.375897407531738,
15.372262954711914,
15.971389770507812,
15.753372192382812,
15.400237083435059,
15.377294540405273,
15.65787124633789,
15.287458419799805,
15.704233169555664,
15.063706398010254,
15.128981590270996,
15.337125778198242,
15.145627975463867,
15.563216209411621,
15.704171180725098,
15.633543014526367,
15.44886589050293,
15.549928665161133,
15.656011581420898,
15.29349136352539,
15.840867042541504,
15.322612762451172,
15.672919273376465,
15.617719650268555
],
"Beta": [
1.4064055681228638,
1.2828519344329834,
1.468850016593933,
1.7444164752960205,
1.6199990510940552,
1.3697280883789062,
1.2706352472305298,
1.5357846021652222,
1.4822189807891846,
1.6722832918167114,
1.369265079498291,
1.4566115140914917,
1.3299659490585327,
1.3810123205184937,
1.3476874828338623,
1.5510755777359009,
1.7177120447158813,
1.3624974489212036,
1.3216533660888672,
1.3339394330978394,
1.2930961847305298,
1.6279221773147583,
1.6160264015197754,
1.528560757637024,
1.510753870010376,
1.3254910707473755,
1.4221922159194946,
1.2564609050750732,
1.6635781526565552,
1.3418669700622559,
1.7360178232192993,
1.5526862144470215,
1.4054912328720093,
1.277783989906311
],
"Distribution Type": "Beta Distribution"
},
"FeatureSize Vs Omega3 Distributions": {
"Alpha": [
10.336419105529785,
10.1687650680542,
10.27115249633789,
10.215887069702148,
10.185782432556152,
10.72452449798584,
10.59039306640625,
10.541507720947266,
10.88405990600586,
10.985298156738281,
10.061153411865234,
10.403335571289062,
10.103477478027344,
10.359172821044922,
10.454915046691895,
10.805563926696777,
10.597787857055664,
10.86919116973877,
10.310497283935547,
10.723823547363281,
10.431794166564941,
10.962357521057129,
10.227286338806152,
10.641992568969727,
10.421194076538086,
10.347271919250488,
10.305063247680664,
10.359184265136719,
10.88247013092041,
10.224652290344238,
10.449006080627441,
10.638978958129883,
10.109529495239258,
10.306557655334473
],
"Beta": [
1.952553629875183,
1.8465642929077148,
1.9641268253326416,
1.8473154306411743,
1.8531252145767212,
1.6586203575134277,
1.7890105247497559,
1.5307549238204956,
1.5579677820205688,
1.5402934551239014,
1.8692169189453125,
1.7846438884735107,
1.547948956489563,
1.6955899000167847,
1.7097049951553345,
1.5930047035217285,
1.7674869298934937,
1.519134759902954,
1.655213475227356,
1.846417784690857,
1.6024950742721558,
1.7787903547286987,
1.529666781425476,
1.9883882999420166,
1.9980814456939697,
1.6461148262023926,
1.518980622291565,
1.954341173171997,
1.994722604751587,
1.6828864812850952,
1.5880030393600464,
1.7846791744232178,
1.6626262664794922,
1.714822769165039
],
"Distribution Type": "Beta Distribution"
},
"Feature_Diameter_Info": [
1.0010000467300415,
33.11545181274414,
0.03019738383591175
],
"MDF-Weights": {
},
"Name": "Precipitate",
"ODF-Weights": {
},
"PhaseFraction": 0.10000000149011612,
"PhaseType": "Precipitate",
"Precipitate Boundary Fraction": 0.699999988079071,
"Radial Distribution Function": {
"Bin Count": 50,
"BoxDims": [
100,
100,
100
],
"BoxRes": [
0.10000000149011612,
0.10000000149011612,
0.10000000149011612
],
"Max": 80,
"Min": 10
}
},
"Name": "Statistics",
"Phase Count": 3
},
"StatsDataArrayName": "Statistics",
"StatsGeneratorDataContainerName": "StatsGeneratorDataContainer"
},
"1": {
"BoxDimensions": "X Range: 0 to 10.4 (Delta: 10.4)\nY Range: 0 to 6.4 (Delta: 6.4)\nZ Range: 0 to 8 (Delta: 8)",
"CellAttributeMatrixName": "CellData",
"DataContainerName": "SyntheticVolumeDataContainer",
"Dimensions": {
"x": 13,
"y": 8,
"z": 10
},
"EnsembleAttributeMatrixName": "CellEnsembleData",
"EstimateNumberOfFeatures": 1,
"EstimatedPrimaryFeatures": "17",
"FilterVersion": "6.5.138",
"Filter_Enabled": true,
"Filter_Human_Label": "Initialize Synthetic Volume",
"Filter_Name": "InitializeSyntheticVolume",
"Filter_Uuid": "{c2ae366b-251f-5dbd-9d70-d790376c0c0d}",
"InputPhaseTypesArrayPath": {
"Attribute Matrix Name": "CellEnsembleData",
"Data Array Name": "PhaseTypes",
"Data Container Name": "StatsGeneratorDataContainer"
},
"InputStatsArrayPath": {
"Attribute Matrix Name": "CellEnsembleData",
"Data Array Name": "Statistics",
"Data Container Name": "StatsGeneratorDataContainer"
},
"Origin": {
"x": 0,
"y": 0,
"z": 0
},
"Resolution": {
"x": 0.800000011920929,
"y": 0.800000011920929,
"z": 0.800000011920929
}
},
"2": {
"FilterVersion": "6.5.138",
"Filter_Enabled": true,
"Filter_Human_Label": "Establish Shape Types",
"Filter_Name": "EstablishShapeTypes",
"Filter_Uuid": "{4edbbd35-a96b-5ff1-984a-153d733e2abb}",
"InputPhaseTypesArrayPath": {
"Attribute Matrix Name": "CellEnsembleData",
"Data Array Name": "PhaseTypes",
"Data Container Name": "StatsGeneratorDataContainer"
},
"ShapeTypeData": [
999,
0,
0
],
"ShapeTypesArrayName": "ShapeTypes"
},
"3": {
"CellPhasesArrayName": "Phases",
"FeatureGeneration": 0,
"FeatureIdsArrayName": "FeatureIds",
"FeatureInputFile": "C:/Users/work",
"FeaturePhasesArrayName": "Phases",
"FilterVersion": "6.5.138",
"Filter_Enabled": true,
"Filter_Human_Label": "Pack Primary Phases",
"Filter_Name": "PackPrimaryPhases",
"Filter_Uuid": "{84305312-0d10-50ca-b89a-fda17a353cc9}",
"InputPhaseNamesArrayPath": {
"Attribute Matrix Name": "CellEnsembleData",
"Data Array Name": "PhaseName",
"Data Container Name": "StatsGeneratorDataContainer"
},
"InputPhaseTypesArrayPath": {
"Attribute Matrix Name": "CellEnsembleData",
"Data Array Name": "PhaseTypes",
"Data Container Name": "StatsGeneratorDataContainer"
},
"InputShapeTypesArrayPath": {
"Attribute Matrix Name": "CellEnsembleData",
"Data Array Name": "ShapeTypes",
"Data Container Name": "StatsGeneratorDataContainer"
},
"InputStatsArrayPath": {
"Attribute Matrix Name": "CellEnsembleData",
"Data Array Name": "Statistics",
"Data Container Name": "StatsGeneratorDataContainer"
},
"MaskArrayPath": {
"Attribute Matrix Name": "",
"Data Array Name": "",
"Data Container Name": ""
},
"NewAttributeMatrixPath": {
"Attribute Matrix Name": "Synthetic Shape Parameters (Primary Phase)",
"Data Array Name": "",
"Data Container Name": "SyntheticVolumeDataContainer"
},
"NumFeaturesArrayName": "NumFeatures",
"OutputCellAttributeMatrixPath": {
"Attribute Matrix Name": "CellData",
"Data Array Name": "",
"Data Container Name": "SyntheticVolumeDataContainer"
},
"OutputCellEnsembleAttributeMatrixName": "CellEnsembleData",
"OutputCellFeatureAttributeMatrixName": "Grain Data",
"PeriodicBoundaries": 0,
"SaveGeometricDescriptions": 0,
"SelectedAttributeMatrixPath": {
"Attribute Matrix Name": "",
"Data Array Name": "",
"Data Container Name": ""
},
"UseMask": 0
},
"4": {
"BoundaryCellsArrayName": "BoundaryCells",
"FeatureIdsArrayPath": {
"Attribute Matrix Name": "CellData",
"Data Array Name": "FeatureIds",
"Data Container Name": "SyntheticVolumeDataContainer"
},
"FilterVersion": "6.5.138",
"Filter_Enabled": true,
"Filter_Human_Label": "Find Boundary Cells (Image)",
"Filter_Name": "FindBoundaryCells",
"Filter_Uuid": "{8a1106d4-c67f-5e09-a02a-b2e9b99d031e}",
"IgnoreFeatureZero": 1,
"IncludeVolumeBoundary": 0
},
"5": {
"BoundaryCellsArrayPath": {
"Attribute Matrix Name": "CellData",
"Data Array Name": "BoundaryCells",
"Data Container Name": "SyntheticVolumeDataContainer"
},
"CellPhasesArrayPath": {
"Attribute Matrix Name": "CellData",
"Data Array Name": "Phases",
"Data Container Name": "SyntheticVolumeDataContainer"
},
"FeatureGeneration": 0,
"FeatureIdsArrayPath": {
"Attribute Matrix Name": "CellData",
"Data Array Name": "FeatureIds",
"Data Container Name": "SyntheticVolumeDataContainer"
},
"FeaturePhasesArrayPath": {
"Attribute Matrix Name": "Grain Data",
"Data Array Name": "Phases",
"Data Container Name": "SyntheticVolumeDataContainer"
},
"FilterVersion": "6.5.138",
"Filter_Enabled": true,
"Filter_Human_Label": "Insert Precipitate Phases",
"Filter_Name": "InsertPrecipitatePhases",
"Filter_Uuid": "{1e552e0c-53bb-5ae1-bd1c-c7a6590f9328}",
"InputPhaseTypesArrayPath": {
"Attribute Matrix Name": "CellEnsembleData",
"Data Array Name": "PhaseTypes",
"Data Container Name": "StatsGeneratorDataContainer"
},
"InputShapeTypesArrayPath": {
"Attribute Matrix Name": "CellEnsembleData",
"Data Array Name": "ShapeTypes",
"Data Container Name": "StatsGeneratorDataContainer"
},
"InputStatsArrayPath": {
"Attribute Matrix Name": "CellEnsembleData",
"Data Array Name": "Statistics",
"Data Container Name": "StatsGeneratorDataContainer"
},
"MaskArrayPath": {
"Attribute Matrix Name": "",
"Data Array Name": "",
"Data Container Name": ""
},
"MatchRDF": 0,
"NewAttributeMatrixPath": {
"Attribute Matrix Name": "Synthetic Shape Parameters (Precipitate)",
"Data Array Name": "",
"Data Container Name": "SyntheticVolumeDataContainer"
},
"NumFeaturesArrayPath": {
"Attribute Matrix Name": "CellEnsembleData",
"Data Array Name": "NumFeatures",
"Data Container Name": "SyntheticVolumeDataContainer"
},
"PeriodicBoundaries": 0,
"PrecipInputFile": "C:/Users/work",
"SaveGeometricDescriptions": 0,
"SelectedAttributeMatrixPath": {
"Attribute Matrix Name": "",
"Data Array Name": "",
"Data Container Name": ""
},
"UseMask": 0
},
"6": {
"BoundaryCellsArrayName": "BoundaryCells",
"CellFeatureAttributeMatrixPath": {
"Attribute Matrix Name": "Grain Data",
"Data Array Name": "",
"Data Container Name": "SyntheticVolumeDataContainer"
},
"FeatureIdsArrayPath": {
"Attribute Matrix Name": "CellData",
"Data Array Name": "FeatureIds",
"Data Container Name": "SyntheticVolumeDataContainer"
},
"FilterVersion": "6.5.138",
"Filter_Enabled": true,
"Filter_Human_Label": "Find Feature Neighbors",
"Filter_Name": "FindNeighbors",
"Filter_Uuid": "{97cf66f8-7a9b-5ec2-83eb-f8c4c8a17bac}",
"NeighborListArrayName": "NeighborList",
"NumNeighborsArrayName": "NumNeighbors",
"SharedSurfaceAreaListArrayName": "SharedSurfaceAreaList",
"StoreBoundaryCells": 0,
"StoreSurfaceFeatures": 1,
"SurfaceFeaturesArrayName": "SurfaceFeatures"
},
"7": {
"AvgQuatsArrayName": "AvgQuats",
"CellEulerAnglesArrayName": "EulerAngles",
"CrystalStructuresArrayPath": {
"Attribute Matrix Name": "CellEnsembleData",
"Data Array Name": "CrystalStructures",
"Data Container Name": "StatsGeneratorDataContainer"
},
"FeatureEulerAnglesArrayName": "EulerAngles",
"FeatureIdsArrayPath": {
"Attribute Matrix Name": "CellData",
"Data Array Name": "FeatureIds",
"Data Container Name": "SyntheticVolumeDataContainer"
},
"FeaturePhasesArrayPath": {
"Attribute Matrix Name": "Grain Data",
"Data Array Name": "Phases",
"Data Container Name": "SyntheticVolumeDataContainer"
},
"FilterVersion": "6.5.138",
"Filter_Enabled": true,
"Filter_Human_Label": "Match Crystallography",
"Filter_Name": "MatchCrystallography",
"Filter_Uuid": "{7bfb6e4a-6075-56da-8006-b262d99dff30}",
"InputStatsArrayPath": {
"Attribute Matrix Name": "CellEnsembleData",
"Data Array Name": "Statistics",
"Data Container Name": "StatsGeneratorDataContainer"
},
"MaxIterations": 100,
"NeighborListArrayPath": {
"Attribute Matrix Name": "Grain Data",
"Data Array Name": "NeighborList",
"Data Container Name": "SyntheticVolumeDataContainer"
},
"NumFeaturesArrayPath": {
"Attribute Matrix Name": "CellEnsembleData",
"Data Array Name": "NumFeatures",
"Data Container Name": "SyntheticVolumeDataContainer"
},
"PhaseTypesArrayPath": {
"Attribute Matrix Name": "CellEnsembleData",
"Data Array Name": "PhaseTypes",
"Data Container Name": "StatsGeneratorDataContainer"
},
"SharedSurfaceAreaListArrayPath": {
"Attribute Matrix Name": "Grain Data",
"Data Array Name": "SharedSurfaceAreaList",
"Data Container Name": "SyntheticVolumeDataContainer"
},
"SurfaceFeaturesArrayPath": {
"Attribute Matrix Name": "Grain Data",
"Data Array Name": "SurfaceFeatures",
"Data Container Name": "SyntheticVolumeDataContainer"
},
"VolumesArrayName": "Volumes"
},
"8": {
"CellEulerAnglesArrayPath": {
"Attribute Matrix Name": "CellData",
"Data Array Name": "EulerAngles",
"Data Container Name": "SyntheticVolumeDataContainer"
},
"CellIPFColorsArrayName": "IPFColor",
"CellPhasesArrayPath": {
"Attribute Matrix Name": "CellData",
"Data Array Name": "Phases",
"Data Container Name": "SyntheticVolumeDataContainer"
},
"CrystalStructuresArrayPath": {
"Attribute Matrix Name": "CellEnsembleData",
"Data Array Name": "CrystalStructures",
"Data Container Name": "StatsGeneratorDataContainer"
},
"FilterVersion": "6.5.138",
"Filter_Enabled": true,
"Filter_Human_Label": "Generate IPF Colors",
"Filter_Name": "GenerateIPFColors",
"Filter_Uuid": "{a50e6532-8075-5de5-ab63-945feb0de7f7}",
"GoodVoxelsArrayPath": {
"Attribute Matrix Name": "CellData",
"Data Array Name": "",
"Data Container Name": "SyntheticVolumeDataContainer"
},
"ReferenceDir": {
"x": 0,
"y": 0,
"z": 1
},
"UseGoodVoxels": 0
},
"9": {
"FilterVersion": "1.2.812",
"Filter_Enabled": true,
"Filter_Human_Label": "Write DREAM.3D Data File",
"Filter_Name": "DataContainerWriter",
"Filter_Uuid": "{3fcd4c43-9d75-5b86-aad4-4441bc914f37}",
"OutputFile": "C:\\Users\\work\\Desktop\\2phase_irregularGrid.dream3d",
"WriteTimeSeries": 0,
"WriteXdmfFile": 1
},
"PipelineBuilder": {
"Name": "2phase_irregularGrid",
"Number_Filters": 10,
"Version": 6
}
}

View File

@ -0,0 +1,42 @@
<?xml version="1.0"?>
<!DOCTYPE Xdmf SYSTEM "Xdmf.dtd"[]>
<Xdmf xmlns:xi="http://www.w3.org/2003/XInclude" Version="2.2">
<Domain>
<!-- *************** START OF SyntheticVolumeDataContainer *************** -->
<Grid Name="SyntheticVolumeDataContainer" GridType="Uniform">
<Topology TopologyType="3DCoRectMesh" Dimensions="11 9 14 "></Topology>
<Geometry Type="ORIGIN_DXDYDZ">
<!-- Origin Z, Y, X -->
<DataItem Format="XML" Dimensions="3">0 0 0</DataItem>
<!-- DxDyDz (Spacing/Resolution) Z, Y, X -->
<DataItem Format="XML" Dimensions="3">0.8 0.8 0.8</DataItem>
</Geometry>
<Attribute Name="BoundaryCells" AttributeType="Scalar" Center="Cell">
<DataItem Format="HDF" Dimensions="10 8 13 1" NumberType="Char" Precision="1" >
2phase_irregularGrid.dream3d:/DataContainers/SyntheticVolumeDataContainer/CellData/BoundaryCells
</DataItem>
</Attribute>
<Attribute Name="EulerAngles" AttributeType="Vector" Center="Cell">
<DataItem Format="HDF" Dimensions="10 8 13 3" NumberType="Float" Precision="4" >
2phase_irregularGrid.dream3d:/DataContainers/SyntheticVolumeDataContainer/CellData/EulerAngles
</DataItem>
</Attribute>
<Attribute Name="FeatureIds" AttributeType="Scalar" Center="Cell">
<DataItem Format="HDF" Dimensions="10 8 13 1" NumberType="Int" Precision="4" >
2phase_irregularGrid.dream3d:/DataContainers/SyntheticVolumeDataContainer/CellData/FeatureIds
</DataItem>
</Attribute>
<Attribute Name="IPFColor" AttributeType="Vector" Center="Cell">
<DataItem Format="HDF" Dimensions="10 8 13 3" NumberType="UChar" Precision="1" >
2phase_irregularGrid.dream3d:/DataContainers/SyntheticVolumeDataContainer/CellData/IPFColor
</DataItem>
</Attribute>
<Attribute Name="Phases" AttributeType="Scalar" Center="Cell">
<DataItem Format="HDF" Dimensions="10 8 13 1" NumberType="Int" Precision="4" >
2phase_irregularGrid.dream3d:/DataContainers/SyntheticVolumeDataContainer/CellData/Phases
</DataItem>
</Attribute>
</Grid>
<!-- *************** END OF SyntheticVolumeDataContainer *************** -->
</Domain>
</Xdmf>

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,77 @@
<?xml version="1.0"?>
<!DOCTYPE Xdmf SYSTEM "Xdmf.dtd"[]>
<Xdmf xmlns:xi="http://www.w3.org/2003/XInclude" Version="2.2">
<Domain>
<!-- *************** START OF Small IN100 *************** -->
<Grid Name="Small IN100" GridType="Uniform">
<Topology TopologyType="3DCoRectMesh" Dimensions="2 102 202 "></Topology>
<Geometry Type="ORIGIN_DXDYDZ">
<!-- Origin Z, Y, X -->
<DataItem Format="XML" Dimensions="3">0 35 -294.7</DataItem>
<!-- DxDyDz (Spacing/Resolution) Z, Y, X -->
<DataItem Format="XML" Dimensions="3">0.35 0.35 0.35</DataItem>
</Geometry>
<Attribute Name="Confidence Index" AttributeType="Scalar" Center="Cell">
<DataItem Format="HDF" Dimensions="1 101 201 1" NumberType="Float" Precision="4" >
measured.dream3d:/DataContainers/Small IN100/EBSD Scan Data/Confidence Index
</DataItem>
</Attribute>
<Attribute Name="EulerAngles" AttributeType="Vector" Center="Cell">
<DataItem Format="HDF" Dimensions="1 101 201 3" NumberType="Float" Precision="4" >
measured.dream3d:/DataContainers/Small IN100/EBSD Scan Data/EulerAngles
</DataItem>
</Attribute>
<Attribute Name="FeatureIds" AttributeType="Scalar" Center="Cell">
<DataItem Format="HDF" Dimensions="1 101 201 1" NumberType="Int" Precision="4" >
measured.dream3d:/DataContainers/Small IN100/EBSD Scan Data/FeatureIds
</DataItem>
</Attribute>
<Attribute Name="Fit" AttributeType="Scalar" Center="Cell">
<DataItem Format="HDF" Dimensions="1 101 201 1" NumberType="Float" Precision="4" >
measured.dream3d:/DataContainers/Small IN100/EBSD Scan Data/Fit
</DataItem>
</Attribute>
<Attribute Name="IPFColor" AttributeType="Vector" Center="Cell">
<DataItem Format="HDF" Dimensions="1 101 201 3" NumberType="UChar" Precision="1" >
measured.dream3d:/DataContainers/Small IN100/EBSD Scan Data/IPFColor
</DataItem>
</Attribute>
<Attribute Name="Image Quality" AttributeType="Scalar" Center="Cell">
<DataItem Format="HDF" Dimensions="1 101 201 1" NumberType="Float" Precision="4" >
measured.dream3d:/DataContainers/Small IN100/EBSD Scan Data/Image Quality
</DataItem>
</Attribute>
<Attribute Name="Mask" AttributeType="Scalar" Center="Cell">
<DataItem Format="HDF" Dimensions="1 101 201 1" NumberType="uchar" Precision="1" >
measured.dream3d:/DataContainers/Small IN100/EBSD Scan Data/Mask
</DataItem>
</Attribute>
<Attribute Name="ParentIds" AttributeType="Scalar" Center="Cell">
<DataItem Format="HDF" Dimensions="1 101 201 1" NumberType="Int" Precision="4" >
measured.dream3d:/DataContainers/Small IN100/EBSD Scan Data/ParentIds
</DataItem>
</Attribute>
<Attribute Name="Phases" AttributeType="Scalar" Center="Cell">
<DataItem Format="HDF" Dimensions="1 101 201 1" NumberType="Int" Precision="4" >
measured.dream3d:/DataContainers/Small IN100/EBSD Scan Data/Phases
</DataItem>
</Attribute>
<Attribute Name="SEM Signal" AttributeType="Scalar" Center="Cell">
<DataItem Format="HDF" Dimensions="1 101 201 1" NumberType="Float" Precision="4" >
measured.dream3d:/DataContainers/Small IN100/EBSD Scan Data/SEM Signal
</DataItem>
</Attribute>
<Attribute Name="X Position" AttributeType="Scalar" Center="Cell">
<DataItem Format="HDF" Dimensions="1 101 201 1" NumberType="Float" Precision="4" >
measured.dream3d:/DataContainers/Small IN100/EBSD Scan Data/X Position
</DataItem>
</Attribute>
<Attribute Name="Y Position" AttributeType="Scalar" Center="Cell">
<DataItem Format="HDF" Dimensions="1 101 201 1" NumberType="Float" Precision="4" >
measured.dream3d:/DataContainers/Small IN100/EBSD Scan Data/Y Position
</DataItem>
</Attribute>
</Grid>
<!-- *************** END OF Small IN100 *************** -->
</Domain>
</Xdmf>

View File

@ -1,11 +1,12 @@
import os
import filecmp
import pytest
import numpy as np
from damask import ConfigMaterial
from damask import Table
from damask import Rotation
from damask import Grid
@pytest.fixture
def ref_path(ref_path_base):
@ -108,3 +109,32 @@ class TestConfigMaterial:
m = ConfigMaterial().material_add(**kw)
assert len(m['material']) == N
assert len(m['material'][0]['constituents']) == n
@pytest.mark.parametrize('cell_ensemble_data',[None,'CellEnsembleData'])
def test_load_DREAM3D(self,ref_path,cell_ensemble_data):
grain_c = ConfigMaterial.load_DREAM3D(ref_path/'2phase_irregularGrid.dream3d','Grain Data',
cell_ensemble_data = cell_ensemble_data)
point_c = ConfigMaterial.load_DREAM3D(ref_path/'2phase_irregularGrid.dream3d',
cell_ensemble_data = cell_ensemble_data)
assert point_c.is_valid and grain_c.is_valid and \
len(point_c['material'])+1 == len(grain_c['material'])
grain_m = Grid.load_DREAM3D(ref_path/'2phase_irregularGrid.dream3d','FeatureIds').material.flatten()
point_m = Grid.load_DREAM3D(ref_path/'2phase_irregularGrid.dream3d').material.flatten()
for i in np.unique(point_m):
j = int(grain_m[(point_m==i).nonzero()[0][0]])
assert np.allclose(point_c['material'][i]['constituents'][0]['O'],
grain_c['material'][j]['constituents'][0]['O'])
assert point_c['material'][i]['constituents'][0]['phase'] == \
grain_c['material'][j]['constituents'][0]['phase']
def test_load_DREAM3D_reference(self,tmp_path,ref_path,update):
config = ConfigMaterial.load_DREAM3D(ref_path/'measured.dream3d')
config.save(tmp_path/'material.yaml')
if update:
config.save(ref_path/'measured.material_yaml')
assert config.is_valid and filecmp.cmp(tmp_path/'material.yaml',ref_path/'measured.material_yaml')

View File

@ -420,12 +420,31 @@ class TestGrid:
t = Table(np.column_stack((coords.reshape(-1,3,order='F'),grid.material.flatten(order='F'))),{'c':3,'m':1})
assert grid_equal(grid.sort().renumber(),Grid.from_table(t,'c',['m']))
@pytest.mark.parametrize('periodic',[True,False])
@pytest.mark.parametrize('direction',['x','y','z',['x','y'],'zy','xz',['x','y','z']])
def test_get_grain_boundaries(self,update,ref_path,periodic,direction):
grid=Grid.load(ref_path/'get_grain_boundaries_8g12x15x20.vtr')
current=grid.get_grain_boundaries(periodic,direction)
grid = Grid.load(ref_path/'get_grain_boundaries_8g12x15x20.vtr')
current = grid.get_grain_boundaries(periodic,direction)
if update:
current.save(ref_path/f'get_grain_boundaries_8g12x15x20_{direction}_{periodic}.vtu',parallel=False)
reference=VTK.load(ref_path/f'get_grain_boundaries_8g12x15x20_{"".join(direction)}_{periodic}.vtu')
reference = VTK.load(ref_path/f'get_grain_boundaries_8g12x15x20_{"".join(direction)}_{periodic}.vtu')
assert current.__repr__() == reference.__repr__()
def test_load_DREAM3D(self,ref_path):
grain = Grid.load_DREAM3D(ref_path/'2phase_irregularGrid.dream3d','FeatureIds')
point = Grid.load_DREAM3D(ref_path/'2phase_irregularGrid.dream3d')
assert np.allclose(grain.origin,point.origin) and \
np.allclose(grain.size,point.size) and \
(grain.sort().material == point.material+1).all()
def test_load_DREAM3D_reference(self,ref_path,update):
current = Grid.load_DREAM3D(ref_path/'measured.dream3d')
reference = Grid.load(ref_path/'measured')
if update:
current.save(ref_path/'measured.vtr')
assert grid_equal(current,reference)

View File

@ -1,6 +1,10 @@
import random
import os
import pytest
import numpy as np
from scipy import stats
import h5py
from damask import util
@ -102,3 +106,36 @@ class TestUtil:
@pytest.mark.parametrize('style',[util.emph,util.deemph,util.warn,util.strikeout])
def test_decorate(self,style):
assert 'DAMASK' in style('DAMASK')
@pytest.mark.parametrize('complete',[True,False])
def test_D3D_base_group(self,tmp_path,complete):
base_group = ''.join(random.choices('DAMASK', k=10))
with h5py.File(tmp_path/'base_group.dream3d','w') as f:
f.create_group(os.path.join(base_group,'_SIMPL_GEOMETRY'))
if complete:
f[os.path.join(base_group,'_SIMPL_GEOMETRY')].create_dataset('SPACING',data=np.ones(3))
if complete:
assert base_group == util.DREAM3D_base_group(tmp_path/'base_group.dream3d')
else:
with pytest.raises(ValueError):
util.DREAM3D_base_group(tmp_path/'base_group.dream3d')
@pytest.mark.parametrize('complete',[True,False])
def test_D3D_cell_data_group(self,tmp_path,complete):
base_group = ''.join(random.choices('DAMASK', k=10))
cell_data_group = ''.join(random.choices('KULeuven', k=10))
cells = np.random.randint(1,50,3)
with h5py.File(tmp_path/'cell_data_group.dream3d','w') as f:
f.create_group(os.path.join(base_group,'_SIMPL_GEOMETRY'))
f[os.path.join(base_group,'_SIMPL_GEOMETRY')].create_dataset('SPACING',data=np.ones(3))
f[os.path.join(base_group,'_SIMPL_GEOMETRY')].create_dataset('DIMENSIONS',data=cells[::-1])
f[base_group].create_group(cell_data_group)
if complete:
f[os.path.join(base_group,cell_data_group)].create_dataset('data',shape=np.append(cells,1))
if complete:
assert cell_data_group == util.DREAM3D_cell_data_group(tmp_path/'cell_data_group.dream3d')
else:
with pytest.raises(ValueError):
util.DREAM3D_cell_data_group(tmp_path/'cell_data_group.dream3d')