From 9d547b64eeb94c24b7f605797d41deacb008f05c Mon Sep 17 00:00:00 2001
From: Christoph Lehmann <christoph.lehmann@ufz.de>
Date: Tue, 26 Jul 2022 14:30:20 +0200
Subject: [PATCH] [PL] Moved setIPDataInitialConditions()

---
 .../LocalAssemblerInterface.h                 | 69 ++++++++++++++++++-
 .../ThermoRichardsMechanicsFEM-impl.h         | 66 ------------------
 .../ThermoRichardsMechanicsFEM.h              |  6 --
 3 files changed, 66 insertions(+), 75 deletions(-)

diff --git a/ProcessLib/ThermoRichardsMechanics/LocalAssemblerInterface.h b/ProcessLib/ThermoRichardsMechanics/LocalAssemblerInterface.h
index 411dae3241a..95fc8994c39 100644
--- a/ProcessLib/ThermoRichardsMechanics/LocalAssemblerInterface.h
+++ b/ProcessLib/ThermoRichardsMechanics/LocalAssemblerInterface.h
@@ -17,6 +17,7 @@
 #include "ProcessLib/LocalAssemblerInterface.h"
 #include "ProcessLib/ThermoRichardsMechanics/ConstitutiveSetting.h"
 #include "ProcessLib/ThermoRichardsMechanics/ThermoRichardsMechanicsProcessData.h"
+#include "ProcessLib/Utils/SetOrGetIntegrationPointData.h"
 
 namespace ProcessLib::ThermoRichardsMechanics
 {
@@ -51,9 +52,71 @@ struct LocalAssemblerInterface : public ProcessLib::LocalAssemblerInterface,
         }
     }
 
-    virtual std::size_t setIPDataInitialConditions(
-        std::string const& name, double const* values,
-        int const integration_order) = 0;
+    std::size_t setIPDataInitialConditions(std::string const& name,
+                                           double const* values,
+                                           int const integration_order)
+    {
+        if (integration_order !=
+            static_cast<int>(this->integration_method_.getIntegrationOrder()))
+        {
+            OGS_FATAL(
+                "Setting integration point initial conditions; The integration "
+                "order of the local assembler for element {:d} is different "
+                "from the integration order in the initial condition.",
+                this->element_.getID());
+        }
+
+        if (name == "sigma_ip")
+        {
+            if (this->process_data_.initial_stress != nullptr)
+            {
+                OGS_FATAL(
+                    "Setting initial conditions for stress from integration "
+                    "point data and from a parameter '{:s}' is not possible "
+                    "simultaneously.",
+                    this->process_data_.initial_stress->name);
+            }
+            return ProcessLib::setIntegrationPointKelvinVectorData<
+                DisplacementDim>(values, this->current_states_,
+                                 [](auto const& cs)
+                                 { return cs.s_mech_data.sigma_eff; });
+        }
+
+        if (name == "saturation_ip")
+        {
+            return ProcessLib::setIntegrationPointScalarData(
+                values, this->current_states_,
+                [](auto& state) -> auto& { return state.S_L_data.S_L; });
+        }
+        if (name == "porosity_ip")
+        {
+            return ProcessLib::setIntegrationPointScalarData(
+                values, this->current_states_,
+                [](auto& state) -> auto& { return state.poro_data.phi; });
+        }
+        if (name == "transport_porosity_ip")
+        {
+            return ProcessLib::setIntegrationPointScalarData(
+                values, this->current_states_, [](auto& state) -> auto& {
+                    return state.transport_poro_data.phi;
+                });
+        }
+        if (name == "swelling_stress_ip")
+        {
+            return ProcessLib::setIntegrationPointKelvinVectorData<
+                DisplacementDim>(values, this->current_states_,
+                                 [](auto const& cs)
+                                 { return cs.swelling_data.sigma_sw; });
+        }
+        if (name == "epsilon_ip")
+        {
+            return ProcessLib::setIntegrationPointKelvinVectorData<
+                DisplacementDim>(values, this->current_states_,
+                                 [](auto const& cs)
+                                 { return cs.eps_data.eps; });
+        }
+        return 0;
+    }
 
     virtual std::vector<double> getSigma() const = 0;
 
diff --git a/ProcessLib/ThermoRichardsMechanics/ThermoRichardsMechanicsFEM-impl.h b/ProcessLib/ThermoRichardsMechanics/ThermoRichardsMechanicsFEM-impl.h
index d3335c9f90b..c2bcedfe026 100644
--- a/ProcessLib/ThermoRichardsMechanics/ThermoRichardsMechanicsFEM-impl.h
+++ b/ProcessLib/ThermoRichardsMechanics/ThermoRichardsMechanicsFEM-impl.h
@@ -121,72 +121,6 @@ ThermoRichardsMechanicsLocalAssembler<ShapeFunctionDisplacement, ShapeFunction,
     }
 }
 
-template <typename ShapeFunctionDisplacement, typename ShapeFunction,
-          int DisplacementDim>
-std::size_t ThermoRichardsMechanicsLocalAssembler<
-    ShapeFunctionDisplacement, ShapeFunction,
-    DisplacementDim>::setIPDataInitialConditions(std::string const& name,
-                                                 double const* values,
-                                                 int const integration_order)
-{
-    if (integration_order !=
-        static_cast<int>(this->integration_method_.getIntegrationOrder()))
-    {
-        OGS_FATAL(
-            "Setting integration point initial conditions; The integration "
-            "order of the local assembler for element {:d} is different "
-            "from the integration order in the initial condition.",
-            this->element_.getID());
-    }
-
-    if (name == "sigma_ip")
-    {
-        if (this->process_data_.initial_stress != nullptr)
-        {
-            OGS_FATAL(
-                "Setting initial conditions for stress from integration "
-                "point data and from a parameter '{:s}' is not possible "
-                "simultaneously.",
-                this->process_data_.initial_stress->name);
-        }
-        return ProcessLib::setIntegrationPointKelvinVectorData<DisplacementDim>(
-            values, this->current_states_,
-            [](auto const& cs) { return cs.s_mech_data.sigma_eff; });
-    }
-
-    if (name == "saturation_ip")
-    {
-        return ProcessLib::setIntegrationPointScalarData(
-            values, this->current_states_,
-            [](auto& state) -> auto& { return state.S_L_data.S_L; });
-    }
-    if (name == "porosity_ip")
-    {
-        return ProcessLib::setIntegrationPointScalarData(
-            values, this->current_states_,
-            [](auto& state) -> auto& { return state.poro_data.phi; });
-    }
-    if (name == "transport_porosity_ip")
-    {
-        return ProcessLib::setIntegrationPointScalarData(
-            values, this->current_states_,
-            [](auto& state) -> auto& { return state.transport_poro_data.phi; });
-    }
-    if (name == "swelling_stress_ip")
-    {
-        return ProcessLib::setIntegrationPointKelvinVectorData<DisplacementDim>(
-            values, this->current_states_,
-            [](auto const& cs) { return cs.swelling_data.sigma_sw; });
-    }
-    if (name == "epsilon_ip")
-    {
-        return ProcessLib::setIntegrationPointKelvinVectorData<DisplacementDim>(
-            values, this->current_states_,
-            [](auto const& cs) { return cs.eps_data.eps; });
-    }
-    return 0;
-}
-
 template <typename ShapeFunctionDisplacement, typename ShapeFunction,
           int DisplacementDim>
 void ThermoRichardsMechanicsLocalAssembler<ShapeFunctionDisplacement,
diff --git a/ProcessLib/ThermoRichardsMechanics/ThermoRichardsMechanicsFEM.h b/ProcessLib/ThermoRichardsMechanics/ThermoRichardsMechanicsFEM.h
index 0010418cf63..b4fb4dd4ae6 100644
--- a/ProcessLib/ThermoRichardsMechanics/ThermoRichardsMechanicsFEM.h
+++ b/ProcessLib/ThermoRichardsMechanics/ThermoRichardsMechanicsFEM.h
@@ -87,12 +87,6 @@ public:
         bool const is_axially_symmetric,
         ThermoRichardsMechanicsProcessData<DisplacementDim>& process_data);
 
-    /// \return the number of read integration points.
-    std::size_t setIPDataInitialConditions(
-        std::string const& name,
-        double const* values,
-        int const integration_order) override;
-
     void setInitialConditionsConcrete(std::vector<double> const& local_x,
                                       double const t,
                                       bool const use_monolithic_scheme,
-- 
GitLab