]> https://gitweb.dealii.org/ - dealii.git/commitdiff
make test more robust 16327/head
authorTimo Heister <timo.heister@gmail.com>
Thu, 7 Dec 2023 14:29:43 +0000 (09:29 -0500)
committerTimo Heister <timo.heister@gmail.com>
Mon, 15 Jan 2024 20:09:20 +0000 (15:09 -0500)
By avoiding a floating point equality comparison. This test fails for me
in release mode with march=native with a residual of 1e-14.

tests/mpi/affine_constraints_get_view_01.cc

index def3035761d9e4d6eb89b6cbb219b1c9389fa3ef..763a8718f4f7508630fda95896c26a02f7536a1f 100644 (file)
@@ -192,8 +192,15 @@ test()
     pressure_constraints.distribute(check_vector_2.block(1));
   }
 
-  // Now the assertion part: These vectors are the same:
-  Assert(check_vector_1 == check_vector_2, ExcInternalError());
+  // Finally check that these two vectors are the same. Note that
+  // when we compile with native optimizations we might have a slight
+  // difference in results:
+  {
+    TrilinosWrappers::MPI::BlockVector result = check_vector_1;
+    result -= check_vector_2;
+    Assert(result.l2_norm() / check_vector_1.l2_norm() < 1e-8,
+           ExcInternalError());
+  }
 
   deallog << "OK" << 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.