don't change Neper material ID definition
Neper material ID start at 0 if a buffer layer is added (run "neper -T -n 100 -tesrsize 320:320:320 -domain "cylinder(20,10)" -format vtk"), otherwise at 1. Hence, leave the IDs untouched and let the user change the numbering (either by a constant offset or by re-numbering): "explicit is better than implicit"
This commit is contained in:
parent
85a06c3ed7
commit
cfdf33e4b1
|
@ -317,6 +317,11 @@ class Grid:
|
||||||
loaded : damask.Grid
|
loaded : damask.Grid
|
||||||
Grid-based geometry from file.
|
Grid-based geometry from file.
|
||||||
|
|
||||||
|
Notes
|
||||||
|
-----
|
||||||
|
Material indices in Neper usually start at 1 unless
|
||||||
|
a buffer material with index 0 is added.
|
||||||
|
|
||||||
Examples
|
Examples
|
||||||
--------
|
--------
|
||||||
Read a periodic polycrystal generated with Neper.
|
Read a periodic polycrystal generated with Neper.
|
||||||
|
@ -325,7 +330,7 @@ class Grid:
|
||||||
>>> N_grains = 20
|
>>> N_grains = 20
|
||||||
>>> cells = (32,32,32)
|
>>> cells = (32,32,32)
|
||||||
>>> damask.util.run(f'neper -T -n {N_grains} -tesrsize {cells[0]}:{cells[1]}:{cells[2]} -periodicity all -format vtk')
|
>>> damask.util.run(f'neper -T -n {N_grains} -tesrsize {cells[0]}:{cells[1]}:{cells[2]} -periodicity all -format vtk')
|
||||||
>>> damask.Grid.load_Neper(f'n{N_grains}-id1.vtk')
|
>>> damask.Grid.load_Neper(f'n{N_grains}-id1.vtk').renumber()
|
||||||
cells: 32 × 32 × 32
|
cells: 32 × 32 × 32
|
||||||
size: 1.0 × 1.0 × 1.0 m³
|
size: 1.0 × 1.0 × 1.0 m³
|
||||||
origin: 0.0 0.0 0.0 m
|
origin: 0.0 0.0 0.0 m
|
||||||
|
@ -336,7 +341,7 @@ class Grid:
|
||||||
cells = np.array(v.vtk_data.GetDimensions())-1
|
cells = np.array(v.vtk_data.GetDimensions())-1
|
||||||
bbox = np.array(v.vtk_data.GetBounds()).reshape(3,2).T
|
bbox = np.array(v.vtk_data.GetBounds()).reshape(3,2).T
|
||||||
|
|
||||||
return Grid(material = v.get('MaterialId').reshape(cells,order='F').astype('int32',casting='unsafe') - 1,
|
return Grid(material = v.get('MaterialId').reshape(cells,order='F').astype('int32',casting='unsafe'),
|
||||||
size = bbox[1] - bbox[0],
|
size = bbox[1] - bbox[0],
|
||||||
origin = bbox[0],
|
origin = bbox[0],
|
||||||
comments = util.execution_stamp('Grid','load_Neper'),
|
comments = util.execution_stamp('Grid','load_Neper'),
|
||||||
|
|
|
@ -501,7 +501,7 @@ class TestGrid:
|
||||||
assert current == reference
|
assert current == reference
|
||||||
|
|
||||||
def test_load_Neper_reference(self,res_path,update):
|
def test_load_Neper_reference(self,res_path,update):
|
||||||
current = Grid.load_Neper(res_path/'n10-id1_scaled.vtk')
|
current = Grid.load_Neper(res_path/'n10-id1_scaled.vtk').renumber()
|
||||||
reference = Grid.load(res_path/'n10-id1_scaled.vti')
|
reference = Grid.load(res_path/'n10-id1_scaled.vti')
|
||||||
if update:
|
if update:
|
||||||
current.save(res_path/'n10-id1_scaled.vti')
|
current.save(res_path/'n10-id1_scaled.vti')
|
||||||
|
|
Loading…
Reference in New Issue