From 3ddbff70f6976e4b9df78a5ea677b9a3efe50b17 Mon Sep 17 00:00:00 2001
From: Christoph Lehmann <christoph.lehmann@ufz.de>
Date: Tue, 5 Jul 2016 11:50:26 +0200
Subject: [PATCH] [PL] adapted TES to extrapolator

---
 ProcessLib/TES/TESLocalAssembler-impl.h      | 43 +++++++++++++++--
 ProcessLib/TES/TESLocalAssembler.h           | 34 +++++++++++--
 ProcessLib/TES/TESLocalAssemblerInner-impl.h | 51 --------------------
 ProcessLib/TES/TESLocalAssemblerInner.h      | 14 ------
 ProcessLib/TES/TESProcess.cpp                | 25 ++++++----
 ProcessLib/TES/TESProcess.h                  |  5 +-
 6 files changed, 87 insertions(+), 85 deletions(-)

diff --git a/ProcessLib/TES/TESLocalAssembler-impl.h b/ProcessLib/TES/TESLocalAssembler-impl.h
index 331f67b6352..391b2930736 100644
--- a/ProcessLib/TES/TESLocalAssembler-impl.h
+++ b/ProcessLib/TES/TESLocalAssembler-impl.h
@@ -194,10 +194,47 @@ template <typename ShapeFunction_, typename IntegrationMethod_,
           unsigned GlobalDim>
 std::vector<double> const& TESLocalAssembler<
     ShapeFunction_, IntegrationMethod_,
-    GlobalDim>::getIntegrationPointValues(TESIntPtVariables const var,
-                                          std::vector<double>& cache) const
+    GlobalDim>::getIntPtSolidDensity(std::vector<double>& /*cache*/) const
 {
-    return _d.getIntegrationPointValues(var, cache);
+    return _d.getData().solid_density;
+}
+
+template <typename ShapeFunction_, typename IntegrationMethod_,
+          unsigned GlobalDim>
+std::vector<double> const& TESLocalAssembler<
+    ShapeFunction_, IntegrationMethod_,
+    GlobalDim>::getIntPtReactionRate(std::vector<double>& /*cache*/) const
+{
+    return _d.getData().reaction_rate;
+}
+
+template <typename ShapeFunction_, typename IntegrationMethod_,
+          unsigned GlobalDim>
+std::vector<double> const& TESLocalAssembler<
+    ShapeFunction_, IntegrationMethod_,
+    GlobalDim>::getIntPtDarcyVelocityX(std::vector<double>& /*cache*/) const
+{
+    return _d.getData().velocity[0];
+}
+
+template <typename ShapeFunction_, typename IntegrationMethod_,
+          unsigned GlobalDim>
+std::vector<double> const& TESLocalAssembler<
+    ShapeFunction_, IntegrationMethod_,
+    GlobalDim>::getIntPtDarcyVelocityY(std::vector<double>& /*cache*/) const
+{
+    assert(_d.getData().velocity.size() >= 2);
+    return _d.getData().velocity[1];
+}
+
+template <typename ShapeFunction_, typename IntegrationMethod_,
+          unsigned GlobalDim>
+std::vector<double> const& TESLocalAssembler<
+    ShapeFunction_, IntegrationMethod_,
+    GlobalDim>::getIntPtDarcyVelocityZ(std::vector<double>& /*cache*/) const
+{
+    assert(_d.getData().velocity.size() >= 3);
+    return _d.getData().velocity[2];
 }
 
 template <typename ShapeFunction_, typename IntegrationMethod_,
diff --git a/ProcessLib/TES/TESLocalAssembler.h b/ProcessLib/TES/TESLocalAssembler.h
index 37ce25c3045..5509c0cacf4 100644
--- a/ProcessLib/TES/TESLocalAssembler.h
+++ b/ProcessLib/TES/TESLocalAssembler.h
@@ -17,7 +17,7 @@
 #include "TESAssemblyParams.h"
 #include "TESLocalAssemblerInner-fwd.h"
 
-#include "NumLib/Extrapolation/Extrapolator.h"
+#include "NumLib/Extrapolation/ExtrapolatableElement.h"
 
 namespace ProcessLib
 {
@@ -25,13 +25,28 @@ namespace TES
 {
 class TESLocalAssemblerInterface
     : public ProcessLib::LocalAssemblerInterface,
-      public NumLib::Extrapolatable<TESIntPtVariables>
+      public NumLib::ExtrapolatableElement
 {
 public:
     virtual ~TESLocalAssemblerInterface() = default;
 
     virtual bool checkBounds(std::vector<double> const& local_x,
                              std::vector<double> const& local_x_prev_ts) = 0;
+
+    virtual std::vector<double> const& getIntPtSolidDensity(
+        std::vector<double>& /*cache*/) const = 0;
+
+    virtual std::vector<double> const& getIntPtReactionRate(
+        std::vector<double>& /*cache*/) const = 0;
+
+    virtual std::vector<double> const& getIntPtDarcyVelocityX(
+        std::vector<double>& /*cache*/) const = 0;
+
+    virtual std::vector<double> const& getIntPtDarcyVelocityY(
+        std::vector<double>& /*cache*/) const = 0;
+
+    virtual std::vector<double> const& getIntPtDarcyVelocityZ(
+        std::vector<double>& /*cache*/) const = 0;
 };
 
 template <typename ShapeFunction_, typename IntegrationMethod_,
@@ -66,9 +81,20 @@ public:
     bool checkBounds(std::vector<double> const& local_x,
                      std::vector<double> const& local_x_prev_ts) override;
 
-    std::vector<double> const& getIntegrationPointValues(
-        TESIntPtVariables const var, std::vector<double>& cache) const override;
+    std::vector<double> const& getIntPtSolidDensity(
+        std::vector<double>& /*cache*/) const override;
+
+    std::vector<double> const& getIntPtReactionRate(
+        std::vector<double>& /*cache*/) const override;
+
+    std::vector<double> const& getIntPtDarcyVelocityX(
+        std::vector<double>& /*cache*/) const override;
+
+    std::vector<double> const& getIntPtDarcyVelocityY(
+        std::vector<double>& /*cache*/) const override;
 
+    std::vector<double> const& getIntPtDarcyVelocityZ(
+        std::vector<double>& /*cache*/) const override;
 private:
     std::vector<ShapeMatrices> _shape_matrices;
 
diff --git a/ProcessLib/TES/TESLocalAssemblerInner-impl.h b/ProcessLib/TES/TESLocalAssemblerInner-impl.h
index d587920df98..b0d63166cd6 100644
--- a/ProcessLib/TES/TESLocalAssemblerInner-impl.h
+++ b/ProcessLib/TES/TESLocalAssemblerInner-impl.h
@@ -218,57 +218,6 @@ void TESLocalAssemblerInner<Traits>::preEachAssembleIntegrationPoint(
     _d.rho_GR = fluid_density(_d.p, _d.T, _d.vapour_mass_fraction);
 }
 
-template <typename Traits>
-std::vector<double> const&
-TESLocalAssemblerInner<Traits>::getIntegrationPointValues(
-    TESIntPtVariables const var, std::vector<double>& cache) const
-{
-    switch (var)
-    {
-        case TESIntPtVariables::REACTION_RATE:
-            return _d.reaction_rate;
-        case TESIntPtVariables::SOLID_DENSITY:
-            return _d.solid_density;
-        case TESIntPtVariables::VELOCITY_X:
-            return _d.velocity[0];
-        case TESIntPtVariables::VELOCITY_Y:
-            assert(_d.velocity.size() >= 2);
-            return _d.velocity[1];
-        case TESIntPtVariables::VELOCITY_Z:
-            assert(_d.velocity.size() >= 3);
-            return _d.velocity[2];
-
-        case TESIntPtVariables::LOADING:
-        {
-            auto& Cs = cache;
-            Cs.clear();
-            Cs.reserve(_d.solid_density.size());
-
-            for (auto rho_SR : _d.solid_density)
-            {
-                Cs.push_back(rho_SR / _d.ap.rho_SR_dry - 1.0);
-            }
-
-            return Cs;
-        }
-
-        // TODO that's an element value, ain't it?
-        case TESIntPtVariables::REACTION_DAMPING_FACTOR:
-        {
-            auto const num_integration_points = _d.solid_density.size();
-            auto& alphas = cache;
-            alphas.clear();
-            alphas.resize(num_integration_points,
-                          _d.reaction_adaptor->getReactionDampingFactor());
-
-            return alphas;
-        }
-    }
-
-    cache.clear();
-    return cache;
-}
-
 template <typename Traits>
 void TESLocalAssemblerInner<Traits>::assembleIntegrationPoint(
     unsigned integration_point,
diff --git a/ProcessLib/TES/TESLocalAssemblerInner.h b/ProcessLib/TES/TESLocalAssemblerInner.h
index 3e36cb47180..77d4638fc50 100644
--- a/ProcessLib/TES/TESLocalAssemblerInner.h
+++ b/ProcessLib/TES/TESLocalAssemblerInner.h
@@ -23,17 +23,6 @@ namespace ProcessLib
 {
 namespace TES
 {
-enum class TESIntPtVariables : unsigned
-{
-    SOLID_DENSITY,
-    REACTION_RATE,
-    VELOCITY_X,
-    VELOCITY_Y,
-    VELOCITY_Z,
-    LOADING,
-    REACTION_DAMPING_FACTOR
-};
-
 template <typename Traits>
 class TESLocalAssemblerInner
 {
@@ -56,9 +45,6 @@ public:
 
     void preEachAssemble();
 
-    std::vector<double> const& getIntegrationPointValues(
-        TESIntPtVariables const var, std::vector<double>& cache) const;
-
     // TODO better encapsulation
     AssemblyParams const& getAssemblyParameters() const { return _d.ap; }
     TESFEMReactionAdaptor const& getReactionAdaptor() const
diff --git a/ProcessLib/TES/TESProcess.cpp b/ProcessLib/TES/TESProcess.cpp
index b35eb3c1896..a73f5571f1a 100644
--- a/ProcessLib/TES/TESProcess.cpp
+++ b/ProcessLib/TES/TESProcess.cpp
@@ -204,22 +204,27 @@ void TESProcess::initializeConcreteProcess(
                                                         std::move(fcts));
     };
     auto makeEx =
-        [&](TESIntPtVariables var) -> SecondaryVariableFunctions {
-        return ProcessLib::makeExtrapolator(var, *_extrapolator,
-                                            _local_assemblers);
+        [&](std::vector<double> const& (TESLocalAssemblerInterface::*method)(
+            std::vector<double>&)const) -> SecondaryVariableFunctions {
+        return ProcessLib::makeExtrapolator(*_extrapolator, _local_assemblers,
+                                            method);
     };
 
-    add2nd("solid_density", 1, makeEx(TESIntPtVariables::SOLID_DENSITY));
-    add2nd("reaction_rate", 1, makeEx(TESIntPtVariables::REACTION_RATE));
-    add2nd("velocity_x", 1, makeEx(TESIntPtVariables::VELOCITY_X));
+    // add2nd("solid_density", 1, makeEx(TESIntPtVariables::SOLID_DENSITY));
+    add2nd("reaction_rate", 1,
+           makeEx(&TESLocalAssemblerInterface::getIntPtReactionRate));
+    add2nd("velocity_x", 1,
+           makeEx(&TESLocalAssemblerInterface::getIntPtDarcyVelocityX));
     if (mesh.getDimension() >= 2)
-        add2nd("velocity_y", 1, makeEx(TESIntPtVariables::VELOCITY_Y));
+        add2nd("velocity_y", 1,
+               makeEx(&TESLocalAssemblerInterface::getIntPtDarcyVelocityY));
     if (mesh.getDimension() >= 3)
-        add2nd("velocity_z", 1, makeEx(TESIntPtVariables::VELOCITY_Z));
+        add2nd("velocity_z", 1,
+               makeEx(&TESLocalAssemblerInterface::getIntPtDarcyVelocityZ));
 
-    add2nd("loading", 1, makeEx(TESIntPtVariables::LOADING));
+    /*add2nd("loading", 1, makeEx(TESIntPtVariables::LOADING));
     add2nd("reaction_damping_factor", 1,
-           makeEx(TESIntPtVariables::REACTION_DAMPING_FACTOR));
+           makeEx(TESIntPtVariables::REACTION_DAMPING_FACTOR));*/
 
     namespace PH = std::placeholders;
     using Self = TESProcess;
diff --git a/ProcessLib/TES/TESProcess.h b/ProcessLib/TES/TESProcess.h
index 987f84be056..3f670b68db0 100644
--- a/ProcessLib/TES/TESProcess.h
+++ b/ProcessLib/TES/TESProcess.h
@@ -53,10 +53,9 @@ public:
     bool isLinear() const override { return false; }
 private:
     using ExtrapolatorInterface =
-        NumLib::Extrapolator<TESIntPtVariables, TESLocalAssemblerInterface>;
+        NumLib::Extrapolator;
     using ExtrapolatorImplementation =
-        NumLib::LocalLinearLeastSquaresExtrapolator<
-            TESIntPtVariables, TESLocalAssemblerInterface>;
+        NumLib::LocalLinearLeastSquaresExtrapolator;
 
     void initializeConcreteProcess(
         NumLib::LocalToGlobalIndexMap const& dof_table,
-- 
GitLab