Skip to content

Commit 11fbe0a

Browse files
committed
Reject unsupported 2D hypersingular gradients and enforce warning-free builds
1 parent 1e85303 commit 11fbe0a

7 files changed

Lines changed: 42 additions & 9 deletions

File tree

‎.github/workflows/tests.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
rm -rf build_linux_debug
2323
mkdir build_linux_debug
2424
cd build_linux_debug
25-
cmake .. -GNinja -DCMAKE_BUILD_TYPE=Debug
25+
cmake .. -GNinja -DCMAKE_CXX_FLAGS=-Werror -DCMAKE_BUILD_TYPE=Debug
2626
ninja
2727
ctest -N
2828
ctest --output-on-failure
@@ -42,7 +42,7 @@ jobs:
4242
rm -rf build_linux_release
4343
mkdir build_linux_release
4444
cd build_linux_release
45-
cmake .. -GNinja -DCMAKE_BUILD_TYPE=Release
45+
cmake .. -GNinja -DCMAKE_CXX_FLAGS=-Werror -DCMAKE_BUILD_TYPE=Release
4646
ninja
4747
ctest -N
4848
ctest --output-on-failure

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ build/
66
tests_regression/robin_bconditions/parameters_bem_3.prm
77
tests_regression/robin_bconditions/used_parameters_bem_3.prm
88

9+
build-docker/

‎include/bem_problem.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,8 @@ class BEMProblem : public ParameterAcceptor
351351
/// We compute the potential gradients also in an alternative way.
352352
/// Here we make use of the hypersingular integrals computed with the
353353
/// SingularKernelIntegral class
354+
/// Compute hypersingular gradients in 3D. The unsupported 2D case throws
355+
/// ExcNotImplemented in both Debug and Release before accessing vectors.
354356
void
355357
compute_gradients_hypersingular(const TrilinosWrappers::MPI::Vector &phi,
356358
const TrilinosWrappers::MPI::Vector &dphi_dn);

‎source/bem_problem.cc‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3261,6 +3261,17 @@ BEMProblem<dim>::compute_surface_gradients(
32613261
vector_constraints.distribute(get_vector_surface_gradients_solution());
32623262
}
32633263

3264+
// The singular hypersingular kernels are implemented only for surface cells
3265+
// in 3D. Reject the 2D call before entering the three-component algorithm.
3266+
template <>
3267+
void
3268+
BEMProblem<2>::compute_gradients_hypersingular(
3269+
const TrilinosWrappers::MPI::Vector &,
3270+
const TrilinosWrappers::MPI::Vector &)
3271+
{
3272+
AssertThrow(false, ExcNotImplemented());
3273+
}
3274+
32643275
template <int dim>
32653276
void
32663277
BEMProblem<dim>::compute_gradients_hypersingular(

‎source/quasi_singular_kernel_integral.cc‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ QuasiSingularKernelIntegral<dim>::find_closest_reference_cell_point(
4646
Vector<double> residual(2);
4747
residual = 1.0;
4848
unsigned int iter_counter = 0;
49-
double min_dist;
5049
while (residual.l2_norm() > 1e-7 && iter_counter < 30)
5150
{
5251
// here's the quadrature rule obtained with the solution point only
@@ -89,8 +88,6 @@ QuasiSingularKernelIntegral<dim>::find_closest_reference_cell_point(
8988
dist_vect[0] = external_point[0] - sol_q_points_spacedim[0][0];
9089
dist_vect[1] = external_point[1] - sol_q_points_spacedim[0][1];
9190
dist_vect[2] = external_point[2] - sol_q_points_spacedim[0][2];
92-
min_dist = dist_vect.l2_norm();
93-
// std::cout<<"Min Dist: "<<min_dist<<std::endl;
9491

9592

9693
// this is the jacobian of the mapping
@@ -178,7 +175,6 @@ QuasiSingularKernelIntegral<dim>::find_closest_reference_cell_point(
178175
else
179176
{
180177
// std::cout<<"Solved"<<std::endl;
181-
// std::cout<<"Min Dist: "<<min_dist<<std::endl;
182178
eta_sol[0] = solution[0];
183179
eta_sol[1] = solution[1];
184180
// std::cout<<"Cell minimum distance point: "<<eta_sol<<std::endl;
@@ -188,8 +184,6 @@ QuasiSingularKernelIntegral<dim>::find_closest_reference_cell_point(
188184
{
189185
double minimum_distance_among_faces =
190186
std::numeric_limits<double>::infinity();
191-
unsigned int face_with_minimum_distance =
192-
GeometryInfo<2>::faces_per_cell;
193187
// in this case we must look for the closest point, but on the
194188
// boundary we'll use bisection in the interval [0,1]
195189
for (unsigned int f = 0; f < GeometryInfo<2>::faces_per_cell; ++f)
@@ -311,7 +305,6 @@ QuasiSingularKernelIntegral<dim>::find_closest_reference_cell_point(
311305
if (min_dist_line < minimum_distance_among_faces)
312306
{
313307
minimum_distance_among_faces = min_dist_line;
314-
face_with_minimum_distance = f;
315308
switch (f)
316309
{
317310
case 0:

‎tests/hypersingular_gradient_2d.cc‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Verify that the unsupported 2D hypersingular gradient path fails before
2+
// accessing mesh/vector data, in both Debug and Release.
3+
#include "bem_problem.h"
4+
#include "tests.h"
5+
6+
int
7+
main(int argc, char **argv)
8+
{
9+
Utilities::MPI::MPI_InitFinalize mpi(argc, argv, 1);
10+
initlog();
11+
ComputationalDomain<2> domain;
12+
BEMProblem<2> problem(domain);
13+
TrilinosWrappers::MPI::Vector phi, normal_derivative;
14+
try
15+
{
16+
problem.compute_gradients_hypersingular(phi, normal_derivative);
17+
}
18+
catch (const ExcNotImplemented &)
19+
{
20+
deallog << "2D hypersingular gradients rejected safely" << std::endl;
21+
return 0;
22+
}
23+
AssertThrow(false, ExcMessage("Expected ExcNotImplemented"));
24+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
DEAL::2D hypersingular gradients rejected safely

0 commit comments

Comments
 (0)