version 3.8
basegridgeometry.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3//
4// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12#ifndef DUMUX_DISCRETIZATION_BASE_GRID_GEOMETRY_HH
13#define DUMUX_DISCRETIZATION_BASE_GRID_GEOMETRY_HH
14
15#include <memory>
16#include <dune/common/std/type_traits.hh>
19
20// make the local view function available whenever we use the grid geometry
22
23namespace Dumux {
24
25namespace Detail {
26template<class T>
27using SpecifiesBaseGridGeometry = typename T::BasicGridGeometry;
28
29template<class T>
30using SpecifiesGeometryHelper = typename T::GeometryHelper;
31} // end namespace Detail
32
37template<class GV, class T>
38using BasicGridGeometry_t = Dune::Std::detected_or_t<
41 T
42>;
43
50template<class GV, class Traits>
52{
53 using GridIndexType = typename IndexTraits<GV>::GridIndex;
54 using Element = typename GV::template Codim<0>::Entity;
55 using BaseImplementation = BasicGridGeometry_t<GV, Traits>;
56public:
58 using Grid = typename BaseImplementation::Grid;
60 using GridView = typename BaseImplementation::GridView;
62 using GlobalCoordinate = typename BaseImplementation::GlobalCoordinate;
64 using ElementMapper = typename BaseImplementation::ElementMapper;
66 using VertexMapper = typename BaseImplementation::VertexMapper;
67
72 BaseGridGeometry(std::shared_ptr<BaseImplementation> impl)
73 : impl_(std::move(impl))
74 {}
75
82 : BaseGridGeometry(std::make_shared<BaseImplementation>(gridView))
83 {}
84
89 { impl_->update(gridView); }
90
95 { impl_->update(std::move(gridView)); }
96
100 const GridView& gridView() const
101 { return impl_->gridView(); }
102
107 { return impl_->vertexMapper(); }
108
113 { return impl_->elementMapper(); }
114
119 { return impl_->vertexMapper(); }
120
125 { return impl_->elementMapper(); }
126
130 decltype(auto) boundingBoxTree() const
131 { return impl_->boundingBoxTree(); }
132
136 decltype(auto) elementMap() const
137 { return impl_->elementMap(); }
138
142 Element element(GridIndexType eIdx) const
143 { return impl_->element(eIdx); }
144
150 { return impl_->bBoxMin(); }
151
157 { return impl_->bBoxMax(); }
158
162 bool isPeriodic() const
163 { return periodic_; }
164
165protected:
169 void setPeriodic(bool value = true)
170 { periodic_ = value; }
171
172private:
173 std::shared_ptr<BaseImplementation> impl_;
174
176 bool periodic_ = false;
177};
178
179} // end namespace Dumux
180
181#endif
A basic implementation of a grid geometry with some common interfaces.
Base class for all grid geometries.
Definition: basegridgeometry.hh:52
const ElementMapper & elementMapper() const
Returns the mapper for elements to indices for constant grids.
Definition: basegridgeometry.hh:112
void setPeriodic(bool value=true)
Set the periodicity of the grid geometry.
Definition: basegridgeometry.hh:169
typename BaseImplementation::GridView GridView
export the grid view type
Definition: basegridgeometry.hh:60
typename BaseImplementation::GlobalCoordinate GlobalCoordinate
export the global coordinate type
Definition: basegridgeometry.hh:62
typename BaseImplementation::ElementMapper ElementMapper
export the element mapper type
Definition: basegridgeometry.hh:64
const GlobalCoordinate & bBoxMax() const
The coordinate of the corner of the GridView's bounding box with the largest values.
Definition: basegridgeometry.hh:156
void update(GridView &&gridView)
Update all fvElementGeometries (call this after grid adaption)
Definition: basegridgeometry.hh:94
Element element(GridIndexType eIdx) const
Get an element from a global element index.
Definition: basegridgeometry.hh:142
typename BaseImplementation::Grid Grid
export the grid type
Definition: basegridgeometry.hh:58
decltype(auto) boundingBoxTree() const
Returns the bounding box tree of the grid.
Definition: basegridgeometry.hh:130
const VertexMapper & vertexMapper() const
Returns the mapper for vertices to indices for constant grids.
Definition: basegridgeometry.hh:106
VertexMapper & vertexMapper()
Returns the mapper for vertices to indices for possibly adaptive grids.
Definition: basegridgeometry.hh:118
const GridView & gridView() const
Return the gridView this grid geometry object lives on.
Definition: basegridgeometry.hh:100
ElementMapper & elementMapper()
Returns the mapper for elements to indices for possibly adaptive grids.
Definition: basegridgeometry.hh:124
void update(const GridView &gridView)
Update all fvElementGeometries (call this after grid adaption)
Definition: basegridgeometry.hh:88
const GlobalCoordinate & bBoxMin() const
The coordinate of the corner of the GridView's bounding box with the smallest values.
Definition: basegridgeometry.hh:149
bool isPeriodic() const
Returns if the grid geometry is periodic (at all)
Definition: basegridgeometry.hh:162
decltype(auto) elementMap() const
Returns the element index to element map.
Definition: basegridgeometry.hh:136
typename BaseImplementation::VertexMapper VertexMapper
export the vertex mapper type
Definition: basegridgeometry.hh:66
An implementation of a grid geometry with some basic features.
Definition: basicgridgeometry.hh:37
BaseGridGeometry(std::shared_ptr< BaseImplementation > impl)
Constructor from a BaseImplementation.
Definition: basegridgeometry.hh:72
BaseGridGeometry(const GridView &gridView)
Constructor from a grid view.
Definition: basegridgeometry.hh:81
Dune::Std::detected_or_t< Dumux::BasicGridGeometry< GV, typename T::ElementMapper, typename T::VertexMapper >, Detail::SpecifiesBaseGridGeometry, T > BasicGridGeometry_t
Type of the basic grid geometry implementation used as backend.
Definition: basegridgeometry.hh:42
Defines the index types used for grid and local indices.
Free function to get the local view of a grid cache object.
typename T::GeometryHelper SpecifiesGeometryHelper
Definition: basegridgeometry.hh:30
typename T::BasicGridGeometry SpecifiesBaseGridGeometry
Definition: basegridgeometry.hh:27
Definition: adapt.hh:17
Structure to define the index types used for grid and local indices.
Definition: indextraits.hh:26