Skip to content

Commit cbfc0f0

Browse files
jorgensdmscroggs
andauthored
Resolve jacobians from duplicate meshes (#733)
* Fix multiple jacobians * add test that currently fails on main * ruff --------- Co-authored-by: Matthew Scroggs <matthew.w.scroggs@gmail.com>
1 parent c78d7ea commit cbfc0f0

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

ffcx/codegeneration/symbols.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,9 @@ def x_component(self, mt):
135135

136136
def J_component(self, mt):
137137
"""Jacobian component."""
138-
# FIXME: Add domain number!
139-
return L.Symbol(format_mt_name("J", mt), dtype=L.DataType.REAL)
138+
return L.Symbol(
139+
format_mt_name(f"J{mt.expr.ufl_domain().ufl_id()}", mt), dtype=L.DataType.REAL
140+
)
140141

141142
def domain_dof_access(self, dof, component, gdim, num_scalar_dofs, restriction):
142143
"""Domain DOF access."""

test/test_jit_forms.py

+24
Original file line numberDiff line numberDiff line change
@@ -1128,6 +1128,30 @@ def test_integral_grouping(compile_args):
11281128
assert len(unique_integrals) == 2
11291129

11301130

1131+
def test_derivative_domains(compile_args):
1132+
"""Test a form with derivatives on two different domains will generate valid code."""
1133+
1134+
V_ele = basix.ufl.element("Lagrange", "triangle", 2)
1135+
W_ele = basix.ufl.element("Lagrange", "interval", 1)
1136+
1137+
gdim = 2
1138+
V_domain = ufl.Mesh(basix.ufl.element("Lagrange", "triangle", 1, shape=(gdim,)))
1139+
W_domain = ufl.Mesh(basix.ufl.element("Lagrange", "interval", 1, shape=(gdim,)))
1140+
1141+
V = ufl.FunctionSpace(V_domain, V_ele)
1142+
W = ufl.FunctionSpace(W_domain, W_ele)
1143+
1144+
u = ufl.TrialFunction(V)
1145+
q = ufl.TestFunction(W)
1146+
1147+
ds = ufl.Measure("ds", domain=V_domain)
1148+
1149+
forms = [ufl.inner(u.dx(0), q.dx(0)) * ds]
1150+
compiled_forms, module, code = ffcx.codegeneration.jit.compile_forms(
1151+
forms, options={"scalar_type": np.float64}, cffi_extra_compile_args=compile_args
1152+
)
1153+
1154+
11311155
@pytest.mark.parametrize("dtype", ["float64"])
11321156
@pytest.mark.parametrize("permutation", [[0], [1]])
11331157
def test_mixed_dim_form(compile_args, dtype, permutation):

0 commit comments

Comments
 (0)