27#ifndef DUMUX_FACETCOUPLING_BOX_GRID_FVGEOMETRY_HH
28#define DUMUX_FACETCOUPLING_BOX_GRID_FVGEOMETRY_HH
32#include <dune/grid/common/mcmgmapper.hh>
33#include <dune/geometry/referenceelements.hh>
34#include <dune/localfunctions/lagrange/pqkfactory.hh>
55template<
class Gr
idView>
62 template<
class Gr
idGeometry,
bool enableCache>
66 using ElementMapper = Dune::MultipleCodimMultipleGeomTypeMapper<GridView>;
70 using FacetMapper = Dune::MultipleCodimMultipleGeomTypeMapper<GridView>;
82 bool enableGridGeometryCache =
false,
93template<
class Scalar,
class GV,
class Traits>
102 using Element =
typename GV::template Codim<0>::Entity;
103 using CoordScalar =
typename GV::ctype;
104 static const int dim = GV::dimension;
105 static const int dimWorld = GV::dimensionworld;
107 using ReferenceElements =
typename Dune::ReferenceElements<CoordScalar, dim>;
123 using FeCache = Dune::PQkLocalFiniteElementCache<CoordScalar, Scalar, dim, 1>;
146 {
return numBoundaryScvf_; }
163 template<
class FacetGr
idView,
class CodimOneGr
idAdapter>
164 void update(
const FacetGridView& facetGridView,
166 bool verbose =
false)
172 this->
vertexMapper().enrich(facetGridView, codimOneGridAdapter, verbose);
176 const auto numElements = this->
gridView().size(0);
179 scvs_.resize(numElements);
180 scvfs_.resize(numElements);
181 boundaryDofIndices_.assign(numDof,
false);
182 interiorBoundaryDofIndices_.assign(numDof,
false);
187 numBoundaryScvf_ = 0;
193 numScv_ +=
element.subEntities(dim);
194 numScvf_ +=
element.subEntities(dim-1);
197 auto elementGeometry =
element.geometry();
198 const auto referenceElement = ReferenceElements::general(elementGeometry.type());
201 GeometryHelper geometryHelper(elementGeometry);
205 scvs_[eIdx].reserve(elementGeometry.corners());
206 for (LocalIndexType scvLocalIdx = 0; scvLocalIdx < elementGeometry.corners(); ++scvLocalIdx)
207 scvs_[eIdx].emplace_back(geometryHelper,
213 LocalIndexType scvfLocalIdx = 0;
214 scvfs_[eIdx].clear();
215 scvfs_[eIdx].reserve(
element.subEntities(dim-1));
216 for (; scvfLocalIdx <
element.subEntities(dim-1); ++scvfLocalIdx)
219 std::vector<LocalIndexType> localScvIndices({
static_cast<LocalIndexType
>(referenceElement.subEntity(scvfLocalIdx, dim-1, 0, dim)),
220 static_cast<LocalIndexType
>(referenceElement.subEntity(scvfLocalIdx, dim-1, 1, dim))});
223 scvfs_[eIdx].emplace_back(geometryHelper,
227 std::move(localScvIndices));
232 std::vector<unsigned int> handledFacets;
233 for (
const auto& intersection : intersections(this->
gridView(),
element))
235 if (std::count(handledFacets.begin(), handledFacets.end(), intersection.indexInInside()))
238 handledFacets.push_back(intersection.indexInInside());
241 const auto isGeometry = intersection.geometry();
242 const auto numFaceCorners = isGeometry.corners();
243 const auto idxInInside = intersection.indexInInside();
244 const auto boundary = intersection.boundary();
246 std::vector<LocalIndexType> vIndicesLocal(numFaceCorners);
247 for (
int i = 0; i < numFaceCorners; ++i)
248 vIndicesLocal[i] =
static_cast<LocalIndexType
>(referenceElement.subEntity(idxInInside, 1, i, dim));
250 std::vector<LocalIndexType> gridVertexIndices(numFaceCorners);
251 for (
int i = 0; i < numFaceCorners; ++i)
258 if (boundary && intersection.neighbor())
259 DUNE_THROW(Dune::InvalidStateException,
"Periodic boundaries are not supported by the box facet coupling scheme");
262 if (isOnFacet || boundary)
265 numScvf_ += numFaceCorners;
266 numBoundaryScvf_ += int(boundary)*numFaceCorners;
268 for (
unsigned int isScvfLocalIdx = 0; isScvfLocalIdx < numFaceCorners; ++isScvfLocalIdx)
271 std::vector<LocalIndexType> localScvIndices = {vIndicesLocal[isScvfLocalIdx], vIndicesLocal[isScvfLocalIdx]};
274 scvfs_[eIdx].emplace_back(geometryHelper,
279 std::move(localScvIndices),
284 const auto dofIndex = this->
vertexMapper().subIndex(
element, vIndicesLocal[isScvfLocalIdx], dim);
285 if (boundary) boundaryDofIndices_[ dofIndex ] = boundary;
286 if (isOnFacet) interiorBoundaryDofIndices_[ dofIndex ] = isOnFacet;
301 const std::vector<SubControlVolume>&
scvs(GridIndexType eIdx)
const
302 {
return scvs_[eIdx]; }
305 const std::vector<SubControlVolumeFace>&
scvfs(GridIndexType eIdx)
const
306 {
return scvfs_[eIdx]; }
310 {
return boundaryDofIndices_[dofIdx]; }
314 {
return interiorBoundaryDofIndices_[dofIdx]; }
322 { DUNE_THROW(Dune::InvalidStateException,
"Periodic boundaries are not supported by the box facet coupling scheme"); }
326 {
return std::unordered_map<GridIndexType, GridIndexType>(); }
329 const FeCache feCache_;
331 std::vector<std::vector<SubControlVolume>> scvs_;
332 std::vector<std::vector<SubControlVolumeFace>> scvfs_;
336 std::size_t numScvf_;
337 std::size_t numBoundaryScvf_;
340 std::vector<bool> boundaryDofIndices_;
341 std::vector<bool> interiorBoundaryDofIndices_;
351template<
class Scalar,
class GV,
class Traits>
360 static const int dim = GV::dimension;
361 static const int dimWorld = GV::dimensionworld;
363 using Element =
typename GV::template Codim<0>::Entity;
364 using Intersection =
typename GV::Intersection;
365 using CoordScalar =
typename GV::ctype;
367 using ReferenceElements =
typename Dune::ReferenceElements<CoordScalar, dim>;
382 using FeCache = Dune::PQkLocalFiniteElementCache<CoordScalar, Scalar, dim, 1>;
408 {
return numBoundaryScvf_; }
425 template<
class FacetGr
idView,
class CodimOneGr
idAdapter>
426 void update(
const FacetGridView& facetGridView,
428 bool verbose =
false)
434 this->
vertexMapper().enrich(facetGridView, codimOneGridAdapter, verbose);
440 numBoundaryScvf_ = 0;
443 boundaryDofIndices_.assign(numDof,
false);
444 interiorBoundaryDofIndices_.assign(numDof,
false);
445 facetIsOnInteriorBoundary_.assign(this->
gridView().size(1),
false);
448 numScv_ +=
element.subEntities(dim);
449 numScvf_ +=
element.subEntities(dim-1);
451 const auto elementGeometry =
element.geometry();
452 const auto referenceElement = ReferenceElements::general(elementGeometry.type());
456 std::vector<unsigned int> handledFacets;
457 for (
const auto& intersection : intersections(this->
gridView(),
element))
459 if (std::count(handledFacets.begin(), handledFacets.end(), intersection.indexInInside()))
462 handledFacets.push_back(intersection.indexInInside());
465 const auto isGeometry = intersection.geometry();
466 const auto numFaceCorners = isGeometry.corners();
467 const auto idxInInside = intersection.indexInInside();
468 const auto boundary = intersection.boundary();
470 std::vector<LocalIndexType> vIndicesLocal(numFaceCorners);
471 for (
int i = 0; i < numFaceCorners; ++i)
472 vIndicesLocal[i] =
static_cast<LocalIndexType
>(referenceElement.subEntity(idxInInside, 1, i, dim));
474 std::vector<GridIndexType> gridVertexIndices(numFaceCorners);
475 for (
int i = 0; i < numFaceCorners; ++i)
482 if (boundary && intersection.neighbor())
483 DUNE_THROW(Dune::InvalidStateException,
"Periodic boundaries are not supported by the box facet coupling scheme");
485 if (isOnFacet || boundary)
487 numScvf_ += numFaceCorners;
488 numBoundaryScvf_ += int(boundary)*numFaceCorners;
491 for (
int i = 0; i < numFaceCorners; ++i)
494 if (boundary) boundaryDofIndices_[ dofIndex ] =
true;
497 interiorBoundaryDofIndices_[ dofIndex ] =
true;
498 facetIsOnInteriorBoundary_[ facetMapper_.subIndex(
element, idxInInside, 1) ] =
true;
512 {
return boundaryDofIndices_[dofIdx]; }
516 {
return interiorBoundaryDofIndices_[dofIdx]; }
520 {
return facetIsOnInteriorBoundary_[ facetMapper_.subIndex(
element, intersection.indexInInside(), 1) ]; }
528 { DUNE_THROW(Dune::InvalidStateException,
"Periodic boundaries are not supported by the facet coupling scheme"); }
532 {
return std::unordered_map<GridIndexType, GridIndexType>(); }
535 const FeCache feCache_;
540 std::size_t numScvf_;
541 std::size_t numBoundaryScvf_;
544 std::vector<bool> boundaryDofIndices_;
545 std::vector<bool> interiorBoundaryDofIndices_;
548 typename Traits::FacetMapper facetMapper_;
549 std::vector<bool> facetIsOnInteriorBoundary_;
Defines the index types used for grid and local indices.
Helper class constructing the dual grid finite volume geometries for the box discretizazion method.
The available discretization methods in Dumux.
Base class for grid geometries.
A vertex mapper that allows for enrichment of nodes. Indication on where to enrich the nodes is done ...
BaseGridGeometry(const GridView &gridView)
Constructor computes the bouding box of the entire domain, for e.g. setting boundary conditions.
Definition basegridgeometry.hh:77
DiscretizationMethod
The available discretization methods in Dumux.
Definition method.hh:37
@ box
Definition method.hh:38
Definition common/pdesolver.hh:35
typename GridView::IndexSet::IndexType GridIndex
Definition indextraits.hh:39
unsigned int LocalIndex
Definition indextraits.hh:40
const ElementMapper & elementMapper() const
Returns the mapper for elements to indices for constant grids.
Definition basegridgeometry.hh:119
Element element(GridIndexType eIdx) const
Get an element from a global element index.
Definition basegridgeometry.hh:163
const VertexMapper & vertexMapper() const
Returns the mapper for vertices to indices for constant grids.
Definition basegridgeometry.hh:113
const GridView & gridView() const
Return the gridView this grid geometry object lives on.
Definition basegridgeometry.hh:107
void update()
Update all fvElementGeometries (do this again after grid adaption).
Definition basegridgeometry.hh:90
Create sub control volumes and sub control volume face geometries.
Definition boxgeometryhelper.hh:37
the sub control volume for the box scheme
Definition discretization/box/subcontrolvolume.hh:88
Base class for the element-local finite volume geometry for box models in the context of models consi...
Definition multidomain/facet/box/fvelementgeometry.hh:48
The default traits for the finite volume grid geometry of the box scheme with coupling occuring acros...
Definition multidomain/facet/box/fvgridgeometry.hh:57
BoxFacetCouplingFVElementGeometry< GridGeometry, enableCache > LocalView
Definition multidomain/facet/box/fvgridgeometry.hh:63
Dune::MultipleCodimMultipleGeomTypeMapper< GridView > FacetMapper
Definition multidomain/facet/box/fvgridgeometry.hh:70
BoxFacetCouplingSubControlVolumeFace< GridView > SubControlVolumeFace
Definition multidomain/facet/box/fvgridgeometry.hh:60
EnrichedVertexDofMapper< GridView > VertexMapper
Definition multidomain/facet/box/fvgridgeometry.hh:68
Dune::MultipleCodimMultipleGeomTypeMapper< GridView > ElementMapper
Definition multidomain/facet/box/fvgridgeometry.hh:66
BoxSubControlVolume< GridView > SubControlVolume
Definition multidomain/facet/box/fvgridgeometry.hh:59
Base class for the finite volume geometry vector for box schemes in the context of coupled models whe...
Definition multidomain/facet/box/fvgridgeometry.hh:84
bool dofOnInteriorBoundary(GridIndexType dofIdx) const
If a d.o.f. is on an interior boundary.
Definition multidomain/facet/box/fvgridgeometry.hh:313
GridIndexType periodicallyMappedDof(GridIndexType dofIdx) const
The index of the vertex / d.o.f. on the other side of the periodic boundary.
Definition multidomain/facet/box/fvgridgeometry.hh:321
const std::vector< SubControlVolume > & scvs(GridIndexType eIdx) const
Get the local scvs for an element.
Definition multidomain/facet/box/fvgridgeometry.hh:301
static constexpr DiscretizationMethod discMethod
export discretization method
Definition multidomain/facet/box/fvgridgeometry.hh:112
GV GridView
export the grid view type
Definition multidomain/facet/box/fvgridgeometry.hh:125
std::size_t numScv() const
The total number of sub control volumes.
Definition multidomain/facet/box/fvgridgeometry.hh:136
bool dofOnPeriodicBoundary(GridIndexType dofIdx) const
Periodic boundaries are not supported for the box facet coupling scheme.
Definition multidomain/facet/box/fvgridgeometry.hh:317
bool dofOnBoundary(GridIndexType dofIdx) const
If a d.o.f. is on the boundary.
Definition multidomain/facet/box/fvgridgeometry.hh:309
typename Traits::VertexMapper DofMapper
export dof mapper type
Definition multidomain/facet/box/fvgridgeometry.hh:121
std::size_t numBoundaryScvf() const
Definition multidomain/facet/box/fvgridgeometry.hh:145
void update(const FacetGridView &facetGridView, const CodimOneGridAdapter &codimOneGridAdapter, bool verbose=false)
update all fvElementGeometries (do this again after grid adaption)
Definition multidomain/facet/box/fvgridgeometry.hh:164
const DofMapper & dofMapper() const
the vertex mapper is the dofMapper
Definition multidomain/facet/box/fvgridgeometry.hh:132
typename Traits::SubControlVolume SubControlVolume
export the type of sub control volume
Definition multidomain/facet/box/fvgridgeometry.hh:117
std::size_t numScvf() const
The total number of sun control volume faces.
Definition multidomain/facet/box/fvgridgeometry.hh:140
const FeCache & feCache() const
The finite element cache for creating local FE bases.
Definition multidomain/facet/box/fvgridgeometry.hh:297
std::size_t numDofs() const
The total number of degrees of freedom.
Definition multidomain/facet/box/fvgridgeometry.hh:149
typename Traits::template LocalView< ThisType, true > LocalView
export the type of the fv element geometry (the local view type)
Definition multidomain/facet/box/fvgridgeometry.hh:115
Dune::PQkLocalFiniteElementCache< CoordScalar, Scalar, dim, 1 > FeCache
export the finite element cache type
Definition multidomain/facet/box/fvgridgeometry.hh:123
BoxFacetCouplingFVGridGeometry(const GridView &gridView)
Constructor.
Definition multidomain/facet/box/fvgridgeometry.hh:128
std::unordered_map< GridIndexType, GridIndexType > periodicVertexMap() const
Returns the map between dofs across periodic boundaries.
Definition multidomain/facet/box/fvgridgeometry.hh:325
const std::vector< SubControlVolumeFace > & scvfs(GridIndexType eIdx) const
Get the local scvfs for an element.
Definition multidomain/facet/box/fvgridgeometry.hh:305
typename Traits::SubControlVolumeFace SubControlVolumeFace
export the type of sub control volume
Definition multidomain/facet/box/fvgridgeometry.hh:119
typename Traits::SubControlVolume SubControlVolume
export the type of sub control volume
Definition multidomain/facet/box/fvgridgeometry.hh:376
std::size_t numScv() const
The total number of sub control volumes.
Definition multidomain/facet/box/fvgridgeometry.hh:398
std::size_t numScvf() const
The total number of sun control volume faces.
Definition multidomain/facet/box/fvgridgeometry.hh:402
GV GridView
export the grid view type
Definition multidomain/facet/box/fvgridgeometry.hh:384
std::size_t numDofs() const
The total number of degrees of freedom.
Definition multidomain/facet/box/fvgridgeometry.hh:411
std::unordered_map< GridIndexType, GridIndexType > periodicVertexMap() const
Returns the map between dofs across periodic boundaries.
Definition multidomain/facet/box/fvgridgeometry.hh:531
std::size_t numBoundaryScvf() const
Definition multidomain/facet/box/fvgridgeometry.hh:407
const FeCache & feCache() const
The finite element cache for creating local FE bases.
Definition multidomain/facet/box/fvgridgeometry.hh:507
typename Traits::VertexMapper DofMapper
export dof mapper type
Definition multidomain/facet/box/fvgridgeometry.hh:380
void update(const FacetGridView &facetGridView, const CodimOneGridAdapter &codimOneGridAdapter, bool verbose=false)
update all fvElementGeometries (do this again after grid adaption)
Definition multidomain/facet/box/fvgridgeometry.hh:426
const DofMapper & dofMapper() const
Definition multidomain/facet/box/fvgridgeometry.hh:394
static constexpr DiscretizationMethod discMethod
export discretization method
Definition multidomain/facet/box/fvgridgeometry.hh:371
typename Traits::template LocalView< ThisType, false > LocalView
export the type of the fv element geometry (the local view type)
Definition multidomain/facet/box/fvgridgeometry.hh:374
GridIndexType periodicallyMappedDof(GridIndexType dofIdx) const
The index of the vertex / d.o.f. on the other side of the periodic boundary.
Definition multidomain/facet/box/fvgridgeometry.hh:527
bool dofOnPeriodicBoundary(GridIndexType dofIdx) const
Periodic boundaries are not supported for the box facet coupling scheme.
Definition multidomain/facet/box/fvgridgeometry.hh:523
Dune::PQkLocalFiniteElementCache< CoordScalar, Scalar, dim, 1 > FeCache
export the finite element cache type
Definition multidomain/facet/box/fvgridgeometry.hh:382
typename Traits::SubControlVolumeFace SubControlVolumeFace
export the type of sub control volume
Definition multidomain/facet/box/fvgridgeometry.hh:378
bool dofOnBoundary(unsigned int dofIdx) const
If a d.o.f. is on the boundary.
Definition multidomain/facet/box/fvgridgeometry.hh:511
bool dofOnInteriorBoundary(unsigned int dofIdx) const
If a d.o.f. is on an interior boundary.
Definition multidomain/facet/box/fvgridgeometry.hh:515
BoxFacetCouplingFVGridGeometry(const GridView gridView)
Constructor.
Definition multidomain/facet/box/fvgridgeometry.hh:387
bool isOnInteriorBoundary(const Element &element, const Intersection &intersection) const
returns true if an intersection is on an interior boundary
Definition multidomain/facet/box/fvgridgeometry.hh:519
Class for a sub control volume face in the box method, i.e a part of the boundary of a sub control vo...
Definition multidomain/facet/box/subcontrolvolumeface.hh:52
Adapter that allows retrieving information on a d-dimensional grid for entities of a (d-1)-dimensiona...
Definition codimonegridadapter.hh:53
bool composeFacetElement(const IndexStorage &bulkVertexIndices) const
Returns true if a given set of bulk vertex indices make up a facet grid element.
Definition codimonegridadapter.hh:194
A vertex mapper that allows for enrichment of nodes. Indication on where to enrich the nodes is done ...
Definition vertexmapper.hh:146
Base class for the element-local finite volume geometry for box models in the context of models consi...
the sub control volume for the box scheme
Base class for a sub control volume face of the box method in the context of of models considering co...