better looking test fields

This commit is contained in:
f.basile 2020-05-06 12:54:24 +02:00
parent bd518b2806
commit 8b4baecdee
1 changed files with 41 additions and 40 deletions

View File

@ -6,46 +6,47 @@ from damask import grid_filters
class TestGridFilters:
@pytest.mark.parametrize('field_def,curl_def',
[(['np.sin(np.pi*2*nodes[...,2]/size[2])', '0.0', '0.0',
'0.0', '0.0', '0.0',
'0.0', '0.0', '0.0' ],
['0.0' , '0.0', '0.0',
'np.cos(np.pi*2*nodes[...,2]/size[2])*np.pi*2/size[2]', '0.0', '0.0',
'0.0', '0.0', '0.0']
),
(['np.cos(np.pi*2*nodes[...,1]/size[1])', '0.0', '0.0',
'0.0', '0.0', '0.0',
'np.cos(np.pi*2*nodes[...,0]/size[0])', '0.0', '0.0'],
['0.0', '0.0', '0.0',
'0.0', '0.0', '0.0',
'np.sin(np.pi*2*nodes[...,1]/size[1])*np.pi*2/size[1]', '0.0', '0.0']
),
(['np.sin(np.pi*2*nodes[...,0]/size[0])','np.cos(np.pi*2*nodes[...,1]/size[1])','np.sin(np.pi*2*nodes[...,2]/size[2])',
'np.sin(np.pi*2*nodes[...,0]/size[0])','np.cos(np.pi*2*nodes[...,1]/size[1])','np.sin(np.pi*2*nodes[...,2]/size[2])',
'np.sin(np.pi*2*nodes[...,0]/size[0])','np.cos(np.pi*2*nodes[...,1]/size[1])','np.sin(np.pi*2*nodes[...,2]/size[2])'],
['0.0', '0.0', '0.0',
'0.0', '0.0', '0.0',
'0.0', '0.0', '0.0']
),
(['5.0', '0.0', '0.0',
'0.0', '0.0', '0.0',
'0.0', '0.0', '2*np.cos(np.pi*2*nodes[...,1]/size[1])'],
['0.0', '0.0', '-2*np.pi*2/size[1]*np.sin(np.pi*2*nodes[...,1]/size[1])',
'0.0', '0.0', '0.0',
'0.0', '0.0', '0.0']
),
(['4*np.sin(np.pi*2*nodes[...,2]/size[2])', '8*np.sin(np.pi*2*nodes[...,0]/size[0])', '16*np.sin(np.pi*2*nodes[...,1]/size[1])'],
['16*np.pi*2/size[1]*np.cos(np.pi*2*nodes[...,1]/size[1])', \
'4*np.pi*2/size[2]*np.cos(np.pi*2*nodes[...,2]/size[2])', \
'8*np.pi*2/size[0]*np.cos(np.pi*2*nodes[...,0]/size[0])']
),
(['0.0', 'np.cos(np.pi*2*nodes[...,0]/size[0])+5*np.cos(np.pi*2*nodes[...,2]/size[2])', '0.0'],
['5*np.sin(np.pi*2*nodes[...,2]/size[2])*np.pi*2/size[2]',\
'0.0',\
'-np.sin(np.pi*2*nodes[...,0]/size[0])*np.pi*2/size[0]']
)
])
curl_test_data =[(['np.sin(np.pi*2*nodes[...,2]/size[2])', '0.0', '0.0',
'0.0', '0.0', '0.0',
'0.0', '0.0', '0.0' ],
['0.0' , '0.0', '0.0',
'np.cos(np.pi*2*nodes[...,2]/size[2])*np.pi*2/size[2]', '0.0', '0.0',
'0.0', '0.0', '0.0']
),
(['np.cos(np.pi*2*nodes[...,1]/size[1])', '0.0', '0.0',
'0.0', '0.0', '0.0',
'np.cos(np.pi*2*nodes[...,0]/size[0])', '0.0', '0.0'],
['0.0', '0.0', '0.0',
'0.0', '0.0', '0.0',
'np.sin(np.pi*2*nodes[...,1]/size[1])*np.pi*2/size[1]', '0.0', '0.0']
),
(['np.sin(np.pi*2*nodes[...,0]/size[0])','np.cos(np.pi*2*nodes[...,1]/size[1])','np.sin(np.pi*2*nodes[...,2]/size[2])',
'np.sin(np.pi*2*nodes[...,0]/size[0])','np.cos(np.pi*2*nodes[...,1]/size[1])','np.sin(np.pi*2*nodes[...,2]/size[2])',
'np.sin(np.pi*2*nodes[...,0]/size[0])','np.cos(np.pi*2*nodes[...,1]/size[1])','np.sin(np.pi*2*nodes[...,2]/size[2])'],
['0.0', '0.0', '0.0',
'0.0', '0.0', '0.0',
'0.0', '0.0', '0.0']
),
(['5.0', '0.0', '0.0',
'0.0', '0.0', '0.0',
'0.0', '0.0', '2*np.cos(np.pi*2*nodes[...,1]/size[1])'],
['0.0', '0.0', '-2*np.pi*2/size[1]*np.sin(np.pi*2*nodes[...,1]/size[1])',
'0.0', '0.0', '0.0',
'0.0', '0.0', '0.0']
),
(['4*np.sin(np.pi*2*nodes[...,2]/size[2])', '8*np.sin(np.pi*2*nodes[...,0]/size[0])', '16*np.sin(np.pi*2*nodes[...,1]/size[1])'],
['16*np.pi*2/size[1]*np.cos(np.pi*2*nodes[...,1]/size[1])', \
'4*np.pi*2/size[2]*np.cos(np.pi*2*nodes[...,2]/size[2])', \
'8*np.pi*2/size[0]*np.cos(np.pi*2*nodes[...,0]/size[0])']
),
(['0.0', 'np.cos(np.pi*2*nodes[...,0]/size[0])+5*np.cos(np.pi*2*nodes[...,2]/size[2])', '0.0'],
['5*np.sin(np.pi*2*nodes[...,2]/size[2])*np.pi*2/size[2]',\
'0.0',\
'-np.sin(np.pi*2*nodes[...,0]/size[0])*np.pi*2/size[0]'])]
@pytest.mark.parametrize('field_def,curl_def',curl_test_data)
def test_curl(self,field_def,curl_def):
size = np.random.random(3)+1.0
grid = np.random.randint(8,32,(3))