From 499cc02cc3fc343888cd12151b39bc329f1e9cad Mon Sep 17 00:00:00 2001
From: Dmitri Naumov <github@naumov.de>
Date: Wed, 19 Oct 2016 23:52:40 +0200
Subject: [PATCH] [PL] Fetch the curves once in create, not assembly

ctest runtime drops from 7.33 to 7 time units ~ 4.5%
---
 .../RichardsFlow/CreateRichardsFlowProcess.cpp   |  3 ++-
 ProcessLib/RichardsFlow/RichardsFlowFEM.h        |  4 ++--
 .../RichardsFlow/RichardsFlowProcessData.h       | 16 ++++++++--------
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/ProcessLib/RichardsFlow/CreateRichardsFlowProcess.cpp b/ProcessLib/RichardsFlow/CreateRichardsFlowProcess.cpp
index 7e05e24eca3..1d844b3334f 100644
--- a/ProcessLib/RichardsFlow/CreateRichardsFlowProcess.cpp
+++ b/ProcessLib/RichardsFlow/CreateRichardsFlowProcess.cpp
@@ -107,7 +107,8 @@ std::unique_ptr<Process> createRichardsFlowProcess(
                                          specific_body_force,
                                          has_gravity,
                                          mass_lump,
-                                         curves};
+                                         *curves.at("curve_PC_S"),
+                                         *curves.at("curve_S_Krel")};
     SecondaryVariableCollection secondary_variables;
 
     NumLib::NamedFunctionCaller named_function_caller(
diff --git a/ProcessLib/RichardsFlow/RichardsFlowFEM.h b/ProcessLib/RichardsFlow/RichardsFlowFEM.h
index 3c70ae641d6..a30379f94f4 100644
--- a/ProcessLib/RichardsFlow/RichardsFlowFEM.h
+++ b/ProcessLib/RichardsFlow/RichardsFlowFEM.h
@@ -82,9 +82,9 @@ public:
         assert(local_matrix_size == ShapeFunction::NPOINTS * NUM_NODAL_DOF);
 
         MathLib::PiecewiseLinearInterpolation const& interpolated_Pc =
-            *_process_data.curves.at("curve_PC_S");
+            _process_data.interpolated_Pc;
         MathLib::PiecewiseLinearInterpolation const& interpolated_Kr =
-            *_process_data.curves.at("curve_S_Krel");
+            _process_data.interpolated_Kr;
 
         auto local_M = MathLib::createZeroedMatrix<NodalMatrixType>(
             local_M_data, local_matrix_size, local_matrix_size);
diff --git a/ProcessLib/RichardsFlow/RichardsFlowProcessData.h b/ProcessLib/RichardsFlow/RichardsFlowProcessData.h
index 1b4ce009eaf..ae9a076a4f4 100644
--- a/ProcessLib/RichardsFlow/RichardsFlowProcessData.h
+++ b/ProcessLib/RichardsFlow/RichardsFlowProcessData.h
@@ -33,9 +33,8 @@ struct RichardsFlowProcessData
         Parameter<double> const& specific_body_force_,
         bool const has_gravity_,
         bool const has_mass_lumping_,
-        std::map<std::string,
-                 std::unique_ptr<MathLib::PiecewiseLinearInterpolation>> const&
-            curves_)
+        MathLib::PiecewiseLinearInterpolation const& interpolated_Pc_,
+        MathLib::PiecewiseLinearInterpolation const& interpolated_Kr_)
         : intrinsic_permeability(intrinsic_permeability_),
           porosity(porosity_),
           viscosity(viscosity_),
@@ -44,7 +43,8 @@ struct RichardsFlowProcessData
           specific_body_force(specific_body_force_),
           has_gravity(has_gravity_),
           has_mass_lumping(has_mass_lumping_),
-          curves(curves_)
+          interpolated_Pc(interpolated_Pc_),
+          interpolated_Kr(interpolated_Kr_)
     {
     }
 
@@ -57,7 +57,8 @@ struct RichardsFlowProcessData
           specific_body_force(other.specific_body_force),
           has_gravity(other.has_gravity),
           has_mass_lumping(other.has_mass_lumping),
-          curves(other.curves)
+          interpolated_Pc(other.interpolated_Pc),
+          interpolated_Kr(other.interpolated_Kr)
     {
     }
 
@@ -78,9 +79,8 @@ struct RichardsFlowProcessData
     Parameter<double> const& specific_body_force;
     bool const has_gravity;
     bool const has_mass_lumping;
-    std::map<std::string,
-             std::unique_ptr<MathLib::PiecewiseLinearInterpolation>> const&
-        curves;
+    MathLib::PiecewiseLinearInterpolation const& interpolated_Pc;
+    MathLib::PiecewiseLinearInterpolation const& interpolated_Kr;
 };
 
 }  // namespace RichardsFlow
-- 
GitLab