33"""
44
55from os .path import abspath , dirname , join
6+ from functools import partial
67import pytest
78import numpy as np
89from firedrake import *
910
1011cwd = abspath (dirname (__file__ ))
1112
13+ meshes = [
14+ partial (UnitSquareMesh , 5 , 5 , quadrilateral = False ),
15+ partial (UnitSquareMesh , 5 , 5 , quadrilateral = True ),
16+ partial (UnitIcosahedralSphereMesh , 2 ),
17+ partial (UnitCubedSphereMesh , 3 ),
18+ partial (Mesh , join (cwd , ".." , "meshes" , "unitsquare_unstructured_quadrilaterals.msh" )),
19+ ]
1220
13- @pytest .mark .parametrize ('mesh_thunk' ,
14- [lambda : UnitSquareMesh (5 , 5 , quadrilateral = False ),
15- lambda : UnitSquareMesh (5 , 5 , quadrilateral = True ),
16- lambda : UnitIcosahedralSphereMesh (2 ),
17- lambda : UnitCubedSphereMesh (3 ),
18- lambda : Mesh (join (cwd , ".." , "meshes" ,
19- "unitsquare_unstructured_quadrilaterals.msh" ))])
20- def test_consistent_facet_orientation (mesh_thunk ):
21- mesh = mesh_thunk ()
21+
22+ def run_consistent_facet_orientation (mesh_thunk , variant = "equispaced" , ** kwargs ):
23+ mesh = mesh_thunk (** kwargs )
2224 x = SpatialCoordinate (mesh )
2325 degree = 3
24- fe_cg = FiniteElement ("CG" , mesh .ufl_cell (), degree , variant = "equispaced" )
25- V = FunctionSpace (mesh , fe_cg ) # continuous space
26- fe_dg = FiniteElement ("DG" , mesh .ufl_cell (), degree , variant = "equispaced" )
27- W = FunctionSpace (mesh , fe_dg ) # discontinuous space
26+ V = FunctionSpace (mesh , "CG" , degree , variant = variant ) # continuous space
27+ if variant == "equispaced" :
28+ W = FunctionSpace (mesh , "DG" , degree , variant = variant ) # discontinuous space
29+ else :
30+ W = FunctionSpace (mesh , BrokenElement (V .ufl_element ())) # discontinuous space
2831
2932 Q = FunctionSpace (mesh , "DG" , 0 ) # result space
3033
3134 expression = x [0 ]* (x [0 ] + sqrt (2.0 )) + x [1 ]
3235 f = Function (V ).interpolate (expression )
3336 g = Function (W ).interpolate (expression )
3437
35- q = Function (Q ). interpolate ( Constant ( 0.0 ))
38+ q = Function (Q )
3639
3740 domain = "{[i]: 0 <= i < C.dofs}"
3841 instructions = """
@@ -43,3 +46,16 @@ def test_consistent_facet_orientation(mesh_thunk):
4346 par_loop ((domain , instructions ), dx , {'C' : (f , READ ), 'D' : (g , READ ), 'R' : (q , RW )})
4447
4548 assert np .allclose (q .dat .data , 0.0 )
49+
50+
51+ @pytest .mark .parametrize ('mesh_thunk' , meshes )
52+ def test_consistent_facet_orientation (mesh_thunk ):
53+ run_consistent_facet_orientation (mesh_thunk )
54+
55+
56+ @pytest .mark .parallel (nprocs = 2 )
57+ @pytest .mark .parametrize ('variant' , ("equispaced" , "integral" ))
58+ @pytest .mark .parametrize ('mesh_thunk' , meshes )
59+ def test_consistent_facet_orientation_parallel (mesh_thunk , variant ):
60+ dp = {"overlap_type" : (DistributedMeshOverlapType .NONE , 0 )}
61+ run_consistent_facet_orientation (mesh_thunk , variant = variant , distribution_parameters = dp )
0 commit comments