From 56e8daffa3071f985078f68773c476c54450e32c Mon Sep 17 00:00:00 2001
From: Timo Koch <timo.koch@iws.uni-stuttgart.de>
Date: Mon, 27 Apr 2020 13:54:40 +0000
Subject: [PATCH] Merge branch 'fix/hybrid-depr-warn' into 'master'

Fix Dune::Hybrid deprecation warnings

Closes #872

See merge request dumux-repositories/dumux!2054

(cherry picked from commit 08fbf36221bf05f20d6645901b522364f09b518f)

91009518 [multidomain][fvassembler] Fix Dune::Hybrid deprecation warnings
48ad9e5c [linear][matrixconverter] Fix Dune::Hybrid deprecation warning
d296a126 [matrixconverter] Improve readability by using capture default
cefe45cd [matrixconverter] Remove unused includes
---
 dumux/linear/matrixconverter.hh  | 21 +++++++++++----------
 dumux/multidomain/fvassembler.hh |  8 ++++----
 2 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/dumux/linear/matrixconverter.hh b/dumux/linear/matrixconverter.hh
index 2d8e68d16a..a83ca5fa4b 100644
--- a/dumux/linear/matrixconverter.hh
+++ b/dumux/linear/matrixconverter.hh
@@ -25,13 +25,12 @@
 #define DUMUX_MATRIX_CONVERTER
 
 #include <cmath>
+#include <utility>
 #include <dune/common/indices.hh>
 #include <dune/common/hybridutilities.hh>
 #include <dune/istl/bvector.hh>
 #include <dune/istl/bcrsmatrix.hh>
 #include <dune/istl/matrixindexset.hh>
-#include <dune/istl/multitypeblockvector.hh>
-#include <dune/istl/multitypeblockmatrix.hh>
 
 #include <dumux/common/parameters.hh>
 
@@ -87,7 +86,7 @@ private:
         occupationPattern.resize(numRows, numRows);
 
         // lambda function to fill the occupation pattern
-        auto addIndices = [&occupationPattern](const auto& subMatrix, const std::size_t startRow, const std::size_t startCol)
+        auto addIndices = [&](const auto& subMatrix, const std::size_t startRow, const std::size_t startCol)
         {
             using std::abs;
             static const Scalar eps = getParam<Scalar>("MatrixConverter.DeletePatternEntriesBelowAbsThreshold", -1.0);
@@ -104,11 +103,12 @@ private:
         };
 
         // fill the pattern
+        using namespace Dune::Hybrid;
         std::size_t rowIndex = 0;
-        Dune::Hybrid::forEach(A, [&addIndices, &rowIndex, numRows](const auto& rowOfMultiTypeMatrix)
+        forEach(std::make_index_sequence<MultiTypeBlockMatrix::N()>(), [&A, &addIndices, &rowIndex, numRows](const auto i)
         {
             std::size_t colIndex = 0;
-            Dune::Hybrid::forEach(rowOfMultiTypeMatrix, [&addIndices, &colIndex, &rowIndex, numRows](const auto& subMatrix)
+            forEach(A[i], [&](const auto& subMatrix)
             {
                 addIndices(subMatrix, rowIndex, colIndex);
 
@@ -137,7 +137,7 @@ private:
         const auto numRows = M.N();
 
         // lambda function to copy the values
-        auto copyValues = [&M](const auto& subMatrix, const std::size_t startRow, const std::size_t startCol)
+        auto copyValues = [&](const auto& subMatrix, const std::size_t startRow, const std::size_t startCol)
         {
             using std::abs;
             static const Scalar eps = getParam<Scalar>("MatrixConverter.DeletePatternEntriesBelowAbsThreshold", -1.0);
@@ -154,11 +154,12 @@ private:
 
         };
 
+        using namespace Dune::Hybrid;
         std::size_t rowIndex = 0;
-        Dune::Hybrid::forEach(A, [&copyValues, &rowIndex, numRows](const auto& rowOfMultiTypeMatrix)
+        forEach(std::make_index_sequence<MultiTypeBlockMatrix::N()>(), [&A, &copyValues, &rowIndex, numRows](const auto i)
         {
             std::size_t colIndex = 0;
-            Dune::Hybrid::forEach(rowOfMultiTypeMatrix, [&copyValues, &colIndex, &rowIndex, numRows](const auto& subMatrix)
+            forEach(A[i], [&](const auto& subMatrix)
             {
                 copyValues(subMatrix, rowIndex, colIndex);
 
@@ -219,7 +220,7 @@ public:
         bTmp.resize(size);
 
         std::size_t startIndex = 0;
-        Dune::Hybrid::forEach(b, [&bTmp, &startIndex](const auto& subVector)
+        Dune::Hybrid::forEach(b, [&](const auto& subVector)
         {
             const auto numEq = std::decay_t<decltype(subVector)>::block_type::size();
 
@@ -242,7 +243,7 @@ public:
     static void retrieveValues(MultiTypeBlockVector& x, const BlockVector& y)
     {
         std::size_t startIndex = 0;
-        Dune::Hybrid::forEach(x, [&y, &startIndex](auto& subVector)
+        Dune::Hybrid::forEach(x, [&](auto& subVector)
         {
             const auto numEq = std::decay_t<decltype(subVector)>::block_type::size();
 
diff --git a/dumux/multidomain/fvassembler.hh b/dumux/multidomain/fvassembler.hh
index db59dce18f..22c4ef2acc 100644
--- a/dumux/multidomain/fvassembler.hh
+++ b/dumux/multidomain/fvassembler.hh
@@ -250,7 +250,7 @@ public:
         resetResidual_();
 
         using namespace Dune::Hybrid;
-        forEach(integralRange(Dune::Hybrid::size(*jacobian_)), [&](const auto domainId)
+        forEach(std::make_index_sequence<JacobianMatrix::N()>(), [&](const auto domainId)
         {
             auto& jacRow = (*jacobian_)[domainId];
             auto& subRes = (*residual_)[domainId];
@@ -331,9 +331,9 @@ public:
     void setJacobianBuildMode(JacobianMatrix& jac) const
     {
         using namespace Dune::Hybrid;
-        forEach(jac, [](auto& jacRow)
+        forEach(std::make_index_sequence<JacobianMatrix::N()>(), [&](const auto i)
         {
-            forEach(jacRow, [](auto& jacBlock)
+            forEach(jac[i], [&](auto& jacBlock)
             {
                 using BlockType = std::decay_t<decltype(jacBlock)>;
                 if (jacBlock.buildMode() == BlockType::BuildMode::unknown)
@@ -350,7 +350,7 @@ public:
     void setJacobianPattern(JacobianMatrix& jac) const
     {
         using namespace Dune::Hybrid;
-        forEach(integralRange(Dune::Hybrid::size(jac)), [&](const auto domainI)
+        forEach(std::make_index_sequence<JacobianMatrix::N()>(), [&](const auto domainI)
         {
             forEach(integralRange(Dune::Hybrid::size(jac[domainI])), [&](const auto domainJ)
             {
-- 
GitLab