From dc21214be848279ada7600c1db2f293bca63c09a Mon Sep 17 00:00:00 2001
From: DennisGlaeser <dennis.glaeser@iws.uni-stuttgart.de>
Date: Tue, 5 Jul 2016 12:06:59 +0200
Subject: [PATCH] [implicit][localjac] specialize updateGlobalJacobian routine
 to box or cc

---
 dumux/implicit/localjacobian.hh | 38 +++++++++++++++++++++++++++------
 1 file changed, 32 insertions(+), 6 deletions(-)

diff --git a/dumux/implicit/localjacobian.hh b/dumux/implicit/localjacobian.hh
index 537221f19b..bf7c6968c7 100644
--- a/dumux/implicit/localjacobian.hh
+++ b/dumux/implicit/localjacobian.hh
@@ -226,13 +226,15 @@ protected:
     /*!
      * \brief Updates the current global Jacobian matrix with the
      *        partial derivatives of all equations in regard to the
-     *        primary variable 'pvIdx' at dof 'col' .
+     *        primary variable 'pvIdx' at dof 'col'. Specialization for cc methods.
      */
-    void updateGlobalJacobian_(JacobianMatrix& matrix,
-                               const int globalI,
-                               const int globalJ,
-                               const int pvIdx,
-                               const PrimaryVariables &partialDeriv)
+    template<class T = TypeTag>
+    typename std::enable_if<!GET_PROP_VALUE(T, ImplicitIsBox)>::type
+    updateGlobalJacobian_(JacobianMatrix& matrix,
+                          const int globalI,
+                          const int globalJ,
+                          const int pvIdx,
+                          const PrimaryVariables &partialDeriv)
     {
         for (int eqIdx = 0; eqIdx < numEq; eqIdx++)
         {
@@ -245,6 +247,30 @@ protected:
         }
     }
 
+    /*!
+     * \brief Updates the current global Jacobian matrix with the
+     *        partial derivatives of all equations in regard to the
+     *        primary variable 'pvIdx' at dof 'col'. Specialization for the box method.
+     */
+    template<class T = TypeTag>
+    typename std::enable_if<GET_PROP_VALUE(T, ImplicitIsBox)>::type
+    updateGlobalJacobian_(JacobianMatrix& matrix,
+                          const int globalI,
+                          const int globalJ,
+                          const int pvIdx,
+                          const PrimaryVariables &partialDeriv)
+    {
+        for (int eqIdx = 0; eqIdx < numEq; eqIdx++)
+        {
+            // A[i][col][eqIdx][pvIdx] is the rate of change of
+            // the residual of equation 'eqIdx' at dof 'i'
+            // depending on the primary variable 'pvIdx' at dof
+            // 'col'.
+            matrix[globalI][globalJ][eqIdx][pvIdx] += partialDeriv[eqIdx];
+            Valgrind::CheckDefined(matrix[globalI][globalJ][eqIdx][pvIdx]);
+        }
+    }
+
     // The problem we would like to solve
     Problem *problemPtr_;
 
-- 
GitLab