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/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;
124 using FeCache = Dune::PQkLocalFiniteElementCache<CoordScalar, Scalar, dim, 1>;
147 {
return numBoundaryScvf_; }
164 template<
class FacetGr
idView,
class CodimOneGr
idAdapter>
165 void update(
const FacetGridView& facetGridView,
167 bool verbose =
false)
173 this->
vertexMapper().enrich(facetGridView, codimOneGridAdapter, verbose);
177 const auto numElements = this->
gridView().size(0);
180 scvs_.resize(numElements);
181 scvfs_.resize(numElements);
182 boundaryDofIndices_.assign(numDof,
false);
183 interiorBoundaryDofIndices_.assign(numDof,
false);
188 numBoundaryScvf_ = 0;
194 numScv_ +=
element.subEntities(dim);
195 numScvf_ +=
element.subEntities(dim-1);
198 auto elementGeometry =
element.geometry();
199 const auto refElement = referenceElement(elementGeometry);
202 GeometryHelper geometryHelper(elementGeometry);
206 scvs_[eIdx].reserve(elementGeometry.corners());
207 for (LocalIndexType scvLocalIdx = 0; scvLocalIdx < elementGeometry.corners(); ++scvLocalIdx)
208 scvs_[eIdx].emplace_back(geometryHelper,
214 LocalIndexType scvfLocalIdx = 0;
215 scvfs_[eIdx].clear();
216 scvfs_[eIdx].reserve(
element.subEntities(dim-1));
217 for (; scvfLocalIdx <
element.subEntities(dim-1); ++scvfLocalIdx)
220 std::vector<LocalIndexType> localScvIndices({
static_cast<LocalIndexType
>(refElement.subEntity(scvfLocalIdx, dim-1, 0, dim)),
221 static_cast<LocalIndexType
>(refElement.subEntity(scvfLocalIdx, dim-1, 1, dim))});
224 scvfs_[eIdx].emplace_back(geometryHelper,
228 std::move(localScvIndices));
233 std::vector<unsigned int> handledFacets;
234 for (
const auto& intersection : intersections(this->
gridView(),
element))
236 if (std::count(handledFacets.begin(), handledFacets.end(), intersection.indexInInside()))
239 handledFacets.push_back(intersection.indexInInside());
242 const auto isGeometry = intersection.geometry();
243 const auto numFaceCorners = isGeometry.corners();
244 const auto idxInInside = intersection.indexInInside();
245 const auto boundary = intersection.boundary();
247 std::vector<LocalIndexType> vIndicesLocal(numFaceCorners);
248 for (
int i = 0; i < numFaceCorners; ++i)
249 vIndicesLocal[i] =
static_cast<LocalIndexType
>(refElement.subEntity(idxInInside, 1, i, dim));
251 std::vector<LocalIndexType> gridVertexIndices(numFaceCorners);
252 for (
int i = 0; i < numFaceCorners; ++i)
259 if (boundary && intersection.neighbor())
260 DUNE_THROW(Dune::InvalidStateException,
"Periodic boundaries are not supported by the box facet coupling scheme");
263 if (isOnFacet || boundary)
266 numScvf_ += numFaceCorners;
267 numBoundaryScvf_ += int(boundary)*numFaceCorners;
269 for (
unsigned int isScvfLocalIdx = 0; isScvfLocalIdx < numFaceCorners; ++isScvfLocalIdx)
272 std::vector<LocalIndexType> localScvIndices = {vIndicesLocal[isScvfLocalIdx], vIndicesLocal[isScvfLocalIdx]};
275 scvfs_[eIdx].emplace_back(geometryHelper,
280 std::move(localScvIndices),
285 const auto dofIndex = this->
vertexMapper().subIndex(
element, vIndicesLocal[isScvfLocalIdx], dim);
286 if (boundary) boundaryDofIndices_[ dofIndex ] = boundary;
287 if (isOnFacet) interiorBoundaryDofIndices_[ dofIndex ] = isOnFacet;
302 const std::vector<SubControlVolume>&
scvs(GridIndexType eIdx)
const
303 {
return scvs_[eIdx]; }
306 const std::vector<SubControlVolumeFace>&
scvfs(GridIndexType eIdx)
const
307 {
return scvfs_[eIdx]; }
311 {
return boundaryDofIndices_[dofIdx]; }
315 {
return interiorBoundaryDofIndices_[dofIdx]; }
323 { DUNE_THROW(Dune::InvalidStateException,
"Periodic boundaries are not supported by the box facet coupling scheme"); }
327 {
return std::unordered_map<GridIndexType, GridIndexType>(); }
330 const FeCache feCache_;
332 std::vector<std::vector<SubControlVolume>> scvs_;
333 std::vector<std::vector<SubControlVolumeFace>> scvfs_;
337 std::size_t numScvf_;
338 std::size_t numBoundaryScvf_;
341 std::vector<bool> boundaryDofIndices_;
342 std::vector<bool> interiorBoundaryDofIndices_;
352template<
class Scalar,
class GV,
class Traits>
361 static const int dim = GV::dimension;
362 static const int dimWorld = GV::dimensionworld;
364 using Element =
typename GV::template Codim<0>::Entity;
365 using Intersection =
typename GV::Intersection;
366 using CoordScalar =
typename GV::ctype;
383 using FeCache = Dune::PQkLocalFiniteElementCache<CoordScalar, Scalar, dim, 1>;
409 {
return numBoundaryScvf_; }
426 template<
class FacetGr
idView,
class CodimOneGr
idAdapter>
427 void update(
const FacetGridView& facetGridView,
429 bool verbose =
false)
435 this->
vertexMapper().enrich(facetGridView, codimOneGridAdapter, verbose);
441 numBoundaryScvf_ = 0;
444 boundaryDofIndices_.assign(numDof,
false);
445 interiorBoundaryDofIndices_.assign(numDof,
false);
446 facetIsOnInteriorBoundary_.assign(this->
gridView().size(1),
false);
449 numScv_ +=
element.subEntities(dim);
450 numScvf_ +=
element.subEntities(dim-1);
452 const auto elementGeometry =
element.geometry();
453 const auto refElement = referenceElement(elementGeometry);
457 std::vector<unsigned int> handledFacets;
458 for (
const auto& intersection : intersections(this->
gridView(),
element))
460 if (std::count(handledFacets.begin(), handledFacets.end(), intersection.indexInInside()))
463 handledFacets.push_back(intersection.indexInInside());
466 const auto isGeometry = intersection.geometry();
467 const auto numFaceCorners = isGeometry.corners();
468 const auto idxInInside = intersection.indexInInside();
469 const auto boundary = intersection.boundary();
471 std::vector<LocalIndexType> vIndicesLocal(numFaceCorners);
472 for (
int i = 0; i < numFaceCorners; ++i)
473 vIndicesLocal[i] =
static_cast<LocalIndexType
>(refElement.subEntity(idxInInside, 1, i, dim));
475 std::vector<GridIndexType> gridVertexIndices(numFaceCorners);
476 for (
int i = 0; i < numFaceCorners; ++i)
483 if (boundary && intersection.neighbor())
484 DUNE_THROW(Dune::InvalidStateException,
"Periodic boundaries are not supported by the box facet coupling scheme");
486 if (isOnFacet || boundary)
488 numScvf_ += numFaceCorners;
489 numBoundaryScvf_ += int(boundary)*numFaceCorners;
492 for (
int i = 0; i < numFaceCorners; ++i)
495 if (boundary) boundaryDofIndices_[ dofIndex ] =
true;
498 interiorBoundaryDofIndices_[ dofIndex ] =
true;
499 facetIsOnInteriorBoundary_[ facetMapper_.subIndex(
element, idxInInside, 1) ] =
true;
513 {
return boundaryDofIndices_[dofIdx]; }
517 {
return interiorBoundaryDofIndices_[dofIdx]; }
521 {
return facetIsOnInteriorBoundary_[ facetMapper_.subIndex(
element, intersection.indexInInside(), 1) ]; }
529 { DUNE_THROW(Dune::InvalidStateException,
"Periodic boundaries are not supported by the facet coupling scheme"); }
533 {
return std::unordered_map<GridIndexType, GridIndexType>(); }
536 const FeCache feCache_;
541 std::size_t numScvf_;
542 std::size_t numBoundaryScvf_;
545 std::vector<bool> boundaryDofIndices_;
546 std::vector<bool> interiorBoundaryDofIndices_;
549 typename Traits::FacetMapper facetMapper_;
550 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.
Helper classes to compute the integration elements.
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:78
DiscretizationMethod
The available discretization methods in Dumux.
Definition method.hh:37
@ box
Definition method.hh:38
typename Extrusion< T >::type Extrusion_t
Convenience alias for obtaining the extrusion type.
Definition extrusion.hh:177
Definition common/pdesolver.hh:36
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:127
Element element(GridIndexType eIdx) const
Get an element from a global element index.
Definition basegridgeometry.hh:171
const VertexMapper & vertexMapper() const
Returns the mapper for vertices to indices for constant grids.
Definition basegridgeometry.hh:121
const GridView & gridView() const
Return the gridView this grid geometry object lives on.
Definition basegridgeometry.hh:115
void update()
Update all fvElementGeometries (do this again after grid adaption).
Definition basegridgeometry.hh:91
Create sub control volumes and sub control volume face geometries.
Definition boxgeometryhelper.hh:36
the sub control volume for the box scheme
Definition discretization/box/subcontrolvolume.hh:89
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:314
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:322
Extrusion_t< Traits > Extrusion
export the type of extrusion
Definition multidomain/facet/box/fvgridgeometry.hh:120
const std::vector< SubControlVolume > & scvs(GridIndexType eIdx) const
Get the local scvs for an element.
Definition multidomain/facet/box/fvgridgeometry.hh:302
static constexpr DiscretizationMethod discMethod
export discretization method
Definition multidomain/facet/box/fvgridgeometry.hh:111
GV GridView
export the grid view type
Definition multidomain/facet/box/fvgridgeometry.hh:126
std::size_t numScv() const
The total number of sub control volumes.
Definition multidomain/facet/box/fvgridgeometry.hh:137
bool dofOnPeriodicBoundary(GridIndexType dofIdx) const
Periodic boundaries are not supported for the box facet coupling scheme.
Definition multidomain/facet/box/fvgridgeometry.hh:318
bool dofOnBoundary(GridIndexType dofIdx) const
If a d.o.f. is on the boundary.
Definition multidomain/facet/box/fvgridgeometry.hh:310
typename Traits::VertexMapper DofMapper
export dof mapper type
Definition multidomain/facet/box/fvgridgeometry.hh:122
std::size_t numBoundaryScvf() const
Definition multidomain/facet/box/fvgridgeometry.hh:146
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:165
const DofMapper & dofMapper() const
the vertex mapper is the dofMapper
Definition multidomain/facet/box/fvgridgeometry.hh:133
typename Traits::SubControlVolume SubControlVolume
export the type of sub control volume
Definition multidomain/facet/box/fvgridgeometry.hh:116
std::size_t numScvf() const
The total number of sun control volume faces.
Definition multidomain/facet/box/fvgridgeometry.hh:141
const FeCache & feCache() const
The finite element cache for creating local FE bases.
Definition multidomain/facet/box/fvgridgeometry.hh:298
std::size_t numDofs() const
The total number of degrees of freedom.
Definition multidomain/facet/box/fvgridgeometry.hh:150
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:114
Dune::PQkLocalFiniteElementCache< CoordScalar, Scalar, dim, 1 > FeCache
export the finite element cache type
Definition multidomain/facet/box/fvgridgeometry.hh:124
BoxFacetCouplingFVGridGeometry(const GridView &gridView)
Constructor.
Definition multidomain/facet/box/fvgridgeometry.hh:129
std::unordered_map< GridIndexType, GridIndexType > periodicVertexMap() const
Returns the map between dofs across periodic boundaries.
Definition multidomain/facet/box/fvgridgeometry.hh:326
const std::vector< SubControlVolumeFace > & scvfs(GridIndexType eIdx) const
Get the local scvfs for an element.
Definition multidomain/facet/box/fvgridgeometry.hh:306
typename Traits::SubControlVolumeFace SubControlVolumeFace
export the type of sub control volume
Definition multidomain/facet/box/fvgridgeometry.hh:118
typename Traits::SubControlVolume SubControlVolume
export the type of sub control volume
Definition multidomain/facet/box/fvgridgeometry.hh:375
std::size_t numScv() const
The total number of sub control volumes.
Definition multidomain/facet/box/fvgridgeometry.hh:399
std::size_t numScvf() const
The total number of sun control volume faces.
Definition multidomain/facet/box/fvgridgeometry.hh:403
GV GridView
export the grid view type
Definition multidomain/facet/box/fvgridgeometry.hh:385
std::size_t numDofs() const
The total number of degrees of freedom.
Definition multidomain/facet/box/fvgridgeometry.hh:412
std::unordered_map< GridIndexType, GridIndexType > periodicVertexMap() const
Returns the map between dofs across periodic boundaries.
Definition multidomain/facet/box/fvgridgeometry.hh:532
std::size_t numBoundaryScvf() const
Definition multidomain/facet/box/fvgridgeometry.hh:408
const FeCache & feCache() const
The finite element cache for creating local FE bases.
Definition multidomain/facet/box/fvgridgeometry.hh:508
typename Traits::VertexMapper DofMapper
export dof mapper type
Definition multidomain/facet/box/fvgridgeometry.hh:381
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:427
const DofMapper & dofMapper() const
Definition multidomain/facet/box/fvgridgeometry.hh:395
static constexpr DiscretizationMethod discMethod
export discretization method
Definition multidomain/facet/box/fvgridgeometry.hh:370
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:373
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:528
bool dofOnPeriodicBoundary(GridIndexType dofIdx) const
Periodic boundaries are not supported for the box facet coupling scheme.
Definition multidomain/facet/box/fvgridgeometry.hh:524
Dune::PQkLocalFiniteElementCache< CoordScalar, Scalar, dim, 1 > FeCache
export the finite element cache type
Definition multidomain/facet/box/fvgridgeometry.hh:383
typename Traits::SubControlVolumeFace SubControlVolumeFace
export the type of sub control volume
Definition multidomain/facet/box/fvgridgeometry.hh:377
Extrusion_t< Traits > Extrusion
export the type of extrusion
Definition multidomain/facet/box/fvgridgeometry.hh:379
bool dofOnBoundary(unsigned int dofIdx) const
If a d.o.f. is on the boundary.
Definition multidomain/facet/box/fvgridgeometry.hh:512
bool dofOnInteriorBoundary(unsigned int dofIdx) const
If a d.o.f. is on an interior boundary.
Definition multidomain/facet/box/fvgridgeometry.hh:516
BoxFacetCouplingFVGridGeometry(const GridView gridView)
Constructor.
Definition multidomain/facet/box/fvgridgeometry.hh:388
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:520
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:52
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:192
A vertex mapper that allows for enrichment of nodes. Indication on where to enrich the nodes is done ...
Definition vertexmapper.hh:142
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...