From ec87aeb87e4796232f7690cb819e88fbf9c4e079 Mon Sep 17 00:00:00 2001 From: Kilian Weishaupt Date: Wed, 14 Nov 2018 06:56:08 +0100 Subject: [PATCH 1/6] [tpfa] Add hasBoundaryScvf() to fvGeometry --- .../cellcentered/gridvolumevariables.hh | 37 +++++++++-------- .../tpfa/elementvolumevariables.hh | 41 ++++++++++--------- .../cellcentered/tpfa/fvelementgeometry.hh | 18 +++++++- .../cellcentered/tpfa/fvgridgeometry.hh | 8 ++++ 4 files changed, 67 insertions(+), 37 deletions(-) diff --git a/dumux/discretization/cellcentered/gridvolumevariables.hh b/dumux/discretization/cellcentered/gridvolumevariables.hh index b9b250ffd7..21ad3d9edb 100644 --- a/dumux/discretization/cellcentered/gridvolumevariables.hh +++ b/dumux/discretization/cellcentered/gridvolumevariables.hh @@ -80,25 +80,28 @@ public: volumeVariables_[scv.dofIndex()].update(elemSol, problem(), element, scv); } - // handle the boundary volume variables - for (auto&& scvf : scvfs(fvGeometry)) + if (fvGeometry.hasBoundaryScvf()) { - // if we are not on a boundary, skip the rest - if (!scvf.boundary()) - continue; - - // check if boundary is a pure dirichlet boundary - const auto bcTypes = problem().boundaryTypes(element, scvf); - if (bcTypes.hasOnlyDirichlet()) + // handle the boundary volume variables + for (auto&& scvf : scvfs(fvGeometry)) { - const auto insideScvIdx = scvf.insideScvIdx(); - const auto& insideScv = fvGeometry.scv(insideScvIdx); - const auto dirichletPriVars = elementSolution(problem().dirichlet(element, scvf)); - - volumeVariables_[scvf.outsideScvIdx()].update(dirichletPriVars, - problem(), - element, - insideScv); + // if we are not on a boundary, skip the rest + if (!scvf.boundary()) + continue; + + // check if boundary is a pure dirichlet boundary + const auto bcTypes = problem().boundaryTypes(element, scvf); + if (bcTypes.hasOnlyDirichlet()) + { + const auto insideScvIdx = scvf.insideScvIdx(); + const auto& insideScv = fvGeometry.scv(insideScvIdx); + const auto dirichletPriVars = elementSolution(problem().dirichlet(element, scvf)); + + volumeVariables_[scvf.outsideScvIdx()].update(dirichletPriVars, + problem(), + element, + insideScv); + } } } } diff --git a/dumux/discretization/cellcentered/tpfa/elementvolumevariables.hh b/dumux/discretization/cellcentered/tpfa/elementvolumevariables.hh index 9612e6c1ea..15f70efdbe 100644 --- a/dumux/discretization/cellcentered/tpfa/elementvolumevariables.hh +++ b/dumux/discretization/cellcentered/tpfa/elementvolumevariables.hh @@ -152,28 +152,31 @@ public: ++localIdx; } - // Update boundary volume variables - for (auto&& scvf : scvfs(fvGeometry)) + if (fvGeometry.hasBoundaryScvf()) { - // if we are not on a boundary, skip to the next scvf - if (!scvf.boundary()) + // Update boundary volume variables + for (auto&& scvf : scvfs(fvGeometry)) + { + // if we are not on a boundary, skip to the next scvf + if (!scvf.boundary()) continue; - // check if boundary is a pure dirichlet boundary - const auto bcTypes = problem.boundaryTypes(element, scvf); - if (bcTypes.hasOnlyDirichlet()) - { - const auto dirichletPriVars = elementSolution(problem.dirichlet(element, scvf)); - - volumeVariables_.resize(localIdx+1); - volVarIndices_.resize(localIdx+1); - volumeVariables_[localIdx].update(dirichletPriVars, - problem, - element, - scvI); - volVarIndices_[localIdx] = scvf.outsideScvIdx(); - ++localIdx; - } + // check if boundary is a pure dirichlet boundary + const auto bcTypes = problem.boundaryTypes(element, scvf); + if (bcTypes.hasOnlyDirichlet()) + { + const auto dirichletPriVars = elementSolution(problem.dirichlet(element, scvf)); + + volumeVariables_.resize(localIdx+1); + volVarIndices_.resize(localIdx+1); + volumeVariables_[localIdx].update(dirichletPriVars, + problem, + element, + scvI); + volVarIndices_[localIdx] = scvf.outsideScvIdx(); + ++localIdx; + } + } } //! Check if user added additional DOF dependencies, i.e. the residual of DOF globalI depends diff --git a/dumux/discretization/cellcentered/tpfa/fvelementgeometry.hh b/dumux/discretization/cellcentered/tpfa/fvelementgeometry.hh index c1e4b4388b..3ccaf0ef02 100644 --- a/dumux/discretization/cellcentered/tpfa/fvelementgeometry.hh +++ b/dumux/discretization/cellcentered/tpfa/fvelementgeometry.hh @@ -156,6 +156,10 @@ public: const FVGridGeometry& fvGridGeometry() const { return *fvGridGeometryPtr_; } + //! Returns whether one of the geometry's scvfs lies on a boundary + bool hasBoundaryScvf() const + { return fvGridGeometry().hasBoundaryScvf(scvIndices_[0]); } + private: const Element* elementPtr_; @@ -351,6 +355,10 @@ public: const FVGridGeometry& fvGridGeometry() const { return *fvGridGeometryPtr_; } + //! Returns whether one of the geometry's scvfs lies on a boundary + bool hasBoundaryScvf() const + { return hasBoundaryScvf_; } + private: IndexType findFlippedScvfIndex_(IndexType insideScvIdx, IndexType globalOutsideScvIdx) @@ -412,11 +420,15 @@ private: scvIndices.resize(scvfNeighborVolVarIndices.size() + 1); scvIndices[0] = eIdx; std::copy(scvfNeighborVolVarIndices.begin(), scvfNeighborVolVarIndices.end(), scvIndices.begin()+1); + + const bool onBoundary = intersection.boundary() && !intersection.neighbor(); + hasBoundaryScvf_ = (hasBoundaryScvf_ || onBoundary); + scvfs_.emplace_back(intersection, intersection.geometry(), scvFaceIndices[scvfCounter], scvIndices, - intersection.boundary() && !intersection.neighbor()); + onBoundary); scvfIndices_.emplace_back(scvFaceIndices[scvfCounter]); scvfCounter++; @@ -536,6 +548,8 @@ private: neighborScvs_.clear(); neighborScvfs_.clear(); flippedNeighborScvfIndices_.clear(); + + hasBoundaryScvf_ = false; } const Element* elementPtr_; //!< the element to which this fvgeometry is bound @@ -555,6 +569,8 @@ private: std::vector neighborScvfIndices_; std::vector neighborScvfs_; std::vector> flippedNeighborScvfIndices_; + + bool hasBoundaryScvf_ = false; }; } // end namespace Dumux diff --git a/dumux/discretization/cellcentered/tpfa/fvgridgeometry.hh b/dumux/discretization/cellcentered/tpfa/fvgridgeometry.hh index be19deafec..9d59a04246 100644 --- a/dumux/discretization/cellcentered/tpfa/fvgridgeometry.hh +++ b/dumux/discretization/cellcentered/tpfa/fvgridgeometry.hh @@ -172,6 +172,7 @@ public: scvs_.resize(numScvs); scvfs_.reserve(numScvf); scvfIndicesOfScv_.resize(numScvs); + hasBoundaryScvf_.resize(numScvs, false); // Build the scvs and scv faces IndexType scvfIdx = 0; @@ -254,6 +255,8 @@ public: ScvfGridIndexStorage({eIdx, this->gridView().size(0) + numBoundaryScvf_++}), true); scvfsIndexSet.push_back(scvfIdx++); + + hasBoundaryScvf_[eIdx] = true; } } @@ -314,6 +317,10 @@ public: const ConnectivityMap &connectivityMap() const { return connectivityMap_; } + //! Returns whether one of the geometry's scvfs lies on a boundary + bool hasBoundaryScvf(IndexType eIdx) const + { return hasBoundaryScvf_[eIdx]; } + private: // find the scvf that has insideScvIdx in its outsideScvIdx list and outsideScvIdx as its insideScvIdx IndexType findFlippedScvfIndex_(IndexType insideScvIdx, IndexType outsideScvIdx) @@ -338,6 +345,7 @@ private: std::vector scvfs_; std::vector> scvfIndicesOfScv_; IndexType numBoundaryScvf_; + std::vector hasBoundaryScvf_; //! needed for embedded surface and network grids (dim < dimWorld) std::vector> flipScvfIndices_; -- GitLab From 4043100619bcfcd414fab3fcb9c24e0ac81c73a7 Mon Sep 17 00:00:00 2001 From: Kilian Weishaupt Date: Wed, 14 Nov 2018 06:56:34 +0100 Subject: [PATCH 2/6] [mpfa] Add hasBoundaryScvf() to fvGeometry --- .../mpfa/elementvolumevariables.hh | 43 ++++++++++--------- .../cellcentered/mpfa/fvelementgeometry.hh | 14 ++++++ .../cellcentered/mpfa/fvgridgeometry.hh | 9 ++++ 3 files changed, 46 insertions(+), 20 deletions(-) diff --git a/dumux/discretization/cellcentered/mpfa/elementvolumevariables.hh b/dumux/discretization/cellcentered/mpfa/elementvolumevariables.hh index 926db5889c..675980bf32 100644 --- a/dumux/discretization/cellcentered/mpfa/elementvolumevariables.hh +++ b/dumux/discretization/cellcentered/mpfa/elementvolumevariables.hh @@ -163,28 +163,31 @@ public: volumeVariables_.reserve(numVolVars+maxNumBoundaryVolVars); volVarIndices_.reserve(numVolVars+maxNumBoundaryVolVars); - // treat the BCs inside the element - for (const auto& scvf : scvfs(fvGeometry)) + if (fvGeometry.hasBoundaryScvf()) { - // if we are not on a boundary, skip to the next scvf - if (!scvf.boundary()) - continue; - - const auto bcTypes = problem.boundaryTypes(element, scvf); - - // Only proceed on dirichlet boundaries. Fluxes across Neumann - // boundaries are never computed - the user-defined flux is taken. - if (bcTypes.hasOnlyDirichlet()) + // treat the BCs inside the element + for (const auto& scvf : scvfs(fvGeometry)) { - // boundary volume variables - VolumeVariables dirichletVolVars; - dirichletVolVars.update(elementSolution(problem.dirichlet(element, scvf)), - problem, - element, - scvI); - - volumeVariables_.emplace_back(std::move(dirichletVolVars)); - volVarIndices_.push_back(scvf.outsideScvIdx()); + // if we are not on a boundary, skip to the next scvf + if (!scvf.boundary()) + continue; + + const auto bcTypes = problem.boundaryTypes(element, scvf); + + // Only proceed on dirichlet boundaries. Fluxes across Neumann + // boundaries are never computed - the user-defined flux is taken. + if (bcTypes.hasOnlyDirichlet()) + { + // boundary volume variables + VolumeVariables dirichletVolVars; + dirichletVolVars.update(elementSolution(problem.dirichlet(element, scvf)), + problem, + element, + scvI); + + volumeVariables_.emplace_back(std::move(dirichletVolVars)); + volVarIndices_.push_back(scvf.outsideScvIdx()); + } } } diff --git a/dumux/discretization/cellcentered/mpfa/fvelementgeometry.hh b/dumux/discretization/cellcentered/mpfa/fvelementgeometry.hh index 553f49de84..56f8c37e31 100644 --- a/dumux/discretization/cellcentered/mpfa/fvelementgeometry.hh +++ b/dumux/discretization/cellcentered/mpfa/fvelementgeometry.hh @@ -154,6 +154,10 @@ public: const FVGridGeometry& fvGridGeometry() const { return *fvGridGeometryPtr_; } + //! Returns whether one of the geometry's scvfs lies on a boundary + bool hasBoundaryScvf() const + { return fvGridGeometry().hasBoundaryScvf(scvIndices_[0]); } + private: std::array scvIndices_; @@ -309,6 +313,10 @@ public: const FVGridGeometry& fvGridGeometry() const { return *fvGridGeometryPtr_; } + //! Returns whether one of the geometry's scvfs lies on a boundary + bool hasBoundaryScvf() const + { return hasBoundaryScvf_; } + private: //! Computes the number of neighboring scvfs that have to be prepared @@ -386,6 +394,8 @@ private: if (fvGridGeometry().isGhostVertex(vIdxGlobal)) continue; + hasBoundaryScvf_ = (hasBoundaryScvf_ || is.boundary()); + scvfs_.emplace_back(MpfaHelper(), MpfaHelper::getScvfCorners(isPositions, numCorners, c), is.centerUnitOuterNormal(), @@ -514,6 +524,8 @@ private: neighborScvfIndices_.clear(); neighborScvs_.clear(); neighborScvfs_.clear(); + + hasBoundaryScvf_ = false; } const FVGridGeometry* fvGridGeometryPtr_; @@ -528,6 +540,8 @@ private: std::vector neighborScvfIndices_; std::vector neighborScvs_; std::vector neighborScvfs_; + + bool hasBoundaryScvf_ = false; }; } // end namespace diff --git a/dumux/discretization/cellcentered/mpfa/fvgridgeometry.hh b/dumux/discretization/cellcentered/mpfa/fvgridgeometry.hh index 21a157d483..a1f315aec6 100644 --- a/dumux/discretization/cellcentered/mpfa/fvgridgeometry.hh +++ b/dumux/discretization/cellcentered/mpfa/fvgridgeometry.hh @@ -188,6 +188,7 @@ public: scvs_.resize(numScvs); scvfs_.reserve(numScvf); scvfIndicesOfScv_.resize(numScvs); + hasBoundaryScvf_.resize(numScvs, false); // Some methods require to use a second type of interaction volume, e.g. // around vertices on the boundary or branching points (surface grids) @@ -236,6 +237,9 @@ public: const bool boundary = is.boundary(); const bool neighbor = is.neighbor(); + if (boundary) + hasBoundaryScvf_[eIdx] = true; + // for surface grids, skip the rest if handled already if (dim < dimWorld && neighbor && outsideIndices[indexInInside].empty()) continue; @@ -395,6 +399,10 @@ public: const SubControlVolumeFace& flipScvf(GridIndexType scvfIdx, unsigned int outsideScvfIdx = 0) const { return scvfs_[flipScvfIndices_[scvfIdx][outsideScvfIdx]]; } + //! Returns whether one of the geometry's scvfs lies on a boundary + bool hasBoundaryScvf(GridIndexType eIdx) const + { return hasBoundaryScvf_[eIdx]; } + private: // connectivity map for efficient assembly ConnectivityMap connectivityMap_; @@ -407,6 +415,7 @@ private: std::vector> scvfIndicesOfScv_; std::vector secondaryInteractionVolumeVertices_; GridIndexType numBoundaryScvf_; + std::vector hasBoundaryScvf_; // needed for embedded surface and network grids (dim < dimWorld) FlipScvfIndexSet flipScvfIndices_; -- GitLab From ed79f28279967f214e7fc94d4f4209c9c112d325 Mon Sep 17 00:00:00 2001 From: Kilian Weishaupt Date: Thu, 15 Nov 2018 10:50:54 +0100 Subject: [PATCH 3/6] [box] Add hasBoundaryScvf() to fvGeometry --- dumux/discretization/box/fvelementgeometry.hh | 12 ++++++++++++ dumux/discretization/box/fvgridgeometry.hh | 8 ++++++++ 2 files changed, 20 insertions(+) diff --git a/dumux/discretization/box/fvelementgeometry.hh b/dumux/discretization/box/fvelementgeometry.hh index 926ef8c9ff..3b06ab5230 100644 --- a/dumux/discretization/box/fvelementgeometry.hh +++ b/dumux/discretization/box/fvelementgeometry.hh @@ -148,6 +148,10 @@ public: const FVGridGeometry& fvGridGeometry() const { return *fvGridGeometryPtr_; } + //! Returns whether one of the geometry's scvfs lies on a boundary + bool hasBoundaryScvf() const + { return fvGridGeometry().hasBoundaryScvf(eIdx_); } + private: const Element* elementPtr_; const FVGridGeometry* fvGridGeometryPtr_; @@ -263,11 +267,16 @@ public: const FVGridGeometry& fvGridGeometry() const { return *fvGridGeometryPtr_; } + //! Returns whether one of the geometry's scvfs lies on a boundary + bool hasBoundaryScvf() const + { return hasBoundaryScvf_; } + private: void makeElementGeometries(const Element& element) { auto eIdx = fvGridGeometry().elementMapper().index(element); + hasBoundaryScvf_ = false; // get the element geometry auto elementGeometry = element.geometry(); @@ -316,6 +325,7 @@ private: if (intersection.boundary() && !intersection.neighbor()) { const auto isGeometry = intersection.geometry(); + hasBoundaryScvf_ = true; for (unsigned int isScvfLocalIdx = 0; isScvfLocalIdx < isGeometry.corners(); ++isScvfLocalIdx) { @@ -348,6 +358,8 @@ private: //! vectors to store the geometries locally after binding an element std::vector scvs_; std::vector scvfs_; + + bool hasBoundaryScvf_ = false; }; } // end namespace Dumux diff --git a/dumux/discretization/box/fvgridgeometry.hh b/dumux/discretization/box/fvgridgeometry.hh index 98ea2b78ec..b6d0a3b803 100644 --- a/dumux/discretization/box/fvgridgeometry.hh +++ b/dumux/discretization/box/fvgridgeometry.hh @@ -156,6 +156,7 @@ public: auto numElements = this->gridView().size(0); scvs_.resize(numElements); scvfs_.resize(numElements); + hasBoundaryScvf_.resize(numElements, false); boundaryDofIndices_.assign(numDofs(), false); @@ -215,6 +216,8 @@ public: if (intersection.boundary() && !intersection.neighbor()) { const auto isGeometry = intersection.geometry(); + hasBoundaryScvf_[eIdx] = true; + // count numScvf_ += isGeometry.corners(); numBoundaryScvf_ += isGeometry.corners(); @@ -317,6 +320,10 @@ public: const std::unordered_map& periodicVertexMap() const { return periodicVertexMap_; } + //! Returns whether one of the geometry's scvfs lies on a boundary + bool hasBoundaryScvf(std::size_t eIdx) const + { return hasBoundaryScvf_[eIdx]; } + private: const FeCache feCache_; @@ -330,6 +337,7 @@ private: // vertices on the boudary std::vector boundaryDofIndices_; + std::vector hasBoundaryScvf_; // a map for periodic boundary vertices std::unordered_map periodicVertexMap_; -- GitLab From c6873cc44cd427f20f7317a79d2e3f132d7c92cc Mon Sep 17 00:00:00 2001 From: Kilian Weishaupt Date: Thu, 15 Nov 2018 10:51:11 +0100 Subject: [PATCH 4/6] [staggeredFF] Add hasBoundaryScvf() to fvGeometry --- .../freeflow/elementvolumevariables.hh | 40 ++++++++++--------- .../staggered/fvelementgeometry.hh | 11 +++++ .../staggered/fvgridgeometry.hh | 8 ++++ 3 files changed, 41 insertions(+), 18 deletions(-) diff --git a/dumux/discretization/staggered/freeflow/elementvolumevariables.hh b/dumux/discretization/staggered/freeflow/elementvolumevariables.hh index 420b66fed7..70106b9fca 100644 --- a/dumux/discretization/staggered/freeflow/elementvolumevariables.hh +++ b/dumux/discretization/staggered/freeflow/elementvolumevariables.hh @@ -91,7 +91,8 @@ public: const SolutionVector& sol) { // the last parameter {} is needed for the PassKey pattern which restricts access to the ElementVolVars class - gridVolVars().updateBoundary_(element, fvGeometry, sol, {}); + if (fvGeometry.hasBoundaryScvf()) + gridVolVars().updateBoundary_(element, fvGeometry, sol, {}); } //! function to prepare the vol vars within the element @@ -181,24 +182,27 @@ public: ++localIdx; } - // Update boundary volume variables - for (auto&& scvf : scvfs(fvGeometry)) + if (fvGeometry.hasBoundaryScvf()) { - // if we are not on a boundary, skip to the next scvf - if (!scvf.boundary()) - continue; - - volumeVariables_.resize(localIdx+1); - volVarIndices_.resize(localIdx+1); - - auto boundaryPriVars = gridVolVars().getBoundaryPriVars(problem, sol, element, scvf); - auto elemSol = elementSolution(std::move(boundaryPriVars)); - volumeVariables_[localIdx].update(elemSol, - problem, - element, - scvI); - volVarIndices_[localIdx] = scvf.outsideScvIdx(); - ++localIdx; + // Update boundary volume variables + for (auto&& scvf : scvfs(fvGeometry)) + { + // if we are not on a boundary, skip to the next scvf + if (!scvf.boundary()) + continue; + + volumeVariables_.resize(localIdx+1); + volVarIndices_.resize(localIdx+1); + + auto boundaryPriVars = gridVolVars().getBoundaryPriVars(problem, sol, element, scvf); + auto elemSol = elementSolution(std::move(boundaryPriVars)); + volumeVariables_[localIdx].update(elemSol, + problem, + element, + scvI); + volVarIndices_[localIdx] = scvf.outsideScvIdx(); + ++localIdx; + } } } diff --git a/dumux/discretization/staggered/fvelementgeometry.hh b/dumux/discretization/staggered/fvelementgeometry.hh index 75d83d8ce3..e34dea10ff 100644 --- a/dumux/discretization/staggered/fvelementgeometry.hh +++ b/dumux/discretization/staggered/fvelementgeometry.hh @@ -208,6 +208,10 @@ public: const FVGridGeometry& fvGridGeometry() const { return *fvGridGeometryPtr_; } + //! Returns whether one of the geometry's scvfs lies on a boundary + bool hasBoundaryScvf() const + { return hasBoundaryScvf_; } + private: //! create scvs and scvfs of the bound element @@ -238,6 +242,9 @@ private: geometryHelper); scvfIndices_.emplace_back(scvFaceIndices[scvfCounter]); scvfCounter++; + + if (intersection.boundary()) + hasBoundaryScvf_ = true; } } } @@ -301,6 +308,8 @@ private: neighborScvfIndices_.clear(); neighborScvs_.clear(); neighborScvfs_.clear(); + + hasBoundaryScvf_ = false; } const Element* elementPtr_; //!< the element to which this fvgeometry is bound @@ -318,6 +327,8 @@ private: std::vector neighborScvfIndices_; std::vector neighborScvfs_; + + bool hasBoundaryScvf_ = false; }; diff --git a/dumux/discretization/staggered/fvgridgeometry.hh b/dumux/discretization/staggered/fvgridgeometry.hh index c22674ed6f..8535d30fd5 100644 --- a/dumux/discretization/staggered/fvgridgeometry.hh +++ b/dumux/discretization/staggered/fvgridgeometry.hh @@ -281,6 +281,7 @@ public: scvfs_.reserve(numScvf); scvfIndicesOfScv_.resize(numScvs); localToGlobalScvfIndices_.resize(numScvs); + hasBoundaryScvf_.resize(numScvs, false); // Build the scvs and scv faces IndexType scvfIdx = 0; @@ -328,6 +329,8 @@ public: geometryHelper); localToGlobalScvfIndices_[eIdx][localFaceIndex] = scvfIdx; scvfsIndexSet.push_back(scvfIdx++); + + hasBoundaryScvf_[eIdx] = true; } } @@ -398,6 +401,10 @@ public: return FaceFVGridGeometry(this); } + //! Returns whether one of the geometry's scvfs lies on a boundary + bool hasBoundaryScvf(IndexType eIdx) const + { return hasBoundaryScvf_[eIdx]; } + private: // mappers @@ -409,6 +416,7 @@ private: std::vector> scvfIndicesOfScv_; std::vector> localToGlobalScvfIndices_; IndexType numBoundaryScvf_; + std::vector hasBoundaryScvf_; }; /*! -- GitLab From 0200cdd23ab655f0a65e3f41cad996f7bf9bac2b Mon Sep 17 00:00:00 2001 From: Timo Koch Date: Sun, 18 Nov 2018 21:40:11 +0100 Subject: [PATCH 5/6] [tests] Add fvGeometry.hasBoundaryScvf() to the fvgeometry tests --- test/discretization/box/test_boxfvgeometry.cc | 11 ++++++++++- .../cellcentered/tpfa/test_tpfafvgeometry.cc | 11 ++++++++++- .../staggered/test_staggeredfvgeometry.cc | 11 ++++++++++- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/test/discretization/box/test_boxfvgeometry.cc b/test/discretization/box/test_boxfvgeometry.cc index 227191bc55..b2130b25da 100644 --- a/test/discretization/box/test_boxfvgeometry.cc +++ b/test/discretization/box/test_boxfvgeometry.cc @@ -98,12 +98,21 @@ int main (int argc, char *argv[]) try if(0 != testForwardIterator(range2.begin(), range2.end(), op2)) DUNE_THROW(Dune::Exception, "Iterator does not fulfill the forward iterator concept"); + std::size_t boundaryCount = 0; for (auto&& scvf : scvfs(fvGeometry)) { std::cout << "-- scvf " << scvf.index() << " ip at: " << scvf.ipGlobal() << " normal: " << scvf.unitOuterNormal(); - if (scvf.boundary()) std::cout << " (on boundary)."; + if (scvf.boundary()) + { + ++boundaryCount; + std::cout << " (on boundary)."; + } std::cout << std::endl; } + + if ((boundaryCount>0) != fvGeometry.hasBoundaryScvf()) + DUNE_THROW(Dune::InvalidStateException, "fvGeometry.hasBoundaryScvf() reports " << fvGeometry.hasBoundaryScvf() + << " but the number of boundary scvfs is " << boundaryCount); } } // ////////////////////////////////// diff --git a/test/discretization/cellcentered/tpfa/test_tpfafvgeometry.cc b/test/discretization/cellcentered/tpfa/test_tpfafvgeometry.cc index e7223e64bb..49d715f3ff 100644 --- a/test/discretization/cellcentered/tpfa/test_tpfafvgeometry.cc +++ b/test/discretization/cellcentered/tpfa/test_tpfafvgeometry.cc @@ -99,12 +99,21 @@ int main (int argc, char *argv[]) try if(0 != testForwardIterator(range2.begin(), range2.end(), op2)) DUNE_THROW(Dune::Exception, "Iterator does not fulfill the forward iterator concept"); + std::size_t boundaryCount = 0; for (auto&& scvf : scvfs(fvGeometry)) { std::cout << "-- scvf " << scvf.index() << " ip at: " << scvf.ipGlobal(); - if (scvf.boundary()) std::cout << " (on boundary)."; + if (scvf.boundary()) + { + ++boundaryCount; + std::cout << " (on boundary)."; + } std::cout << std::endl; } + + if ((boundaryCount>0) != fvGeometry.hasBoundaryScvf()) + DUNE_THROW(Dune::InvalidStateException, "fvGeometry.hasBoundaryScvf() reports " << fvGeometry.hasBoundaryScvf() + << " but the number of boundary scvfs is " << boundaryCount); } } // ////////////////////////////////// diff --git a/test/discretization/staggered/test_staggeredfvgeometry.cc b/test/discretization/staggered/test_staggeredfvgeometry.cc index d3d45349e8..130e0be2df 100644 --- a/test/discretization/staggered/test_staggeredfvgeometry.cc +++ b/test/discretization/staggered/test_staggeredfvgeometry.cc @@ -133,12 +133,21 @@ int main (int argc, char *argv[]) try if(0 != testForwardIterator(range2.begin(), range2.end(), op2)) DUNE_THROW(Dune::Exception, "Iterator does not fulfill the forward iterator concept"); + std::size_t boundaryCount = 0; for (auto&& scvf : scvfs(fvGeometry)) { std::cout << "-- scvf " << scvf.index() << " ip at: " << scvf.ipGlobal() << " normal: " << scvf.unitOuterNormal(); - if (scvf.boundary()) std::cout << " (on boundary)."; + if (scvf.boundary()) + { + ++boundaryCount; + std::cout << " (on boundary)."; + } std::cout << std::endl; } + + if ((boundaryCount>0) != fvGeometry.hasBoundaryScvf()) + DUNE_THROW(Dune::InvalidStateException, "fvGeometry.hasBoundaryScvf() reports " << fvGeometry.hasBoundaryScvf() + << " but the number of boundary scvfs is " << boundaryCount); } } // ////////////////////////////////// -- GitLab From 4e9569f9b29c97a9838d488b803ce94d60bc1368 Mon Sep 17 00:00:00 2001 From: Timo Koch Date: Sun, 18 Nov 2018 21:41:15 +0100 Subject: [PATCH 6/6] [labels][tests] Add discretization label --- test/discretization/box/CMakeLists.txt | 4 ++-- test/discretization/cellcentered/tpfa/CMakeLists.txt | 8 ++++---- test/discretization/staggered/CMakeLists.txt | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/discretization/box/CMakeLists.txt b/test/discretization/box/CMakeLists.txt index 5bbe00764e..3dc0efdbc2 100644 --- a/test/discretization/box/CMakeLists.txt +++ b/test/discretization/box/CMakeLists.txt @@ -1,12 +1,12 @@ dune_add_test(NAME test_boxfvgeometry SOURCES test_boxfvgeometry.cc COMPILE_DEFINITIONS ENABLE_CACHING=false - LABELS unit) + LABELS unit discretization) dune_add_test(NAME test_boxfvgeometry_caching SOURCES test_boxfvgeometry.cc COMPILE_DEFINITIONS ENABLE_CACHING=true - LABELS unit) + LABELS unit discretization) #install sources install(FILES diff --git a/test/discretization/cellcentered/tpfa/CMakeLists.txt b/test/discretization/cellcentered/tpfa/CMakeLists.txt index 813ea9e4e7..3acfe25990 100644 --- a/test/discretization/cellcentered/tpfa/CMakeLists.txt +++ b/test/discretization/cellcentered/tpfa/CMakeLists.txt @@ -1,21 +1,21 @@ dune_add_test(NAME test_tpfafvgeometry SOURCES test_tpfafvgeometry.cc COMPILE_DEFINITIONS ENABLE_CACHING=false - LABELS unit) + LABELS unit discretization) dune_add_test(NAME test_tpfafvgeometry_caching SOURCES test_tpfafvgeometry.cc COMPILE_DEFINITIONS ENABLE_CACHING=true - LABELS unit) + LABELS unit discretization) dune_add_test(NAME test_tpfafvgeometry_nonconforming SOURCES test_tpfafvgeometry_nonconforming.cc COMPILE_DEFINITIONS ENABLE_CACHING=false CMAKE_GUARD dune-alugrid_FOUND - LABELS unit) + LABELS unit discretization) dune_add_test(NAME test_cachedtpfafvgeometry_nonconforming SOURCES test_tpfafvgeometry_nonconforming.cc COMPILE_DEFINITIONS ENABLE_CACHING=true CMAKE_GUARD dune-alugrid_FOUND - LABELS unit) + LABELS unit discretization) diff --git a/test/discretization/staggered/CMakeLists.txt b/test/discretization/staggered/CMakeLists.txt index e5e3e4fcc9..cab4a791fd 100644 --- a/test/discretization/staggered/CMakeLists.txt +++ b/test/discretization/staggered/CMakeLists.txt @@ -1,10 +1,10 @@ dune_add_test(NAME test_staggeredfvgeometry SOURCES test_staggeredfvgeometry.cc - LABELS unit) + LABELS unit discretization) dune_add_test(NAME test_staggered_free_flow_geometry SOURCES test_staggered_free_flow_geometry.cc - LABELS unit) + LABELS unit discretization) #install sources install(FILES -- GitLab