From 5b3ec5bed5d1567477b69161b4df5399506f4724 Mon Sep 17 00:00:00 2001 From: Kilian Weishaupt <kilian.weishaupt@iws.uni-stuttgart.de> Date: Fri, 19 Jan 2018 13:13:42 +0100 Subject: [PATCH] [staggerednewtoncontroller] Make check for matrix subblock sizes generic --- dumux/nonlinear/staggerednewtoncontroller.hh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/dumux/nonlinear/staggerednewtoncontroller.hh b/dumux/nonlinear/staggerednewtoncontroller.hh index f1bc8f0789..d7cf5919c8 100644 --- a/dumux/nonlinear/staggerednewtoncontroller.hh +++ b/dumux/nonlinear/staggerednewtoncontroller.hh @@ -268,6 +268,26 @@ private: return converged; } + //! helper method to assure the MultiType matrix's sub blocks have the correct sizes + template<class JacobianMatrix> + bool checkMatrix_(const JacobianMatrix& A) + { + bool matrixHasCorrectSize = true; + using namespace Dune::Hybrid; + using namespace Dune::Indices; + forEach(A, [&matrixHasCorrectSize](const auto& rowOfMultiTypeMatrix) + { + const auto numRowsLeftMostBlock = rowOfMultiTypeMatrix[_0].N(); + + forEach(rowOfMultiTypeMatrix, [&matrixHasCorrectSize, &numRowsLeftMostBlock](const auto& subBlock) + { + if (subBlock.N() != numRowsLeftMostBlock) + matrixHasCorrectSize = false; + }); + }); + return matrixHasCorrectSize; + } + }; } // end namespace Dumux -- GitLab