Skip to content

Commit f5afedb

Browse files
committed
k
1 parent b1b6fb9 commit f5afedb

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

tests/submesh/test_submesh_solve.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,3 +421,44 @@ def test_submesh_solve_mixed_poisson_check_sanity_3d(hexahedral, degree, submesh
421421
sigma_error, u_error = _mixed_poisson_solve_3d(hexahedral, degree, submesh_region)
422422
assert sigma_error < 0.07
423423
assert u_error < 0.003
424+
425+
426+
@pytest.mark.parallel(nprocs=4)
427+
@pytest.mark.parametrize('simplex', [True, False])
428+
@pytest.mark.parametrize('nref', [1, 3])
429+
@pytest.mark.parametrize('degree', [2, 4])
430+
def test_submesh_solve_cell_cell_equation_bc(nref, degree, simplex):
431+
mesh = RectangleMesh(3 ** nref, 2 ** nref, 3., 2., quadrilateral=not simplex)
432+
x, y = SpatialCoordinate(mesh)
433+
label_outer = 101
434+
label_inner = 100
435+
label_interface = 5 # automatically labeled by Submesh
436+
DG0 = FunctionSpace(mesh, "DG", 0)
437+
f_outer = Function(DG0).interpolate(conditional(Or(Or(x < 1., x > 2.), y > 1.), 1, 0))
438+
f_inner = Function(DG0).interpolate(conditional(And(And(x > 1., x < 2.), y < 1.), 1, 0))
439+
mesh = RelabeledMesh(mesh, [f_outer, f_inner], [label_outer, label_inner])
440+
x, y = SpatialCoordinate(mesh)
441+
mesh_outer = Submesh(mesh, dmcommon.CELL_SETS_LABEL, label_outer, mesh.topological_dimension())
442+
x_outer, y_outer = SpatialCoordinate(mesh_outer)
443+
mesh_inner = Submesh(mesh, dmcommon.CELL_SETS_LABEL, label_inner, mesh.topological_dimension())
444+
x_inner, y_inner = SpatialCoordinate(mesh_inner)
445+
V_outer = FunctionSpace(mesh_outer, "CG", degree)
446+
V_inner = FunctionSpace(mesh_inner, "CG", degree)
447+
V = V_outer * V_inner
448+
u = TrialFunction(V)
449+
v = TestFunction(V)
450+
sol = Function(V)
451+
u_outer, u_inner = split(u)
452+
v_outer, v_inner = split(v)
453+
dx_outer = Measure("dx", domain=mesh_outer)
454+
dx_inner = Measure("dx", domain=mesh_inner)
455+
ds_outer = Measure("ds", domain=mesh_outer)
456+
ds_inner = Measure("ds", domain=mesh_inner)
457+
a = inner(grad(u_outer), grad(v_outer)) * dx_outer + \
458+
inner(u_inner, v_inner) * dx_inner
459+
L = inner(x * y, v_inner) * dx_inner
460+
dbc = DirichletBC(V.sub(0), x_outer * y_outer, (1, 2, 3, 4))
461+
ebc = EquationBC(inner(u_outer - u_inner, v_outer) * ds_outer(label_interface) == inner(Constant(0.), v_outer) * ds_outer(label_interface), sol, label_interface, V=V.sub(0))
462+
solve(a == L, sol, bcs=[dbc, ebc])
463+
assert sqrt(assemble(inner(sol[0] - x * y, sol[0] - x * y) * dx_outer)) < 1.e-13
464+
assert sqrt(assemble(inner(sol[1] - x * y, sol[1] - x * y) * dx_inner)) < 1.e-13

0 commit comments

Comments
 (0)