From f11974390bbabcade2a2be7a6203e959396925af Mon Sep 17 00:00:00 2001 From: Kilian Weishaupt <kilian.weishaupt@iws.uni-stuttgart.de> Date: Thu, 21 Dec 2017 10:24:50 +0100 Subject: [PATCH] [staggered] Move general assembly map to freeflow * calculate stencils directly in assembly map * remove stencils class and property --- .../{ => freeflow}/connectivitymap.hh | 99 +++++++++++-- .../staggered/freeflow/fluxstencil.hh | 135 ------------------ .../staggered/freeflow/properties.hh | 5 +- .../staggered/fvgridgeometry.hh | 3 +- dumux/discretization/staggered/properties.hh | 1 - .../staggered/test_staggeredfvgeometry.cc | 36 +---- 6 files changed, 95 insertions(+), 184 deletions(-) rename dumux/discretization/staggered/{ => freeflow}/connectivitymap.hh (56%) delete mode 100644 dumux/discretization/staggered/freeflow/fluxstencil.hh diff --git a/dumux/discretization/staggered/connectivitymap.hh b/dumux/discretization/staggered/freeflow/connectivitymap.hh similarity index 56% rename from dumux/discretization/staggered/connectivitymap.hh rename to dumux/discretization/staggered/freeflow/connectivitymap.hh index 5891359696..addeb6b8ca 100644 --- a/dumux/discretization/staggered/connectivitymap.hh +++ b/dumux/discretization/staggered/freeflow/connectivitymap.hh @@ -22,8 +22,8 @@ * that contribute to the derivative calculation. This is used for * finite-volume schemes with symmetric sparsity pattern in the global matrix. */ -#ifndef DUMUX_STAGGERED_CONNECTIVITY_MAP_HH -#define DUMUX_STAGGERED_CONNECTIVITY_MAP_HH +#ifndef DUMUX_STAGGERED_FREEFLOW_CONNECTIVITY_MAP_HH +#define DUMUX_STAGGERED_FREEFLOW_CONNECTIVITY_MAP_HH #include <vector> #include <dumux/common/properties.hh> @@ -31,13 +31,8 @@ namespace Dumux { -namespace Properties -{ - NEW_PROP_TAG(StaggeredFluxStencils); -} - template<class TypeTag> -class StaggeredConnectivityMap +class StaggeredFreeFlowConnectivityMap { using GridView = typename GET_PROP_TYPE(TypeTag, GridView); using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); @@ -60,7 +55,6 @@ class StaggeredConnectivityMap using FaceToFaceMap = std::vector<std::vector<IndexType>>; using Stencil = std::vector<IndexType>; - using FluxStencils = typename GET_PROP_TYPE(TypeTag, StaggeredFluxStencils); public: @@ -94,12 +88,12 @@ public: for (auto&& scvf : scvfs(fvGeometry)) { const auto dofIdxCellCenter = fvGridGeometry.elementMapper().index(element); - FluxStencils::computeCellCenterToCellCenterStencil(cellCenterToCellCenterMap_[dofIdxCellCenter], element, fvGeometry, scvf); - FluxStencils::computeCellCenterToFaceStencil(cellCenterToFaceMap_[dofIdxCellCenter], element, fvGeometry, scvf); + computeCellCenterToCellCenterStencil_(cellCenterToCellCenterMap_[dofIdxCellCenter], element, fvGeometry, scvf); + computeCellCenterToFaceStencil_(cellCenterToFaceMap_[dofIdxCellCenter], element, fvGeometry, scvf); const auto scvfIdx = scvf.index(); - FluxStencils::computeFaceToCellCenterStencil(faceToCellCenterMap_[scvfIdx], fvGeometry, scvf); - FluxStencils::computeFaceToFaceStencil(faceToFaceMap_[scvfIdx], fvGeometry, scvf); + computeFaceToCellCenterStencil_(faceToCellCenterMap_[scvfIdx], fvGeometry, scvf); + computeFaceToFaceStencil_(faceToFaceMap_[scvfIdx], fvGeometry, scvf); } } } @@ -126,6 +120,83 @@ public: private: + /* + * \brief Computes the stencil for cell center dofs w.r.t to other cell center dofs. + * Basically, these are the dof indices of the neighboring elements plus the dof index of the element itself. + */ + void computeCellCenterToCellCenterStencil_(Stencil& stencil, + const Element& element, + const FVElementGeometry& fvGeometry, + const SubControlVolumeFace& scvf) + { + // the first entry is always the cc dofIdx itself + if(stencil.empty()) + stencil.push_back(scvf.insideScvIdx()); + if(!scvf.boundary()) + stencil.push_back(scvf.outsideScvIdx()); + } + + /* + * \brief Computes the stencil for cell center dofs w.r.t to face dofs. + * Basically, these are the dof indices of the element's faces. + */ + void computeCellCenterToFaceStencil_(Stencil& stencil, + const Element& element, + const FVElementGeometry& fvGeometry, + const SubControlVolumeFace& scvf) + { + stencil.push_back(scvf.dofIndex()); + } + + /* + * \brief Computes the stencil for face dofs w.r.t to cell center dofs. + * Basically, these are the dof indices of the elements adjacent to the face and those of + * the elements adjacent to the faces parallel to the own face. + */ + void computeFaceToCellCenterStencil_(Stencil& stencil, + const FVElementGeometry& fvGeometry, + const SubControlVolumeFace& scvf) + { + const auto eIdx = scvf.insideScvIdx(); + stencil.push_back(scvf.insideScvIdx()); + + for(const auto& data : scvf.pairData()) + { + auto& normalFace = fvGeometry.scvf(eIdx, data.localNormalFaceIdx); + if(!normalFace.boundary()) + { + const auto outerParallelElementDofIdx = normalFace.outsideScvIdx(); + stencil.push_back(outerParallelElementDofIdx); + } + } + } + + /* + * \brief Computes the stencil for face dofs w.r.t to face dofs. + * For a full description of the stencil, please see the document under dumux/doc/docextra/staggered + */ + void computeFaceToFaceStencil_(Stencil& stencil, + const FVElementGeometry& fvGeometry, + const SubControlVolumeFace& scvf) + { + // the first entries are always the face dofIdx itself and the one of the opposing face + if(stencil.empty()) + { + stencil.push_back(scvf.dofIndex()); + stencil.push_back(scvf.dofIndexOpposingFace()); + } + + for(const auto& data : scvf.pairData()) + { + stencil.push_back(data.normalPair.first); + const auto outerParallelFaceDofIdx = data.outerParallelFaceDofIdx; + if(outerParallelFaceDofIdx >= 0) + stencil.push_back(outerParallelFaceDofIdx); + if(!scvf.boundary()) + stencil.push_back(data.normalPair.second); + } + } + CellCenterToCellCenterMap cellCenterToCellCenterMap_; CellCenterToFaceMap cellCenterToFaceMap_; FaceToCellCenterMap faceToCellCenterMap_; @@ -134,4 +205,4 @@ private: } // end namespace Dumux -#endif +#endif // DUMUX_STAGGERED_FREEFLOW_CONNECTIVITY_MAP_HH diff --git a/dumux/discretization/staggered/freeflow/fluxstencil.hh b/dumux/discretization/staggered/freeflow/fluxstencil.hh deleted file mode 100644 index 0d37f8e9f8..0000000000 --- a/dumux/discretization/staggered/freeflow/fluxstencil.hh +++ /dev/null @@ -1,135 +0,0 @@ -// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- -// vi: set et ts=4 sw=4 sts=4: -/***************************************************************************** - * See the file COPYING for full copying permissions. * - * * - * This program is free software: you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation, either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program. If not, see <http://www.gnu.org/licenses/>. * - *****************************************************************************/ -/*! - * \file - * \copydoc Dumux::StaggeredNavierStokesFluxStencils - */ -#ifndef DUMUX_STAGGERED_NAVIERSTOKES_FLUX_STENCIL_HH -#define DUMUX_STAGGERED_NAVIERSTOKES_FLUX_STENCIL_HH - -#include <vector> -#include <dumux/common/properties.hh> - -namespace Dumux -{ - -/*! - * \brief Computes the stencil for the Navier-Stokes specific staggered grid discretization. -* For a full description of the stencils, please see the document under dumux/doc/docextra/staggered - */ -template<class TypeTag> -class StaggeredNavierStokesFluxStencils -{ - using GridView = typename GET_PROP_TYPE(TypeTag, GridView); - using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); - using FVElementGeometry = typename GET_PROP_TYPE(TypeTag, FVElementGeometry); - using SubControlVolumeFace = typename GET_PROP_TYPE(TypeTag, SubControlVolumeFace); - - using Element = typename GridView::template Codim<0>::Entity; - using IndexType = typename GridView::IndexSet::IndexType; - - using DofTypeIndices = typename GET_PROP(TypeTag, DofTypeIndices); - typename DofTypeIndices::CellCenterIdx cellCenterIdx; - typename DofTypeIndices::FaceIdx faceIdx; - - using Stencil = std::vector<IndexType>; - -public: - - /* - * \brief Computes the stencil for cell center dofs w.r.t to other cell center dofs. - * Basically, these are the dof indices of the neighboring elements plus the dof index of the element itself. - */ - static void computeCellCenterToCellCenterStencil(Stencil& stencil, - const Element& element, - const FVElementGeometry& fvGeometry, - const SubControlVolumeFace& scvf) - { - // the first entry is always the cc dofIdx itself - if(stencil.empty()) - stencil.push_back(scvf.insideScvIdx()); - if(!scvf.boundary()) - stencil.push_back(scvf.outsideScvIdx()); - } - - /* - * \brief Computes the stencil for cell center dofs w.r.t to face dofs. - * Basically, these are the dof indices of the element's faces. - */ - static void computeCellCenterToFaceStencil(Stencil& stencil, - const Element& element, - const FVElementGeometry& fvGeometry, - const SubControlVolumeFace& scvf) - { - stencil.push_back(scvf.dofIndex()); - } - - /* - * \brief Computes the stencil for face dofs w.r.t to cell center dofs. - * Basically, these are the dof indices of the elements adjacent to the face and those of - * the elements adjacent to the faces parallel to the own face. - */ - static void computeFaceToCellCenterStencil(Stencil& stencil, - const FVElementGeometry& fvGeometry, - const SubControlVolumeFace& scvf) - { - const auto eIdx = scvf.insideScvIdx(); - stencil.push_back(scvf.insideScvIdx()); - - for(const auto& data : scvf.pairData()) - { - auto& normalFace = fvGeometry.scvf(eIdx, data.localNormalFaceIdx); - if(!normalFace.boundary()) - { - const auto outerParallelElementDofIdx = normalFace.outsideScvIdx(); - stencil.push_back(outerParallelElementDofIdx); - } - } - } - - /* - * \brief Computes the stencil for face dofs w.r.t to face dofs. - * For a full description of the stencil, please see the document under dumux/doc/docextra/staggered - */ - static void computeFaceToFaceStencil(Stencil& stencil, - const FVElementGeometry& fvGeometry, - const SubControlVolumeFace& scvf) - { - // the first entries are always the face dofIdx itself and the one of the opposing face - if(stencil.empty()) - { - stencil.push_back(scvf.dofIndex()); - stencil.push_back(scvf.dofIndexOpposingFace()); - } - - for(const auto& data : scvf.pairData()) - { - stencil.push_back(data.normalPair.first); - const auto outerParallelFaceDofIdx = data.outerParallelFaceDofIdx; - if(outerParallelFaceDofIdx >= 0) - stencil.push_back(outerParallelFaceDofIdx); - if(!scvf.boundary()) - stencil.push_back(data.normalPair.second); - } - } -}; - -} // end namespace Dumux - -#endif //DUMUX_STAGGERED_NAVIERSTOKES_FLUX_STENCIL_HH diff --git a/dumux/discretization/staggered/freeflow/properties.hh b/dumux/discretization/staggered/freeflow/properties.hh index 14acdd8483..6477489b3d 100644 --- a/dumux/discretization/staggered/freeflow/properties.hh +++ b/dumux/discretization/staggered/freeflow/properties.hh @@ -31,7 +31,7 @@ #include <dumux/freeflow/properties.hh> #include "subcontrolvolumeface.hh" -#include "fluxstencil.hh" +#include "connectivitymap.hh" #include "facevariables.hh" #include "boundarytypes.hh" #include "velocityoutput.hh" @@ -111,7 +111,8 @@ public: SET_TYPE_PROP(StaggeredFreeFlowModel, VelocityOutput, StaggeredFreeFlowVelocityOutput<TypeTag>); -SET_TYPE_PROP(StaggeredFreeFlowModel, StaggeredFluxStencils, StaggeredNavierStokesFluxStencils<TypeTag>); +SET_TYPE_PROP(StaggeredFreeFlowModel, AssemblyMap, StaggeredFreeFlowConnectivityMap<TypeTag>); + } // namespace Properties } // namespace Dumux diff --git a/dumux/discretization/staggered/fvgridgeometry.hh b/dumux/discretization/staggered/fvgridgeometry.hh index e1df6246c7..a7f362398d 100644 --- a/dumux/discretization/staggered/fvgridgeometry.hh +++ b/dumux/discretization/staggered/fvgridgeometry.hh @@ -27,7 +27,6 @@ #include <dumux/common/properties.hh> #include <dumux/discretization/basefvgridgeometry.hh> -#include <dumux/discretization/staggered/connectivitymap.hh> namespace Dumux { @@ -65,7 +64,7 @@ class StaggeredFVGridGeometry<TypeTag, true> : public BaseFVGridGeometry<TypeTag }; using GeometryHelper = typename GET_PROP_TYPE(TypeTag, StaggeredGeometryHelper); - using ConnectivityMap = StaggeredConnectivityMap<TypeTag>; + using ConnectivityMap = typename GET_PROP_TYPE(TypeTag, AssemblyMap); public: //! Constructor diff --git a/dumux/discretization/staggered/properties.hh b/dumux/discretization/staggered/properties.hh index c85872c21e..12ae7d4c25 100644 --- a/dumux/discretization/staggered/properties.hh +++ b/dumux/discretization/staggered/properties.hh @@ -65,7 +65,6 @@ NEW_PROP_TAG(FaceSolutionVector); NEW_PROP_TAG(StaggeredFaceSolution); NEW_PROP_TAG(ElementFaceVariables); NEW_PROP_TAG(EnableGlobalFaceVariablesCache); -NEW_PROP_TAG(StaggeredFluxStencils); //! Type tag for the staggered scheme. NEW_TYPE_TAG(StaggeredModel, INHERITS_FROM(FiniteVolumeModel)); diff --git a/test/discretization/staggered/test_staggeredfvgeometry.cc b/test/discretization/staggered/test_staggeredfvgeometry.cc index fb6049fdb6..14827323bd 100644 --- a/test/discretization/staggered/test_staggeredfvgeometry.cc +++ b/test/discretization/staggered/test_staggeredfvgeometry.cc @@ -37,37 +37,13 @@ namespace Dumux { -//! Dummy flux variables class so that we can update the connectivity map -class MockFluxStencil +//! Dummy connectivity map, required by FVGridGeometry +class MockConnectivityMap { public: - - template<class Map, class Element, class FvGeometry, class Scvf> - static void computeCellCenterToCellCenterStencil(Map& map, - const Element& element, - const FvGeometry& fvGeometry, - const Scvf& scvf) - {} - - template<class Map, class Element, class FvGeometry, class Scvf> - static void computeCellCenterToFaceStencil(Map& map, - const Element& element, - const FvGeometry& fvGeometry, - const Scvf& scvf) - {} - - template<class Map, class FvGeometry, class Scvf> - static void computeFaceToCellCenterStencil(Map& map, - const FvGeometry& fvGeometry, - const Scvf& scvf) - {} - - template<class Map, class FvGeometry, class Scvf> - static void computeFaceToFaceStencil(Map& map, - const FvGeometry& fvGeometry, - const Scvf& scvf) - {} - + template<class FVGridGeometry> + void update(const FVGridGeometry& fvGridGeometry) + {} }; namespace Properties @@ -76,7 +52,7 @@ NEW_TYPE_TAG(TestFVGeometry, INHERITS_FROM(StaggeredModel)); SET_TYPE_PROP(TestFVGeometry, Grid, Dune::YaspGrid<2>); -SET_TYPE_PROP(TestFVGeometry, StaggeredFluxStencils, MockFluxStencil); +SET_TYPE_PROP(TestFVGeometry, AssemblyMap, MockConnectivityMap); SET_BOOL_PROP(TestFVGeometry, EnableFVGridGeometryCache, true); } -- GitLab