From 3b1362c1880f5440182428dee0cc63b34f5638e0 Mon Sep 17 00:00:00 2001
From: Dmitri Naumov <dmitri.naumov@ufz.de>
Date: Wed, 17 Jul 2024 11:23:33 +0200
Subject: [PATCH] [PL] Only asmJacobian is implemented for asmMixins

The Picard implementation would be slightly different
then the current assembleGeneric suggests anyway.

Simplifying the code, small cleanups.
---
 ProcessLib/AssemblyMixin.h | 55 ++++++++++++++------------------------
 1 file changed, 20 insertions(+), 35 deletions(-)

diff --git a/ProcessLib/AssemblyMixin.h b/ProcessLib/AssemblyMixin.h
index 2d00a31f7df..b082a5873ff 100644
--- a/ProcessLib/AssemblyMixin.h
+++ b/ProcessLib/AssemblyMixin.h
@@ -137,23 +137,22 @@ public:
     }
 
     // cppcheck-suppress functionStatic
-    void assemble(const double /*t*/, double const /*dt*/,
+    void assemble(double const t, double const dt,
                   std::vector<GlobalVector*> const& /*x*/,
                   std::vector<GlobalVector*> const& /*x_prev*/,
-                  int const /*process_id*/, GlobalMatrix& /*M*/,
+                  int const process_id, GlobalMatrix& /*M*/,
                   GlobalMatrix& /*K*/, GlobalVector& /*b*/)
     {
-        /*
         DBUG("AssemblyMixin assemble(t={}, dt={}, process_id={}).", t, dt,
              process_id);
 
-        assembleGeneric(&Assembly::ParallelVectorMatrixAssembler::assemble, t,
-        dt, x, x_prev, process_id, M, K, b);
-        */
-        OGS_FATAL("Not yet implemented.");
+        /// Implementation similar to assembleWithJacobian calling
+        /// Assembly::ParallelVectorMatrixAssembler::assemble function.
+        /// Residuum must be correctly computed.
+        OGS_FATAL("AssemblyMixin for Picard scheme is not yet implemented.");
     }
 
-    void assembleWithJacobian(const double t, double const dt,
+    void assembleWithJacobian(double const t, double const dt,
                               std::vector<GlobalVector*> const& x,
                               std::vector<GlobalVector*> const& x_prev,
                               int const process_id, GlobalMatrix& M,
@@ -163,27 +162,6 @@ public:
         DBUG("AssemblyMixin assembleWithJacobian(t={}, dt={}, process_id={}).",
              t, dt, process_id);
 
-        assembleGeneric(
-            &Assembly::ParallelVectorMatrixAssembler::assembleWithJacobian, t,
-            dt, x, x_prev, process_id, M, K, b, Jac);
-    }
-
-private:
-    Process& derived() { return static_cast<Process&>(*this); }
-    Process const& derived() const
-    {
-        return static_cast<Process const&>(*this);
-    }
-
-    /// Generic assembly routine covering both the case with and without
-    /// Jacobian assembly.
-    template <typename Method, typename... Jac>
-    void assembleGeneric(Method global_assembler_method, const double t,
-                         double const dt, std::vector<GlobalVector*> const& x,
-                         std::vector<GlobalVector*> const& x_prev,
-                         int const process_id, GlobalMatrix& M, GlobalMatrix& K,
-                         GlobalVector& b, Jac&... jac_or_not_jac)
-    {
         // TODO why not getDOFTables(x.size()); ?
         std::vector<NumLib::LocalToGlobalIndexMap const*> const dof_tables{
             derived()._local_to_global_index_map.get()};
@@ -199,9 +177,9 @@ private:
             {
                 b_submesh.setZero();
 
-                (pvma_.*global_assembler_method)(
-                    loc_asms, sad.active_element_ids, dof_tables, t, dt, x,
-                    x_prev, process_id, M, K, b_submesh, jac_or_not_jac...);
+                pvma_.assembleWithJacobian(loc_asms, sad.active_element_ids,
+                                           dof_tables, t, dt, x, x_prev,
+                                           process_id, M, K, b_submesh, Jac);
 
                 MathLib::LinAlg::axpy(b, 1.0, b_submesh);
 
@@ -218,14 +196,21 @@ private:
             ProcessLib::ProcessVariable const& pv =
                 derived().getProcessVariables(process_id)[0];
 
-            (pvma_.*global_assembler_method)(
-                loc_asms, pv.getActiveElementIDs(), dof_tables, t, dt, x,
-                x_prev, process_id, M, K, b, jac_or_not_jac...);
+            pvma_.assembleWithJacobian(loc_asms, pv.getActiveElementIDs(),
+                                       dof_tables, t, dt, x, x_prev, process_id,
+                                       M, K, b, Jac);
         }
 
         AssemblyMixinBase::copyResiduumVectorsToBulkMesh(
             b, *(dof_tables.front()), residuum_vectors_bulk_);
     }
+
+private:
+    Process& derived() { return static_cast<Process&>(*this); }
+    Process const& derived() const
+    {
+        return static_cast<Process const&>(*this);
+    }
 };
 
 }  // namespace ProcessLib
-- 
GitLab