From: David Wells Date: Fri, 11 Apr 2025 17:08:01 +0000 (-0400) Subject: FEInterfaceValues tests: check with a tolerance. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=68c18369d569f320ade93870b239e741c8dcefdd;p=dealii.git FEInterfaceValues tests: check with a tolerance. This is more robust since some values may not be exactly zero due to rounding. --- diff --git a/tests/feinterface/fe_interface_view_01.cc b/tests/feinterface/fe_interface_view_01.cc index 21b7aa1654..5b2f19d680 100644 --- a/tests/feinterface/fe_interface_view_01.cc +++ b/tests/feinterface/fe_interface_view_01.cc @@ -69,28 +69,34 @@ test(const Triangulation &tr, const FiniteElement &fe) for (unsigned int c = 0; c < fe.n_components(); ++c) { const FEValuesExtractors::Scalar single_component(c); + constexpr double tolerance = 1e-10; for (unsigned int i = 0; i < n_dofs_face; ++i) for (unsigned int q = 0; q < n_q_points; ++q) { - if (fe_iv[single_component].value(true, i, q) != 0) + if (std::abs(fe_iv[single_component].value(true, i, q)) > + tolerance) deallog << fe_iv[single_component].value(true, i, q) << " "; - if (fe_iv[single_component].value(false, i, q) != 0) + if (std::abs(fe_iv[single_component].value(false, i, q)) > + tolerance) deallog << fe_iv[single_component].value(false, i, q) << " "; - if (fe_iv[single_component].jump_in_values(i, q) != 0) + if (std::abs(fe_iv[single_component].jump_in_values(i, q)) > + tolerance) deallog << fe_iv[single_component].jump_in_values(i, q) << " "; - if (fe_iv[single_component].average_of_values(i, q) != 0) + if (std::abs( + fe_iv[single_component].average_of_values(i, q)) > + tolerance) deallog << fe_iv[single_component].average_of_values(i, q) << " "; - if (fe_iv[single_component].jump_in_gradients(i, q).norm() != - 0) + if (fe_iv[single_component].jump_in_gradients(i, q).norm() > + tolerance) deallog << fe_iv[single_component].jump_in_gradients(i, q) << " "; if (fe_iv[single_component] .average_of_gradients(i, q) - .norm() != 0) + .norm() > tolerance) deallog << fe_iv[single_component].average_of_gradients(i, q) << std::endl; diff --git a/tests/feinterface/fe_interface_view_02.cc b/tests/feinterface/fe_interface_view_02.cc index a354c90f8a..cdd7bd8aaa 100644 --- a/tests/feinterface/fe_interface_view_02.cc +++ b/tests/feinterface/fe_interface_view_02.cc @@ -79,32 +79,33 @@ test(const Triangulation &tr, const FiniteElement &fe) if (c + dim <= fe.n_components()) { const FEValuesExtractors::Vector vec_components(c); + constexpr double tolerance = 1e-10; for (unsigned int i = 0; i < n_dofs_face; ++i) for (unsigned int q = 0; q < n_q_points; ++q) { - if (fe_iv[vec_components].value(true, i, q).norm() != 0) + if (fe_iv[vec_components].value(true, i, q).norm() > + tolerance) deallog << fe_iv[vec_components].value(true, i, q) << " "; - if (fe_iv[vec_components].value(false, i, q).norm() != 0) + if (fe_iv[vec_components].value(false, i, q).norm() > + tolerance) deallog << fe_iv[vec_components].value(false, i, q) << " "; - if (fe_iv[vec_components].jump_in_values(i, q).norm() != - 0) + if (fe_iv[vec_components].jump_in_values(i, q).norm() > + tolerance) deallog << fe_iv[vec_components].jump_in_values(i, q) << " "; - if (fe_iv[vec_components] - .average_of_values(i, q) - .norm() != 0) + if (fe_iv[vec_components].average_of_values(i, q).norm() > + tolerance) deallog << fe_iv[vec_components].average_of_values(i, q) << " "; - if (fe_iv[vec_components] - .jump_in_gradients(i, q) - .norm() != 0) + if (fe_iv[vec_components].jump_in_gradients(i, q).norm() > + tolerance) deallog << fe_iv[vec_components].jump_in_gradients(i, q) << " "; if (fe_iv[vec_components] .average_of_gradients(i, q) - .norm() != 0) + .norm() > tolerance) deallog << fe_iv[vec_components].average_of_gradients(i, q) << std::endl;