3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
geometricentityset.hh
Go to the documentation of this file.
1/*****************************************************************************
2 * See the file COPYING for full copying permissions. *
3 * *
4 * This program is free software: you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation, either version 3 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
16 *****************************************************************************/
24#ifndef DUMUX_GRIDVIEW_GEOMETRIC_ENTITY_SET_HH
25#define DUMUX_GRIDVIEW_GEOMETRIC_ENTITY_SET_HH
26
27#include <memory>
28#include <dune/grid/common/mcmgmapper.hh>
30
31namespace Dumux {
32
39template <class GridView, int codim = 0, class Mapper = Dune::MultipleCodimMultipleGeomTypeMapper<GridView>>
41{
43public:
44 using Entity = typename GridView::template Codim<codim>::Entity;
45
46 GridViewGeometricEntitySet(const GridView& gridView)
47 : GridViewGeometricEntitySet(gridView, Mapper(gridView, Dune::mcmgLayout(Dune::Codim<codim>())))
48 {}
49
50 GridViewGeometricEntitySet(const GridView& gridView, const Mapper& mapper)
51 : gridView_(gridView)
52 , mapper_(mapper)
53 , entityMap_(std::make_shared<EntityMap>(gridView.grid(), mapper_))
54 {}
55
56 GridViewGeometricEntitySet(const GridView& gridView,
57 const Mapper& mapper,
58 std::shared_ptr<const EntityMap> entityMap)
59 : gridView_(gridView)
60 , mapper_(mapper)
61 , entityMap_(entityMap)
62 {}
63
67 enum { dimensionworld = GridView::dimensionworld };
68
72 using ctype = typename GridView::ctype;
73
77 decltype(auto) size() const
78 { return gridView_.size(codim); }
79
83 decltype(auto) begin() const
84 { return entities(gridView_, Dune::Codim<codim>()).begin(); }
85
89 decltype(auto) end() const
90 { return entities(gridView_, Dune::Codim<codim>()).end(); }
91
95 std::size_t index(const Entity& e) const
96 { return mapper_.index(e); }
97
101 Entity entity(std::size_t index) const
102 { return (*entityMap_)[index]; }
103
104private:
105 GridView gridView_;
106 Mapper mapper_;
107 std::shared_ptr<const EntityMap> entityMap_;
108
109};
110
111} // end namespace Dumux
112
113#endif
A map from indices to entities using grid entity seeds.
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
Definition: common/properties/model.hh:34
A map from indices to entities using grid entity seeds.
Definition: entitymap.hh:39
An interface for a set of geometric entities.
Definition: geometricentityset.hh:41
typename GridView::ctype ctype
the coordinate type
Definition: geometricentityset.hh:72
GridViewGeometricEntitySet(const GridView &gridView, const Mapper &mapper)
Definition: geometricentityset.hh:50
std::size_t index(const Entity &e) const
get an entities index
Definition: geometricentityset.hh:95
typename GridView::template Codim< codim >::Entity Entity
Definition: geometricentityset.hh:44
decltype(auto) size() const
the number of entities in this set
Definition: geometricentityset.hh:77
GridViewGeometricEntitySet(const GridView &gridView)
Definition: geometricentityset.hh:46
Entity entity(std::size_t index) const
get an entity from an index
Definition: geometricentityset.hh:101
decltype(auto) end() const
end iterator to enable range-based for iteration
Definition: geometricentityset.hh:89
GridViewGeometricEntitySet(const GridView &gridView, const Mapper &mapper, std::shared_ptr< const EntityMap > entityMap)
Definition: geometricentityset.hh:56
decltype(auto) begin() const
begin iterator to enable range-based for iteration
Definition: geometricentityset.hh:83
@ dimensionworld
Definition: geometricentityset.hh:67