Skip to content

Commit

Permalink
Fixup: allow eps outside of block.
Browse files Browse the repository at this point in the history
  • Loading branch information
markscheel committed Jan 31, 2023
1 parent 3d47911 commit d1bf0a4
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions src/ApparentHorizons/StrahlkorperCoordsInDifferentFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,16 @@ void strahlkorper_coords_in_different_frame(
{get<0>(src_cartesian_coords)[s], get<1>(src_cartesian_coords)[s],
get<2>(src_cartesian_coords)[s]}};
const auto x_logical = logical_to_grid_map.inverse(x_src);
const double one_plus_eps =
1.0 + std::numeric_limits<double>::epsilon() * 100.0;
// x_logical might be an empty std::optional.
if (x_logical.has_value() and get<0>(x_logical.value()) <= 1.0 and
get<0>(x_logical.value()) >= -1.0 and
get<1>(x_logical.value()) <= 1.0 and
get<1>(x_logical.value()) >= -1.0 and
get<2>(x_logical.value()) <= 1.0 and
get<2>(x_logical.value()) >= -1.0) {
if (x_logical.has_value() and
get<0>(x_logical.value()) <= one_plus_eps and
get<0>(x_logical.value()) >= -one_plus_eps and
get<1>(x_logical.value()) <= one_plus_eps and
get<1>(x_logical.value()) >= -one_plus_eps and
get<2>(x_logical.value()) <= one_plus_eps and
get<2>(x_logical.value()) >= -one_plus_eps) {
const auto x_dest =
grid_to_inertial_map(x_src, time, functions_of_time);
get<0>(*dest_cartesian_coords)[s] = get<0>(x_dest);
Expand Down Expand Up @@ -105,13 +108,16 @@ void strahlkorper_coords_in_different_frame(
grid_to_distorted_map.inverse(x_src, time, functions_of_time);
if (x_grid.has_value()) {
const auto x_logical = logical_to_grid_map.inverse(x_grid.value());
const double one_plus_eps =
1.0 + std::numeric_limits<double>::epsilon() * 100.0;
// x_logical might be an empty std::optional.
if (x_logical.has_value() and get<0>(x_logical.value()) <= 1.0 and
get<0>(x_logical.value()) >= -1.0 and
get<1>(x_logical.value()) <= 1.0 and
get<1>(x_logical.value()) >= -1.0 and
get<2>(x_logical.value()) <= 1.0 and
get<2>(x_logical.value()) >= -1.0) {
if (x_logical.has_value() and
get<0>(x_logical.value()) <= one_plus_eps and
get<0>(x_logical.value()) >= -one_plus_eps and
get<1>(x_logical.value()) <= one_plus_eps and
get<1>(x_logical.value()) >= -one_plus_eps and
get<2>(x_logical.value()) <= one_plus_eps and
get<2>(x_logical.value()) >= -one_plus_eps) {
const auto x_dest =
distorted_to_inertial_map(x_src, time, functions_of_time);
get<0>(*dest_cartesian_coords)[s] = get<0>(x_dest);
Expand Down

0 comments on commit d1bf0a4

Please sign in to comment.