From 3f11cb84c0457d703878a0cbcc87b9aadfa5dda3 Mon Sep 17 00:00:00 2001
From: Thomas Fischer <thomas.fischer@ufz.de>
Date: Wed, 30 May 2018 11:46:50 +0200
Subject: [PATCH] [PL] Change return type of getFlux().

---
 ProcessLib/GroundwaterFlow/GroundwaterFlowFEM.h     | 9 ++++-----
 ProcessLib/GroundwaterFlow/GroundwaterFlowProcess.h | 2 +-
 ProcessLib/HT/HTFEM.h                               | 7 +++----
 ProcessLib/HT/HTLocalAssemblerInterface.h           | 2 +-
 ProcessLib/HT/HTProcess.cpp                         | 6 +++---
 ProcessLib/HT/HTProcess.h                           | 2 +-
 ProcessLib/LocalAssemblerInterface.h                | 4 ++--
 ProcessLib/Process.h                                | 8 ++++----
 8 files changed, 19 insertions(+), 21 deletions(-)

diff --git a/ProcessLib/GroundwaterFlow/GroundwaterFlowFEM.h b/ProcessLib/GroundwaterFlow/GroundwaterFlowFEM.h
index 4a198995d3d..eb773365081 100644
--- a/ProcessLib/GroundwaterFlow/GroundwaterFlowFEM.h
+++ b/ProcessLib/GroundwaterFlow/GroundwaterFlowFEM.h
@@ -105,7 +105,7 @@ public:
     /// Computes the flux in the point \c p_local_coords that is given in local
     /// coordinates using the values from \c local_x.
     // TODO add time dependency
-    std::vector<double> getFlux(
+    Eigen::Vector3d getFlux(
         MathLib::Point3d const& p_local_coords,
         std::vector<double> const& local_x) const override
     {
@@ -123,8 +123,6 @@ public:
         // here, which is not affected by axial symmetry.
         fe.computeShapeFunctions(p_local_coords.getCoords(), shape_matrices,
                                  GlobalDim, false);
-        std::vector<double> flux;
-        flux.resize(3);
 
         // fetch hydraulic conductivity
         SpatialPosition pos;
@@ -133,9 +131,10 @@ public:
         double const t = 0.0;
         auto const k = _process_data.hydraulic_conductivity(t, pos)[0];
 
-        Eigen::Map<Eigen::RowVectorXd>(flux.data(), flux.size()) =
+        Eigen::Vector3d flux;
+        flux.head<GlobalDim>() =
             -k * shape_matrices.dNdx *
-            Eigen::Map<const Eigen::VectorXd>(local_x.data(), local_x.size());
+            Eigen::Map<const NodalVectorType>(local_x.data(), local_x.size());
 
         return flux;
     }
diff --git a/ProcessLib/GroundwaterFlow/GroundwaterFlowProcess.h b/ProcessLib/GroundwaterFlow/GroundwaterFlowProcess.h
index eb58aa8e57d..5ce132d81af 100644
--- a/ProcessLib/GroundwaterFlow/GroundwaterFlowProcess.h
+++ b/ProcessLib/GroundwaterFlow/GroundwaterFlowProcess.h
@@ -47,7 +47,7 @@ public:
     bool isLinear() const override { return true; }
     //! @}
 
-    std::vector<double> getFlux(std::size_t element_id,
+    Eigen::Vector3d getFlux(std::size_t element_id,
                                 MathLib::Point3d const& p,
                                 GlobalVector const& x) const override
     {
diff --git a/ProcessLib/HT/HTFEM.h b/ProcessLib/HT/HTFEM.h
index 3cc9cfca86f..ce156e71f35 100644
--- a/ProcessLib/HT/HTFEM.h
+++ b/ProcessLib/HT/HTFEM.h
@@ -91,7 +91,7 @@ public:
     /// Computes the flux in the point \c pnt_local_coords that is given in
     /// local coordinates using the values from \c local_x.
     // TODO add time dependency
-    std::vector<double> getFlux(
+    Eigen::Vector3d getFlux(
         MathLib::Point3d const& pnt_local_coords,
         std::vector<double> const& local_x) const override
     {
@@ -149,10 +149,9 @@ public:
             auto const b = this->_material_properties.specific_body_force;
             q += K_over_mu * rho_w * b;
         }
-        std::vector<double> flux;
-        flux.resize(3);
-        Eigen::Map<GlobalDimVectorType>(flux.data(), flux.size()) = q;
 
+        Eigen::Vector3d flux;
+        flux.head<GlobalDim>() = q;
         return flux;
     }
 
diff --git a/ProcessLib/HT/HTLocalAssemblerInterface.h b/ProcessLib/HT/HTLocalAssemblerInterface.h
index 53117d69412..fbcd85a711d 100644
--- a/ProcessLib/HT/HTLocalAssemblerInterface.h
+++ b/ProcessLib/HT/HTLocalAssemblerInterface.h
@@ -59,7 +59,7 @@ public:
         NumLib::LocalToGlobalIndexMap const& /*dof_table*/,
         std::vector<double>& /*cache*/) const = 0;
 
-    virtual std::vector<double> getFlux(
+    virtual Eigen::Vector3d getFlux(
         MathLib::Point3d const& pnt_local_coords,
         std::vector<double> const& local_x) const = 0;
 
diff --git a/ProcessLib/HT/HTProcess.cpp b/ProcessLib/HT/HTProcess.cpp
index 41159d51693..969b073abe9 100644
--- a/ProcessLib/HT/HTProcess.cpp
+++ b/ProcessLib/HT/HTProcess.cpp
@@ -240,9 +240,9 @@ void HTProcess::setCoupledSolutionsOfPreviousTimeStep()
     }
 }
 
-std::vector<double> HTProcess::getFlux(std::size_t element_id,
-                                       MathLib::Point3d const& p,
-                                       GlobalVector const& x) const
+Eigen::Vector3d HTProcess::getFlux(std::size_t element_id,
+                                   MathLib::Point3d const& p,
+                                   GlobalVector const& x) const
 {
     // fetch local_x from primary variable
     std::vector<GlobalIndexType> indices_cache;
diff --git a/ProcessLib/HT/HTProcess.h b/ProcessLib/HT/HTProcess.h
index 3972add55f2..ab13614ba7b 100644
--- a/ProcessLib/HT/HTProcess.h
+++ b/ProcessLib/HT/HTProcess.h
@@ -69,7 +69,7 @@ public:
     bool isLinear() const override { return false; }
     //! @}
 
-    std::vector<double> getFlux(std::size_t element_id,
+    Eigen::Vector3d getFlux(std::size_t element_id,
                                 MathLib::Point3d const& p,
                                 GlobalVector const& x) const override;
 
diff --git a/ProcessLib/LocalAssemblerInterface.h b/ProcessLib/LocalAssemblerInterface.h
index f750b6aa2a7..aa24d8d3907 100644
--- a/ProcessLib/LocalAssemblerInterface.h
+++ b/ProcessLib/LocalAssemblerInterface.h
@@ -85,11 +85,11 @@ public:
 
     /// Computes the flux in the point \c p_local_coords that is given in local
     /// coordinates using the values from \c local_x.
-    virtual std::vector<double> getFlux(
+    virtual Eigen::Vector3d getFlux(
         MathLib::Point3d const& /*p_local_coords*/,
         std::vector<double> const& /*local_x*/) const
     {
-        return std::vector<double>();
+        return Eigen::Vector3d{};
     }
 
 private:
diff --git a/ProcessLib/Process.h b/ProcessLib/Process.h
index 10bdeb8ba4c..17718362a43 100644
--- a/ProcessLib/Process.h
+++ b/ProcessLib/Process.h
@@ -136,11 +136,11 @@ public:
 
     // Used as a call back for CalculateSurfaceFlux process.
 
-    virtual std::vector<double> getFlux(std::size_t /*element_id*/,
-                                        MathLib::Point3d const& /*p*/,
-                                        GlobalVector const& /*x*/) const
+    virtual Eigen::Vector3d getFlux(std::size_t /*element_id*/,
+                                    MathLib::Point3d const& /*p*/,
+                                    GlobalVector const& /*x*/) const
     {
-        return std::vector<double>{};
+        return Eigen::Vector3d{};
     }
 
 protected:
-- 
GitLab