From 5ba965b89a8f66c2b232ca40bb8efb16f16fdbdb Mon Sep 17 00:00:00 2001
From: Dmitri Naumov <github@naumov.de>
Date: Wed, 5 May 2021 11:12:46 +0200
Subject: [PATCH] [PL/HM] Use initial stress for sigma_eff init.

---
 ProcessLib/HydroMechanics/HydroMechanicsFEM.h | 22 ++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/ProcessLib/HydroMechanics/HydroMechanicsFEM.h b/ProcessLib/HydroMechanics/HydroMechanicsFEM.h
index 6c8fe1b68ae..245f1acf03d 100644
--- a/ProcessLib/HydroMechanics/HydroMechanicsFEM.h
+++ b/ProcessLib/HydroMechanics/HydroMechanicsFEM.h
@@ -195,7 +195,27 @@ public:
 
         for (unsigned ip = 0; ip < n_integration_points; ip++)
         {
-            _ip_data[ip].pushBackState();
+            auto& ip_data = _ip_data[ip];
+
+            /// Set initial stress from parameter.
+            if (_process_data.initial_stress != nullptr)
+            {
+                ParameterLib::SpatialPosition const x_position{
+                    std::nullopt, _element.getID(), ip,
+                    MathLib::Point3d(NumLib::interpolateCoordinates<
+                                     ShapeFunctionDisplacement,
+                                     ShapeMatricesTypeDisplacement>(
+                        _element, ip_data.N_u))};
+
+                ip_data.sigma_eff =
+                    MathLib::KelvinVector::symmetricTensorToKelvinVector<
+                        DisplacementDim>((*_process_data.initial_stress)(
+                        std::numeric_limits<
+                            double>::quiet_NaN() /* time independent */,
+                        x_position));
+            }
+
+            ip_data.pushBackState();
         }
     }
 
-- 
GitLab