]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Expose rpe parameters through AdditionalData
authorMarco Feder <marco.feder@sissa.it>
Sun, 20 Aug 2023 17:12:47 +0000 (17:12 +0000)
committerMarco Feder <marco.feder@sissa.it>
Sun, 20 Aug 2023 22:20:59 +0000 (22:20 +0000)
include/deal.II/multigrid/mg_transfer_global_coarsening.h
include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h

index 11d7181354088a78375754436d5b885550178995..301849a824e30e34ff0a214bdc0628dc70b78883 100644 (file)
@@ -706,6 +706,30 @@ private:
   using VectorizedArrayType = VectorizedArray<Number, 1>;
 
 public:
+  /**
+   * AdditionalData structure for construction arguments needed by
+   * RemotePointEvaluation. Default values are the same as the ones in
+   * RemotePointEvaluation.
+   */
+  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 = {})
+      : tolerance(tol)
+      , enforce_unique_mapping(enf_unique_mapping)
+      , rtree_level(rtree_l)
+      , marked_vertices(marked_verts)
+    {}
+    double                             tolerance;
+    bool                               enforce_unique_mapping;
+    unsigned int                       rtree_level;
+    std::function<std::vector<bool>()> marked_vertices;
+  };
+
+  MGTwoLevelTransferNonNested(const AdditionalData &data = AdditionalData());
+
   /**
    * Set up transfer operator between the given DoFHandler objects (
    * @p dof_handler_fine and @p dof_handler_coarse).
@@ -788,7 +812,7 @@ private:
    * Object to evaluate shape functions on one mesh on visited support points of
    * the other mesh.
    */
-  Utilities::MPI::RemotePointEvaluation<dim> rpe;
+  std::shared_ptr<Utilities::MPI::RemotePointEvaluation<dim>> rpe;
 
   /**
    * MappingInfo object needed as Mapping argument by FEPointEvaluation.
index dfb99460fcba67275ef4bbebc4e14f83bbc3f2af..7dd71601eeffb420443777263eec97753eae2a9e 100644 (file)
@@ -4100,6 +4100,18 @@ namespace internal
 } // namespace internal
 
 
+
+template <int dim, typename Number>
+MGTwoLevelTransferNonNested<dim, LinearAlgebra::distributed::Vector<Number>>::
+  MGTwoLevelTransferNonNested(const AdditionalData &data)
+{
+  rpe = std::make_shared<Utilities::MPI::RemotePointEvaluation<dim>>(
+    data.tolerance,
+    data.enforce_unique_mapping,
+    data.rtree_level,
+    data.marked_vertices);
+}
+
 template <int dim, typename Number>
 void
 MGTwoLevelTransferNonNested<dim, LinearAlgebra::distributed::Vector<Number>>::
@@ -4170,13 +4182,13 @@ MGTwoLevelTransferNonNested<dim, LinearAlgebra::distributed::Vector<Number>>::
       this->partitioner_fine->global_to_local(global_dof_indices[i]);
 
   // hand points over to RPE
-  rpe.reinit(points, dof_handler_coarse.get_triangulation(), mapping_coarse);
+  rpe->reinit(points, dof_handler_coarse.get_triangulation(), mapping_coarse);
 
   // set up MappingInfo for easier data access
-  mapping_info = internal::fill_mapping_info<dim, Number>(rpe);
+  mapping_info = internal::fill_mapping_info<dim, Number>(*rpe);
 
   // set up constraints
-  const auto &cell_data = rpe.get_cell_data();
+  const auto &cell_data = rpe->get_cell_data();
 
   constraint_info.reinit(dof_handler_coarse,
                          cell_data.cells.size(),
@@ -4185,7 +4197,7 @@ MGTwoLevelTransferNonNested<dim, LinearAlgebra::distributed::Vector<Number>>::
   for (unsigned int i = 0; i < cell_data.cells.size(); ++i)
     {
       typename DoFHandler<dim>::active_cell_iterator cell(
-        &rpe.get_triangulation(),
+        &rpe->get_triangulation(),
         cell_data.cells[i].first,
         cell_data.cells[i].second,
         &dof_handler_coarse);
@@ -4295,18 +4307,18 @@ MGTwoLevelTransferNonNested<dim, LinearAlgebra::distributed::Vector<Number>>::
       }
   };
 
-  rpe.template evaluate_and_process<value_type>(evaluation_point_results,
-                                                buffer,
-                                                evaluation_function);
+  rpe->template evaluate_and_process<value_type>(evaluation_point_results,
+                                                 buffer,
+                                                 evaluation_function);
 
   // Weight operator in case some points are owned by multiple cells.
-  if (rpe.is_map_unique() == false)
+  if (rpe->is_map_unique() == false)
     {
       const auto evaluation_point_results_temp = evaluation_point_results;
       evaluation_point_results.clear();
-      evaluation_point_results.reserve(rpe.get_point_ptrs().size() - 1);
+      evaluation_point_results.reserve(rpe->get_point_ptrs().size() - 1);
 
-      const auto &ptr = rpe.get_point_ptrs();
+      const auto &ptr = rpe->get_point_ptrs();
 
       for (unsigned int i = 0; i < ptr.size() - 1; ++i)
         {
@@ -4388,7 +4400,7 @@ MGTwoLevelTransferNonNested<dim, LinearAlgebra::distributed::Vector<Number>>::
   std::vector<value_type> evaluation_point_results;
   std::vector<value_type> buffer;
 
-  evaluation_point_results.resize(rpe.get_point_ptrs().size() - 1);
+  evaluation_point_results.resize(rpe->get_point_ptrs().size() - 1);
 
   for (unsigned int j = 0; j < evaluation_point_results.size(); ++j)
     {
@@ -4423,9 +4435,9 @@ MGTwoLevelTransferNonNested<dim, LinearAlgebra::distributed::Vector<Number>>::
     }
 
   // Weight operator in case some points are owned by multiple cells.
-  if (rpe.is_map_unique() == false)
+  if (rpe->is_map_unique() == false)
     {
-      const auto &ptr = rpe.get_point_ptrs();
+      const auto &ptr = rpe->get_point_ptrs();
 
       for (unsigned int i = 0; i < ptr.size() - 1; ++i)
         {
@@ -4470,9 +4482,9 @@ MGTwoLevelTransferNonNested<dim, LinearAlgebra::distributed::Vector<Number>>::
       }
   };
 
-  rpe.template process_and_evaluate<value_type>(evaluation_point_results,
-                                                buffer,
-                                                evaluation_function);
+  rpe->template process_and_evaluate<value_type>(evaluation_point_results,
+                                                 buffer,
+                                                 evaluation_function);
 }
 
 

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.