Commit f1197439 authored by Kilian Weishaupt's avatar Kilian Weishaupt
Browse files

[staggered] Move general assembly map to freeflow

* calculate stencils directly in assembly map
* remove stencils class and property
parent 9f393fa4
......@@ -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
// -*- 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
......@@ -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
......
......@@ -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
......
......@@ -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));
......
......@@ -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);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment