From 8ba9bb02c7468854c5d1bc5c19ce0e466594a4da Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Tue, 29 Nov 2022 15:47:11 -0500 Subject: [PATCH] slight reduction of code doubling --- python/damask/grid_filters.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/python/damask/grid_filters.py b/python/damask/grid_filters.py index cbd4b35e5..38039ac14 100644 --- a/python/damask/grid_filters.py +++ b/python/damask/grid_filters.py @@ -103,8 +103,8 @@ def divergence(size: _FloatSequence, k_s = _ks(size,f.shape[:3],True) f_fourier = _np.fft.rfftn(f,axes=(0,1,2)) - divergence_ = (_np.einsum('ijkl,ijkl ->ijk', k_s,f_fourier)*2.0j*_np.pi if n == 3 else # vector, 3 -> 1 - _np.einsum('ijkm,ijklm->ijkl',k_s,f_fourier)*2.0j*_np.pi) # tensor, 3x3 -> 3 + divergence_ = (_np.einsum('ijkl,ijkl ->ijk' if n==3 else + 'ijkm,ijklm->ijkl', k_s,f_fourier)*2.0j*_np.pi) # vector 3 -> 1, tensor 3x3 -> 3 return _np.fft.irfftn(divergence_,axes=(0,1,2),s=f.shape[:3]) @@ -131,8 +131,8 @@ def gradient(size: _FloatSequence, k_s = _ks(size,f.shape[:3],True) f_fourier = _np.fft.rfftn(f,axes=(0,1,2)) - gradient_ = (_np.einsum('ijkl,ijkm->ijkm', f_fourier,k_s)*2.0j*_np.pi if n == 1 else # scalar, 1 -> 3 - _np.einsum('ijkl,ijkm->ijklm',f_fourier,k_s)*2.0j*_np.pi) # vector, 3 -> 3x3 + gradient_ = (_np.einsum('ijkl,ijkm->ijkm' if n==1 else + 'ijkl,ijkm->ijklm',f_fourier,k_s)*2.0j*_np.pi) # scalar 1 -> 3, vector 3 -> 3x3 return _np.fft.irfftn(gradient_,axes=(0,1,2),s=f.shape[:3])