@@ -1173,13 +1173,18 @@ def test_derivative_domains(compile_args):
11731173
11741174
11751175@pytest .mark .parametrize ("dtype" , ["float64" ])
1176- def test_mixed_dim_form (compile_args , dtype , permutation , local_index ):
1176+ @pytest .mark .parametrize ("permutation" , [[0 ], [1 ]])
1177+ def test_mixed_dim_form (compile_args , dtype , permutation ):
11771178 """Test that the local element tensor corresponding to a mixed-dimensional form is correct.
11781179 The form involves an integral over a facet of the cell. The trial function and a coefficient f
11791180 are of codim 0. The test function and a coefficient g are of codim 1. We compare against another
11801181 form where the test function and g are codim 0 but have the same trace on the facet.
11811182 """
11821183
1184+ (facet_index ,) = [
1185+ i for i , v in enumerate (basix .topology (basix .CellType .triangle )[1 ]) if v == [1 , 2 ]
1186+ ]
1187+
11831188 def tabulate_tensor (ele_type , V_cell_type , W_cell_type , coeffs ):
11841189 "Helper function to create a form and compute the local element tensor"
11851190 V_ele = basix .ufl .element (ele_type , V_cell_type , 2 )
@@ -1212,7 +1217,7 @@ def tabulate_tensor(ele_type, V_cell_type, W_cell_type, coeffs):
12121217 A = np .zeros ((W_ele .dim , V_ele .dim ), dtype = dtype )
12131218 w = np .array (coeffs , dtype = dtype )
12141219 c = np .array ([], dtype = dtype )
1215- facet = np .array ([0 ], dtype = np .intc )
1220+ facet = np .array ([facet_index ], dtype = np .intc )
12161221 perm = np .array (permutation , dtype = np .uint8 )
12171222
12181223 xdtype = dtype_to_scalar_dtype (dtype )
@@ -1261,32 +1266,33 @@ def tabulate_tensor(ele_type, V_cell_type, W_cell_type, coeffs):
12611266 A_ref = A_ref [1 :][:]
12621267
12631268 # The orientation of the interval is assumed to be fixed (since it is given uniquely
1264- # by its global orientation in the mesh). Let us focus on local facet 0. It can have
1265- # two possible orientations depending on the cell topology:
1269+ # by its global orientation in the mesh). Let us focus on the local facet between vertices
1270+ # 1 and 2. It can have two possible orientations depending on the cell topology:
12661271 #
12671272 # 2 1 1 1
12681273 # | \ \ | \ \
12691274 # | \ \ or | \ \
12701275 # 0---1 0 0---2 0
12711276 #
1272- # In the second case, local facet 0 is flipped relative to the interval. If we look at
1277+ # In the second case, the local facet is flipped relative to the interval. If we look at
12731278 # the degrees of freedom second-order Lagrange on the triangle and first-order Lagrange
12741279 # on the interval, we have
12751280 #
12761281 # 2 1 1 1
12771282 # | \ \ | \ \
1278- # 4 3 \ 5 3 \
1283+ # B C \ A C \
12791284 # | \ \ or | \ \
1280- # 0--5 --1 0 0--4 --2 0
1285+ # 0--A --1 0 0--B --2 0
12811286 #
12821287 # Since the trial function is defined on the triangle, the second case (where the
1283- # permutation is 1) is thus the same as swapping cols 1 and 2 and cols 4 and 5 of the
1288+ # permutation is 1) is thus the same as swapping cols 1 and 2 and cols A and B of the
12841289 # first case result.
12851290 # NOTE: Although we choose to fix the orientation of the interval, the same result
12861291 # can be obtained by fixing the triangle and considering flipping the interval.
12871292 if permutation [0 ] == 1 :
12881293 A_ref [:, [1 , 2 ]] = A_ref [:, [2 , 1 ]]
1289- A_ref [:, [4 , 5 ]] = A_ref [:, [5 , 4 ]]
1294+ edge_dofs = [3 + i for i in range (3 ) if i != facet_index ]
1295+ A_ref [:, edge_dofs ] = A_ref [:, edge_dofs [::- 1 ]]
12901296
12911297 assert np .allclose (A , A_ref )
12921298
@@ -1660,7 +1666,7 @@ def tabulate_tensor(ele_type, V_cell_type, W_cell_type, coeffs, l_i):
16601666 A_ref = tabulate_tensor (ele_type , V_cell_type , V_cell_type , coeff_data , local_entity_index )
16611667
16621668 # Map from local edge index to (local) DOF indices on that edge
1663- local_index_to_slice = { 0 : [ 2 , 3 ] , 1 : [ 1 , 3 ], 2 : [ 1 , 2 ], 3 : [ 0 , 3 ], 4 : [ 0 , 2 ], 5 : [ 0 , 1 ]}
1669+ local_index_to_slice = basix . ufl . element ( ele_type , V_cell_type , 1 ). entity_closure_dofs [ 1 ]
16641670
16651671 A_ref = A_ref [local_index_to_slice [local_entity_index ]]
16661672
@@ -1832,7 +1838,10 @@ def tabulate_tensor(ele_type, V_cell_type, l_i):
18321838 V_cell_type = "tetrahedron"
18331839
18341840 # Tabulate the tensor for the mixed-dimensional form
1835- b = tabulate_tensor (ele_type , V_cell_type , 0 )
1841+ (ridge_index ,) = [
1842+ i for i , v in enumerate (basix .topology (basix .CellType .tetrahedron )[1 ]) if v == [2 , 3 ]
1843+ ]
1844+ b = tabulate_tensor (ele_type , V_cell_type , ridge_index )
18361845
18371846 # Ref first ridge integral length
18381847 rl = np .sqrt (y_ext ** 2 + z_ext ** 2 ) / y_ext
0 commit comments