]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Allow throwing if not all points have been found
authorMarco Feder <marco.feder@sissa.it>
Mon, 21 Aug 2023 09:57:30 +0000 (09:57 +0000)
committerMarco Feder <marco.feder@sissa.it>
Mon, 21 Aug 2023 11:05:47 +0000 (11:05 +0000)
include/deal.II/multigrid/mg_transfer_global_coarsening.h
include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h
tests/multigrid-global-coarsening/non_nested_multigrid_03.cc
tests/multigrid-global-coarsening/non_nested_transfer_02.cc

index 301849a824e30e34ff0a214bdc0628dc70b78883..756e75084b6ca9b5c9f3bde12c32058db042f42f 100644 (file)
@@ -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<std::vector<bool>()> &marked_verts = {})
+                   const std::function<std::vector<bool>()> &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<std::vector<bool>()> 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.
    */
index 7dd71601eeffb420443777263eec97753eae2a9e..1de0ac783081ca7f9d02152981d927e02d0ce186 100644 (file)
@@ -4104,6 +4104,7 @@ namespace internal
 template <int dim, typename Number>
 MGTwoLevelTransferNonNested<dim, LinearAlgebra::distributed::Vector<Number>>::
   MGTwoLevelTransferNonNested(const AdditionalData &data)
+  : additional_data(data)
 {
   rpe = std::make_shared<Utilities::MPI::RemotePointEvaluation<dim>>(
     data.tolerance,
@@ -4184,6 +4185,12 @@ MGTwoLevelTransferNonNested<dim, LinearAlgebra::distributed::Vector<Number>>::
   // 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<dim, Number>(*rpe);
 
index ba419ca58701d8feaa229ffecbba02297bebf847..05fa1370d5420b7c85406df0b537e1ec857811b5 100644 (file)
@@ -77,10 +77,12 @@ test(const unsigned int n_refinements, const unsigned int fe_degree_fine)
     }
 
   // set up transfer operator
+  typename MGTwoLevelTransferNonNested<dim, VectorType>::AdditionalData data;
+  data.enforce_all_points_found = false;
   for (unsigned int l = min_level; l < max_level; ++l)
     {
       transfers[l + 1] =
-        std::make_shared<MGTwoLevelTransferNonNested<dim, VectorType>>();
+        std::make_shared<MGTwoLevelTransferNonNested<dim, VectorType>>(data);
       transfers[l + 1]->reinit(dof_handlers[l + 1],
                                dof_handlers[l],
                                mappings[l + 1],
index 4bc2ef7c49532ee345d9f205570525375c694ed0..e69b685c97e8b817bf29c41d36c044cfdb0e51cc 100644 (file)
@@ -80,8 +80,12 @@ do_test(const FiniteElement<dim> &   fe_fine,
   constraint_fine.close();
 
   // setup transfer operator
+  typename MGTwoLevelTransferNonNested<
+    dim,
+    LinearAlgebra::distributed::Vector<Number>>::AdditionalData data;
+  data.enforce_all_points_found = false;
   MGTwoLevelTransferNonNested<dim, LinearAlgebra::distributed::Vector<Number>>
-                 transfer;
+                 transfer(data);
   MappingQ1<dim> mapping_fine, mapping_coarse;
   transfer.reinit(dof_handler_fine,
                   dof_handler_coarse,

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.