Merge branch 'fix_grid_add_primitive_bug' into 'development'
fix grid add primitive bug Closes #207 See merge request damask/DAMASK!618
This commit is contained in:
commit
0cc64b87c2
|
@ -1206,7 +1206,7 @@ class Grid:
|
||||||
coords_rot = R.broadcast_to(tuple(self.cells))@coords
|
coords_rot = R.broadcast_to(tuple(self.cells))@coords
|
||||||
|
|
||||||
with np.errstate(all='ignore'):
|
with np.errstate(all='ignore'):
|
||||||
mask = np.sum(np.power(coords_rot/r,2.0**np.array(exponent)),axis=-1) > 1.0
|
mask = np.sum(np.power(np.abs(coords_rot)/r,2.0**np.array(exponent)),axis=-1) > 1.0
|
||||||
|
|
||||||
if periodic: # translate back to center
|
if periodic: # translate back to center
|
||||||
mask = np.roll(mask,((c/self.size-0.5)*self.cells).round().astype(np.int64),(0,1,2))
|
mask = np.roll(mask,((c/self.size-0.5)*self.cells).round().astype(np.int64),(0,1,2))
|
||||||
|
|
|
@ -299,7 +299,6 @@ class TestGrid:
|
||||||
G_2 = Grid(np.ones(g,'i'),s,o).add_primitive(diameter,center2,exponent)
|
G_2 = Grid(np.ones(g,'i'),s,o).add_primitive(diameter,center2,exponent)
|
||||||
assert np.count_nonzero(G_1.material!=2) == np.count_nonzero(G_2.material!=2)
|
assert np.count_nonzero(G_1.material!=2) == np.count_nonzero(G_2.material!=2)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('center',[np.random.randint(4,10,(3)),
|
@pytest.mark.parametrize('center',[np.random.randint(4,10,(3)),
|
||||||
np.random.randint(2,10),
|
np.random.randint(2,10),
|
||||||
np.random.rand()*4,
|
np.random.rand()*4,
|
||||||
|
@ -315,6 +314,14 @@ class TestGrid:
|
||||||
G_2 = Grid(np.ones(g,'i'),s).add_primitive(.3,center,1,fill,Rotation.from_random(),inverse,periodic=periodic)
|
G_2 = Grid(np.ones(g,'i'),s).add_primitive(.3,center,1,fill,Rotation.from_random(),inverse,periodic=periodic)
|
||||||
assert G_1 == G_2
|
assert G_1 == G_2
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('exponent',[1,np.inf,np.random.random(3)*2.])
|
||||||
|
def test_add_primitive_shape_symmetry(self,exponent):
|
||||||
|
"""Shapes defined in the center should always produce a grid with reflection symmetry along the coordinate axis."""
|
||||||
|
o = np.random.random(3)-.5
|
||||||
|
s = np.random.random(3)*5.
|
||||||
|
grid = Grid(np.zeros(np.random.randint(8,32,3),'i'),s,o).add_primitive(np.random.random(3)*3.,o+s/2.,exponent)
|
||||||
|
for axis in [0,1,2]:
|
||||||
|
assert np.all(grid.material==np.flip(grid.material,axis=axis))
|
||||||
|
|
||||||
@pytest.mark.parametrize('selection',[1,None])
|
@pytest.mark.parametrize('selection',[1,None])
|
||||||
def test_vicinity_offset(self,selection):
|
def test_vicinity_offset(self,selection):
|
||||||
|
|
Loading…
Reference in New Issue