From 0b8d7c149e7b4909809d2e30e83392e771a0820c Mon Sep 17 00:00:00 2001
From: Dmitri Naumov <github@naumov.de>
Date: Mon, 22 Mar 2021 16:44:22 +0100
Subject: [PATCH] [PL/DS] Use curve replacing time interval.

Creating the curve for time interval s.t. the whole material ids group
is deactivated, as it was for the time interval case.
---
 .../DeactivatedSubdomainDirichlet.cpp         | 11 ++++++----
 .../DeactivatedSubdomainDirichlet.h           |  6 ++---
 ProcessLib/DeactivatedSubdomain.cpp           | 22 ++++++++++++++-----
 ProcessLib/DeactivatedSubdomain.h             |  6 ++---
 ProcessLib/ProcessVariable.cpp                |  1 -
 5 files changed, 29 insertions(+), 17 deletions(-)

diff --git a/ProcessLib/BoundaryCondition/DeactivatedSubdomainDirichlet.cpp b/ProcessLib/BoundaryCondition/DeactivatedSubdomainDirichlet.cpp
index 3a6a0e20b23..1157f26d47e 100644
--- a/ProcessLib/BoundaryCondition/DeactivatedSubdomainDirichlet.cpp
+++ b/ProcessLib/BoundaryCondition/DeactivatedSubdomainDirichlet.cpp
@@ -6,10 +6,8 @@
  *              See accompanying file LICENSE.txt or
  *              http://www.opengeosys.org/project/license
  */
-
 #include "DeactivatedSubdomainDirichlet.h"
 
-#include "BaseLib/TimeInterval.h"
 #include "DirichletBoundaryCondition.h"
 #include "DirichletBoundaryConditionAuxiliaryFunctions.h"
 #include "NumLib/DOF/LocalToGlobalIndexMap.h"
@@ -21,7 +19,7 @@ namespace ProcessLib
 {
 DeactivatedSubdomainDirichlet::DeactivatedSubdomainDirichlet(
     std::vector<std::size_t> const* const active_element_ids,
-    BaseLib::TimeInterval const& time_interval,
+    MathLib::PiecewiseLinearInterpolation time_interval,
     ParameterLib::Parameter<double> const& parameter,
     DeactivatedSubdomainMesh const& subdomain,
     NumLib::LocalToGlobalIndexMap const& dof_table_bulk, int const variable_id,
@@ -75,7 +73,12 @@ void DeactivatedSubdomainDirichlet::getEssentialBCValues(
                      return std::all_of(begin(connected_elements),
                                         end(connected_elements), is_inactive);
                  });
-    if (_time_interval.contains(t))
+
+    auto time_interval_contains = [&](double const t) {
+        return _time_interval.getSupportMin() <= t &&
+               t <= _time_interval.getSupportMax();
+    };
+    if (time_interval_contains(t))
     {
         getEssentialBCValuesLocal(_parameter, *_subdomain.mesh,
                                   inactive_nodes_in_bc_mesh, *_dof_table_boundary,
diff --git a/ProcessLib/BoundaryCondition/DeactivatedSubdomainDirichlet.h b/ProcessLib/BoundaryCondition/DeactivatedSubdomainDirichlet.h
index cadfba543ad..bbdd987f0d5 100644
--- a/ProcessLib/BoundaryCondition/DeactivatedSubdomainDirichlet.h
+++ b/ProcessLib/BoundaryCondition/DeactivatedSubdomainDirichlet.h
@@ -11,8 +11,8 @@
 #include <memory>
 #include <vector>
 
-#include "BaseLib/TimeInterval.h"
 #include "BoundaryCondition.h"
+#include "MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.h"
 
 namespace BaseLib
 {
@@ -42,7 +42,7 @@ class DeactivatedSubdomainDirichlet final : public BoundaryCondition
 public:
     DeactivatedSubdomainDirichlet(
         std::vector<std::size_t> const* active_element_ids,
-        BaseLib::TimeInterval const& time_interval,
+        MathLib::PiecewiseLinearInterpolation time_interval,
         ParameterLib::Parameter<double> const& parameter,
         DeactivatedSubdomainMesh const& subdomain,
         NumLib::LocalToGlobalIndexMap const& dof_table_bulk,
@@ -64,7 +64,7 @@ private:
     int const _variable_id;
     int const _component_id;
 
-    BaseLib::TimeInterval const _time_interval;
+    MathLib::PiecewiseLinearInterpolation const _time_interval;
     std::vector<std::size_t> const* _active_element_ids = nullptr;
 };
 }  // namespace ProcessLib
diff --git a/ProcessLib/DeactivatedSubdomain.cpp b/ProcessLib/DeactivatedSubdomain.cpp
index 4aa7e563cec..3425d570da3 100644
--- a/ProcessLib/DeactivatedSubdomain.cpp
+++ b/ProcessLib/DeactivatedSubdomain.cpp
@@ -33,11 +33,11 @@ DeactivatedSubdomainMesh::DeactivatedSubdomainMesh(
 }
 
 DeactivatedSubdomain::DeactivatedSubdomain(
-    BaseLib::TimeInterval const& time_interval_,
+    MathLib::PiecewiseLinearInterpolation time_interval_,
     std::vector<int>&& materialIDs_,
     std::vector<std::unique_ptr<DeactivatedSubdomainMesh>>&&
         deactivated_subdomain_meshes_)
-    : time_interval(time_interval_),
+    : time_interval(std::move(time_interval_)),
       materialIDs(std::move(materialIDs_)),
       deactivated_subdomain_meshes(std::move(deactivated_subdomain_meshes_))
 {
@@ -45,7 +45,8 @@ DeactivatedSubdomain::DeactivatedSubdomain(
 
 bool DeactivatedSubdomain::includesTimeOf(double const t) const
 {
-    return time_interval.contains(t);
+    return time_interval.getSupportMin() <= t &&
+           t <= time_interval.getSupportMax();
 }
 
 template <typename IsActive>
@@ -112,8 +113,17 @@ std::unique_ptr<DeactivatedSubdomain const> createDeactivatedSubdomain(
     BaseLib::ConfigTree const& config, MeshLib::Mesh const& mesh)
 {
     //! \ogs_file_param{prj__process_variables__process_variable__deactivated_subdomains__deactivated_subdomain__time_interval}
-    config.peekConfigParameter<std::string>("time_interval");
-    auto time_interval = BaseLib::createTimeInterval(config);
+    auto const& time_interval_config = config.getConfigSubtree("time_interval");
+
+    auto const start_time =
+        //! \ogs_file_param{prj__process_variables__process_variable__deactivated_subdomains__deactivated_subdomain__time_interval__start}
+        time_interval_config.getConfigParameter<double>("start");
+
+    auto const end_time =
+        //! \ogs_file_param{prj__process_variables__process_variable__deactivated_subdomains__deactivated_subdomain__time_interval__end}
+        time_interval_config.getConfigParameter<double>("end");
+    MathLib::PiecewiseLinearInterpolation time_interval{
+        {start_time, end_time}, {1, 1}, false};
 
     auto deactivated_subdomain_material_ids =
         //! \ogs_file_param{prj__process_variables__process_variable__deactivated_subdomains__deactivated_subdomain__material_ids}
@@ -149,7 +159,7 @@ std::unique_ptr<DeactivatedSubdomain const> createDeactivatedSubdomain(
     }
 
     return std::make_unique<DeactivatedSubdomain const>(
-        time_interval,
+        std::move(time_interval),
         std::move(deactivated_subdomain_material_ids),
         std::move(deactivated_subdomain_meshes));
 }
diff --git a/ProcessLib/DeactivatedSubdomain.h b/ProcessLib/DeactivatedSubdomain.h
index a752bb44e12..3c043ad9f6c 100644
--- a/ProcessLib/DeactivatedSubdomain.h
+++ b/ProcessLib/DeactivatedSubdomain.h
@@ -17,7 +17,7 @@
 #include <string>
 #include <vector>
 
-#include "BaseLib/TimeInterval.h"
+#include "MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.h"
 
 namespace BaseLib
 {
@@ -45,14 +45,14 @@ struct DeactivatedSubdomainMesh
 struct DeactivatedSubdomain
 {
     DeactivatedSubdomain(
-        BaseLib::TimeInterval const& time_interval_,
+        MathLib::PiecewiseLinearInterpolation time_interval_,
         std::vector<int>&& materialIDs_,
         std::vector<std::unique_ptr<DeactivatedSubdomainMesh>>&&
             deactivated_subdomain_meshes_);
 
     bool includesTimeOf(double const t) const;
 
-    BaseLib::TimeInterval const time_interval;
+    MathLib::PiecewiseLinearInterpolation const time_interval;
 
     /// The material IDs of the deactivated the subdomains
     std::vector<int> const materialIDs;
diff --git a/ProcessLib/ProcessVariable.cpp b/ProcessLib/ProcessVariable.cpp
index 310d9937d4f..8bb2524353b 100644
--- a/ProcessLib/ProcessVariable.cpp
+++ b/ProcessLib/ProcessVariable.cpp
@@ -15,7 +15,6 @@
 
 #include "BaseLib/Algorithm.h"
 #include "BaseLib/Logging.h"
-#include "BaseLib/TimeInterval.h"
 #include "MeshGeoToolsLib/ConstructMeshesFromGeometries.h"
 #include "MeshLib/Mesh.h"
 #include "MeshLib/Node.h"
-- 
GitLab