Skip to content

Commit

Permalink
fix: wrong result with symmetries and direct solver (capytaine#594)
Browse files Browse the repository at this point in the history
  • Loading branch information
mancellin authored Sep 13, 2024
1 parent 940bde0 commit 7a764ac
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions capytaine/bem/engines.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ def build_matrices(self, mesh1, mesh2, free_surface, water_depth, wavenumber, gr

S_a, V_a = self.build_matrices(
mesh1[0], mesh2[0], free_surface, water_depth, wavenumber,
green_function)
green_function, adjoint_double_layer=adjoint_double_layer)
S_b, V_b = self.build_matrices(
mesh1[0], mesh2[1], free_surface, water_depth, wavenumber,
green_function)
green_function, adjoint_double_layer=adjoint_double_layer)

return BlockSymmetricToeplitzMatrix([[S_a, S_b]]), BlockSymmetricToeplitzMatrix([[V_a, V_b]])

Expand Down
3 changes: 3 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ Bug fixes

* User does not need to import `pyplot` themself before running `show_matplotlib()` (:pull:`592`)

* Fixes usage of ``ReflectionSymmetricMesh`` with direct solver (:issue:`593` and :pull:`594`).


-------------------------------
New in version 2.2 (2024-07-08)
-------------------------------
Expand Down
12 changes: 12 additions & 0 deletions pytest/test_bem_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ def test_direct_solver(sphere):
assert direct_result.forces["Surge"] == pytest.approx(indirect_result.forces["Surge"], rel=1e-1)


@pytest.mark.parametrize("method", ["direct", "indirect"])
def test_same_result_with_symmetries(method):
solver = cpt.BEMSolver()
sym_mesh = cpt.ReflectionSymmetricMesh(cpt.mesh_sphere(center=(0, 2, 0)).immersed_part(), cpt.xOz_Plane)
sym_body = cpt.FloatingBody(mesh=sym_mesh, dofs=cpt.rigid_body_dofs())
sym_result = solver.solve(cpt.DiffractionProblem(body=sym_body, omega=1.0), method=method)
mesh = sym_mesh.merged()
body = cpt.FloatingBody(mesh=mesh, dofs=cpt.rigid_body_dofs())
result = solver.solve(cpt.DiffractionProblem(body=body, omega=1.0), method=method)
assert sym_result.forces["Surge"] == pytest.approx(result.forces["Surge"], rel=1e-10)


def test_parallelization(sphere):
pytest.importorskip("joblib")
solver = cpt.BEMSolver()
Expand Down

0 comments on commit 7a764ac

Please sign in to comment.