Skip to content

Commit ee42d5d

Browse files
committed
Merge branch 'improved-load_DREAM3D-test' into 'development'
more thorough check See merge request damask/DAMASK!936
2 parents c0303c4 + 8024381 commit ee42d5d

File tree

3 files changed

+57
-26
lines changed

3 files changed

+57
-26
lines changed

python/damask/_configmaterial.py

+14-5
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,20 @@ def load_DREAM3D(fname: str,
106106
107107
Notes
108108
-----
109-
damask.GeomGrid.load_DREAM3D gives the corresponding geometry for
110-
the grid solver.
111-
112-
For cell-wise data, only unique combinations of
113-
orientation and phase are considered.
109+
A grain-wise material configuration is based on segmented data from
110+
the DREAM.3D file. This data is typically available when the microstructure
111+
was synthetically created. In cell-wise representations, cells having the
112+
same orientation and phase are grouped. Since synthetically created
113+
microstructures have typically no in-grain scatter, cell-wise grids
114+
can appear to be segmented.
115+
116+
damask.GeomGrid.load_DREAM3D creates the corresponding grid-based
117+
geometry definition. Since the numbering of materials in cell-wise
118+
and grain-wise grids is different, it is imperative to use the same
119+
mode for both load_DREAM3D functions. That means, if the "grain_data"
120+
argument is used for this function, the correct grid configuration
121+
is only obtained if the "feature_IDs" argument is used when calling
122+
damask.GeomGrid.load_DREAM3D.
114123
115124
Homogenization and phase entries are emtpy and need to be
116125
defined separately.

python/damask/_geomgrid.py

+24-15
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def _load(fname: Union[str, Path], label: str) -> 'GeomGrid':
212212
Returns
213213
-------
214214
loaded : damask.GeomGrid
215-
GeomGrid-based geometry from file.
215+
Grid-based geometry from file.
216216
217217
"""
218218
v = VTK.load(fname if str(fname).endswith('.vti') else str(fname)+'.vti')
@@ -241,7 +241,7 @@ def load(fname: Union[str, Path]) -> 'GeomGrid':
241241
Returns
242242
-------
243243
loaded : damask.GeomGrid
244-
GeomGrid-based geometry from file.
244+
Grid-based geometry from file.
245245
246246
"""
247247
return GeomGrid._load(fname,'material')
@@ -261,7 +261,7 @@ def load_SPPARKS(fname: Union[str, Path]) -> 'GeomGrid':
261261
Returns
262262
-------
263263
loaded : damask.GeomGrid
264-
GeomGrid-based geometry from file.
264+
Grid-based geometry from file.
265265
266266
Notes
267267
-----
@@ -289,7 +289,7 @@ def load_ASCII(fname)-> 'GeomGrid':
289289
Returns
290290
-------
291291
loaded : damask.GeomGrid
292-
GeomGrid-based geometry from file.
292+
Grid-based geometry from file.
293293
294294
"""
295295
warnings.warn('Support for ASCII-based geom format will be removed in DAMASK 3.0.0', DeprecationWarning,2)
@@ -362,7 +362,7 @@ def load_Neper(fname: Union[str, Path]) -> 'GeomGrid':
362362
Returns
363363
-------
364364
loaded : damask.GeomGrid
365-
GeomGrid-based geometry from file.
365+
Grid-based geometry from file.
366366
367367
Notes
368368
-----
@@ -437,15 +437,24 @@ def load_DREAM3D(fname: Union[str, Path],
437437
Returns
438438
-------
439439
loaded : damask.GeomGrid
440-
GeomGrid-based geometry from file.
440+
Grid-based geometry from file.
441441
442442
Notes
443443
-----
444-
damask.ConfigMaterial.load_DREAM3D gives the corresponding
445-
material definition.
446-
447-
For cell-wise data, only unique combinations of
448-
orientation and phase are considered.
444+
A grain-wise geometry definition is based on segmented data from the
445+
DREAM.3D file. This data is typically available when the microstructure
446+
was synthetically created. In cell-wise representations, cells having
447+
the same orientation and phase are grouped. Since synthetically created
448+
microstructures have typically no in-grain scatter, cell-wise grids
449+
can appear to be segmented.
450+
451+
damask.ConfigMaterial.load_DREAM3D creates the corresponding
452+
material definition. Since the numbering of materials in cell-wise
453+
and grain-wise grids is different, it is imperative to use the same
454+
mode for both load_DREAM3D functions. That means, if the "feature_IDs"
455+
argument is used for this function, the correct material configuration
456+
is only obtained if the "grain_data" argument is used when calling
457+
damask.ConfigMaterial.load_DREAM3D.
449458
450459
"""
451460
with h5py.File(fname, 'r') as f:
@@ -493,7 +502,7 @@ def from_table(table: Table,
493502
Returns
494503
-------
495504
new : damask.GeomGrid
496-
GeomGrid-based geometry from values in table.
505+
Grid-based geometry from values in table.
497506
498507
"""
499508
cells,size,origin = grid_filters.cellsSizeOrigin_coordinates0_point(table.get(coordinates))
@@ -548,7 +557,7 @@ def from_Laguerre_tessellation(cells: IntSequence,
548557
Returns
549558
-------
550559
new : damask.GeomGrid
551-
GeomGrid-based geometry from tessellation.
560+
Grid-based geometry from tessellation.
552561
553562
"""
554563
weights_p: FloatSequence
@@ -604,7 +613,7 @@ def from_Voronoi_tessellation(cells: IntSequence,
604613
Returns
605614
-------
606615
new : damask.GeomGrid
607-
GeomGrid-based geometry from tessellation.
616+
Grid-based geometry from tessellation.
608617
609618
"""
610619
coords = grid_filters.coordinates0_point(cells,size).reshape(-1,3)
@@ -691,7 +700,7 @@ def from_minimal_surface(cells: IntSequence,
691700
Returns
692701
-------
693702
new : damask.GeomGrid
694-
GeomGrid-based geometry from definition of minimal surface.
703+
Grid-based geometry from definition of minimal surface.
695704
696705
Notes
697706
-----

python/tests/test_GeomGrid.py

+19-6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from damask import Table
1010
from damask import Rotation
1111
from damask import Colormap
12+
from damask import ConfigMaterial
1213
from damask import util
1314
from damask import seeds
1415
from damask import grid_filters
@@ -491,12 +492,24 @@ def test_get_grain_boundaries_invalid(self,default,directions):
491492
default.get_grain_boundaries(directions=directions)
492493

493494
def test_load_DREAM3D(self,res_path):
494-
grain = GeomGrid.load_DREAM3D(res_path/'2phase_irregularGrid.dream3d','FeatureIds')
495-
point = GeomGrid.load_DREAM3D(res_path/'2phase_irregularGrid.dream3d')
496-
497-
assert np.allclose(grain.origin,point.origin) and \
498-
np.allclose(grain.size,point.size) and \
499-
(grain.sort().material == point.material+1).all()
495+
"""
496+
For synthetic microstructures (no in-grain scatter), check that:
497+
1) the sorted and renumbered grain-wise representation is equivalent to the cell-wise representation.
498+
2) the same orientations are assigned to each cell for the grain-wise and cell-wise approaches.
499+
"""
500+
# grain-wise data (using existing DREAM.3D segmentation)
501+
grid_grain = GeomGrid.load_DREAM3D(res_path/'2phase_irregularGrid.dream3d','FeatureIds')
502+
material_grain = ConfigMaterial.load_DREAM3D(res_path/'2phase_irregularGrid.dream3d','Grain Data')
503+
O_grain = np.array([material['constituents'][0]['O'] for material in material_grain['material']])
504+
# cell-wise data (clustering identical orientation-phase combinations)
505+
grid_cell = GeomGrid.load_DREAM3D(res_path/'2phase_irregularGrid.dream3d')
506+
material_cell = ConfigMaterial.load_DREAM3D(res_path/'2phase_irregularGrid.dream3d')
507+
O_cell = np.array([material['constituents'][0]['O'] for material in material_cell['material']])
508+
509+
assert np.allclose(grid_grain.origin,grid_cell.origin) and \
510+
np.allclose(grid_grain.size,grid_cell.size) and \
511+
np.allclose(O_grain[grid_grain.material],O_cell[grid_cell.material]) and \
512+
(grid_grain.renumber().sort().material == grid_cell.material).all()
500513

501514
def test_load_DREAM3D_reference(self,res_path,update):
502515
current = GeomGrid.load_DREAM3D(res_path/'measured.dream3d')

0 commit comments

Comments
 (0)