diff --git a/capytaine/bem/engines.py b/capytaine/bem/engines.py index 268bd12f..17cc4bf7 100644 --- a/capytaine/bem/engines.py +++ b/capytaine/bem/engines.py @@ -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]]) diff --git a/docs/changelog.rst b/docs/changelog.rst index f9394c56..67f0e186 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -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) ------------------------------- diff --git a/pytest/test_bem_solver.py b/pytest/test_bem_solver.py index a0c9857e..a9dfe217 100644 --- a/pytest/test_bem_solver.py +++ b/pytest/test_bem_solver.py @@ -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()