From d0fcac06d6c4a9094100a2294bc6a99dd1cc6ab5 Mon Sep 17 00:00:00 2001 From: Kilian Weishaupt <kilian.weishaupt@iws.uni-stuttgart.de> Date: Sun, 5 Mar 2017 11:48:12 +0100 Subject: [PATCH] [mixeddimension] Use SFINAE for cell-center and box model assembler * TODO: correct box-versions of buildLowDimMatrixBlocks_ and buildBulkMatrixBlocks_ --- dumux/mixeddimension/assembler.hh | 114 ++++++++++++++---------------- 1 file changed, 54 insertions(+), 60 deletions(-) diff --git a/dumux/mixeddimension/assembler.hh b/dumux/mixeddimension/assembler.hh index 8c25ab1cbf..4271bb240b 100644 --- a/dumux/mixeddimension/assembler.hh +++ b/dumux/mixeddimension/assembler.hh @@ -182,7 +182,8 @@ protected: residual_[lowDimIdx]); } - void buildBulkMatrixBlocksCC_(BulkMatrixBlock& m, BulkCouplingMatrixBlock& cm) + template <class T = BulkProblemTypeTag, typename std::enable_if<((!GET_PROP_VALUE(T, ImplicitIsBox))), bool>::type = 0> + void buildBulkMatrixBlocks_(BulkMatrixBlock& m, BulkCouplingMatrixBlock& cm) { // get occupation pattern of the matrix Dune::MatrixIndexSet bulkPattern, bulkCouplingPattern; @@ -213,7 +214,8 @@ protected: bulkCouplingPattern.exportIdx(cm); } - void buildLowDimMatrixBlocksCC_(LowDimMatrixBlock& m, LowDimCouplingMatrixBlock& cm) + template <class T = LowDimProblemTypeTag, typename std::enable_if<((!GET_PROP_VALUE(T, ImplicitIsBox))), bool>::type = 0> + void buildLowDimMatrixBlocks_(LowDimMatrixBlock& m, LowDimCouplingMatrixBlock& cm) { // get occupation pattern of the matrix Dune::MatrixIndexSet lowDimPattern, lowDimCouplingPattern; @@ -244,63 +246,65 @@ protected: lowDimCouplingPattern.exportIdx(cm); } - // void buildBulkMatrixBlocksBox_(BulkMatrixBlock& m, BulkCouplingMatrixBlock& cm) - // { - // // get occupation pattern of the matrix - // Dune::MatrixIndexSet bulkPattern, bulkCouplingPattern; - // bulkPattern.resize(m.N(), m.M()); - // bulkCouplingPattern.resize(cm.N(), cm.M()); + template <class T = BulkProblemTypeTag, typename std::enable_if<((GET_PROP_VALUE(T, ImplicitIsBox))), bool>::type = 0> + void buildBulkMatrixBlocks_(BulkMatrixBlock& m, BulkCouplingMatrixBlock& cm) + { + // get occupation pattern of the matrix + Dune::MatrixIndexSet bulkPattern, bulkCouplingPattern; + bulkPattern.resize(m.N(), m.M()); + bulkCouplingPattern.resize(cm.N(), cm.M()); - // for (const auto& element : elements(problem_().bulkGridView())) - // { - // const auto& stencil = problem_().couplingManager().stencil(element); - // const auto& couplingStencil = problem_().couplingManager().couplingStencil(element); + for (const auto& element : elements(problem_().bulkGridView())) + { + const auto& stencil = problem_().couplingManager().stencil(element); + const auto& couplingStencil = problem_().couplingManager().couplingStencil(element); - // for (unsigned int scvIdx = 0; scvIdx < element.subEntities(bulkDim); ++scvIdx) - // { - // auto globalI = problem_().model().bulkVertexMapper().subIndex(element, scvIdx, bulkDim); + for (unsigned int scvIdx = 0; scvIdx < element.subEntities(bulkDim); ++scvIdx) + { + auto globalI = problem_().model().bulkVertexMapper().subIndex(element, scvIdx, bulkDim); - // for (auto&& globalJ : stencil) - // bulkPattern.add(globalI, globalJ); + for (auto&& globalJ : stencil) + bulkPattern.add(globalI, globalJ); - // for (auto&& globalJ : couplingStencil) - // bulkCouplingPattern.add(globalI, globalJ); - // } - // } + for (auto&& globalJ : couplingStencil) + bulkCouplingPattern.add(globalI, globalJ); + } + } - // // export occupation patterns to matrices - // bulkPattern.exportIdx(m); - // bulkCouplingPattern.exportIdx(cm); - // } + // export occupation patterns to matrices + bulkPattern.exportIdx(m); + bulkCouplingPattern.exportIdx(cm); + } - // void buildLowDimMatrixBlocksBox_(LowDimMatrixBlock& m, LowDimCouplingMatrixBlock& cm) - // { - // // get occupation pattern of the matrix - // Dune::MatrixIndexSet lowDimPattern, lowDimCouplingPattern; - // lowDimPattern.resize(m.N(), m.M()); - // lowDimCouplingPattern.resize(cm.N(), cm.M()); + template <class T = LowDimProblemTypeTag, typename std::enable_if<((GET_PROP_VALUE(T, ImplicitIsBox))), bool>::type = 0> + void buildLowDimMatrixBlocks_(LowDimMatrixBlock& m, LowDimCouplingMatrixBlock& cm) + { + // get occupation pattern of the matrix + Dune::MatrixIndexSet lowDimPattern, lowDimCouplingPattern; + lowDimPattern.resize(m.N(), m.M()); + lowDimCouplingPattern.resize(cm.N(), cm.M()); - // for (const auto& element : elements(problem_().lowDimGridView())) - // { - // const auto& stencil = problem_().couplingManager().stencil(element); - // const auto& couplingStencil = problem_().couplingManager().couplingStencil(element); + for (const auto& element : elements(problem_().lowDimGridView())) + { + const auto& stencil = problem_().couplingManager().stencil(element); + const auto& couplingStencil = problem_().couplingManager().couplingStencil(element); - // for (unsigned int scvIdx = 0; scvIdx < element.subEntities(lowDimDim); ++scvIdx) - // { - // auto globalI = problem_().model().lowDimVertexMapper().subIndex(element, scvIdx, lowDimDim); + for (unsigned int scvIdx = 0; scvIdx < element.subEntities(lowDimDim); ++scvIdx) + { + auto globalI = problem_().model().lowDimVertexMapper().subIndex(element, scvIdx, lowDimDim); - // for (auto&& globalJ : stencil) - // lowDimPattern.add(globalI, globalJ); + for (auto&& globalJ : stencil) + lowDimPattern.add(globalI, globalJ); - // for (auto&& globalJ : couplingStencil) - // lowDimCouplingPattern.add(globalI, globalJ); - // } - // } + for (auto&& globalJ : couplingStencil) + lowDimCouplingPattern.add(globalI, globalJ); + } + } - // // export occupation patterns to matrices - // lowDimPattern.exportIdx(m); - // lowDimCouplingPattern.exportIdx(cm); - // } + // export occupation patterns to matrices + lowDimPattern.exportIdx(m); + lowDimCouplingPattern.exportIdx(cm); + } // Construct the multitype matrix for the global jacobian void createMatrix_() @@ -318,18 +322,8 @@ protected: auto A22 = LowDimMatrixBlock(lowDimSize, lowDimSize, LowDimMatrixBlock::random); auto A21 = LowDimCouplingMatrixBlock(lowDimSize, bulkSize, LowDimCouplingMatrixBlock::random); - // cell-centered - if (!bulkIsBox) - buildBulkMatrixBlocksCC_(A11, A12); - else{ - // buildBulkMatrixBlocksBox_(A11, A12); - } - - if (!lowDimIsBox) - buildLowDimMatrixBlocksCC_(A22, A21); - else{ - // buildLowDimMatrixBlocksBox_(A22, A21); - } + buildBulkMatrixBlocks_(A11, A12); + buildLowDimMatrixBlocks_(A22, A21); (*matrix_)[bulkIdx][bulkIdx] = A11; (*matrix_)[bulkIdx][lowDimIdx] = A12; -- GitLab