1 #ifndef DUNE_FEM_SIMPLEBLOCKVECTOR_HH
2 #define DUNE_FEM_SIMPLEBLOCKVECTOR_HH
8 #include <dune/common/densevector.hh>
9 #include <dune/common/dynvector.hh>
18 #include <dune/istl/bvector.hh>
37 template<
class Imp,
class Field >
55 if( &
asImp() != &other )
67 const auto endit =
asImp().end();
68 auto oit = other.
begin();
69 for(
auto it =
asImp().begin(); it != endit; ++it, ++oit )
80 const auto endit =
asImp().end();
81 auto oit = other.
begin();
82 for(
auto it =
asImp().begin(); it != endit; ++it, ++oit )
94 const auto endit =
asImp().end();
96 for(
auto it =
asImp().begin(); it != endit; ++it, ++oit )
109 const auto endit =
asImp().end();
110 for(
auto it =
asImp().begin(); it != endit; ++it )
126 assert(
asImp().size() == other.
size() );
127 const auto endit =
asImp().end();
128 auto oit = other.
begin();
129 for(
auto it =
asImp().begin(); it != endit; ++it, ++oit )
130 *it += scalar * (*oit);
147 assert(
asImp().size() == other.
size() );
166 template<
class Container,
int BlockSize >
168 :
public BlockVectorInterface< SimpleBlockVector< Container, BlockSize>, typename Container::value_type >
172 typedef Container ArrayType;
221 assert( i <
size() );
228 assert( i <
size() );
281 template<
class Container,
unsigned int BlockSize >
288 typedef Container ArrayType;
344 template<
class Field,
unsigned int BlockSize >
386 assert( container_ );
393 assert( container_ );
412 template<
class DofBlock >
418 typedef BlockVector< DofBlock > ArrayType;
421 typedef Dune::DynamicVector< DofBlock > ArrayType;
439 template <
class EmbeddedIterator,
class V>
441 :
public ForwardIteratorFacade< Iterator< EmbeddedIterator,V >, V >
446 mutable EmbeddedIterator
it_;
455 ,
const EmbeddedIterator&
end = EmbeddedIterator()
Definition: bindguard.hh:11
static constexpr std::decay_t< T > sum(T a)
Definition: utility.hh:33
Definition: defaultblockvectors.hh:26
Definition: defaultblockvectors.hh:40
CounterType sequence_
Definition: defaultblockvectors.hh:154
Field FieldType
Type of the field the dofs lie in.
Definition: defaultblockvectors.hh:50
Imp ThisType
Type of derived class (implementation)
Definition: defaultblockvectors.hh:47
const ThisType & operator*=(const FieldType &scalar)
Scale this block vector.
Definition: defaultblockvectors.hh:107
DebugCounter< size_t > CounterType
Definition: defaultblockvectors.hh:42
void axpy(const FieldType &scalar, const ThisType &other)
Add a scalar multiple of another block vector to this block vector.
Definition: defaultblockvectors.hh:124
ThisType & asImp()
Definition: defaultblockvectors.hh:151
BlockVectorInterface()
Definition: defaultblockvectors.hh:44
const ThisType & operator=(const ThisType &other)
Copy assignment operator.
Definition: defaultblockvectors.hh:53
FieldType operator*(const ThisType &other) const
Scalar product between *this and another block vector.
Definition: defaultblockvectors.hh:90
void assign(const ThisType &other)
Definition: defaultblockvectors.hh:145
const ThisType & asImp() const
Definition: defaultblockvectors.hh:152
const ThisType & operator-=(const ThisType &other)
Subtract another block vector from *this.
Definition: defaultblockvectors.hh:77
void clear()
Clear this block vector, i.e. set each dof to 0.
Definition: defaultblockvectors.hh:136
const ThisType & operator+=(const ThisType &other)
Add another block vector to *this.
Definition: defaultblockvectors.hh:64
This is the reference implementation of a block vector as it is expected as the second template param...
Definition: defaultblockvectors.hh:169
ArrayType::size_type SizeType
Used for indexing the blocks, for example.
Definition: defaultblockvectors.hh:186
SubVector< DofContainerType, StaticOffsetSubMapper< BlockSize > > DofBlockType
Type of one (mutable) block.
Definition: defaultblockvectors.hh:194
Fem::Envelope< DofBlockType > DofBlockPtrType
Definition: defaultblockvectors.hh:198
SizeType numDofs() const
Number of dofs in the block vector.
Definition: defaultblockvectors.hh:260
SizeType size() const
Number of blocks.
Definition: defaultblockvectors.hh:257
ArrayType DofContainerType
Definition: defaultblockvectors.hh:177
ArrayType::const_iterator ConstIteratorType
Constant iterator to iterate over the dofs.
Definition: defaultblockvectors.hh:184
ConstIteratorType end() const
Const-iterator pointing to the last dof.
Definition: defaultblockvectors.hh:254
ArrayType::value_type FieldType
Type of the field the dofs lie in.
Definition: defaultblockvectors.hh:180
Hybrid::IndexRange< int, blockSize > BlockIndices
Definition: defaultblockvectors.hh:204
ConstDofBlockPtrType blockPtr(const unsigned int i) const
Constant access for the i-th block.
Definition: defaultblockvectors.hh:233
ConstIteratorType begin() const
Const-iterator pointing to the first dof.
Definition: defaultblockvectors.hh:248
FieldType * data()
Definition: defaultblockvectors.hh:262
ArrayType & array_
Definition: defaultblockvectors.hh:269
ArrayType::iterator IteratorType
Iterator to iterate over the dofs.
Definition: defaultblockvectors.hh:182
IteratorType end()
Iterator pointing to the last dof.
Definition: defaultblockvectors.hh:251
const ArrayType & array() const
Definition: defaultblockvectors.hh:265
const FieldType * data() const
Definition: defaultblockvectors.hh:263
SimpleBlockVector(ArrayType &array)
Constructor.
Definition: defaultblockvectors.hh:207
DofBlockPtrType blockPtr(const unsigned int i)
Access the i-th block.
Definition: defaultblockvectors.hh:239
SizeType size_type
Typedef to make this class STL-compatible.
Definition: defaultblockvectors.hh:191
ArrayType & array()
Definition: defaultblockvectors.hh:266
@ blockSize
Definition: defaultblockvectors.hh:202
FieldType value_type
Typedef to make this class STL-compatible.
Definition: defaultblockvectors.hh:189
DofBlockType ConstDofBlockType
Type of one constant block.
Definition: defaultblockvectors.hh:196
IteratorType begin()
Iterator pointing to the first dof.
Definition: defaultblockvectors.hh:245
ConstDofBlockType operator[](const unsigned int i) const
Constant access the i-th block.
Definition: defaultblockvectors.hh:219
const ThisType & operator=(const ThisType &other)
Copy assignment operator.
Definition: defaultblockvectors.hh:212
Fem::Envelope< ConstDofBlockType > ConstDofBlockPtrType
Definition: defaultblockvectors.hh:199
Definition: defaultblockvectors.hh:284
MutableBlockVector(const ThisType &other)
Copy constructor.
Definition: defaultblockvectors.hh:303
void reserve(const int size)
Reserve memory.
Definition: defaultblockvectors.hh:322
BaseType ::SizeType SizeType
Definition: defaultblockvectors.hh:295
~MutableBlockVector()
Definition: defaultblockvectors.hh:309
MutableBlockVector(SizeType size)
Construct a block vector with 'size' blocks (not initialized)
Definition: defaultblockvectors.hh:298
void resize(SizeType size)
Resize the block vector.
Definition: defaultblockvectors.hh:328
MutableBlockVector(const ThisType &other)
Copy constructor.
Definition: defaultblockvectors.hh:369
void resize(SizeType size)
Resize the block vector.
Definition: defaultblockvectors.hh:391
std::unique_ptr< MutableContainer > container_
Definition: defaultblockvectors.hh:357
BaseType ::SizeType SizeType
Definition: defaultblockvectors.hh:360
MutableBlockVector(SizeType size)
Construct a block vector with 'size' blocks (not initialized)
Definition: defaultblockvectors.hh:363
StaticContainer & allocateContainer(const SizeType size)
Definition: defaultblockvectors.hh:399
void reserve(const int size)
Reserve memory.
Definition: defaultblockvectors.hh:384
Definition: defaultblockvectors.hh:415
ISTLBlockVector(ArrayType &array)
Constructor.
Definition: defaultblockvectors.hh:507
DofBlock ::value_type FieldType
Definition: defaultblockvectors.hh:436
ConstIteratorType begin() const
Definition: defaultblockvectors.hh:534
void reserve(const int size)
Reserve memory.
Definition: defaultblockvectors.hh:555
DofBlock DofBlockType
Definition: defaultblockvectors.hh:496
IteratorType end()
Definition: defaultblockvectors.hh:542
ArrayType & array()
Definition: defaultblockvectors.hh:567
DofBlockType & operator[](const unsigned int i)
Definition: defaultblockvectors.hh:526
const ThisType & operator=(const ThisType &other)
Copy assignment operator.
Definition: defaultblockvectors.hh:514
ConstDofBlockType * ConstDofBlockPtrType
Definition: defaultblockvectors.hh:500
ConstIteratorType end() const
Definition: defaultblockvectors.hh:543
ArrayType DofContainerType
Definition: defaultblockvectors.hh:431
DofBlockType * DofBlockPtrType
Definition: defaultblockvectors.hh:499
SizeType size() const
Definition: defaultblockvectors.hh:545
ISTLBlockVector(const ThisType &)=default
const ArrayType & array() const
Definition: defaultblockvectors.hh:568
ArrayType::value_type value_type
Typedef to make this class STL-compatible.
Definition: defaultblockvectors.hh:504
ArrayType::size_type SizeType
Definition: defaultblockvectors.hh:502
Iterator< typename ArrayType::ConstIterator, const FieldType > ConstIteratorType
Definition: defaultblockvectors.hh:494
Hybrid::IndexRange< int, blockSize > BlockIndices
Definition: defaultblockvectors.hh:434
IteratorType begin()
Definition: defaultblockvectors.hh:529
DofBlockPtrType blockPtr(const unsigned int i)
Definition: defaultblockvectors.hh:523
ISTLBlockVector()=default
Iterator< typename ArrayType::Iterator, FieldType > IteratorType
Definition: defaultblockvectors.hh:493
@ blockSize
Definition: defaultblockvectors.hh:433
const DofBlock ConstDofBlockType
Definition: defaultblockvectors.hh:497
ArrayType * array_
Definition: defaultblockvectors.hh:572
ConstDofBlockPtrType blockPtr(const unsigned int i) const
Definition: defaultblockvectors.hh:524
void resize(SizeType size)
Resize the block vector.
Definition: defaultblockvectors.hh:561
Definition: defaultblockvectors.hh:442
void increment()
go to next dof
Definition: defaultblockvectors.hh:474
EmbeddedIterator end_
Definition: defaultblockvectors.hh:448
EmbeddedIterator it_
Definition: defaultblockvectors.hh:446
FieldType & dereference() const
return dof
Definition: defaultblockvectors.hh:466
int index_
Definition: defaultblockvectors.hh:450
V FieldType
Definition: defaultblockvectors.hh:444
bool equals(const Iterator &other) const
compare
Definition: defaultblockvectors.hh:485
Iterator(const EmbeddedIterator &it, const EmbeddedIterator &end=EmbeddedIterator())
Default constructor.
Definition: defaultblockvectors.hh:453
An implementation of DenseVector which uses a C-array of fixed size as storage.
Definition: dynamicarray.hh:142
BaseType::size_type size_type
Definition: dynamicarray.hh:147
BaseType::value_type value_type
Definition: dynamicarray.hh:149
An implementation of DenseVector which uses a C-array of dynamic size as storage.
Definition: dynamicarray.hh:238
Definition: envelope.hh:11
An implementation of DenseVector to extract a portion, not necessarly contiguos, of a vector.
Definition: subvector.hh:165
Index mapper with static size which simply adds an offset to the index.
Definition: subvector.hh:123