From 559e930c8e95c2caa4cf3b4c42c9bb943b9efef3 Mon Sep 17 00:00:00 2001
From: Dmitri Naumov <github@naumov.de>
Date: Wed, 6 Apr 2022 17:43:07 +0200
Subject: [PATCH] [PL/TH2M] Computation of elastic tangent stiffness

Same code as in TRM or RM.
---
 ProcessLib/TH2M/IntegrationPointData.h | 44 ++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/ProcessLib/TH2M/IntegrationPointData.h b/ProcessLib/TH2M/IntegrationPointData.h
index 85c00b68924..87e933cd6cb 100644
--- a/ProcessLib/TH2M/IntegrationPointData.h
+++ b/ProcessLib/TH2M/IntegrationPointData.h
@@ -202,6 +202,50 @@ struct IntegrationPointData final
         material_state_variables->pushBackState();
     }
 
+    MathLib::KelvinVector::KelvinMatrixType<DisplacementDim>
+    computeElasticTangentStiffness(
+        double const t, ParameterLib::SpatialPosition const& x_position,
+        double const dt, double const temperature_prev,
+        double const temperature)
+    {
+        namespace MPL = MaterialPropertyLib;
+
+        MPL::VariableArray variable_array;
+        MPL::VariableArray variable_array_prev;
+
+        auto const null_state = solid_material.createMaterialStateVariables();
+
+        using KV = MathLib::KelvinVector::KelvinVectorType<DisplacementDim>;
+
+        variable_array[static_cast<int>(MPL::Variable::stress)].emplace<KV>(
+            KV::Zero());
+        variable_array[static_cast<int>(MPL::Variable::mechanical_strain)]
+            .emplace<KV>(KV::Zero());
+        variable_array[static_cast<int>(MPL::Variable::temperature)]
+            .emplace<double>(temperature);
+
+        variable_array_prev[static_cast<int>(MPL::Variable::stress)]
+            .emplace<KV>(KV::Zero());
+        variable_array_prev[static_cast<int>(MPL::Variable::mechanical_strain)]
+            .emplace<KV>(KV::Zero());
+        variable_array_prev[static_cast<int>(MPL::Variable::temperature)]
+            .emplace<double>(temperature_prev);
+
+        auto&& solution =
+            solid_material.integrateStress(variable_array_prev, variable_array,
+                                           t, x_position, dt, *null_state);
+
+        if (!solution)
+        {
+            OGS_FATAL("Computation of elastic tangent stiffness failed.");
+        }
+
+        MathLib::KelvinVector::KelvinMatrixType<DisplacementDim> C =
+            std::move(std::get<2>(*solution));
+
+        return C;
+    }
+
     typename BMatricesType::KelvinMatrixType updateConstitutiveRelation(
         MaterialPropertyLib::VariableArray& variable_array,
         double const t,
-- 
GitLab