Dune Core Modules (2.8.0)

yaspgridpersistentcontainer.hh
Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_GRID_YASPGRIDPERSISTENTCONTAINER_HH
4#define DUNE_GRID_YASPGRIDPERSISTENTCONTAINER_HH
5
10#include <cassert>
11#include <vector>
12
13#include <dune/grid/utility/persistentcontainer.hh>
14#include <dune/grid/utility/persistentcontainervector.hh>
15#include "../yaspgrid.hh"
16
17namespace Dune
18{
19
31 template<typename Grid>
33 {
34
35 public:
36 YaspPersistentContainerIndex(const Grid & grid, int codim)
37 : _grid(grid), _codim(codim)
38 {
39 recomputeOffsets();
40 }
41
43 typedef std::size_t IndexType;
44
46 template<class Entity>
47 IndexType index (const Entity& e) const
48 {
49 static const int cc = Entity::codimension;
50 std::size_t level = e.level();
51 return _grid.indexsets[level]->template index<cc>(e) + _offsets[level];
52 }
53
55 template< class Entity >
56 IndexType subIndex ( const Entity &e, int i, unsigned int codim ) const
57 {
58
59 static const int cc = Entity::codimension;
60 std::size_t level = e.level();
61 return _grid.indexsets[level]->template subIndex<cc>(e,i,codim) + _offsets[level];
62 }
63
65 std::size_t size (int /* codim */) const
66 {
67 if (_grid.indexsets.size()+1 != _offsets.size())
68 recomputeOffsets();
69 return _offsets.back();
70 }
71
72 private:
73 void recomputeOffsets() const
74 {
75 _offsets.resize(_grid.indexsets.size()+1,0);
76 _offsets[0] = 0;
77 for (std::size_t i=0; i<_grid.indexsets.size(); i++)
78 _offsets[i+1] = _offsets[i] + _grid.indexsets[i]->size(_codim);
79 }
80
81 const Grid& _grid;
82 int _codim;
83 mutable std::vector<std::size_t> _offsets;
84 };
85
92 template<int dim, class CoordCont, class T>
93 class PersistentContainer< YaspGrid<dim, CoordCont>, T >
94 /* We have to pass the reference to the IndexSet to the constructor
95 of the PersistentContainerVector. In order to have a valid
96 indexset available, we inherit from a private indexset
97 */
98 : private YaspPersistentContainerIndex< const YaspGrid<dim, CoordCont> >,
99 public PersistentContainerVector< YaspGrid<dim, CoordCont>,
100 YaspPersistentContainerIndex< const YaspGrid<dim, CoordCont> >,
101 std::vector<T> >
102 {
105
106 public:
107 typedef typename Base::Grid Grid;
108 typedef typename Base::Value Value;
109
110 using Base::size;
111
112 PersistentContainer ( const Grid &grid, int codim, const Value &value = Value() )
113 : IndexSet(grid, codim),
114 Base(*this, codim, value)
115 {}
116 };
117
118} // end namespace Dune
119
120#endif // end DUNE_GRID_YASPGRIDPERSISTENTCONTAINER_HH
Wrapper class for entities.
Definition: entity.hh:64
@ codimension
Know your own codimension.
Definition: entity.hh:105
int level() const
The level of this entity.
Definition: entity.hh:126
Grid abstract base class.
Definition: grid.hh:372
int size(int level, int codim) const
Return number of grid entities of a given codim on a given level in this process.
Definition: grid.hh:541
vector-based implementation of the PersistentContainer
Definition: persistentcontainervector.hh:49
A class for storing data during an adaptation cycle.
Definition: persistentcontainer.hh:20
[ provides Dune::Grid ]
Definition: yaspgrid.hh:160
implement a consecutive index for all entities of given codim of a YaspGrid
Definition: yaspgridpersistentcontainer.hh:33
IndexType index(const Entity &e) const
Map entity to index. The result of calling this method with an entity that is not in the index set is...
Definition: yaspgridpersistentcontainer.hh:47
std::size_t size(int) const
Return total number of entities of given geometry type in entity set .
Definition: yaspgridpersistentcontainer.hh:65
IndexType subIndex(const Entity &e, int i, unsigned int codim) const
Map a subentity to an index.
Definition: yaspgridpersistentcontainer.hh:56
std::size_t IndexType
The type used for the indices.
Definition: yaspgridpersistentcontainer.hh:43
Dune namespace.
Definition: alignedallocator.hh:11
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 21, 23:30, 2024)