Skip to content

Commit

Permalink
k
Browse files Browse the repository at this point in the history
  • Loading branch information
ksagiyam committed Dec 6, 2024
1 parent fec0994 commit 19bb3ee
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions tests/firedrake/regression/test_restricted_function_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,15 +287,16 @@ def test_restricted_function_space_extrusion_basics():
def test_restricted_function_space_extrusion_poisson(ncells):
mesh = UnitIntervalMesh(ncells)
extm = ExtrudedMesh(mesh, ncells)
subdomain_ids = ["bottom", "top", 1, 2]
V = FunctionSpace(extm, "CG", 4)
V_res = RestrictedFunctionSpace(V, boundary_set=["bottom", "top", 1, 2])
V_res = RestrictedFunctionSpace(V, boundary_set=subdomain_ids)
x, y = SpatialCoordinate(extm)
exact = Function(V_res).interpolate(x**2 * y**2)
u = TrialFunction(V_res)
v = TestFunction(V_res)
a = inner(grad(u), grad(v)) * dx
L = inner(-2 * (x**2 + y**2), v) * dx
bc = DirichletBC(V_res, exact, ["bottom", "top", 1, 2])
bc = DirichletBC(V_res, exact, subdomain_ids)
sol = Function(V_res)
solve(a == L, sol, bcs=[bc])
assert assemble(inner(sol - exact, sol - exact) * dx)**0.5 < 1.e-15
Expand All @@ -306,25 +307,28 @@ def test_restricted_function_space_extrusion_poisson(ncells):
def test_restricted_function_space_extrusion_stokes(ncells):
mesh = UnitIntervalMesh(ncells)
extm = ExtrudedMesh(mesh, ncells)
subdomain_ids = [1, 2, "bottom"]
f_value = as_vector([1., 1.])
bc_value_0 = as_vector([0., 0.])
# Solve reference problem.
V = VectorFunctionSpace(extm, "CG", 2)
Q = FunctionSpace(extm, "CG", 1)
W = V * Q
u, p = TrialFunctions(W)
v, q = TestFunctions(W)
a = inner(2 * sym(grad(u)), grad(v)) * dx - inner(p, div(v)) * dx + inner(div(u), q) * dx
L = inner(as_vector([1., 1.]), v) * dx
bc = DirichletBC(W.sub(0), as_vector([0., 0.]), [1, 2, "bottom"])
L = inner(f_value, v) * dx
bc = DirichletBC(W.sub(0), bc_value_0, subdomain_ids)
sol = Function(W)
solve(a == L, sol, bcs=[bc])
# Solve problem on restricted space.
V_res = RestrictedFunctionSpace(V, boundary_set=[1, 2, "bottom"])
V_res = RestrictedFunctionSpace(V, boundary_set=subdomain_ids)
W_res = V_res * Q
u_res, p = TrialFunctions(W_res)
v_res, q = TestFunctions(W_res)
a_res = inner(2 * sym(grad(u_res)), grad(v_res)) * dx - inner(p, div(v_res)) * dx + inner(div(u_res), q) * dx
L_res = inner(as_vector([1., 1.]), v_res) * dx
bc_res = DirichletBC(W_res.sub(0), as_vector([0., 0.]), [1, 2, "bottom"])
L_res = inner(f_value, v_res) * dx
bc_res = DirichletBC(W_res.sub(0), bc_value_0, subdomain_ids)
sol_res = Function(W_res)
solve(a_res == L_res, sol_res, bcs=[bc_res])
# Compare.
Expand Down

0 comments on commit 19bb3ee

Please sign in to comment.