24#ifndef DUMUX_DISCRETIZATION_FACECENTERED_DIAMOND_FV_GRID_GEOMETRY
25#define DUMUX_DISCRETIZATION_FACECENTERED_DIAMOND_FV_GRID_GEOMETRY
28#include <unordered_map>
30#include <dune/grid/common/mcmgmapper.hh>
31#include <dune/geometry/type.hh>
57template<
class Gr
idView>
62 using DofMapper = Dune::MultipleCodimMultipleGeomTypeMapper<GridView>;
64 template<
class Gr
idGeometry,
bool enableCache>
73 bool enableCaching =
true,
82 using Element =
typename GV::template Codim<0>::Entity;
85 using Scalar =
typename GV::ctype;
87 static const int dim = GV::dimension;
88 static const int dimWorld = GV::dimensionworld;
90 static_assert(dim > 1,
"Only implemented for dim > 1");
132 {
return numBoundaryScvf_; }
136 {
return this->
gridView().size(1); }
158 {
return dofMapper_; }
162 {
return periodicFaceMap_.count(dofIdx); }
166 {
return periodicFaceMap_.at(dofIdx); }
170 {
return periodicFaceMap_; }
174 {
return { gg.cache_ }; }
178 class FCDiamondGridGeometryCache
186 const FaceCenteredDiamondFVGridGeometry& gridGeometry()
const
187 {
return *gridGeometry_; }
190 const std::vector<SubControlVolume>& scvs(GridIndexType eIdx)
const
191 {
return scvs_[eIdx]; }
194 const std::vector<SubControlVolumeFace>& scvfs(GridIndexType eIdx)
const
195 {
return scvfs_[eIdx]; }
198 bool hasBoundaryScvf(GridIndexType eIdx)
const
199 {
return hasBoundaryScvf_[eIdx]; }
206 hasBoundaryScvf_.clear();
209 std::vector<std::vector<SubControlVolume>> scvs_;
210 std::vector<std::vector<SubControlVolumeFace>> scvfs_;
211 std::vector<bool> hasBoundaryScvf_;
213 const FaceCenteredDiamondFVGridGeometry* gridGeometry_;
219 using Cache = FCDiamondGridGeometryCache;
227 dofMapper_.update(this->
gridView());
230 const auto numElements = this->
gridView().size(0);
231 cache_.scvs_.resize(numElements);
232 cache_.scvfs_.resize(numElements);
233 cache_.hasBoundaryScvf_.resize(numElements,
false);
237 numBoundaryScvf_ = 0;
244 const auto geometry =
element.geometry();
245 GeometryHelper geometryHelper(geometry);
248 cache_.scvs_[eIdx].reserve(geometryHelper.
numScv());
249 numScv_ += geometryHelper.
numScv();
250 for (LocalIndexType localScvIdx = 0; localScvIdx < geometryHelper.
numScv(); ++localScvIdx)
253 const auto& corners = geometryHelper.
getScvCorners(localScvIdx);
255 SubControlVolume::Traits::geometryType(geometry.type()),
256 [&](
unsigned int i){ return corners[i]; }
259 cache_.scvs_[eIdx].emplace_back(
270 LocalIndexType localScvfIdx = 0;
273 for (; localScvfIdx < geometryHelper.
numInteriorScvf(); ++localScvfIdx)
275 const auto& corners = geometryHelper.
getScvfCorners(localScvfIdx);
278 SubControlVolumeFace::Traits::interiorGeometryType(geometry.type()),
279 [&](
unsigned int i){
return corners[i]; }
282 cache_.scvfs_[eIdx].emplace_back(
285 geometryHelper.
normal(corners, scvPair),
292 for (
const auto& intersection : intersections(this->
gridView(),
element))
294 if (onDomainBoundary_(intersection))
296 cache_.hasBoundaryScvf_[eIdx] =
true;
298 const LocalIndexType localFacetIndex = intersection.indexInInside();
299 const auto geo = intersection.geometry();
300 cache_.scvfs_[eIdx].emplace_back(
303 intersection.centerUnitOuterNormal(),
304 std::array<LocalIndexType, 2>{{localFacetIndex, localFacetIndex}},
306 typename SubControlVolumeFace::Traits::BoundaryFlag{ intersection }
316 if (onPeriodicBoundary_(intersection))
318 const LocalIndexType localFacetIndex = intersection.indexInInside();
323 const auto& otherElement = intersection.outside();
325 LocalIndexType otherIntersectionLocalIdx = 0;
326 bool periodicFaceFound =
false;
328 for (
const auto& otherIntersection : intersections(this->
gridView(), otherElement))
330 if (periodicFaceFound)
333 if (Dune::FloatCmp::eq(intersection.centerUnitOuterNormal()*otherIntersection.centerUnitOuterNormal(), -1.0, 1e-7))
335 const auto periodicDofIdx =
dofMapper().subIndex(otherElement, otherIntersectionLocalIdx, 1);
336 periodicFaceMap_[dofIndex] = periodicDofIdx;
337 periodicFaceFound =
true;
340 ++otherIntersectionLocalIdx;
347 bool onDomainBoundary_(
const typename GridView::Intersection& intersection)
const
349 return !intersection.neighbor() && intersection.boundary();
352 bool onProcessorBoundary_(
const typename GridView::Intersection& intersection)
const
354 return !intersection.neighbor() && !intersection.boundary();
357 bool onPeriodicBoundary_(
const typename GridView::Intersection& intersection)
const
359 return intersection.boundary() && intersection.neighbor();
362 DofMapper dofMapper_;
365 std::size_t numScvf_;
366 std::size_t numBoundaryScvf_;
369 std::unordered_map<GridIndexType, GridIndexType> periodicFaceMap_;
371 const FeCache feCache_;
Defines the default element and vertex mapper types.
Defines the index types used for grid and local indices.
Define some often used mathematical functions.
Check the overlap size for different discretization methods.
Base class for grid geometries.
Helper classes to compute the integration elements.
The available discretization methods in Dumux.
A finite element cache for the non-conforming FE spaces RT and CR.
Compute the center point of a convex polytope geometry or a random-access container of corner points.
Compute the volume of several common geometry types.
auto volume(const Geometry &geo, unsigned int integrationOrder=4)
The volume of a given geometry.
Definition volume.hh:171
auto convexPolytopeVolume(Dune::GeometryType type, const CornerF &c)
Compute the volume of several common geometry types.
Definition volume.hh:53
Corners::value_type center(const Corners &corners)
The center of a given list of corners.
Definition center.hh:36
BaseGridGeometry(std::shared_ptr< BaseImplementation > impl)
Constructor from a BaseImplementation.
Definition basegridgeometry.hh:81
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition adapt.hh:29
typename Extrusion< T >::type Extrusion_t
Convenience alias for obtaining the extrusion type.
Definition extrusion.hh:251
Definition deprecated.hh:149
CVFE< CVFEMethods::CR_RT > FCDiamond
Definition method.hh:90
Definition defaultmappertraits.hh:35
typename GridView::IndexSet::IndexType GridIndex
Definition indextraits.hh:39
std::uint_least8_t SmallLocalIndex
Definition indextraits.hh:41
const ElementMapper & elementMapper() const
Returns the mapper for elements to indices for constant grids.
Definition basegridgeometry.hh:121
void setPeriodic(bool value=true)
Set the periodicity of the grid geometry.
Definition basegridgeometry.hh:178
Element element(GridIndexType eIdx) const
Definition basegridgeometry.hh:151
const GridView & gridView() const
Definition basegridgeometry.hh:109
void update(const GridView &gridView)
Update all fvElementGeometries (call this after grid adaption).
Definition basegridgeometry.hh:97
Element-wise grid geometry (local view).
Definition discretization/facecentered/diamond/fvelementgeometry.hh:44
The default traits for the face-centered diamond finite volume grid geometry Defines the scv and scvf...
Definition discretization/facecentered/diamond/fvgridgeometry.hh:59
FaceCenteredDiamondSubControlVolume< GridView > SubControlVolume
Definition discretization/facecentered/diamond/fvgridgeometry.hh:60
Dune::MultipleCodimMultipleGeomTypeMapper< GridView > DofMapper
Definition discretization/facecentered/diamond/fvgridgeometry.hh:62
FaceCenteredDiamondFVElementGeometry< GridGeometry, enableCache > LocalView
Definition discretization/facecentered/diamond/fvgridgeometry.hh:65
FaceCenteredDiamondSubControlVolumeFace< GridView > SubControlVolumeFace
Definition discretization/facecentered/diamond/fvgridgeometry.hh:61
Grid geometry for the diamond discretization.
Definition discretization/facecentered/diamond/fvgridgeometry.hh:77
static constexpr bool cachingEnabled
Definition discretization/facecentered/diamond/fvgridgeometry.hh:96
friend LocalView localView(const FaceCenteredDiamondFVGridGeometry &gg)
local view of this object (constructed with the internal cache)
Definition discretization/facecentered/diamond/fvgridgeometry.hh:173
DiscretizationMethods::FCDiamond DiscretizationMethod
Definition discretization/facecentered/diamond/fvgridgeometry.hh:94
GridIndexType periodicallyMappedDof(GridIndexType dofIdx) const
The index of the d.o.f. on the other side of the periodic boundary.
Definition discretization/facecentered/diamond/fvgridgeometry.hh:165
FaceCenteredDiamondFVGridGeometry(const GridView &gridView, const std::string ¶mGroup="")
Constructor.
Definition discretization/facecentered/diamond/fvgridgeometry.hh:114
GV GridView
Definition discretization/facecentered/diamond/fvgridgeometry.hh:105
std::size_t numScv() const
The total number of sub control volumes.
Definition discretization/facecentered/diamond/fvgridgeometry.hh:123
FCDiamondGridGeometryCache Cache
Definition discretization/facecentered/diamond/fvgridgeometry.hh:219
typename Traits::SubControlVolumeFace SubControlVolumeFace
Definition discretization/facecentered/diamond/fvgridgeometry.hh:103
bool dofOnPeriodicBoundary(GridIndexType dofIdx) const
If a d.o.f. is on a periodic boundary.
Definition discretization/facecentered/diamond/fvgridgeometry.hh:161
const FeCache & feCache() const
The finite element cache for creating local FE bases.
Definition discretization/facecentered/diamond/fvgridgeometry.hh:153
Extrusion_t< Traits > Extrusion
Definition discretization/facecentered/diamond/fvgridgeometry.hh:109
const std::unordered_map< GridIndexType, GridIndexType > & periodicVertexMap() const
Returns the map between dofs across periodic boundaries // TODO rename to periodic dof map in fvassem...
Definition discretization/facecentered/diamond/fvgridgeometry.hh:169
static constexpr DiscretizationMethod discMethod
Definition discretization/facecentered/diamond/fvgridgeometry.hh:95
std::size_t numBoundaryScvf() const
The total number of boundary sub control volume faces.
Definition discretization/facecentered/diamond/fvgridgeometry.hh:131
std::size_t numDofs() const
the total number of dofs
Definition discretization/facecentered/diamond/fvgridgeometry.hh:135
void update(GridView &&gridView)
update all fvElementGeometries (call this after grid adaption)
Definition discretization/facecentered/diamond/fvgridgeometry.hh:146
const DofMapper & dofMapper() const
Return a reference to the dof mapper.
Definition discretization/facecentered/diamond/fvgridgeometry.hh:157
NonconformingFECache< Scalar, Scalar, dim > FeCache
Definition discretization/facecentered/diamond/fvgridgeometry.hh:111
typename Traits::template LocalView< ThisType, true > LocalView
Definition discretization/facecentered/diamond/fvgridgeometry.hh:99
typename Traits::SubControlVolume SubControlVolume
Definition discretization/facecentered/diamond/fvgridgeometry.hh:101
std::size_t numScvf() const
The total number of sub control volume faces.
Definition discretization/facecentered/diamond/fvgridgeometry.hh:127
void update(const GridView &gridView)
update all fvElementGeometries (call this after grid adaption)
Definition discretization/facecentered/diamond/fvgridgeometry.hh:139
typename Traits::DofMapper DofMapper
Definition discretization/facecentered/diamond/fvgridgeometry.hh:107
Helper class to construct SCVs and SCVFs for the diamond scheme.
Definition discretization/facecentered/diamond/geometryhelper.hh:267
GlobalPosition facetCenter(unsigned int localFacetIndex) const
Definition discretization/facecentered/diamond/geometryhelper.hh:356
ScvfCornerStorage getScvfCorners(unsigned int localEdgeIndex) const
Create a corner storage with the scvf corners for a given edge (codim-2) index.
Definition discretization/facecentered/diamond/geometryhelper.hh:315
std::size_t numInteriorScvf()
number of interior sub control volume faces (number of codim-2 entities)
Definition discretization/facecentered/diamond/geometryhelper.hh:377
std::array< LocalIndexType, 2 > getInsideOutsideScvForScvf(unsigned int localEdgeIndex)
Definition discretization/facecentered/diamond/geometryhelper.hh:361
ScvCornerStorage getScvCorners(unsigned int localFacetIndex) const
Create a corner storage with the scv corners for a given face (codim-1) index.
Definition discretization/facecentered/diamond/geometryhelper.hh:287
GlobalPosition normal(const ScvfCornerStorage &p, const std::array< LocalIndexType, 2 > &scvPair)
Definition discretization/facecentered/diamond/geometryhelper.hh:389
std::size_t numScv()
number of sub control volumes (number of codim-1 entities)
Definition discretization/facecentered/diamond/geometryhelper.hh:383
Face centered diamond subcontrolvolume face.
Definition discretization/facecentered/diamond/subcontrolvolume.hh:74
The SCVF implementation for diamond.
Definition discretization/facecentered/diamond/subcontrolvolumeface.hh:75
Definition nonconformingfecache.hh:41
Element-wise grid geometry (local view).
Face centered diamond subcontrolvolume face.
The SCVF implementation for diamond.
Helper class to construct SCVs and SCVFs for the diamond scheme.