From: Magdalena Schreter <magdalena.schreter@tum.de>
Date: Sun, 17 Sep 2023 20:31:53 +0000 (+0200)
Subject: add alternative interfaces for RemotePointEvaluation::evaluate_and_process and :... 
X-Git-Tag: relicensing~495^2
X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F15996%2Fhead;p=dealii.git

add alternative interfaces for RemotePointEvaluation::evaluate_and_process and ::process_and_evaluate
---

diff --git a/doc/news/changes/minor/20230917SchreterMunch_2 b/doc/news/changes/minor/20230917SchreterMunch_2
new file mode 100644
index 0000000000..e8c180d843
--- /dev/null
+++ b/doc/news/changes/minor/20230917SchreterMunch_2
@@ -0,0 +1,4 @@
+New: Add alternative interfaces to RemotePointEvaluation::evaluate_and_proecss and 
+RemotePointEvaluation::process_and_evaluate.
+<br>
+(Magdalena Schreter, Peter Munch, 2023/09/17)
diff --git a/include/deal.II/base/mpi_remote_point_evaluation.h b/include/deal.II/base/mpi_remote_point_evaluation.h
index 24f7d837a6..af7de52437 100644
--- a/include/deal.II/base/mpi_remote_point_evaluation.h
+++ b/include/deal.II/base/mpi_remote_point_evaluation.h
@@ -161,6 +161,16 @@ namespace Utilities
         const std::function<void(const ArrayView<T> &, const CellData &)>
           &evaluation_function) const;
 
+      /**
+       * Same as above but with the result provided as return value and
+       * without external allocation of a user-provided buffer.
+       */
+      template <typename T>
+      std::vector<T>
+      evaluate_and_process(
+        const std::function<void(const ArrayView<T> &, const CellData &)>
+          &evaluation_function) const;
+
       /**
        * This method is the inverse of the method evaluate_and_process(). It
        * makes the data at the points, provided by @p input, available in the
@@ -177,6 +187,17 @@ namespace Utilities
         const std::function<void(const ArrayView<const T> &, const CellData &)>
           &evaluation_function) const;
 
+      /**
+       * Same as above but without external allocation of a user-provided
+       * buffer.
+       */
+      template <typename T>
+      void
+      process_and_evaluate(
+        const std::vector<T> &input,
+        const std::function<void(const ArrayView<const T> &, const CellData &)>
+          &evaluation_function) const;
+
       /**
        * Return a CRS-like data structure to determine the position of the
        * result corresponding a point and the amount.
@@ -487,6 +508,23 @@ namespace Utilities
     }
 
 
+    template <int dim, int spacedim>
+    template <typename T>
+    std::vector<T>
+    RemotePointEvaluation<dim, spacedim>::evaluate_and_process(
+      const std::function<void(const ArrayView<T> &, const CellData &)>
+        &evaluation_function) const
+    {
+      std::vector<T> output;
+      std::vector<T> buffer;
+
+      this->evaluate_and_process(output, buffer, evaluation_function);
+
+      return output;
+    }
+
+
+
     template <int dim, int spacedim>
     template <typename T>
     void
@@ -660,6 +698,20 @@ namespace Utilities
 #endif
     }
 
+
+
+    template <int dim, int spacedim>
+    template <typename T>
+    void
+    RemotePointEvaluation<dim, spacedim>::process_and_evaluate(
+      const std::vector<T> &input,
+      const std::function<void(const ArrayView<const T> &, const CellData &)>
+        &evaluation_function) const
+    {
+      std::vector<T> buffer;
+      this->process_and_evaluate(input, buffer, evaluation_function);
+    }
+
   } // end of namespace MPI
 } // end of namespace Utilities