From d8bece774e16123d658228b7116a40ce3ba97af3 Mon Sep 17 00:00:00 2001 From: Marc Fehling Date: Mon, 5 Jun 2023 20:43:16 -0600 Subject: [PATCH] Use numbers::is_finite whenever we compare with infinity. --- include/deal.II/lac/utilities.h | 2 +- source/fe/mapping_q.cc | 13 ++++++------- source/particles/particle_handler.cc | 8 ++++---- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/include/deal.II/lac/utilities.h b/include/deal.II/lac/utilities.h index 1e91f3623f..058aaf5b69 100644 --- a/include/deal.II/lac/utilities.h +++ b/include/deal.II/lac/utilities.h @@ -432,7 +432,7 @@ namespace Utilities const double b = unwanted_spectrum.second; Assert(degree > 0, ExcMessage("Only positive degrees make sense.")); - const bool scale = (a_L < std::numeric_limits::infinity()); + const bool scale = numbers::is_finite(a_L); Assert( a < b, ExcMessage( diff --git a/source/fe/mapping_q.cc b/source/fe/mapping_q.cc index 7d0f7472ff..527004b332 100644 --- a/source/fe/mapping_q.cc +++ b/source/fe/mapping_q.cc @@ -580,9 +580,8 @@ MappingQ::transform_real_to_unit_cell( // statement may throw an exception, which we simply pass up to the caller const Point p_unit = this->transform_real_to_unit_cell_internal(cell, p, initial_p_unit); - if (p_unit[0] == std::numeric_limits::infinity()) - AssertThrow(false, - (typename Mapping::ExcTransformationFailed())); + AssertThrow(numbers::is_finite(p_unit[0]), + (typename Mapping::ExcTransformationFailed())); return p_unit; } @@ -646,7 +645,10 @@ MappingQ::transform_points_real_to_unit_cell( // determinants) from other SIMD lanes. Repeat the computation in this // unlikely case with scalar arguments. for (unsigned int j = 0; j < n_lanes && i + j < n_points; ++j) - if (unit_point[0][j] == std::numeric_limits::infinity()) + if (numbers::is_finite(unit_point[0][j])) + for (unsigned int d = 0; d < dim; ++d) + unit_points[i + j][d] = unit_point[d][j]; + else unit_points[i + j] = internal::MappingQImplementation:: do_transform_real_to_unit_cell_internal( real_points[i + j], @@ -654,9 +656,6 @@ MappingQ::transform_points_real_to_unit_cell( support_points, polynomials_1d, renumber_lexicographic_to_hierarchic); - else - for (unsigned int d = 0; d < dim; ++d) - unit_points[i + j][d] = unit_point[d][j]; } else unit_points[i] = internal::MappingQImplementation:: diff --git a/source/particles/particle_handler.cc b/source/particles/particle_handler.cc index 0bc71a019d..6f46f472df 100644 --- a/source/particles/particle_handler.cc +++ b/source/particles/particle_handler.cc @@ -1261,11 +1261,11 @@ namespace Particles auto particle = pic.begin(); for (const auto &p_unit : reference_locations) { - if (p_unit[0] == std::numeric_limits::infinity() || - !GeometryInfo::is_inside_unit_cell(p_unit)) - particles_out_of_cell.push_back(particle); - else + if (numbers::is_finite(p_unit[0]) && + GeometryInfo::is_inside_unit_cell(p_unit)) particle->set_reference_location(p_unit); + else + particles_out_of_cell.push_back(particle); ++particle; } -- 2.39.5