@@ -470,3 +470,36 @@ def test_divergence_cleaning(Nphi, Ntheta, dealias, dtype):
470470 h .change_scales (1 )
471471 assert np .allclose (u ['g' ], h ['g' ])
472472
473+
474+ @pytest .mark .parametrize ('Nphi' , Nphi_range )
475+ @pytest .mark .parametrize ('Ntheta' , Ntheta_range )
476+ @pytest .mark .parametrize ('dealias' , dealias_range )
477+ @pytest .mark .parametrize ('dtype' , [np .float64 , np .complex128 ])
478+ def test_sphere_ell_product_scalar (Nphi , Ntheta , dealias , dtype ):
479+ c , d , b , phi , theta = build_sphere (Nphi , Ntheta , dealias , dtype )
480+ f = field .Field (dist = d , bases = (b ,), dtype = dtype )
481+ g = field .Field (dist = d , bases = (b ,), dtype = dtype )
482+ f .fill_random ('g' )
483+ func = lambda ell , r : ell + 3
484+ for ell , m_ind , ell_ind in b .ell_maps :
485+ g ['c' ][m_ind , ell_ind ] = func (ell , b .radius ) * f ['c' ][m_ind , ell_ind ]
486+ h = operators .SphereEllProduct (f , c , func ).evaluate ()
487+ assert np .allclose (g ['c' ], h ['c' ])
488+
489+
490+ @pytest .mark .parametrize ('Nphi' , Nphi_range )
491+ @pytest .mark .parametrize ('Ntheta' , Ntheta_range )
492+ @pytest .mark .parametrize ('dealias' , dealias_range )
493+ @pytest .mark .parametrize ('dtype' , [np .float64 , np .complex128 ])
494+ def test_sphere_ell_product_vector (Nphi , Ntheta , dealias , dtype ):
495+ c , d , b , phi , theta = build_sphere (Nphi , Ntheta , dealias , dtype )
496+ f = field .Field (dist = d , bases = (b ,), dtype = dtype , tensorsig = (c ,))
497+ g = field .Field (dist = d , bases = (b ,), dtype = dtype , tensorsig = (c ,))
498+ f .fill_random ('g' )
499+ func = lambda ell , r : ell + 3
500+ for ell , m_ind , ell_ind in b .ell_maps :
501+ for i in range (c .dim ):
502+ g ['c' ][i , m_ind , ell_ind ] = func (ell , b .radius ) * f ['c' ][i , m_ind , ell_ind ]
503+ h = operators .SphereEllProduct (f , c , func ).evaluate ()
504+ assert np .allclose (g ['c' ], h ['c' ])
505+
0 commit comments