From 4e51e8fff4870a0cac624be695164de3c943fa24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Thu, 13 Aug 2020 12:16:58 +0200 Subject: [PATCH] Avoid assembling ghost row off-diagonals. The diagonal element will still be assembled. --- .../discretization/common/fvbaselinearizer.hh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/opm/models/discretization/common/fvbaselinearizer.hh b/opm/models/discretization/common/fvbaselinearizer.hh index bb0c9ccfb5..a3af5fe9a3 100644 --- a/opm/models/discretization/common/fvbaselinearizer.hh +++ b/opm/models/discretization/common/fvbaselinearizer.hh @@ -349,10 +349,18 @@ private: for (unsigned primaryDofIdx = 0; primaryDofIdx < stencil.numPrimaryDof(); ++primaryDofIdx) { unsigned myIdx = stencil.globalSpaceIndex(primaryDofIdx); - for (unsigned dofIdx = 0; dofIdx < stencil.numDof(); ++dofIdx) { + if (dofIdx > 0 && stencil.element(dofIdx).partitionType() != Dune::PartitionType::InteriorEntity) { + // Skip non-diagonal elements on non-interior rows. + continue; + } unsigned neighborIdx = stencil.globalSpaceIndex(dofIdx); - sparsityPattern[myIdx].insert(neighborIdx); + // When the stencil is used later (in + // linearizeElement_(), via an element context) it + // assumes that the stencil is column-wise, + // i.e. the first index myIdx refers to the column + // number. + sparsityPattern[neighborIdx].insert(myIdx); } } } @@ -526,6 +534,10 @@ private: // update the global Jacobian matrix for (unsigned dofIdx = 0; dofIdx < elementCtx->numDof(/*timeIdx=*/0); ++ dofIdx) { + if (dofIdx > 0 && elementCtx->stencil(/*timeIdx=*/0).element(dofIdx).partitionType() != Dune::PartitionType::InteriorEntity) { + // Skip non-diagonal elements on non-interior rows. + continue; + } unsigned globJ = elementCtx->globalSpaceIndex(/*spaceIdx=*/dofIdx, /*timeIdx=*/0); jacobian_->addToBlock(globJ, globI, localLinearizer.jacobian(dofIdx, primaryDofIdx));