version 3.8
reservedblockvector.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3//
4// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12#ifndef DUMUX_RESERVED_BLOCK_VECTOR_HH
13#define DUMUX_RESERVED_BLOCK_VECTOR_HH
14
15#include <algorithm>
16#include <dune/common/reservedvector.hh>
17
18namespace Dumux {
19
24template<class BlockType, int capacity>
25class ReservedBlockVector : public Dune::ReservedVector<BlockType, capacity>
26{
27 using Base = Dune::ReservedVector<BlockType, capacity>;
28public:
29
30 using size_type = typename Base::size_type;
31 using value_type = BlockType;
32
33 using Base::Base;
34
35 explicit ReservedBlockVector() : Base() {}
36 explicit ReservedBlockVector(size_type size) : Base() { this->resize(size); }
37
40
43
45
47 ReservedBlockVector& operator= (const typename BlockType::field_type& v)
48 {
49 std::fill(this->begin(), this->end(), v);
50 return *this;
51 }
52
55 {
56 for (size_type i = 0; i < this->size(); ++i)
57 (*this)[i] += other[i];
58 return *this;
59 }
60
63 {
64 for (size_type i = 0; i < this->size(); ++i)
65 (*this)[i] -= other[i];
66 return *this;
67 }
68
70 ReservedBlockVector& operator/= (const typename BlockType::field_type& v)
71 {
72 for (size_type i = 0; i < this->size(); ++i)
73 (*this)[i] /= v;
74 return *this;
75 }
76
78 ReservedBlockVector& operator*= (const typename BlockType::field_type& v)
79 {
80 for (size_type i = 0; i < this->size(); ++i)
81 (*this)[i] *= v;
82 return *this;
83 }
84};
85
86} // end namespace Dumux
87
88#endif
A arithmetic block vector type based on DUNE's reserved vector.
Definition: reservedblockvector.hh:26
ReservedBlockVector(const ReservedBlockVector &)=default
ReservedBlockVector & operator=(const ReservedBlockVector &)=default
ReservedBlockVector & operator-=(const ReservedBlockVector &other)
vector space subtraction
Definition: reservedblockvector.hh:62
ReservedBlockVector & operator+=(const ReservedBlockVector &other)
vector space addition
Definition: reservedblockvector.hh:54
ReservedBlockVector & operator/=(const typename BlockType::field_type &v)
division by scalar
Definition: reservedblockvector.hh:70
typename Base::size_type size_type
Definition: reservedblockvector.hh:30
ReservedBlockVector(ReservedBlockVector &&)=default
ReservedBlockVector()
Definition: reservedblockvector.hh:35
BlockType value_type
Definition: reservedblockvector.hh:31
ReservedBlockVector(size_type size)
Definition: reservedblockvector.hh:36
ReservedBlockVector & operator*=(const typename BlockType::field_type &v)
multiplication by scalar
Definition: reservedblockvector.hh:78
Definition: adapt.hh:17