1#ifndef DUNE_FEM_SUBVECTOR_HH
2#define DUNE_FEM_SUBVECTOR_HH
6#include <dune/common/densevector.hh>
7#include <dune/common/ftraits.hh>
17 template<
class K,
class M >
class SubVector;
21 template<
class K,
class M >
22 struct DenseMatVecTraits< Fem::SubVector< K, M > >
27 typedef std::decay_t< decltype( std::declval< K >().size() ) >
size_type;
28 typedef std::decay_t< decltype( std::declval< K >()[ std::declval< size_type >() ] ) >
value_type;
31 template<
class K,
class M >
32 struct FieldTraits< Fem::SubVector< K, M > >
34 typedef typename FieldTraits< typename DenseMatVecTraits< Fem::SubVector< K, M > >::value_type >::field_type
field_type;
35 typedef typename FieldTraits< typename DenseMatVecTraits< Fem::SubVector< K, M > >::value_type >::real_type
real_type;
59 return asImp().operator[]( index );
65 return asImp().range();
71 return asImp().size();
89 : size_(
size ), offset_( offset )
111 const unsigned int size_;
112 const unsigned int offset_;
118 template<
unsigned int dim>
133 static constexpr unsigned int size()
138 static constexpr unsigned int range()
149 const unsigned int offset_;
159 template<
class BaseVectorImp,
class IndexMapperImp >
160 class SubVector :
public DenseVector< SubVector< BaseVectorImp, IndexMapperImp > >
163 typedef DenseVector< ThisType > BaseType;
169 using BaseType::operator=;
182 : baseVector_( baseVector ), indexMapper_( indexMapper )
186 : baseVector_( other.baseVector_ ), indexMapper_( other.indexMapper_ )
192 std::copy( other.begin(), other.end(), this->begin() );
198 std::fill( this->begin(), this->end(),
FieldType(0) );
206 return baseVector_[ indexMapper_[ i ] ];
211 return baseVector_[ indexMapper_[ i ] ];
216 return indexMapper_.size();
Definition: bindguard.hh:11
Definition: bartonnackmaninterface.hh:17
const Implementation & asImp() const
Definition: bartonnackmaninterface.hh:37
An implementation of DenseVector to extract a portion, not necessarly contiguos, of a vector.
Definition: subvector.hh:161
void resize(size_type)
Definition: subvector.hh:201
const value_type & operator[](size_type i) const
Definition: subvector.hh:204
SubVector(const ThisType &other)
Definition: subvector.hh:185
value_type & operator[](size_type i)
Definition: subvector.hh:209
ThisType & operator=(const ThisType &other)
Copy entries.
Definition: subvector.hh:190
BaseType::value_type value_type
Definition: subvector.hh:167
BaseType::size_type size_type
Definition: subvector.hh:166
size_type size() const
Definition: subvector.hh:214
void clear()
Definition: subvector.hh:196
BaseVectorImp BaseVectorType
Type of the base vector.
Definition: subvector.hh:172
value_type FieldType
Type of vector elements.
Definition: subvector.hh:178
IndexMapperImp IndexMapperType
Type of the index mapper.
Definition: subvector.hh:175
SubVector(BaseVectorType &baseVector, IndexMapperType &&indexMapper)
Constructor.
Definition: subvector.hh:181
std::decay_t< decltype(std::declval< K >()[std::declval< size_type >()]) > value_type
Definition: subvector.hh:28
std::decay_t< decltype(std::declval< K >().size()) > size_type
Definition: subvector.hh:27
K container_type
Definition: subvector.hh:25
Fem::SubVector< K, M > derived_type
Definition: subvector.hh:24
FieldTraits< typenameDenseMatVecTraits< Fem::SubVector< K, M > >::value_type >::real_type real_type
Definition: subvector.hh:35
FieldTraits< typenameDenseMatVecTraits< Fem::SubVector< K, M > >::value_type >::field_type field_type
Definition: subvector.hh:34
Abstract index mapper interface.
Definition: subvector.hh:45
unsigned int operator[](unsigned int index) const
Maps an index onto another one.
Definition: subvector.hh:57
unsigned int size() const
Returns the map's size.
Definition: subvector.hh:69
const Implementation & asImp() const
Definition: bartonnackmaninterface.hh:37
ThisType IndexMapperInterfaceType
Type of the interface.
Definition: subvector.hh:54
unsigned int range() const
Returns the map's range.
Definition: subvector.hh:63
IM IndexMapperType
Type of the implementation (Barton-Nackman)
Definition: subvector.hh:51
Index mapper which simply adds an offset to the index.
Definition: subvector.hh:83
OffsetSubMapper(ThisType &&)=default
OffsetSubMapper(unsigned int size, unsigned int offset)
Definition: subvector.hh:88
unsigned int size() const
Definition: subvector.hh:95
unsigned int operator[](unsigned int i) const
Definition: subvector.hh:105
unsigned int range() const
Definition: subvector.hh:100
OffsetSubMapper(const ThisType &)=default
Index mapper with static size which simply adds an offset to the index.
Definition: subvector.hh:121
StaticOffsetSubMapper(ThisType &&)=default
static constexpr unsigned int size()
Definition: subvector.hh:133
StaticOffsetSubMapper(const ThisType &)=default
StaticOffsetSubMapper(unsigned int offset)
Definition: subvector.hh:126
unsigned int operator[](unsigned int i) const
Definition: subvector.hh:143
static constexpr unsigned int range()
Definition: subvector.hh:138