]> https://gitweb.dealii.org/ - dealii.git/commitdiff
FEInterfaceValues tests: check with a tolerance.
authorDavid Wells <drwells@email.unc.edu>
Fri, 11 Apr 2025 17:08:01 +0000 (13:08 -0400)
committerDavid Wells <drwells@email.unc.edu>
Thu, 17 Apr 2025 17:26:09 +0000 (13:26 -0400)
This is more robust since some values may not be exactly zero due to rounding.

tests/feinterface/fe_interface_view_01.cc
tests/feinterface/fe_interface_view_02.cc

index 21b7aa16542391280cdf4d536ceecd5f10d59927..5b2f19d680a5feb7cb5868f46fd73c5cb7fce6dd 100644 (file)
@@ -69,28 +69,34 @@ test(const Triangulation<dim> &tr, const FiniteElement<dim> &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;
index a354c90f8a6f76bb9290da5e64327d165cb8e099..cdd7bd8aaacb158666f8e583e66310c590c98190 100644 (file)
@@ -79,32 +79,33 @@ test(const Triangulation<dim> &tr, const FiniteElement<dim> &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;

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.