testing non-trivial situation

This commit is contained in:
Martin Diehl 2022-01-10 08:03:37 +01:00
parent 076de59375
commit 8de4829d0f
1 changed files with 11 additions and 2 deletions

View File

@ -2,6 +2,8 @@ import pytest
import numpy as np import numpy as np
from damask import grid_filters from damask import grid_filters
from damask import Grid
from damask import seeds
class TestGridFilters: class TestGridFilters:
@ -139,12 +141,19 @@ class TestGridFilters:
else: else:
function(unordered,mode) function(unordered,mode)
def test_regrid(self): def test_regrid_identity(self):
size = np.random.random(3) size = np.random.random(3)
cells = np.random.randint(8,32,(3)) cells = np.random.randint(8,32,(3))
F = np.broadcast_to(np.eye(3), tuple(cells)+(3,3)) F = np.broadcast_to(np.eye(3), tuple(cells)+(3,3))
assert all(grid_filters.regrid(size,F,cells) == np.arange(cells.prod())) assert all(grid_filters.regrid(size,F,cells) == np.arange(cells.prod()))
def test_regrid_double_cells(self):
size = np.random.random(3)
cells = np.random.randint(8,32,(3))
g = Grid.from_Voronoi_tessellation(cells,size,seeds.from_random(size,10))
F = np.broadcast_to(np.eye(3), tuple(cells)+(3,3))
assert all(g.scale(cells*2).material.flatten() ==
g.material.flatten()[grid_filters.regrid(size,F,cells*2)])
@pytest.mark.parametrize('differential_operator',[grid_filters.curl, @pytest.mark.parametrize('differential_operator',[grid_filters.curl,
grid_filters.divergence, grid_filters.divergence,