OpenLB 1.8.1
Loading...
Searching...
No Matches
olb::Vector< T, Size > Class Template Reference

Plain old scalar vector. More...

#include <vector.h>

+ Inheritance diagram for olb::Vector< T, Size >:
+ Collaboration diagram for olb::Vector< T, Size >:

Public Types

using value_t = T
 
- Public Types inherited from olb::ScalarVector< T, D, Vector< T, D > >
using type
 
- Public Types inherited from olb::GenericVector< T, D, Vector< T, D > >
using value_type
 

Public Member Functions

constexpr Vector () any_platform
 
constexpr Vector (const Vector &rhs) any_platform
 
constexpr Vector (Vector &&rhs) any_platform
 
template<typename W , typename IMPL >
constexpr Vector (const ScalarVector< W, D, IMPL > &rhs) any_platform
 
template<typename... I, typename std::enable_if_t<(sizeof...(I) > 1 &&(meta::is_arithmetic< I >::value &&...) &&sizeof...(I)==D), int > = 0>
constexpr Vector (I... indexes) any_platform
 
template<typename U >
constexpr Vector (const U *v) any_platform
 Construct from Array-of-Structures element at v.
 
constexpr Vector (const Vector< T *, D > &ref, std::size_t idx) any_platform
 Construct from Structure-of-Arrays addresses given by ref and index idx.
 
constexpr Vector (const std::vector< T > &v)
 
constexpr Vector (std::initializer_list< T > v)
 
constexpr Vector (T scalar) any_platform
 
template<typename F , typename = decltype(std::declval<F&>()(std::size_t{0}))>
constexpr Vector (F &&f) any_platform
 Construct with entries given by a lambda expression.
 
constexpr const T * getComponentPointer (unsigned iDim) const any_platform
 
constexpr T * getComponentPointer (unsigned iDim) any_platform
 
template<typename U , typename IMPL_ >
constexpr Vectoroperator= (const GenericVector< U, D, IMPL_ > &rhs) any_platform
 
constexpr Vectoroperator= (const Vector &rhs) any_platform
 
constexpr Vectoroperator= (const Vector &&rhs) any_platform
 
constexpr const T * data () const any_platform
 
constexpr T * data () any_platform
 
constexpr auto begin ()
 
constexpr auto end ()
 
constexpr int getDim () const any_platform
 
constexpr Vector< T, D+1 > withPrefix (T prefix) const any_platform
 Return new (prefix,this...) vector.
 
constexpr Vector< T, D-1 > withoutPrefix () const any_platform
 Return vector without first element.
 
template<unsigned E>
constexpr Vector< T, D+E > append (const Vector< T, E > &rhs) const any_platform
 Return new (this..., rhs...) vector.
 
constexpr std::size_t getNblock () const
 
constexpr std::size_t getSerializableSize () const
 
bool * getBlock (std::size_t iBlock, std::size_t &sizeBlock, bool loadingMode)
 
- Public Member Functions inherited from olb::ScalarVector< T, D, Vector< T, D > >
constexpr ScalarVector ()=default
 
 ScalarVector (const ScalarVector &)=delete
 
 ScalarVector (ScalarVector &&)=delete
 
- Public Member Functions inherited from olb::GenericVector< T, D, Vector< T, D > >
constexpr GenericVector ()=default
 
 GenericVector (const GenericVector &)=delete
 
 GenericVector (GenericVector &&)=delete
 
GenericVectoroperator= (GenericVector &&rhs)=delete
 
constexpr Vector< T, D > & operator= (const GenericVector< T, D, IMPL_ > &rhs) any_platform
 
constexpr const T & operator[] (unsigned iDim) const any_platform
 
constexpr T & operator[] (unsigned iDim) any_platform
 
constexpr Vector< T, D > & operator+= (const GenericVector< U, D, IMPL_ > &rhs) any_platform
 
constexpr meta::enable_if_arithmetic_t< U, Vector< T, D > & > operator+= (const U &rhs) any_platform
 
constexpr Vector< T, D > & operator-= (const GenericVector< T, D, IMPL_ > &rhs) any_platform
 
constexpr meta::enable_if_arithmetic_t< U, Vector< T, D > & > operator-= (const U &rhs) any_platform
 
constexpr Vector< T, D > & operator*= (const GenericVector< U, D, IMPL_ > &rhs) any_platform
 
constexpr meta::enable_if_arithmetic_t< U, Vector< T, D > & > operator*= (const U &rhs) any_platform
 
constexpr meta::enable_if_arithmetic_t< U, Vector< T, D > & > operator/= (const U &rhs) any_platform
 
constexpr bool operator== (const GenericVector< T, D, IMPL_ > &rhs) const any_platform
 
constexpr bool operator!= (const GenericVector< T, D, IMPL_ > &rhs) const any_platform
 
constexpr bool operator!= (T rhs) const any_platform
 

Additional Inherited Members

- Static Public Member Functions inherited from olb::GenericVector< T, D, Vector< T, D > >
static constexpr unsigned size ()
 
- Static Public Attributes inherited from olb::GenericVector< T, D, Vector< T, D > >
static constexpr unsigned d
 

Detailed Description

template<typename T, unsigned Size>
class olb::Vector< T, Size >

Plain old scalar vector.

Definition at line 41 of file vectorHelpers.h.

Member Typedef Documentation

◆ value_t

template<typename T , unsigned Size>
using olb::Vector< T, Size >::value_t = T

Definition at line 57 of file vector.h.

Constructor & Destructor Documentation

◆ Vector() [1/11]

template<typename T , unsigned Size>
olb::Vector< T, Size >::Vector ( )
inlineconstexpr

Definition at line 59 of file vector.h.

59 :
60 _data{}
61 { }

◆ Vector() [2/11]

template<typename T , unsigned Size>
olb::Vector< T, Size >::Vector ( const Vector< T, Size > & rhs)
inlineconstexpr

Definition at line 63 of file vector.h.

63 :
64 _data(rhs._data)
65 { }

◆ Vector() [3/11]

template<typename T , unsigned Size>
olb::Vector< T, Size >::Vector ( Vector< T, Size > && rhs)
inlineconstexpr

Definition at line 67 of file vector.h.

67 :
68 _data(rhs._data)
69 { }

◆ Vector() [4/11]

template<typename T , unsigned Size>
template<typename W , typename IMPL >
olb::Vector< T, Size >::Vector ( const ScalarVector< W, D, IMPL > & rhs)
inlineconstexpr

Definition at line 72 of file vector.h.

73 {
74 for (unsigned iDim=0; iDim < D; ++iDim) {
75 _data[iDim] = rhs[iDim];
76 }
77 }

◆ Vector() [5/11]

template<typename T , unsigned Size>
template<typename... I, typename std::enable_if_t<(sizeof...(I) > 1 &&(meta::is_arithmetic< I >::value &&...) &&sizeof...(I)==D), int > = 0>
olb::Vector< T, Size >::Vector ( I... indexes)
inlineconstexpr

Definition at line 83 of file vector.h.

83 :
84 _data{T(indexes)...}
85 { }

◆ Vector() [6/11]

template<typename T , unsigned Size>
template<typename U >
olb::Vector< T, Size >::Vector ( const U * v)
inlineconstexpr

Construct from Array-of-Structures element at v.

Definition at line 89 of file vector.h.

90 {
91 for (unsigned iDim=0; iDim < D; ++iDim) {
92 _data[iDim] = static_cast<T>(v[iDim]);
93 }
94 }

◆ Vector() [7/11]

template<typename T , unsigned Size>
olb::Vector< T, Size >::Vector ( const Vector< T *, D > & ref,
std::size_t idx )
inlineexplicitconstexpr

Construct from Structure-of-Arrays addresses given by ref and index idx.

Definition at line 97 of file vector.h.

98 {
99 for (unsigned iDim=0; iDim < D; ++iDim) {
100 _data[iDim] = ref[iDim][idx];
101 }
102 }

◆ Vector() [8/11]

template<typename T , unsigned Size>
olb::Vector< T, Size >::Vector ( const std::vector< T > & v)
inlineconstexpr

Definition at line 105 of file vector.h.

106 {
107 OLB_PRECONDITION(v.size() == D);
108 for (unsigned iDim=0; iDim < D; ++iDim) {
109 _data[iDim] = v[iDim];
110 }
111 }
#define OLB_PRECONDITION(COND)
Definition olbDebug.h:46

References OLB_PRECONDITION.

◆ Vector() [9/11]

template<typename T , unsigned Size>
olb::Vector< T, Size >::Vector ( std::initializer_list< T > v)
inlineconstexpr

Definition at line 114 of file vector.h.

115 {
116 OLB_PRECONDITION(v.size() == D);
117 std::copy(v.begin(), v.end(), _data.begin());
118 }

References OLB_PRECONDITION.

◆ Vector() [10/11]

template<typename T , unsigned Size>
olb::Vector< T, Size >::Vector ( T scalar)
inlineconstexpr

Definition at line 121 of file vector.h.

122 {
123 for (unsigned iDim=0; iDim < D; ++iDim) {
124 _data[iDim] = scalar;
125 }
126 }

◆ Vector() [11/11]

template<typename T , unsigned Size>
template<typename F , typename = decltype(std::declval<F&>()(std::size_t{0}))>
olb::Vector< T, Size >::Vector ( F && f)
inlineconstexpr

Construct with entries given by a lambda expression.

Definition at line 130 of file vector.h.

131 {
132 for (unsigned iDim=0; iDim < D; ++iDim) {
133 _data[iDim] = f(iDim);
134 }
135 }

Member Function Documentation

◆ append()

template<typename T , unsigned Size>
template<unsigned E>
Vector< T, D+E > olb::Vector< T, Size >::append ( const Vector< T, E > & rhs) const
inlineconstexpr

Return new (this..., rhs...) vector.

Definition at line 220 of file vector.h.

221 {
222 Vector<T,D+E> tmp;
223 for (unsigned iDim=0; iDim < D; ++iDim) {
224 tmp[iDim] = _data[iDim];
225 }
226 for (unsigned iDim=0; iDim < E; ++iDim) {
227 tmp[iDim+D] = rhs[iDim];
228 }
229 return tmp;
230 }
constexpr Vector() any_platform
Definition vector.h:59

◆ begin()

template<typename T , unsigned Size>
auto olb::Vector< T, Size >::begin ( )
inlineconstexpr

Definition at line 182 of file vector.h.

183 {
184 return _data.begin();
185 }

◆ data() [1/2]

template<typename T , unsigned Size>
T * olb::Vector< T, Size >::data ( )
inlineconstexpr

Definition at line 177 of file vector.h.

178 {
179 return _data.data();
180 }

◆ data() [2/2]

template<typename T , unsigned Size>
const T * olb::Vector< T, Size >::data ( ) const
inlineconstexpr

Definition at line 172 of file vector.h.

173 {
174 return _data.data();
175 }
+ Here is the caller graph for this function:

◆ end()

template<typename T , unsigned Size>
auto olb::Vector< T, Size >::end ( )
inlineconstexpr

Definition at line 187 of file vector.h.

188 {
189 return _data.end();
190 }

◆ getBlock()

template<typename T , unsigned Size>
bool * olb::Vector< T, Size >::getBlock ( std::size_t iBlock,
std::size_t & sizeBlock,
bool loadingMode )
inline

Definition at line 237 of file vector.h.

238 {
239 std::size_t currentBlock = 0;
240 bool* dataPtr = nullptr;
241 //registerVar(iBlock, sizeBlock, currentBlock, dataPtr, *_data.data(), D);
242 if (iBlock == currentBlock) {
243 sizeBlock = sizeof(T) * D;
244 dataPtr = (bool*) _data.data();
245 }
246 currentBlock++;
247 return dataPtr;
248 }

◆ getComponentPointer() [1/2]

template<typename T , unsigned Size>
T * olb::Vector< T, Size >::getComponentPointer ( unsigned iDim)
inlineconstexpr

Definition at line 142 of file vector.h.

143 {
144 return &_data[iDim];
145 }

◆ getComponentPointer() [2/2]

template<typename T , unsigned Size>
const T * olb::Vector< T, Size >::getComponentPointer ( unsigned iDim) const
inlineconstexpr

Definition at line 137 of file vector.h.

138 {
139 return &_data[iDim];
140 }

◆ getDim()

template<typename T , unsigned Size>
int olb::Vector< T, Size >::getDim ( ) const
inlineconstexpr

Definition at line 192 of file vector.h.

193 {
194 return D;
195 }

◆ getNblock()

template<typename T , unsigned Size>
std::size_t olb::Vector< T, Size >::getNblock ( ) const
inlineconstexpr

Definition at line 232 of file vector.h.

232{ return 1; }

◆ getSerializableSize()

template<typename T , unsigned Size>
std::size_t olb::Vector< T, Size >::getSerializableSize ( ) const
inlineconstexpr

Definition at line 233 of file vector.h.

234 {
235 return D * sizeof(T);
236 };
+ Here is the caller graph for this function:

◆ operator=() [1/3]

template<typename T , unsigned Size>
template<typename U , typename IMPL_ >
Vector & olb::Vector< T, Size >::operator= ( const GenericVector< U, D, IMPL_ > & rhs)
inlineconstexpr

Definition at line 148 of file vector.h.

149 {
150 for (unsigned iDim=0; iDim < D; ++iDim) {
151 this->operator[](iDim) = rhs[iDim];
152 }
153 return *this;
154 }
constexpr const T & operator[](unsigned iDim) const any_platform

References olb::GenericVector< T, D, Vector< T, D > >::operator[]().

+ Here is the call graph for this function:

◆ operator=() [2/3]

template<typename T , unsigned Size>
Vector & olb::Vector< T, Size >::operator= ( const Vector< T, Size > && rhs)
inlineconstexpr

Definition at line 164 of file vector.h.

165 {
166 for (unsigned iDim=0; iDim < D; ++iDim) {
167 _data[iDim] = rhs[iDim];
168 }
169 return *this;
170 }

◆ operator=() [3/3]

template<typename T , unsigned Size>
Vector & olb::Vector< T, Size >::operator= ( const Vector< T, Size > & rhs)
inlineconstexpr

Definition at line 156 of file vector.h.

157 {
158 for (unsigned iDim=0; iDim < D; ++iDim) {
159 _data[iDim] = rhs[iDim];
160 }
161 return *this;
162 }

◆ withoutPrefix()

template<typename T , unsigned Size>
Vector< T, D-1 > olb::Vector< T, Size >::withoutPrefix ( ) const
inlineconstexpr

Return vector without first element.

Definition at line 209 of file vector.h.

210 {
211 Vector<T,D-1> tmp{};
212 for (unsigned iDim=1; iDim < D; ++iDim) {
213 tmp[iDim-1] = _data[iDim];
214 }
215 return tmp;
216 }
+ Here is the caller graph for this function:

◆ withPrefix()

template<typename T , unsigned Size>
Vector< T, D+1 > olb::Vector< T, Size >::withPrefix ( T prefix) const
inlineconstexpr

Return new (prefix,this...) vector.

Definition at line 198 of file vector.h.

199 {
200 Vector<T,D+1> tmp;
201 tmp[0] = prefix;
202 for (unsigned iDim=0; iDim < D; ++iDim) {
203 tmp[iDim+1] = _data[iDim];
204 }
205 return tmp;
206 }
+ Here is the caller graph for this function:

The documentation for this class was generated from the following files: