documented and tested
This commit is contained in:
parent
e5b414419a
commit
4960cf43d4
|
@ -82,10 +82,14 @@ def from_geom(geom,selection=None,invert=False):
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
geom : damask.Geom
|
geom : damask.Geom
|
||||||
...
|
Geometry, from which the material IDs are used as seeds
|
||||||
|
selection : iterable of integers, optional
|
||||||
|
Material IDs to consider
|
||||||
|
invert : boolean, false
|
||||||
|
Do not consider the material IDs given in selection. Defaults to False.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
material = geom.materials.reshape((-1,1),order='F')
|
material = geom.material.reshape((-1,1),order='F')
|
||||||
mask = _np.full(geom.grid.prod(),True,dtype=bool) if selection is None else \
|
mask = _np.full(geom.grid.prod(),True,dtype=bool) if selection is None else \
|
||||||
_np.isin(material,selection,invert=invert)
|
_np.isin(material,selection,invert=invert)
|
||||||
coords = grid_filters.cell_coord0(geom.grid,geom.size).reshape(-1,3,order='F')
|
coords = grid_filters.cell_coord0(geom.grid,geom.size).reshape(-1,3,order='F')
|
||||||
|
|
|
@ -3,6 +3,7 @@ import numpy as np
|
||||||
from scipy.spatial import cKDTree
|
from scipy.spatial import cKDTree
|
||||||
|
|
||||||
from damask import seeds
|
from damask import seeds
|
||||||
|
from damask import Geom
|
||||||
|
|
||||||
class TestSeeds:
|
class TestSeeds:
|
||||||
|
|
||||||
|
@ -23,3 +24,13 @@ class TestSeeds:
|
||||||
min_dists, _ = cKDTree(coords,boxsize=size).query(coords, 2) if periodic else \
|
min_dists, _ = cKDTree(coords,boxsize=size).query(coords, 2) if periodic else \
|
||||||
cKDTree(coords).query(coords, 2)
|
cKDTree(coords).query(coords, 2)
|
||||||
assert (0<= coords).all() and (coords<size).all() and np.min(min_dists[:,1])>=distance
|
assert (0<= coords).all() and (coords<size).all() and np.min(min_dists[:,1])>=distance
|
||||||
|
|
||||||
|
def test_from_geom(self):
|
||||||
|
grid = np.random.randint(10,20,3)
|
||||||
|
N_seeds = np.random.randint(30,300)
|
||||||
|
size = np.ones(3) + np.random.random(3)
|
||||||
|
coords = seeds.from_random(size,N_seeds,grid)
|
||||||
|
geom_1 = Geom.from_Voronoi_tessellation(grid,size,coords)
|
||||||
|
coords,material = seeds.from_geom(geom_1)
|
||||||
|
geom_2 = Geom.from_Voronoi_tessellation(grid,size,coords,material)
|
||||||
|
assert (geom_2.material==geom_1.material).all()
|
||||||
|
|
Loading…
Reference in New Issue