24#ifndef DUMUX_DISCRETIZATION_BASE_GRID_GEOMETRY_HH
25#define DUMUX_DISCRETIZATION_BASE_GRID_GEOMETRY_HH
30#include <dune/grid/common/mcmgmapper.hh>
49template<
class GV,
class Traits>
56 static constexpr int dim = GV::dimension;
57 static constexpr int dimWorld = GV::dimensionworld;
60 using Element =
typename GV::template Codim<0>::Entity;
64 using Grid =
typename GV::Grid;
81 , elementMapper_(makeElementMapper_(
gridView))
82 , vertexMapper_(makeVertexMapper_(
gridView))
83 , bBoxMin_(std::numeric_limits<double>::max())
84 , bBoxMax_(-std::numeric_limits<double>::max())
86 computeGlobalBoundingBox_();
93 [[deprecated(
"Use update(gridView) instead! Will be removed after release 3.5.")]]
121 {
return gridView_; }
127 {
return vertexMapper_; }
133 {
return elementMapper_; }
139 {
return vertexMapper_; }
145 {
return elementMapper_; }
151 {
return *boundingBoxTree_; }
157 {
return *elementMap_; }
183 {
return periodic_; }
189 { periodic_ = value; }
196 if constexpr (std::is_constructible<ElementMapper, GridView, Dune::MCMGLayout>())
205 if constexpr (std::is_constructible<VertexMapper, GridView, Dune::MCMGLayout>())
212 void computeGlobalBoundingBox_()
215 for (
const auto& vertex : vertices(gridView_))
217 for (
int i=0; i<dimWorld; i++)
221 bBoxMin_[i] = min(bBoxMin_[i],
vertex.geometry().corner(0)[i]);
222 bBoxMax_[i] = max(bBoxMax_[i],
vertex.geometry().corner(0)[i]);
227 if (gridView_.comm().size() > 1)
229 for (
int i = 0; i < dimWorld; ++i)
231 bBoxMin_[i] = gridView_.comm().min(bBoxMin_[i]);
232 bBoxMax_[i] = gridView_.comm().max(bBoxMax_[i]);
240 if constexpr (Deprecated::hasUpdateGridView<ElementMapper, GridView>())
241 elementMapper_.update(gridView_);
243 Deprecated::update(elementMapper_);
245 if constexpr (Deprecated::hasUpdateGridView<VertexMapper, GridView>())
246 vertexMapper_.update(gridView_);
248 Deprecated::update(vertexMapper_);
251 computeGlobalBoundingBox_();
257 elementMap_ = std::make_shared<ElementMap>(gridView_.grid(), elementMapper_);
258 boundingBoxTree_ = std::make_unique<BoundingBoxTree>(
259 std::make_shared<ElementSet>(gridView_,
elementMapper(), elementMap_)
271 std::unique_ptr<const BoundingBoxTree> boundingBoxTree_;
274 std::shared_ptr<const ElementMap> elementMap_;
281 bool periodic_ =
false;
A map from indices to entities using grid entity seeds.
Defines the index types used for grid and local indices.
Free function to get the local view of a grid cache object.
An axis-aligned bounding box volume hierarchy for dune grids.
An interface for a set of geometric entities.
BaseGridGeometry(const GridView &gridView)
Constructor computes the bounding box of the entire domain, for e.g. setting boundary conditions.
Definition: basegridgeometry.hh:79
A map from indices to entities using grid entity seeds.
Definition: entitymap.hh:39
Struture to define the index types used for grid and local indices.
Definition: indextraits.hh:38
Base class for all finite volume grid geometries.
Definition: basegridgeometry.hh:51
GV GridView
export the grid view type
Definition: basegridgeometry.hh:66
typename GV::Grid Grid
export the grid type
Definition: basegridgeometry.hh:64
const ElementMapper & elementMapper() const
Returns the mapper for elements to indices for constant grids.
Definition: basegridgeometry.hh:132
void setPeriodic(bool value=true)
Set the periodicity of the grid geometry.
Definition: basegridgeometry.hh:188
const GlobalCoordinate & bBoxMax() const
The coordinate of the corner of the GridView's bounding box with the largest values.
Definition: basegridgeometry.hh:176
void update(GridView &&gridView)
Update all fvElementGeometries (call this after grid adaption)
Definition: basegridgeometry.hh:111
const BoundingBoxTree & boundingBoxTree() const
Returns the bounding box tree of the grid.
Definition: basegridgeometry.hh:150
Element element(GridIndexType eIdx) const
Get an element from a global element index.
Definition: basegridgeometry.hh:162
const VertexMapper & vertexMapper() const
Returns the mapper for vertices to indices for constant grids.
Definition: basegridgeometry.hh:126
VertexMapper & vertexMapper()
Returns the mapper for vertices to indices for possibly adaptive grids.
Definition: basegridgeometry.hh:138
const GridView & gridView() const
Return the gridView this grid geometry object lives on.
Definition: basegridgeometry.hh:120
void update()
Update all fvElementGeometries (do this again after grid adaption)
Definition: basegridgeometry.hh:94
ElementMapper & elementMapper()
Returns the mapper for elements to indices for possibly adaptive grids.
Definition: basegridgeometry.hh:144
void update(const GridView &gridView)
Update all fvElementGeometries (call this after grid adaption)
Definition: basegridgeometry.hh:102
const GlobalCoordinate & bBoxMin() const
The coordinate of the corner of the GridView's bounding box with the smallest values.
Definition: basegridgeometry.hh:169
bool isPeriodic() const
Returns if the grid geometry is periodic (at all)
Definition: basegridgeometry.hh:182
typename Traits::VertexMapper VertexMapper
export the vertex mapper type
Definition: basegridgeometry.hh:72
typename Traits::ElementMapper ElementMapper
export the element mapper type
Definition: basegridgeometry.hh:70
typename Element::Geometry::GlobalCoordinate GlobalCoordinate
export the global coordinate type
Definition: basegridgeometry.hh:68
const ElementMap & elementMap() const
Returns the element index to element map.
Definition: basegridgeometry.hh:156
An axis-aligned bounding box volume tree implementation.
Definition: boundingboxtree.hh:66
An interface for a set of geometric entities based on a GridView.
Definition: geometricentityset.hh:42