use original DREAM.3D file as reference
current loop runs over all datasets (except those that should be ignored).
This commit is contained in:
parent
8e5f5cc124
commit
bfb207d34d
|
@ -1974,7 +1974,7 @@ class Result:
|
||||||
for c in range(self.N_constituents):
|
for c in range(self.N_constituents):
|
||||||
crystal_structure = [999]
|
crystal_structure = [999]
|
||||||
phase_name = ['Unknown Phase Type']
|
phase_name = ['Unknown Phase Type']
|
||||||
cell_orientation = np.zeros((np.prod(self.cells),3))
|
cell_orientation = np.zeros((np.prod(self.cells),3),np.float32)
|
||||||
phase_ID = np.zeros((np.prod(self.cells)),dtype=np.int32)
|
phase_ID = np.zeros((np.prod(self.cells)),dtype=np.int32)
|
||||||
count = 1
|
count = 1
|
||||||
for label in self.visible['phases']:
|
for label in self.visible['phases']:
|
||||||
|
|
Binary file not shown.
|
@ -0,0 +1 @@
|
||||||
|
../GeomGrid/2phase_irregularGrid.dream3d
|
|
@ -1,122 +0,0 @@
|
||||||
---
|
|
||||||
homogenization:
|
|
||||||
SX:
|
|
||||||
N_constituents: 1
|
|
||||||
mechanical: {type: pass}
|
|
||||||
|
|
||||||
phase:
|
|
||||||
Aluminum:
|
|
||||||
lattice: cF
|
|
||||||
mechanical:
|
|
||||||
output: [F, P, F_e, F_p, L_p, O]
|
|
||||||
elastic: {type: Hooke, C_11: 106.75e+9, C_12: 60.41e+9, C_44: 28.34e+9}
|
|
||||||
plastic:
|
|
||||||
type: phenopowerlaw
|
|
||||||
N_sl: [12]
|
|
||||||
a_sl: [2.25]
|
|
||||||
atol_xi: 1.0
|
|
||||||
dot_gamma_0_sl: [0.001]
|
|
||||||
h_0_sl-sl: [75.e+6]
|
|
||||||
h_sl-sl: [1, 1, 1.4, 1.4, 1.4, 1.4, 1.4]
|
|
||||||
n_sl: [20]
|
|
||||||
output: [xi_sl]
|
|
||||||
xi_0_sl: [31.e+6]
|
|
||||||
xi_inf_sl: [63.e+6]
|
|
||||||
Precipitate:
|
|
||||||
lattice: hP
|
|
||||||
c/a: 1.629
|
|
||||||
mechanical:
|
|
||||||
output: [F, P, F_e, F_p, L_p, O]
|
|
||||||
elastic: {type: Hooke, C_11: 162.4e9, C_12: 92.0e9, C_13: 69.0e9, C_33: 180.7e9, C_44: 49.7e9}
|
|
||||||
|
|
||||||
material:
|
|
||||||
- constituents:
|
|
||||||
- phase: Aluminum
|
|
||||||
O: [0.1312565298463503, -0.6783546785504293, -0.5822736006738253, 0.4284438206110302]
|
|
||||||
v: 1.0
|
|
||||||
homogenization: SX
|
|
||||||
- constituents:
|
|
||||||
- phase: Aluminum
|
|
||||||
O: [0.3891991356899201, 0.024147743013653567, 0.3536664846442759, -0.8502122893283336]
|
|
||||||
v: 1.0
|
|
||||||
homogenization: SX
|
|
||||||
- constituents:
|
|
||||||
- phase: Aluminum
|
|
||||||
O: [0.35508306685640884, -0.3893349018602677, -0.8446679875041884, 0.09418248622184058]
|
|
||||||
v: 1.0
|
|
||||||
homogenization: SX
|
|
||||||
- constituents:
|
|
||||||
- phase: Aluminum
|
|
||||||
O: [0.40195601820142496, -0.1636779350134876, -0.4207744499665131, 0.7966114205035945]
|
|
||||||
v: 1.0
|
|
||||||
homogenization: SX
|
|
||||||
- constituents:
|
|
||||||
- phase: Aluminum
|
|
||||||
O: [0.044972436776441485, 0.7143848123638518, -0.24549539260737738, -0.6537307029678221]
|
|
||||||
v: 1.0
|
|
||||||
homogenization: SX
|
|
||||||
- constituents:
|
|
||||||
- phase: Precipitate
|
|
||||||
O: [0.30372565221929093, -0.24301975423298977, -0.8125481043098195, -0.43411715632882125]
|
|
||||||
v: 1.0
|
|
||||||
homogenization: SX
|
|
||||||
- constituents:
|
|
||||||
- phase: Precipitate
|
|
||||||
O: [0.4596497204333957, -0.39026498957046113, 0.7976125696376123, 0.015151276419962625]
|
|
||||||
v: 1.0
|
|
||||||
homogenization: SX
|
|
||||||
- constituents:
|
|
||||||
- phase: Aluminum
|
|
||||||
O: [0.0827510723946788, 0.6317627669782209, 0.4175514636120652, -0.6478262433036925]
|
|
||||||
v: 1.0
|
|
||||||
homogenization: SX
|
|
||||||
- constituents:
|
|
||||||
- phase: Aluminum
|
|
||||||
O: [0.2996310655335684, 0.10384972751072818, 0.8974007140905373, 0.3067709520358135]
|
|
||||||
v: 1.0
|
|
||||||
homogenization: SX
|
|
||||||
- constituents:
|
|
||||||
- phase: Aluminum
|
|
||||||
O: [0.6358670871419496, 0.4180753134572028, -0.5146965710042285, -0.3949348295146467]
|
|
||||||
v: 1.0
|
|
||||||
homogenization: SX
|
|
||||||
- constituents:
|
|
||||||
- phase: Aluminum
|
|
||||||
O: [0.6972058990579978, 0.2748121746094387, -0.4615030442772494, 0.4747600900749678]
|
|
||||||
v: 1.0
|
|
||||||
homogenization: SX
|
|
||||||
- constituents:
|
|
||||||
- phase: Aluminum
|
|
||||||
O: [0.023323490584044985, -0.4124930466803271, 0.5037800801437966, 0.7586245000510248]
|
|
||||||
v: 1.0
|
|
||||||
homogenization: SX
|
|
||||||
- constituents:
|
|
||||||
- phase: Aluminum
|
|
||||||
O: [0.5327908616905777, 0.17796155315964704, 0.602711877421405, -0.5667468359957407]
|
|
||||||
v: 1.0
|
|
||||||
homogenization: SX
|
|
||||||
- constituents:
|
|
||||||
- phase: Aluminum
|
|
||||||
O: [0.5031041456929413, -0.4763268942553399, 0.6700266228868177, 0.2665768801275235]
|
|
||||||
v: 1.0
|
|
||||||
homogenization: SX
|
|
||||||
- constituents:
|
|
||||||
- phase: Precipitate
|
|
||||||
O: [0.5641709021797874, 0.6941319122105223, -0.0813139963653807, -0.4396363446983193]
|
|
||||||
v: 1.0
|
|
||||||
homogenization: SX
|
|
||||||
- constituents:
|
|
||||||
- phase: Aluminum
|
|
||||||
O: [0.40014270416551667, 0.38360239122229783, -0.040760057321212455, 0.8313083901169376]
|
|
||||||
v: 1.0
|
|
||||||
homogenization: SX
|
|
||||||
- constituents:
|
|
||||||
- phase: Precipitate
|
|
||||||
O: [0.25941430307519847, -0.7938792882664125, -0.20362736335049575, -0.510877472508378]
|
|
||||||
v: 1.0
|
|
||||||
homogenization: SX
|
|
||||||
- constituents:
|
|
||||||
- phase: Precipitate
|
|
||||||
O: [0.3297509101153507, 0.7826199404802652, 0.20188018251173903, -0.4878675618954298]
|
|
||||||
v: 1.0
|
|
||||||
homogenization: SX
|
|
|
@ -1,19 +0,0 @@
|
||||||
<?xml version="1.0"?>
|
|
||||||
<VTKFile type="ImageData" version="0.1" byte_order="LittleEndian" header_type="UInt32" compressor="vtkZLibDataCompressor">
|
|
||||||
<ImageData WholeExtent="0 13 0 8 0 10" Origin="0 0 0" Spacing="0.800000011920929 0.800000011920929 0.800000011920929" Direction="1 0 0 0 1 0 0 0 1">
|
|
||||||
<FieldData>
|
|
||||||
<Array type="String" Name="comments" NumberOfTuples="1" format="binary">
|
|
||||||
AQAAAACAAABDAAAASQAAAA==eF5LScxNLM7Wcy/KTNHLyU9MiXcJcnX0NXZRKNPT0weiMNegYE9/PwUNIwMjY11DQ10DUwUDcytjIysDC20DQwMDTQYAn+cREg==
|
|
||||||
</Array>
|
|
||||||
</FieldData>
|
|
||||||
<Piece Extent="0 13 0 8 0 10">
|
|
||||||
<PointData>
|
|
||||||
</PointData>
|
|
||||||
<CellData>
|
|
||||||
<DataArray type="Int64" Name="material" format="binary" RangeMin="0" RangeMax="17">
|
|
||||||
AQAAAACAAACAIAAAWQEAAA==eF7tlUFuwkAQBBdIAoEQyP8/m4vn0vJQuzuzxiD3pYVAVZLdI0oZk530qCzt2T/8VTwH6VEZ5fmAzspoD/GzPF6W3nWW59Pp7PvxPLbnr5ITz2O9lCdrb8bx+FHPcWq6m6iHspeOht5P1EN87d4Qd+2ek3wm7qt4jtLEz7of8qx918TbPPMhXpands9Znlpf9H6Ib/1dYiF+9LkRb/PMh3hZnvPUxO31nKWJ2+vREPdVPMTbPPMhnteX0pbeXV+kNXo3vXcUDfHf9f+ndQfEIw/twUK8LE/rzsijvt4913qi9/NTckIeux96H16IX/vcKMSt9Xi+69TEbfWob7RH90fcXo/u2fZKfPsd8clT279OU66N7Xlob9r6vPR74ymf9la7O/XU9rt6btJZnru08WnPrfejHuLW3g+9l9Zemyfqo/eyFs+fdLZH+Vke3bXnefb9/AOizxNG
|
|
||||||
</DataArray>
|
|
||||||
</CellData>
|
|
||||||
</Piece>
|
|
||||||
</ImageData>
|
|
||||||
</VTKFile>
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,18 +0,0 @@
|
||||||
---
|
|
||||||
|
|
||||||
solver:
|
|
||||||
mechanical: spectral_basic
|
|
||||||
|
|
||||||
loadstep:
|
|
||||||
- boundary_conditions:
|
|
||||||
mechanical:
|
|
||||||
dot_F: [[1.0e-3, 0, 0],
|
|
||||||
[0, x, 0],
|
|
||||||
[0, 0, x]]
|
|
||||||
P: [[x, x, x],
|
|
||||||
[x, 0, x],
|
|
||||||
[x, x, 0]]
|
|
||||||
discretization:
|
|
||||||
t: 10
|
|
||||||
N: 40
|
|
||||||
f_out: 40
|
|
|
@ -450,98 +450,34 @@ class TestResult:
|
||||||
single_phase.export_VTK(mode='point',target_dir=export_dir,parallel=False)
|
single_phase.export_VTK(mode='point',target_dir=export_dir,parallel=False)
|
||||||
assert set(os.listdir(export_dir)) == set([f'{single_phase.fname.stem}_inc{i:02}.vtp' for i in range(0,40+1,4)])
|
assert set(os.listdir(export_dir)) == set([f'{single_phase.fname.stem}_inc{i:02}.vtp' for i in range(0,40+1,4)])
|
||||||
|
|
||||||
def test_export_DREAM3D(self,tmp_path,res_path):
|
def test_export_DREAM3D(self,tmp_path,res_path,h5py_dataset_iterator):
|
||||||
result = Result(res_path/'2phase_irregularGrid_tensionX.hdf5').view(increments=0) #comparing the initial data only
|
result = Result(res_path/'2phase_irregularGrid_tensionX_material.hdf5').view(increments=0) # compare the initial data only
|
||||||
result.export_DREAM3D(target_dir=tmp_path)
|
result.export_DREAM3D(target_dir=tmp_path)
|
||||||
|
|
||||||
ref = h5py.File(res_path/'2phase_irregularGrid.dream3d','r')
|
def ignore(path):
|
||||||
cur = h5py.File(tmp_path/f'2phase_irregularGrid_tensionX_inc000.dream3d','r')
|
# features present in reference but not in exported file
|
||||||
|
for i in ['Pipeline','StatsGeneratorDataContainer','Grain Data',
|
||||||
|
'BoundaryCells','FeatureIds','IPFColor','NumFeatures']:
|
||||||
|
if path.find(i) >= 0: return True
|
||||||
|
return False
|
||||||
|
|
||||||
error_messages = []
|
with h5py.File(res_path/'2phase_irregularGrid.dream3d','r') as ref, \
|
||||||
|
h5py.File(tmp_path/'2phase_irregularGrid_tensionX_material_inc0.dream3d','r') as cur:
|
||||||
|
|
||||||
data_container_label = 'DataContainers/SyntheticVolumeDataContainer'
|
for (path,dset) in h5py_dataset_iterator(ref):
|
||||||
cell_data_label = data_container_label + '/CellData'
|
if ignore(path): continue
|
||||||
ensemble_label = data_container_label + '/CellEnsembleData'
|
if path.find('PhaseName') < 0:
|
||||||
geom_label = data_container_label + '/_SIMPL_GEOMETRY'
|
assert np.array_equal(dset,cur[path])
|
||||||
|
else:
|
||||||
|
c = [_.decode() for _ in cur[path]]
|
||||||
|
r = ['Unknown Phase Type'] + result.phases
|
||||||
|
assert c == r
|
||||||
|
grp = os.path.split(path)[0]
|
||||||
|
for attr in ref[grp].attrs:
|
||||||
|
assert np.array_equal(ref[grp].attrs[attr],cur[grp].attrs[attr])
|
||||||
|
for attr in dset.attrs:
|
||||||
|
assert np.array_equal(dset.attrs[attr],cur[path].attrs[attr])
|
||||||
|
|
||||||
# check phase array
|
|
||||||
results_phase = np.array(cur[cell_data_label + '/Phases'])
|
|
||||||
ref_phase = np.array(ref[cell_data_label + '/Phases'])
|
|
||||||
if not np.array_equal(results_phase,ref_phase):
|
|
||||||
error_messages.append('Phase array does not match')
|
|
||||||
|
|
||||||
# check euler angles
|
|
||||||
results_eulers = np.array(cur[cell_data_label + '/EulerAngles'])
|
|
||||||
ref_eulers = np.array(ref[cell_data_label + '/EulerAngles'])
|
|
||||||
if not np.allclose(results_eulers,ref_eulers,atol=1E-06):
|
|
||||||
error_messages.append('Euler angles array does not match')
|
|
||||||
|
|
||||||
# check CellData group attributes
|
|
||||||
for attrs in ['AttributeMatrixType','TupleDimensions']:
|
|
||||||
ref_val = ref[cell_data_label].attrs[attrs]
|
|
||||||
actual_val = cur[cell_data_label].attrs[attrs]
|
|
||||||
if not np.array_equal(ref_val,actual_val):
|
|
||||||
error_messages.append("Cell Data attributes do not match")
|
|
||||||
|
|
||||||
# Common Attributes for datasets in CellData
|
|
||||||
for dataset in ['/Phases','/EulerAngles']:
|
|
||||||
for attrs in ['DataArrayVersion','Tuple Axis Dimensions','ComponentDimensions','ObjectType','TupleDimensions']:
|
|
||||||
ref_val = ref[cell_data_label + '/' + dataset].attrs[attrs]
|
|
||||||
actual_val = cur[cell_data_label + '/' + dataset].attrs[attrs]
|
|
||||||
if not np.array_equal(ref_val,actual_val):
|
|
||||||
error_messages.append("Common attributes in datasets of CellData do not match")
|
|
||||||
|
|
||||||
# check crystal structure array
|
|
||||||
results_crystal_structure = np.array(cur[ensemble_label + '/CrystalStructures'])
|
|
||||||
ref_crystal_structure = np.array(ref[ensemble_label + '/CrystalStructures'])
|
|
||||||
if not np.allclose(results_crystal_structure, ref_crystal_structure):
|
|
||||||
error_messages.append('Crystal structure does not match')
|
|
||||||
|
|
||||||
# check PhaseName array
|
|
||||||
results_phase_name = np.array(cur[ensemble_label + '/PhaseName'])
|
|
||||||
ref_phase_name = ['Unknown Phase Type']
|
|
||||||
ref_phase_name.extend(i for i in result.visible['phases'])
|
|
||||||
ref_phase_name = [bytes(i,encoding='utf-8') for i in ref_phase_name]
|
|
||||||
if not np.all(results_phase_name == np.array(ref_phase_name,dtype=object)):
|
|
||||||
error_messages.append('Phase names are different')
|
|
||||||
|
|
||||||
# check attributes ensemble matrix
|
|
||||||
for attrs in ['AttributeMatrixType','TupleDimensions']:
|
|
||||||
ref_val = ref[ensemble_label].attrs[attrs]
|
|
||||||
actual_val = cur[ensemble_label].attrs[attrs]
|
|
||||||
if not np.array_equal(ref_val,actual_val):
|
|
||||||
error_messages.append("Attributes of CellEnsembleData do not match")
|
|
||||||
|
|
||||||
# check attributes of the data in ensemble matrix
|
|
||||||
# in the reference file the dataset PhaseTypes is in another group, so the path is different
|
|
||||||
for dataset in ['CrystalStructures','PhaseTypes']:
|
|
||||||
for attrs in ['DataArrayVersion','Tuple Axis Dimensions','ComponentDimensions','ObjectType','TupleDimensions']:
|
|
||||||
ref_value = ref['DataContainers/StatsGeneratorDataContainer/CellEnsembleData/' + dataset].attrs[attrs]
|
|
||||||
actual_val = cur[ensemble_label + '/' + dataset].attrs[attrs]
|
|
||||||
if not np.array_equal(ref_value,actual_val):
|
|
||||||
error_messages.append(f'Attributes of {dataset}s within CellEnsembleData do not match for this {attrs}')
|
|
||||||
|
|
||||||
for dataset in ['PhaseName']:
|
|
||||||
for attrs in ['DataArrayVersion','Tuple Axis Dimensions','ComponentDimensions','ObjectType','TupleDimensions']:
|
|
||||||
ref_value = ref['DataContainers/StatsGeneratorDataContainer/CellEnsembleData/' + dataset].attrs[attrs]
|
|
||||||
actual_val = cur[ensemble_label + '/' + dataset].attrs[attrs]
|
|
||||||
if not np.array_equal(ref_value,actual_val):
|
|
||||||
error_messages.append(f'Attributes of {dataset}s within CellEnsembleData do not match for this {attrs}')
|
|
||||||
|
|
||||||
# check geometry data
|
|
||||||
for dataset in ['DIMENSIONS','ORIGIN','SPACING']:
|
|
||||||
results_val = np.array(cur[geom_label + '/' + dataset])
|
|
||||||
ref_val = np.array(ref[geom_label + '/' + dataset])
|
|
||||||
if not np.array_equal(ref_val,results_val):
|
|
||||||
error_messages.append(f'The {dataset} values are incorrect')
|
|
||||||
|
|
||||||
for attrs in ['GeometryName','GeometryTypeName','GeometryType','SpatialDimensionality','UnitDimensionality']:
|
|
||||||
ref_value = ref[geom_label].attrs[attrs]
|
|
||||||
actual_val = cur[geom_label].attrs[attrs]
|
|
||||||
if not np.array_equal(ref_value,actual_val):
|
|
||||||
error_messages.append("Geometry attributes do not match")
|
|
||||||
|
|
||||||
assert not error_messages
|
|
||||||
|
|
||||||
def test_XDMF_datatypes(self,tmp_path,single_phase,update,res_path):
|
def test_XDMF_datatypes(self,tmp_path,single_phase,update,res_path):
|
||||||
for what,shape in {'scalar':(),'vector':(3,),'tensor':(3,3),'matrix':(12,)}.items():
|
for what,shape in {'scalar':(),'vector':(3,),'tensor':(3,3),'matrix':(12,)}.items():
|
||||||
|
|
Loading…
Reference in New Issue