Skip to content

Commit

Permalink
make test more robust
Browse files Browse the repository at this point in the history
By avoiding a floating point equality comparison. This test fails for me
in release mode with march=native with a residual of 1e-14.
  • Loading branch information
tjhei committed Jan 15, 2024
1 parent 4c1077b commit c7d0191
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tests/mpi/affine_constraints_get_view_01.cc
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,14 @@ 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;
}
Expand Down

0 comments on commit c7d0191

Please sign in to comment.