3
3
"""
4
4
5
5
from os .path import abspath , dirname , join
6
+ from functools import partial
6
7
import pytest
7
8
import numpy as np
8
9
from firedrake import *
9
10
10
11
cwd = abspath (dirname (__file__ ))
11
12
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
+ ]
12
20
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 )
22
24
x = SpatialCoordinate (mesh )
23
25
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
28
31
29
32
Q = FunctionSpace (mesh , "DG" , 0 ) # result space
30
33
31
34
expression = x [0 ]* (x [0 ] + sqrt (2.0 )) + x [1 ]
32
35
f = Function (V ).interpolate (expression )
33
36
g = Function (W ).interpolate (expression )
34
37
35
- q = Function (Q ). interpolate ( Constant ( 0.0 ))
38
+ q = Function (Q )
36
39
37
40
domain = "{[i]: 0 <= i < C.dofs}"
38
41
instructions = """
@@ -43,3 +46,16 @@ def test_consistent_facet_orientation(mesh_thunk):
43
46
par_loop ((domain , instructions ), dx , {'C' : (f , READ ), 'D' : (g , READ ), 'R' : (q , RW )})
44
47
45
48
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