From 370cfc0c712dc0c04b43c9977e051617b3a68187 Mon Sep 17 00:00:00 2001
From: Dmitri Naumov <github@naumov.de>
Date: Fri, 26 Mar 2021 16:22:27 +0100
Subject: [PATCH] [PL/DS] Parse and store boundary value parameter.

Allowing not only a zero value to be applied to the inactive
nodes but also heterogeneous, time-dependent values.
---
 .../t_boundary_parameter.md                   |  1 +
 ProcessLib/CreateDeactivatedSubdomain.cpp     | 20 +++++++++++++++++--
 ProcessLib/CreateDeactivatedSubdomain.h       |  6 ++++++
 ProcessLib/DeactivatedSubdomain.cpp           |  7 +++++--
 ProcessLib/DeactivatedSubdomain.h             | 13 +++++++++++-
 ProcessLib/ProcessVariable.cpp                |  2 +-
 6 files changed, 43 insertions(+), 6 deletions(-)
 create mode 100644 Documentation/ProjectFile/prj/process_variables/process_variable/deactivated_subdomains/deactivated_subdomain/t_boundary_parameter.md

diff --git a/Documentation/ProjectFile/prj/process_variables/process_variable/deactivated_subdomains/deactivated_subdomain/t_boundary_parameter.md b/Documentation/ProjectFile/prj/process_variables/process_variable/deactivated_subdomains/deactivated_subdomain/t_boundary_parameter.md
new file mode 100644
index 00000000000..8cd8c4cec7c
--- /dev/null
+++ b/Documentation/ProjectFile/prj/process_variables/process_variable/deactivated_subdomains/deactivated_subdomain/t_boundary_parameter.md
@@ -0,0 +1 @@
+\copydoc ProcessLib::DeactivatedSubdomain::boundary_value_parameter
diff --git a/ProcessLib/CreateDeactivatedSubdomain.cpp b/ProcessLib/CreateDeactivatedSubdomain.cpp
index 362a6fa41fe..602fbbb863f 100644
--- a/ProcessLib/CreateDeactivatedSubdomain.cpp
+++ b/ProcessLib/CreateDeactivatedSubdomain.cpp
@@ -17,6 +17,8 @@
 #include "MeshLib/Mesh.h"
 #include "MeshLib/MeshEditing/DuplicateMeshComponents.h"
 #include "MeshLib/Node.h"
+#include "ParameterLib/Parameter.h"
+#include "ParameterLib/Utils.h"
 
 namespace ProcessLib
 {
@@ -170,6 +172,7 @@ static std::pair<Eigen::Vector3d, Eigen::Vector3d> parseLineSegment(
 
 std::unique_ptr<DeactivatedSubdomain const> createDeactivatedSubdomain(
     BaseLib::ConfigTree const& config, MeshLib::Mesh const& mesh,
+    std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
     std::map<std::string,
              std::unique_ptr<MathLib::PiecewiseLinearInterpolation>> const&
         curves)
@@ -212,6 +215,17 @@ std::unique_ptr<DeactivatedSubdomain const> createDeactivatedSubdomain(
         line_segment = parseLineSegment(*line_segment_config);
     }
 
+    ParameterLib::Parameter<double>* boundary_value_parameter = nullptr;
+    auto boundary_value_parameter_name =
+        //! \ogs_file_param{prj__process_variables__process_variable__deactivated_subdomains__deactivated_subdomain__boundary_parameter}
+        config.getConfigParameterOptional<std::string>("boundary_parameter");
+    if (boundary_value_parameter_name)
+    {
+        DBUG("Using parameter {:s}", *boundary_value_parameter_name);
+        boundary_value_parameter = &ParameterLib::findParameter<double>(
+            *boundary_value_parameter_name, parameters, 1, &mesh);
+    }
+
     auto deactivated_subdomain_material_ids =
         //! \ogs_file_param{prj__process_variables__process_variable__deactivated_subdomains__deactivated_subdomain__material_ids}
         config.getConfigParameter("material_ids", std::vector<int>{});
@@ -250,13 +264,15 @@ std::unique_ptr<DeactivatedSubdomain const> createDeactivatedSubdomain(
         std::move(time_interval),
         line_segment,
         std::move(deactivated_subdomain_material_ids),
-        std::move(deactivated_subdomain_meshes));
+        std::move(deactivated_subdomain_meshes),
+        boundary_value_parameter);
 }
 
 std::vector<std::unique_ptr<DeactivatedSubdomain const>>
 createDeactivatedSubdomains(
     BaseLib::ConfigTree const& config,
     MeshLib::Mesh const& mesh,
+    std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
     std::map<std::string,
              std::unique_ptr<MathLib::PiecewiseLinearInterpolation>> const&
         curves)
@@ -277,7 +293,7 @@ createDeactivatedSubdomains(
             begin(deactivated_subdomain_configs),
             end(deactivated_subdomain_configs),
             back_inserter(deactivated_subdomains), [&](auto const& config) {
-                return createDeactivatedSubdomain(config, mesh, curves);
+                return createDeactivatedSubdomain(config, mesh, parameters, curves);
             });
     }
     return deactivated_subdomains;
diff --git a/ProcessLib/CreateDeactivatedSubdomain.h b/ProcessLib/CreateDeactivatedSubdomain.h
index 0769baadf7f..af34e746eed 100644
--- a/ProcessLib/CreateDeactivatedSubdomain.h
+++ b/ProcessLib/CreateDeactivatedSubdomain.h
@@ -30,6 +30,11 @@ class Mesh;
 class Node;
 }  // namespace MeshLib
 
+namespace ParameterLib
+{
+struct ParameterBase;
+}
+
 namespace ProcessLib
 {
 struct DeactivatedSubdomain;
@@ -40,6 +45,7 @@ std::vector<std::unique_ptr<DeactivatedSubdomain const>>
 createDeactivatedSubdomains(
     BaseLib::ConfigTree const& config,
     MeshLib::Mesh const& mesh,
+    std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters,
     std::map<std::string,
              std::unique_ptr<MathLib::PiecewiseLinearInterpolation>> const&
         curves);
diff --git a/ProcessLib/DeactivatedSubdomain.cpp b/ProcessLib/DeactivatedSubdomain.cpp
index 85a8438a3f1..8ddd1edfbd5 100644
--- a/ProcessLib/DeactivatedSubdomain.cpp
+++ b/ProcessLib/DeactivatedSubdomain.cpp
@@ -16,6 +16,7 @@
 #include "MeshLib/Elements/Element.h"
 #include "MeshLib/Mesh.h"
 #include "MeshLib/Node.h"
+#include "ParameterLib/Parameter.h"
 
 namespace ProcessLib
 {
@@ -38,11 +39,13 @@ DeactivatedSubdomain::DeactivatedSubdomain(
         line_segment,
     std::vector<int>&& materialIDs_,
     std::vector<std::unique_ptr<DeactivatedSubdomainMesh>>&&
-        deactivated_subdomain_meshes_)
+        deactivated_subdomain_meshes_,
+    ParameterLib::Parameter<double> const* const boundary_value_parameter)
     : time_interval(std::move(time_interval_)),
       line_segment(line_segment),
       materialIDs(std::move(materialIDs_)),
-      deactivated_subdomain_meshes(std::move(deactivated_subdomain_meshes_))
+      deactivated_subdomain_meshes(std::move(deactivated_subdomain_meshes_)),
+      boundary_value_parameter(boundary_value_parameter)
 {
 }
 
diff --git a/ProcessLib/DeactivatedSubdomain.h b/ProcessLib/DeactivatedSubdomain.h
index e7075ef8970..df1327167ba 100644
--- a/ProcessLib/DeactivatedSubdomain.h
+++ b/ProcessLib/DeactivatedSubdomain.h
@@ -26,6 +26,12 @@ class Mesh;
 class Node;
 }  // namespace MeshLib
 
+namespace ParameterLib
+{
+template <typename T>
+struct Parameter;
+}
+
 namespace ProcessLib
 {
 struct DeactivatedSubdomainMesh
@@ -67,7 +73,8 @@ struct DeactivatedSubdomain
             line_segment,
         std::vector<int>&& materialIDs_,
         std::vector<std::unique_ptr<DeactivatedSubdomainMesh>>&&
-            deactivated_subdomain_meshes_);
+            deactivated_subdomain_meshes_,
+        ParameterLib::Parameter<double> const* boundary_value_parameter);
 
     bool includesTimeOf(double const t) const;
 
@@ -89,6 +96,10 @@ struct DeactivatedSubdomain
     std::vector<std::unique_ptr<DeactivatedSubdomainMesh>> const
         deactivated_subdomain_meshes;
 
+    /// A pararameter for the optional Dirichlet boundary condition applied on
+    /// the surface of the deactivated subdomain/excavation.
+    ParameterLib::Parameter<double> const* const boundary_value_parameter;
+
     static const std::string zero_parameter_name;
 };
 }  // namespace ProcessLib
diff --git a/ProcessLib/ProcessVariable.cpp b/ProcessLib/ProcessVariable.cpp
index 34719e83133..7d48d033c84 100644
--- a/ProcessLib/ProcessVariable.cpp
+++ b/ProcessLib/ProcessVariable.cpp
@@ -105,7 +105,7 @@ ProcessVariable::ProcessVariable(
       //! \ogs_file_param{prj__process_variables__process_variable__order}
       _shapefunction_order(config.getConfigParameter<unsigned>("order")),
       _deactivated_subdomains(
-          createDeactivatedSubdomains(config, mesh, curves)),
+          createDeactivatedSubdomains(config, mesh, parameters, curves)),
       _initial_condition(ParameterLib::findParameter<double>(
           //! \ogs_file_param{prj__process_variables__process_variable__initial_condition}
           config.getConfigParameter<std::string>("initial_condition"),
-- 
GitLab