From e70228a582ebfe9541c31a96a2b8ca6b37115497 Mon Sep 17 00:00:00 2001
From: Wenqing Wang <wenqing.wang@ufz.de>
Date: Tue, 10 Oct 2017 17:53:02 +0200
Subject: [PATCH] Added a boolean member to class Process to distinguish the
 monolithic scheme and the staggered scheme

---
 ProcessLib/Process.cpp                    | 19 +++++++++++++++----
 ProcessLib/Process.h                      | 14 ++++++++++----
 ProcessLib/UncoupledProcessesTimeLoop.cpp | 22 +++++++++++++++++++---
 3 files changed, 44 insertions(+), 11 deletions(-)

diff --git a/ProcessLib/Process.cpp b/ProcessLib/Process.cpp
index 119e9063dd9..0a4a85f36b7 100644
--- a/ProcessLib/Process.cpp
+++ b/ProcessLib/Process.cpp
@@ -31,7 +31,8 @@ Process::Process(
       _secondary_variables(std::move(secondary_variables)),
       _named_function_caller(std::move(named_function_caller)),
       _global_assembler(std::move(jacobian_assembler)),
-      _coupled_solutions(nullptr),
+      _is_monolithic_scheme(true),
+      _coupling_term(nullptr),
       _integration_order(integration_order),
       _process_variables(std::move(process_variables)),
       _boundary_conditions(parameters)
@@ -188,9 +189,19 @@ void Process::constructDofTable()
 
     // Create a vector of the number of variable components
     std::vector<int> vec_var_n_components;
-    for (ProcessVariable const& pv : _process_variables)
-        vec_var_n_components.push_back(pv.getNumberOfComponents());
-
+    if (_is_monolithic_scheme)
+    {
+        for (ProcessVariable const& pv : _process_variables)
+            vec_var_n_components.push_back(pv.getNumberOfComponents());
+    }
+    else  // for staggered scheme
+    {
+        // Assuming that all equations of the coupled process use the same
+        // element order. Other cases can be considered by overloading this
+        // member function in the derived class.
+        vec_var_n_components.push_back(
+            _process_variables[0].get().getNumberOfComponents());
+    }
     _local_to_global_index_map =
         std::make_unique<NumLib::LocalToGlobalIndexMap>(
             std::move(all_mesh_subsets), vec_var_n_components,
diff --git a/ProcessLib/Process.h b/ProcessLib/Process.h
index ef2ef4d1b09..4f35961f0cc 100644
--- a/ProcessLib/Process.h
+++ b/ProcessLib/Process.h
@@ -77,9 +77,9 @@ public:
         _coupled_solutions = coupled_solutions;
     }
 
-    void preAssemble(const double t, GlobalVector const& x) override final;
 
     virtual void setCoupledSolutionsForStaggeredSchemeToLocalAssemblers() {}
+    void preAssemble(const double t, GlobalVector const& x) override final;
     void assemble(const double t, GlobalVector const& x, GlobalMatrix& M,
                   GlobalMatrix& K, GlobalVector& b) final;
 
@@ -89,6 +89,11 @@ public:
                               GlobalMatrix& K, GlobalVector& b,
                               GlobalMatrix& Jac) final;
 
+    void setDecouplingSchemeType(const bool is_monolithic_scheme)
+    {
+        _is_monolithic_scheme = is_monolithic_scheme;
+    }
+
     std::vector<NumLib::IndexValueVector<GlobalIndexType>> const*
     getKnownSolutions(double const t) const final
     {
@@ -211,10 +216,11 @@ protected:
 
     VectorMatrixAssembler _global_assembler;
 
+    mutable bool _is_monolithic_scheme;
+
     /// Pointer to CoupledSolutionsForStaggeredScheme, which contains the
-    /// references to the
-    /// coupled processes and the references to the solutions of the coupled
-    /// processes.
+    /// references to the coupled processes and the references to the
+    /// solutions of the coupled processes.
     CoupledSolutionsForStaggeredScheme* _coupled_solutions;
 
     /// Order of the integration method for element-wise integration.
diff --git a/ProcessLib/UncoupledProcessesTimeLoop.cpp b/ProcessLib/UncoupledProcessesTimeLoop.cpp
index b2e6a015c2e..b9d45047765 100644
--- a/ProcessLib/UncoupledProcessesTimeLoop.cpp
+++ b/ProcessLib/UncoupledProcessesTimeLoop.cpp
@@ -336,9 +336,25 @@ std::vector<std::unique_ptr<SingleProcessData>> createPerProcessData(
     }
 
     if (per_process_data.size() != processes.size())
-        OGS_FATAL(
-            "Some processes have not been configured to be solved by this time "
-            "time loop.");
+    {
+        if (processes.size() > 1)
+        {
+            OGS_FATAL(
+                "Some processes have not been configured to be solved by this "
+                " time loop.");
+        }
+        else
+        {
+            const bool _is_monolithic_scheme = false;
+            for (auto const& process : processes)
+            {
+                process.second->setDecouplingSchemeType(_is_monolithic_scheme);
+            }
+            INFO(
+                "The equations of the coupled processes will be solved by the "
+                "staggered scheme.")
+        }
+    }
 
     return per_process_data;
 }
-- 
GitLab