DUNE-FEM (unstable)

geometrytypemap.hh
1#ifndef DUNE_FEM_COMMON_GEOMETRYTYPEMAP_HH
2#define DUNE_FEM_COMMON_GEOMETRYTYPEMAP_HH
3
4#include <array>
5#include <type_traits>
6#include <utility>
7
10
11namespace Dune
12{
13
14 // GeometryTypeMap
15 // ---------------
16
41 template< class T, int dim, class TypeIndex >
43 {
45 typedef std::array< T, TypeIndex::size( dim ) > Container;
46
47 public:
49 typedef typename Container::value_type value_type;
51 typedef typename Container::reference reference;
53 typedef typename Container::const_reference const_reference;
55 typedef typename Container::pointer pointer;
57 typedef typename Container::const_pointer const_pointer;
59 typedef typename Container::iterator iterator;
61 typedef typename Container::const_iterator const_iterator;
63 typedef typename Container::size_type size_type;
65 typedef typename Container::difference_type difference_type;
66
74 typedef size_type Size;
75
82 GeometryTypeMap () : container_() {}
83
85 GeometryTypeMap ( const This & ) = default;
86
88 GeometryTypeMap ( This && ) = default;
89
91 This &operator= ( const This & ) = default;
92
94 This &operator= ( This && ) = default;
95
104 Iterator begin () noexcept { return container_.begin(); }
106 Iterator end () noexcept { return container_.end(); }
108 ConstIterator begin () const noexcept { return container_.begin(); }
110 ConstIterator end () const noexcept { return container_.end(); }
111
113 ConstIterator cbegin () const noexcept { return container_.cbegin(); }
115 ConstIterator cend () const noexcept { return container_.cend(); }
116
125 constexpr Size size () const noexcept { return TypeIndex::size( dim ); }
127 constexpr Size max_size () const noexcept { return size(); }
129 constexpr bool empty () const noexcept { return (size() > 0); }
130
138 Value &operator[] ( const GeometryType &type ) { return container_[ TypeIndex::index( type ) ]; }
140 const Value &operator[] ( const GeometryType &type ) const { return container_[ TypeIndex::index( type ) ]; }
141
143 Value &at ( const GeometryType &type ) { return container_.at( TypeIndex::index( type ) ); }
145 const Value &at ( const GeometryType &type ) const { return container_.at( TypeIndex::index( type ) ); }
146
148 Value &front () { return container_.front(); }
150 const Value &front () const { return container_.front(); }
151
153 Value &back () { return container_.back(); }
155 const Value &back () const { return container_.back(); }
156
158 Value *data () noexcept { return container_.data(); }
160 const Value *data () const noexcept { return container_.data(); }
161
169 void fill ( const Value &value ) { container_.fill( value ); }
170
172 void swap ( This &other ) noexcept(noexcept(swap(std::declval<Value &>(), std::declval<Value &>())))
173 {
174 container_.swap( other.container_ );
175 }
176
179 private:
180 Container container_;
181 };
182
183
184
185 // LocalGeometryTypeMap
186 // --------------------
187
196 template< class T, int dim >
197 using LocalGeometryTypeMap = GeometryTypeMap< T, dim, LocalGeometryTypeIndex >;
198
199
200
201 // GlobalGeometryTypeMap
202 // ---------------------
203
212 template< class T, int maxdim >
213 using GlobalGeometryTypeMap = GeometryTypeMap< T, maxdim, GlobalGeometryTypeIndex >;
214
215} // namespace Dune
216
217#endif // #ifndef DUNE_FEM_COMMON_GEOMETRYTYPEMAP_HH
associative container assigning values to each GeometryType
Definition: geometrytypemap.hh:43
iterator Iterator
iterator type
Definition: geometrytypemap.hh:70
const Value & back() const
access last element
Definition: geometrytypemap.hh:155
constexpr Size max_size() const noexcept
return maximum size
Definition: geometrytypemap.hh:127
Container::size_type size_type
size type
Definition: geometrytypemap.hh:63
Container::const_iterator const_iterator
const iterator type
Definition: geometrytypemap.hh:61
void fill(const Value &value)
fill container with value
Definition: geometrytypemap.hh:169
void swap(This &other) noexcept(noexcept(swap(std::declval< Value & >(), std::declval< Value & >())))
swap content
Definition: geometrytypemap.hh:172
GeometryTypeMap(const This &)=default
copy constructor
ConstIterator begin() const noexcept
return iterator to beginning
Definition: geometrytypemap.hh:108
value_type Value
value type
Definition: geometrytypemap.hh:68
This & operator=(const This &)=default
copy assignment
Container::const_reference const_reference
const reference type
Definition: geometrytypemap.hh:53
Iterator end() noexcept
return iterator to end
Definition: geometrytypemap.hh:106
Value & operator[](const GeometryType &type)
access element
Definition: geometrytypemap.hh:138
Value & front()
access first element
Definition: geometrytypemap.hh:148
Value & back()
access last element
Definition: geometrytypemap.hh:153
Value * data() noexcept
get pointer to data
Definition: geometrytypemap.hh:158
Iterator begin() noexcept
return iterator to beginning
Definition: geometrytypemap.hh:104
Container::const_pointer const_pointer
const pointer type
Definition: geometrytypemap.hh:57
Container::difference_type difference_type
difference type
Definition: geometrytypemap.hh:65
GeometryTypeMap(This &&)=default
move constructor
const Value * data() const noexcept
get pointer to data
Definition: geometrytypemap.hh:160
constexpr bool empty() const noexcept
test whether container is empty
Definition: geometrytypemap.hh:129
Container::iterator iterator
iterator type
Definition: geometrytypemap.hh:59
constexpr Size size() const noexcept
return size
Definition: geometrytypemap.hh:125
GeometryTypeMap()
default constructor
Definition: geometrytypemap.hh:82
const Value & front() const
access first element
Definition: geometrytypemap.hh:150
ConstIterator cbegin() const noexcept
return const_iterator to beginning
Definition: geometrytypemap.hh:113
const_iterator ConstIterator
iterator type
Definition: geometrytypemap.hh:72
Container::pointer pointer
pointer type
Definition: geometrytypemap.hh:55
Container::reference reference
reference type
Definition: geometrytypemap.hh:51
size_type Size
size type
Definition: geometrytypemap.hh:74
ConstIterator end() const noexcept
return iterator to end
Definition: geometrytypemap.hh:110
Container::value_type value_type
value type
Definition: geometrytypemap.hh:49
const Value & at(const GeometryType &type) const
access element
Definition: geometrytypemap.hh:145
Value & at(const GeometryType &type)
access element
Definition: geometrytypemap.hh:143
ConstIterator cend() const noexcept
return const_iterator to end
Definition: geometrytypemap.hh:115
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:114
Please doc me.
Please doc me.
Dune namespace.
Definition: alignedallocator.hh:13
A unique label for each type of element that can occur in a grid.
Helper classes to provide indices for geometrytypes for use in a vector.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 24, 22:29, 2024)