Skip to content

Commit

Permalink
Tighten relative tolerance, fix warning messages
Browse files Browse the repository at this point in the history
  • Loading branch information
hughcars committed Aug 29, 2023
1 parent 8006ee8 commit eca90d2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
6 changes: 3 additions & 3 deletions palace/fem/lumpedelement.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class UniformElementData : public LumpedElementData
{
// Check that the bounding box discovered matches the area. This validates that the
// boundary elements form a right angled quadrilateral port.
constexpr double rel_tol = 1.0e-3;
constexpr double rel_tol = 1.0e-6;
double A = GetArea(fespace);
MFEM_VERIFY((!bounding_box.planar || (std::abs(A - bounding_box.Area()) / A < rel_tol)),
"Discovered bounding box area "
Expand Down Expand Up @@ -102,7 +102,7 @@ class UniformElementData : public LumpedElementData
}
Mpi::Warning(
"User specified direction {:.3e} does not align with either bounding box "
"axis up to {:.3e} degrees.\n"
"axis up to {:.3e} degrees!\n"
"Axis 1: {:.3e} ({:.3e} degrees)\nAxis 2: {:.3e} ({:.3e} degrees)\nAxis 3: "
"{:.3e} ({:.3e} degrees)!\n",
input_dir, angle_warning_deg, normal_0, deviation_deg[0], normal_1,
Expand All @@ -124,7 +124,7 @@ class UniformElementData : public LumpedElementData
MFEM_ASSERT(
(l - mesh::GetProjectedLength(*fespace.GetParMesh(), marker, true, input_dir)) / l <
rel_tol,
"Bounding box discovered length should match projected length");
"Bounding box discovered length should match projected length!");
w = A / l;
}

Expand Down
11 changes: 5 additions & 6 deletions palace/utils/geodata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,6 @@ BoundingBox BoundingBoxFromPointCloud(MPI_Comm comm,
// useful for checking pointers later.
const auto &v_000 = *p_000;
const auto &v_111 = *p_111;

MFEM_VERIFY(&v_000 != &v_111, "Minimum and maximum extents cannot be identical!");
const auto origin = v_000;
const Eigen::Vector3d n_1 = (v_111 - v_000).normalized();
Expand Down Expand Up @@ -775,7 +774,7 @@ BoundingBox BoundingBoxFromPointCloud(MPI_Comm comm,
[OutOfPlaneDistance](const auto &x, const auto &y)
{ return OutOfPlaneDistance(x) < OutOfPlaneDistance(y); }));

constexpr double rel_tol = 1e-3;
constexpr double rel_tol = 1e-6;
box.planar = max_distance < (rel_tol * (v_111 - v_000).norm());

// Given numerical tolerance, collect other points with an almost matching distance.
Expand Down Expand Up @@ -870,9 +869,9 @@ BoundingBall BoundingBallFromPointCloud(MPI_Comm comm,
vertices.begin(), vertices.end(),
[&delta, PerpendicularDistance](const auto &x, const auto &y)
{ return PerpendicularDistance({delta}, x) < PerpendicularDistance({delta}, y); });
constexpr double radius_tol = 1.0e-3;
constexpr double rel_tol = 1.0e-6;
MFEM_VERIFY(std::abs(PerpendicularDistance({delta}, perp) - ball.radius) <=
radius_tol * ball.radius,
rel_tol * ball.radius,
"Furthest point perpendicular must be on the exterior of the ball: "
<< PerpendicularDistance({delta}, perp) << " vs. " << ball.radius
<< "!");
Expand All @@ -892,12 +891,12 @@ BoundingBall BoundingBallFromPointCloud(MPI_Comm comm,
});

ball.planar =
PerpendicularDistance({delta, n_radial}, out_of_plane) < radius_tol * ball.radius;
PerpendicularDistance({delta, n_radial}, out_of_plane) / ball.radius < rel_tol;
if (!ball.planar)
{
// The points are not functionally coplanar, zero out the normal.
MFEM_VERIFY(std::abs(PerpendicularDistance({delta}, perp) - ball.radius) <=
radius_tol * ball.radius,
rel_tol * ball.radius,
"Furthest point perpendicular must be on the exterior of the sphere!");
Vector3dMap(ball.planar_normal.data()) *= 0;
}
Expand Down

0 comments on commit eca90d2

Please sign in to comment.