From dda8f1874fbb972fbf0984db999f657c5543f8ad Mon Sep 17 00:00:00 2001 From: Marco Feder Date: Mon, 21 Aug 2023 09:57:30 +0000 Subject: [PATCH] Allow throwing if not all points have been found --- .../multigrid/mg_transfer_global_coarsening.h | 14 ++++++++++---- .../mg_transfer_global_coarsening.templates.h | 7 +++++++ .../non_nested_multigrid_03.cc | 4 +++- .../non_nested_transfer_02.cc | 6 +++++- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/include/deal.II/multigrid/mg_transfer_global_coarsening.h b/include/deal.II/multigrid/mg_transfer_global_coarsening.h index 301849a824..756e75084b 100644 --- a/include/deal.II/multigrid/mg_transfer_global_coarsening.h +++ b/include/deal.II/multigrid/mg_transfer_global_coarsening.h @@ -707,25 +707,30 @@ private: public: /** - * AdditionalData structure for construction arguments needed by - * RemotePointEvaluation. Default values are the same as the ones in - * RemotePointEvaluation. + * AdditionalData structure with the arguments needed by + * RemotePointEvaluation. Default values are the same as the ones described in + * the documentation of RemotePointEvaluation. The last boolean parameter, @p enf_all_points_found is true by defaults and + * checks if RemotePointEvaluation::all_points_found() evaluates to true, i.e. + * all submitted points have been found inside the domain. */ struct AdditionalData { AdditionalData(const double tol = 1e-6, const bool enf_unique_mapping = false, const unsigned int rtree_l = 0, - const std::function()> &marked_verts = {}) + const std::function()> &marked_verts = {}, + const bool enf_all_points_found = true) : tolerance(tol) , enforce_unique_mapping(enf_unique_mapping) , rtree_level(rtree_l) , marked_vertices(marked_verts) + , enforce_all_points_found(enf_all_points_found) {} double tolerance; bool enforce_unique_mapping; unsigned int rtree_level; std::function()> marked_vertices; + bool enforce_all_points_found; }; MGTwoLevelTransferNonNested(const AdditionalData &data = AdditionalData()); @@ -773,6 +778,7 @@ public: memory_consumption() const override; protected: + AdditionalData additional_data; /** * Perform prolongation. */ diff --git a/include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h b/include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h index 7dd71601ee..1de0ac7830 100644 --- a/include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h +++ b/include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h @@ -4104,6 +4104,7 @@ namespace internal template MGTwoLevelTransferNonNested>:: MGTwoLevelTransferNonNested(const AdditionalData &data) + : additional_data(data) { rpe = std::make_shared>( data.tolerance, @@ -4184,6 +4185,12 @@ MGTwoLevelTransferNonNested>:: // hand points over to RPE rpe->reinit(points, dof_handler_coarse.get_triangulation(), mapping_coarse); + if (additional_data.enforce_all_points_found) + AssertThrow( + rpe->all_points_found(), + ExcMessage( + "You requested that all points should be found, but this didn't happen. You can change this option through the AdditionaData struct in the constructor.")); + // set up MappingInfo for easier data access mapping_info = internal::fill_mapping_info(*rpe); diff --git a/tests/multigrid-global-coarsening/non_nested_multigrid_03.cc b/tests/multigrid-global-coarsening/non_nested_multigrid_03.cc index ba419ca587..05fa1370d5 100644 --- a/tests/multigrid-global-coarsening/non_nested_multigrid_03.cc +++ b/tests/multigrid-global-coarsening/non_nested_multigrid_03.cc @@ -77,10 +77,12 @@ test(const unsigned int n_refinements, const unsigned int fe_degree_fine) } // set up transfer operator + typename MGTwoLevelTransferNonNested::AdditionalData data; + data.enforce_all_points_found = false; for (unsigned int l = min_level; l < max_level; ++l) { transfers[l + 1] = - std::make_shared>(); + std::make_shared>(data); transfers[l + 1]->reinit(dof_handlers[l + 1], dof_handlers[l], mappings[l + 1], diff --git a/tests/multigrid-global-coarsening/non_nested_transfer_02.cc b/tests/multigrid-global-coarsening/non_nested_transfer_02.cc index 4bc2ef7c49..e69b685c97 100644 --- a/tests/multigrid-global-coarsening/non_nested_transfer_02.cc +++ b/tests/multigrid-global-coarsening/non_nested_transfer_02.cc @@ -80,8 +80,12 @@ do_test(const FiniteElement & fe_fine, constraint_fine.close(); // setup transfer operator + typename MGTwoLevelTransferNonNested< + dim, + LinearAlgebra::distributed::Vector>::AdditionalData data; + data.enforce_all_points_found = false; MGTwoLevelTransferNonNested> - transfer; + transfer(data); MappingQ1 mapping_fine, mapping_coarse; transfer.reinit(dof_handler_fine, dof_handler_coarse, -- 2.39.5