Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion firedrake/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def init_petsc():
from firedrake.cofunction import Cofunction, RieszMap # noqa: F401
from firedrake.constant import Constant # noqa: F401
from firedrake.deflation import DeflatedSNES, Deflation # noqa: F401
from firedrake.exceptions import ConvergenceError # noqa: F401
from firedrake.exceptions import ConvergenceError, MismatchingDomainError # noqa: F401
from firedrake.function import ( # noqa: F401
Function, PointNotInDomainError,
CoordinatelessFunction, PointEvaluator
Expand Down
1 change: 1 addition & 0 deletions firedrake/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from tsfc.exceptions import MismatchingDomainError # noqa: F401


class ConvergenceError(Exception):
Expand Down
16 changes: 8 additions & 8 deletions tests/firedrake/regression/test_multiple_domains.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ def test_mismatching_meshes_indexed_function(mesh1, mesh3):
with pytest.raises(NotImplementedError):
project(d1, target)

with pytest.raises(ValueError):
with pytest.raises(MismatchingDomainError):
assemble(inner(d1, TestFunction(V2))*dx(domain=mesh3))

with pytest.raises(ValueError):
with pytest.raises(MismatchingDomainError):
assemble(inner(d1, TestFunction(V2))*dx(domain=mesh1))


Expand Down Expand Up @@ -177,29 +177,29 @@ def test_multi_domain_assemble():

for i, j in [(0, 1), (1, 0)]:
a1 = inner(u[i], v[j])*dx(domain=mesh1)
with pytest.raises(ValueError):
with pytest.raises(MismatchingDomainError):
assemble(a1)
a2 = inner(u[i], v[j])*dx(domain=mesh2)
with pytest.raises(ValueError):
with pytest.raises(MismatchingDomainError):
assemble(a2)
l1 = inner(f[i], v[j])*dx(domain=mesh1)
with pytest.raises(ValueError):
with pytest.raises(MismatchingDomainError):
assemble(l1)
l2 = inner(f[i], v[j])*dx(domain=mesh2)
with pytest.raises(ValueError):
with pytest.raises(MismatchingDomainError):
assemble(l2)

for i, j in [(0, 0), (1, 1)]:
a = inner(u[i], v[j])*dx(domain=mesh1)
if i == 1:
with pytest.raises(ValueError):
with pytest.raises(MismatchingDomainError):
assemble(a)
continue
A = assemble(a)
assert A.M.values.shape == (V.dim(), V.dim())

a = inner(u[0], v[0])*dx(domain=mesh1) + inner(u[0], v[1])*dx(domain=mesh2)
with pytest.raises(ValueError):
with pytest.raises(MismatchingDomainError):
assemble(a)

a = inner(u[0], v[0])*dx(domain=mesh1) + inner(u[1], v[1])*dx(domain=mesh2)
Expand Down
1 change: 1 addition & 0 deletions tsfc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from tsfc.driver import compile_form, compile_expression_dual_evaluation # noqa: F401
from tsfc.parameters import default_parameters # noqa: F401
from tsfc.exceptions import MismatchingDomainError # noqa: F401


def register_citations():
Expand Down
14 changes: 8 additions & 6 deletions tsfc/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
from tsfc.parameters import default_parameters, is_complex
from tsfc.ufl_utils import apply_mapping, extract_firedrake_constants
import tsfc.kernel_interface.firedrake_loopy as firedrake_interface_loopy
from tsfc.exceptions import MismatchingDomainError


# To handle big forms. The various transformations might need a deeper stack
sys.setrecursionlimit(3000)
Expand Down Expand Up @@ -188,19 +190,19 @@ def validate_domains(form):
domain = itg.ufl_domain()
for other_domain in itg.extra_domain_integral_type_map():
if domain.submesh_youngest_common_ancester(other_domain) is None:
raise ValueError("Assembly of forms over unrelated meshes is not supported. "
"Try using Submeshes or cross-mesh interpolation.")
raise MismatchingDomainError("Assembly of forms over unrelated meshes is not supported. "
"Try using Submeshes or cross-mesh interpolation.")

# Check that all Arguments and Coefficients are defined on the valid domains
valid_domains = set(itg.extra_domain_integral_type_map())
valid_domains.add(domain)

itg_domains = set(extract_domains(itg))
if len(itg_domains - valid_domains) > 0:
raise ValueError("Argument or Coefficient domain not found in integral. "
"Possibly, the form contains coefficients on different meshes "
"and requires measure intersection, for example: "
'Measure("dx", argument_mesh, intersect_measures=[Measure("dx", coefficient_mesh)]).')
raise MismatchingDomainError("Argument or Coefficient domain not found in integral. "
"Possibly, the form contains coefficients on different meshes "
"and requires measure intersection, for example: "
'Measure("dx", argument_mesh, intersect_measures=[Measure("dx", coefficient_mesh)]).')


def preprocess_parameters(parameters):
Expand Down
4 changes: 4 additions & 0 deletions tsfc/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@


class MismatchingDomainError(Exception):
"""Error raised for unsupported multidomain problems"""
Loading