24#ifndef DUMUX_DISCRETIZATION_BASE_GRID_GEOMETRY_HH
25#define DUMUX_DISCRETIZATION_BASE_GRID_GEOMETRY_HH
29#include <dune/grid/common/mcmgmapper.hh>
47template<
class GV,
class Traits>
54 static constexpr int dim = GV::dimension;
55 static constexpr int dimWorld = GV::dimensionworld;
58 using Element =
typename GV::template Codim<0>::Entity;
62 using Grid =
typename GV::Grid;
81 , bBoxMin_(std::numeric_limits<double>::max())
82 , bBoxMax_(-std::numeric_limits<double>::max())
84 computeGlobalBoundingBox_();
93 vertexMapper_.update();
94 elementMapper_.update();
97 computeGlobalBoundingBox_();
100 boundingBoxTree_.release();
108 {
return gridView_; }
114 {
return vertexMapper_; }
120 {
return elementMapper_; }
126 {
return vertexMapper_; }
132 {
return elementMapper_; }
139 if(!boundingBoxTree_)
142 boundingBoxTree_ = std::make_unique<BoundingBoxTree>
143 ( std::make_shared<ElementSet>(gridView_,
elementMapper(), elementMap_) );
146 return *boundingBoxTree_;
155 elementMap_ = std::make_shared<ElementMap>(gridView_.grid(), elementMapper_);
184 {
return periodic_; }
190 { periodic_ = value; }
195 void computeGlobalBoundingBox_()
198 for (
const auto& vertex : vertices(gridView_))
200 for (
int i=0; i<dimWorld; i++)
204 bBoxMin_[i] = min(bBoxMin_[i], vertex.geometry().corner(0)[i]);
205 bBoxMax_[i] = max(bBoxMax_[i], vertex.geometry().corner(0)[i]);
210 if (gridView_.comm().size() > 1)
212 for (
int i = 0; i < dimWorld; ++i)
214 bBoxMin_[i] = gridView_.comm().min(bBoxMin_[i]);
215 bBoxMax_[i] = gridView_.comm().max(bBoxMax_[i]);
228 mutable std::unique_ptr<BoundingBoxTree> boundingBoxTree_;
231 mutable std::shared_ptr<ElementMap> elementMap_;
238 bool periodic_ =
false;
A map from indices to entities using grid entity seeds.
An axis-aligned bounding box volume hierarchy for dune grids.
An interface for a set of geometric entities.
Defines the index types used for grid and local indices.
Free function to get the local view of a grid cache object.
BaseGridGeometry(const GridView &gridView)
Constructor computes the bouding box of the entire domain, for e.g. setting boundary conditions.
Definition: basegridgeometry.hh:77
Definition: common/pdesolver.hh:35
A map from indices to entities using grid entity seeds.
Definition: entitymap.hh:39
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
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:49
GV GridView
export the grid view type
Definition: basegridgeometry.hh:64
typename GV::Grid Grid
export the grid type
Definition: basegridgeometry.hh:62
const ElementMapper & elementMapper() const
Returns the mapper for elements to indices for constant grids.
Definition: basegridgeometry.hh:119
void setPeriodic(bool value=true)
Set the periodicity of the grid geometry.
Definition: basegridgeometry.hh:189
const GlobalCoordinate & bBoxMax() const
The coordinate of the corner of the GridView's bounding box with the largest values.
Definition: basegridgeometry.hh:177
const BoundingBoxTree & boundingBoxTree() const
Returns the bounding box tree of the grid.
Definition: basegridgeometry.hh:137
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
VertexMapper & vertexMapper()
Returns the mapper for vertices to indices for possibly adaptive grids.
Definition: basegridgeometry.hh:125
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
ElementMapper & elementMapper()
Returns the mapper for elements to indices for possibly adaptive grids.
Definition: basegridgeometry.hh:131
const GlobalCoordinate & bBoxMin() const
The coordinate of the corner of the GridView's bounding box with the smallest values.
Definition: basegridgeometry.hh:170
bool isPeriodic() const
Returns if the grid geometry is periodic (at all)
Definition: basegridgeometry.hh:183
typename Traits::VertexMapper VertexMapper
export the vertex mapper type
Definition: basegridgeometry.hh:70
typename Traits::ElementMapper ElementMapper
export the element mapper type
Definition: basegridgeometry.hh:68
typename Element::Geometry::GlobalCoordinate GlobalCoordinate
export the global coordinate type
Definition: basegridgeometry.hh:66
const ElementMap & elementMap() const
Returns the element index to element map.
Definition: basegridgeometry.hh:152