@@ -338,7 +338,7 @@ def test_ipdg_direct_solver(fs):
338338
339339
340340@pytest .mark .parallel (nprocs = 2 )
341- @pytest .mark .parametrize ("mat_type" , ("aij" , "is" ))
341+ @pytest .mark .parametrize ("mat_type" , ("aij" ,))
342342@pytest .mark .parametrize ("degree" , (1 , 4 ))
343343@pytest .mark .parametrize ("variant" , ("spectral" , "integral" , "fdm" ))
344344def test_tabulate_gradient (mesh , variant , degree , mat_type ):
@@ -348,13 +348,40 @@ def test_tabulate_gradient(mesh, variant, degree, mat_type):
348348
349349 V0 = FunctionSpace (mesh , "Lagrange" , degree , variant = variant )
350350 V1 = FunctionSpace (mesh , family , degree - (tdim == 1 ), variant = variant )
351- D = tabulate_exterior_derivative (V0 , V1 )
351+ D = tabulate_exterior_derivative (V0 , V1 , mat_type = mat_type )
352+
353+ M = assemble (inner (TrialFunction (V1 ), TestFunction (V1 ))* dx ).petscmat
354+ Dij = D if D .type .endswith ("aij" ) else D .convert (M .type , PETSc .Mat ())
355+ B = M .matMult (Dij )
352356
353- u0 = Function (V0 ).interpolate (1 )
354- u1 = Function (V1 )
355- with u0 .dat .vec as x , u1 .dat .vec as y :
356- D .mult (x , y )
357- assert y .norm () < 1E-12
357+ Bref = assemble (inner (grad (TrialFunction (V0 )), TestFunction (V1 ))* dx ).petscmat
358+ Bref .axpy (- 1 , B )
359+ _ , _ , vals = Bref .getValuesCSR ()
360+ assert numpy .allclose (vals , 0 )
361+
362+
363+ @pytest .mark .parallel (nprocs = 2 )
364+ @pytest .mark .parametrize ("mat_type" , ("aij" ,))
365+ @pytest .mark .parametrize ("degree" , (1 , 4 ))
366+ @pytest .mark .parametrize ("variant" , ("spectral" , "integral" , "fdm" ))
367+ def test_tabulate_curl (mesh , variant , degree , mat_type ):
368+ from firedrake .preconditioners .fdm import tabulate_exterior_derivative
369+ tdim = mesh .topological_dimension ()
370+ family1 = {1 : "CG" , 2 : "CG" , 3 : "NCE" }[tdim ]
371+ family2 = {1 : "DG" , 2 : "RTCF" , 3 : "NCF" }[tdim ]
372+
373+ V1 = FunctionSpace (mesh , family1 , degree , variant = variant )
374+ V2 = FunctionSpace (mesh , family2 , degree - (tdim == 1 ), variant = variant )
375+ D = tabulate_exterior_derivative (V1 , V2 , mat_type = mat_type )
376+
377+ M = assemble ((- 1 )** (tdim - 1 )* inner (TrialFunction (V2 ), TestFunction (V2 ))* dx ).petscmat
378+ Dij = D if D .type .endswith ("aij" ) else D .convert (M .type , PETSc .Mat ())
379+ B = M .matMult (Dij )
380+
381+ Bref = assemble (inner (curl (TrialFunction (V1 )), TestFunction (V2 ))* dx ).petscmat
382+ Bref .axpy (- 1 , B )
383+ _ , _ , vals = Bref .getValuesCSR ()
384+ assert numpy .allclose (vals , 0 )
358385
359386
360387@pytest .mark .parallel (nprocs = 2 )
@@ -372,13 +399,12 @@ def test_tabulate_divergence(mesh, variant, degree, mat_type):
372399
373400 # Fix scale
374401 Jdet = JacobianDeterminant (mesh )
375- s = assemble (inner (TrialFunction (Q )* (1 / Jdet ), TestFunction (Q ))* dx , diagonal = True )
376- with s .dat .vec as svec :
377- D .diagonalScale (svec , None )
402+ M = assemble (inner (TrialFunction (Q )* (1 / Jdet ), TestFunction (Q ))* dx , diagonal = True )
403+ with M .dat .vec as mvec :
404+ D .diagonalScale (mvec , None )
378405
379406 Dref = assemble (inner (div (TrialFunction (V )), TestFunction (Q ))* dx ).petscmat
380407 Dij = D if D .type .endswith ("aij" ) else D .convert (Dref .type , PETSc .Mat ())
381-
382408 Dref .axpy (- 1 , Dij )
383409 _ , _ , vals = Dref .getValuesCSR ()
384410 assert numpy .allclose (vals , 0 )
0 commit comments