From 0d920d3b38b4aea03b1ce2ae8a57dd1422007a0f Mon Sep 17 00:00:00 2001 From: Peter Munch Date: Wed, 16 Mar 2022 22:10:45 +0100 Subject: [PATCH] Add RPE::all_points_found() and ::valid_point_masks() --- .../base/mpi_remote_point_evaluation.h | 15 +++++++++++ .../deal.II/numerics/vector_tools_evaluate.h | 5 ++++ source/base/mpi_remote_point_evaluation.cc | 27 +++++++++++++++++++ 3 files changed, 47 insertions(+) diff --git a/include/deal.II/base/mpi_remote_point_evaluation.h b/include/deal.II/base/mpi_remote_point_evaluation.h index 87665dd88a..cf1429a536 100644 --- a/include/deal.II/base/mpi_remote_point_evaluation.h +++ b/include/deal.II/base/mpi_remote_point_evaluation.h @@ -74,6 +74,9 @@ namespace Utilities * * @warning This is a collective call that needs to be executed by all * processors in the communicator. + * + * @note If you want to be sure that all points have been found, call + * all_points_found() after calling this function. */ void reinit(const std::vector> &points, @@ -156,6 +159,18 @@ namespace Utilities bool is_map_unique() const; + /** + * Return if all points could be found in the domain. + */ + bool + all_points_found() const; + + /** + * Return if point @p i could be found in the domain. + */ + bool + point_found(const unsigned int i) const; + /** * Return the Triangulation object used during reinit(). */ diff --git a/include/deal.II/numerics/vector_tools_evaluate.h b/include/deal.II/numerics/vector_tools_evaluate.h index 53148451b9..22bb95a672 100644 --- a/include/deal.II/numerics/vector_tools_evaluate.h +++ b/include/deal.II/numerics/vector_tools_evaluate.h @@ -108,6 +108,11 @@ namespace VectorTools * cache, dof_handler_2, vector_2); * @endcode * + * @note If a point cannot be found, the result for these points will + * be undefined (most probably 0). If you want to be sure that all + * points received a valid result, call `cache.all_points_found()` + * after this function call. + * * @warning This is a collective call that needs to be executed by all * processors in the communicator. */ diff --git a/source/base/mpi_remote_point_evaluation.cc b/source/base/mpi_remote_point_evaluation.cc index 404f15e6b0..2f059ffb6c 100644 --- a/source/base/mpi_remote_point_evaluation.cc +++ b/source/base/mpi_remote_point_evaluation.cc @@ -185,6 +185,33 @@ namespace Utilities + template + bool + RemotePointEvaluation::all_points_found() const + { + if (is_map_unique()) + return true; + + for (unsigned int i = 1; i < point_ptrs.size(); ++i) + if (point_found(i) == false) + return false; + + return true; + } + + + + template + bool + RemotePointEvaluation::point_found( + const unsigned int i) const + { + AssertIndexRange(i, point_ptrs.size()); + return (point_ptrs[i] - point_ptrs[i - 1]) > 0; + } + + + template const Triangulation & RemotePointEvaluation::get_triangulation() const -- 2.39.5