Skip to content

Commit

Permalink
Extend tests to account for case where only one boundary segment is f…
Browse files Browse the repository at this point in the history
…ixed
  • Loading branch information
jwallwork23 committed Aug 26, 2024
1 parent 5353439 commit 0a68eac
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion movement/monge_ampere.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def _l2_projector_bcs(self, boundary_tag):
:rtype: :class:`tuple` of :class:`~.DirichletBC`\s
"""
zero_bc = firedrake.DirichletBC(self.P1_vec, 0, boundary_tag)
if boundary_tag in self.fixed_boundary_segments or self.dim == 1:
if (boundary_tag in self.fixed_boundary_segments) or self.dim == 1:
return (zero_bc,)
ds = self.ds(boundary_tag)

Expand Down
18 changes: 17 additions & 1 deletion test/test_monge_ampere.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,16 +261,22 @@ def test_periodic(self, dim, method):
@parameterized.expand(
[
(1, "relaxation", "on_boundary"),
(1, "relaxation", [1]),
(1, "relaxation", []),
(1, "quasi_newton", "on_boundary"),
(1, "quasi_newton", [1]),
(1, "quasi_newton", []),
(2, "relaxation", "on_boundary"),
(2, "relaxation", [1]),
(2, "relaxation", []),
(2, "quasi_newton", "on_boundary"),
(2, "quasi_newton", [1]),
(2, "quasi_newton", []),
(3, "relaxation", "on_boundary"),
(3, "relaxation", [1]),
(3, "relaxation", []),
(3, "quasi_newton", "on_boundary"),
(3, "quasi_newton", [1]),
(3, "quasi_newton", []),
]
)
Expand All @@ -293,12 +299,16 @@ def test_boundary_preservation_axis_aligned(self, dim, method, fixed_boundaries)
@parameterized.expand(
[
(2, "relaxation", "on_boundary"),
(2, "relaxation", [1]),
(2, "relaxation", []),
(2, "quasi_newton", "on_boundary"),
(2, "quasi_newton", [1]),
(2, "quasi_newton", []),
(3, "relaxation", "on_boundary"),
(3, "relaxation", [1]),
(3, "relaxation", []),
(3, "quasi_newton", "on_boundary"),
(3, "quasi_newton", [1]),
(3, "quasi_newton", []),
]
)
Expand Down Expand Up @@ -331,9 +341,15 @@ def test_boundary_preservation_non_axis_aligned(
# If boundaries are not fixed then EquationBCs should be used for boundaries of
# the xy-plane
bcs = mover._l2_projector._problem.bcs
if fixed_boundaries:
if fixed_boundaries == "on_boundary":
self.assertTrue(len(bcs) == 2 * dim)
self.assertTrue(all(isinstance(bc, DirichletBC) for bc in bcs))
elif fixed_boundaries == [1]:
self.assertTrue(len(bcs) == 8)
self.assertTrue(sum(isinstance(bc, DirichletBC) for bc in bcs) == 1)
self.assertTrue(
sum(isinstance(bc, EquationBC) for bc in bcs) == 2 * dim - 1
)
elif dim == 2:
self.assertTrue(len(bcs) == 8)
self.assertTrue(all(isinstance(bc, EquationBC) for bc in bcs))
Expand Down

0 comments on commit 0a68eac

Please sign in to comment.