From 9df277c661983beb45893aca100fa103128c5423 Mon Sep 17 00:00:00 2001 From: ksagiyam Date: Thu, 5 Dec 2024 01:21:59 +0000 Subject: [PATCH] k --- firedrake/bcs.py | 2 +- .../regression/test_restricted_function_space.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/firedrake/bcs.py b/firedrake/bcs.py index 272b74ddbf..77b47555bc 100644 --- a/firedrake/bcs.py +++ b/firedrake/bcs.py @@ -290,7 +290,7 @@ def __init__(self, V, g, sub_domain, method=None): warnings.warn("Selecting a bcs method is deprecated. Only topological association is supported", DeprecationWarning) if len(V.boundary_set) and sub_domain not in V.boundary_set: - raise ValueError(f"Sub-domain {sub_domain} not in the boundary set of the restricted space.") + raise ValueError(f"Sub-domain {sub_domain} not in the boundary set of the restricted space {V.boundary_set}.") super().__init__(V, sub_domain) if len(V) > 1: raise ValueError("Cannot apply boundary conditions on mixed spaces directly.\n" diff --git a/tests/firedrake/regression/test_restricted_function_space.py b/tests/firedrake/regression/test_restricted_function_space.py index 20ff838ea9..afc20e1b99 100644 --- a/tests/firedrake/regression/test_restricted_function_space.py +++ b/tests/firedrake/regression/test_restricted_function_space.py @@ -270,3 +270,16 @@ def test_restricted_function_space_extrusion(): assert np.allclose(v.getArray(), local_array[:n][local_global_filter]) v *= 2. assert np.allclose(f.dat.data_ro_with_halos[:n][local_global_filter], 2. * local_array[:n][local_global_filter]) + # Solve Poisson problem. + x, y = SpatialCoordinate(extm) + normal = FacetNormal(extm) + exact = Function(V_res).interpolate(x**2 * y**2) + exact_grad = as_vector([2 * x * y**2, 2 * x**2 * y]) + u = TrialFunction(V_res) + v = TestFunction(V_res) + a = inner(grad(u), grad(v)) * dx + L = inner(-2 * (x**2 + y**2), v) * dx + inner(dot(exact_grad, normal), v) * ds_v(2) + inner(dot(exact_grad, normal), v) * ds_t + bc = DirichletBC(V_res, 0., "bottom") + sol = Function(V_res) + solve(a == L, sol, bcs=[bc]) + assert assemble(inner(sol - exact, sol - exact) * dx) ** 0.5 < 1.e-14