Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loosen tolerance for particle interpolation limiter #5386

Merged
merged 1 commit into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 11 additions & 2 deletions source/particle/interpolator/bilinear_least_squares.cc
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,17 @@ namespace aspect
{
// Assert that the limiter was reasonably effective. We can not expect perfect accuracy
// due to inaccuracies e.g. in the inversion of the mapping.
Assert(interpolated_value >= property_minimums[property_index] - 1e-9 * std::max(std::abs(property_minimums[property_index]), std::abs(property_maximums[property_index])), ExcInternalError());
Assert(interpolated_value <= property_maximums[property_index] + 1e-9 * std::max(std::abs(property_minimums[property_index]), std::abs(property_maximums[property_index])), ExcInternalError());
const double tolerance = std::sqrt(std::numeric_limits<double>::epsilon())
* std::max(std::abs(property_minimums[property_index]),
std::abs(property_maximums[property_index]));
(void) tolerance;
Assert(interpolated_value >= property_minimums[property_index] - tolerance,
ExcMessage("The particle interpolation limiter did not succeed. Interpolated value: " + std::to_string(interpolated_value)
+ " is smaller than the minimum particle property value: " + std::to_string(property_minimums[property_index]) + "."));
Assert(interpolated_value <= property_maximums[property_index] + tolerance,
ExcMessage("The particle interpolation limiter did not succeed. Interpolated value: " + std::to_string(interpolated_value)
+ " is larger than the maximum particle property value: " + std::to_string(property_maximums[property_index]) + "."));

interpolated_value = std::min(interpolated_value, property_maximums[property_index]);
interpolated_value = std::max(interpolated_value, property_minimums[property_index]);
}
Expand Down
13 changes: 11 additions & 2 deletions source/particle/interpolator/quadratic_least_squares.cc
Original file line number Diff line number Diff line change
Expand Up @@ -521,8 +521,17 @@ namespace aspect
{
// Assert that the limiter was reasonably effective. We can not expect perfect accuracy
// due to inaccuracies e.g. in the inversion of the mapping.
Assert(interpolated_value >= property_minimums[property_index] - 1e-9 * std::max(std::abs(property_minimums[property_index]), std::abs(property_maximums[property_index])), ExcInternalError());
Assert(interpolated_value <= property_maximums[property_index] + 1e-9 * std::max(std::abs(property_minimums[property_index]), std::abs(property_maximums[property_index])), ExcInternalError());
const double tolerance = std::sqrt(std::numeric_limits<double>::epsilon())
* std::max(std::abs(property_minimums[property_index]),
std::abs(property_maximums[property_index]));
(void) tolerance;
Assert(interpolated_value >= property_minimums[property_index] - tolerance,
ExcMessage("The particle interpolation limiter did not succeed. Interpolated value: " + std::to_string(interpolated_value)
+ " is smaller than the minimum particle property value: " + std::to_string(property_minimums[property_index]) + "."));
Assert(interpolated_value <= property_maximums[property_index] + tolerance,
ExcMessage("The particle interpolation limiter did not succeed. Interpolated value: " + std::to_string(interpolated_value)
+ " is larger than the maximum particle property value: " + std::to_string(property_maximums[property_index]) + "."));

// This chopping is done to avoid values that are just outside
// of the limiting bounds.
interpolated_value = std::min(interpolated_value, property_maximums[property_index]);
Expand Down