OpenLB 1.7
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | List of all members
olb::Vector< T, D > Class Template Reference

Plain old scalar vector. More...

#include <vector.h>

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

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, IMPL >
using value_type = T
 

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
 
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.
 
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
 
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, IMPL >
constexpr GenericVector ()=default
 
 GenericVector (const GenericVector &)=delete
 
 GenericVector (GenericVector &&)=delete
 
GenericVectoroperator= (GenericVector &&rhs)=delete
 
constexpr const T & operator[] (unsigned iDim) const any_platform
 
constexpr T & operator[] (unsigned iDim) any_platform
 
template<typename IMPL_ >
constexpr IMPL & operator= (const GenericVector< T, D, IMPL_ > &rhs) any_platform
 
template<typename U , typename IMPL_ >
constexpr IMPL & operator+= (const GenericVector< U, D, IMPL_ > &rhs) any_platform
 
template<typename IMPL_ >
constexpr IMPL & operator-= (const GenericVector< T, D, IMPL_ > &rhs) any_platform
 
template<typename U , typename IMPL_ >
constexpr IMPL & operator*= (const GenericVector< U, D, IMPL_ > &rhs) any_platform
 
template<typename U >
constexpr meta::enable_if_arithmetic_t< U, IMPL & > operator+= (const U &rhs) any_platform
 
template<typename U >
constexpr meta::enable_if_arithmetic_t< U, IMPL & > operator-= (const U &rhs) any_platform
 
template<typename U >
constexpr meta::enable_if_arithmetic_t< U, IMPL & > operator*= (const U &rhs) any_platform
 
template<typename U >
constexpr meta::enable_if_arithmetic_t< U, IMPL & > operator/= (const U &rhs) any_platform
 
template<typename IMPL_ >
constexpr bool operator== (const GenericVector< T, D, IMPL_ > &rhs) const any_platform
 
template<typename IMPL_ >
constexpr bool operator!= (const GenericVector< T, D, IMPL_ > &rhs) const any_platform
 

Protected Member Functions

constexpr const T * getComponentPointer (unsigned iDim) const any_platform
 
constexpr T * getComponentPointer (unsigned iDim) any_platform
 

Additional Inherited Members

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

Detailed Description

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

Plain old scalar vector.

Definition at line 47 of file vector.h.

Member Typedef Documentation

◆ value_t

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

Definition at line 64 of file vector.h.

Constructor & Destructor Documentation

◆ Vector() [1/10]

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

Definition at line 66 of file vector.h.

66 :
67 _data{}
68 { }

◆ Vector() [2/10]

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

Definition at line 70 of file vector.h.

70 :
71 _data(rhs._data)
72 { }

◆ Vector() [3/10]

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

Definition at line 74 of file vector.h.

74 :
75 _data(rhs._data)
76 { }

◆ Vector() [4/10]

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

Definition at line 79 of file vector.h.

80 {
81 for (unsigned iDim=0; iDim < D; ++iDim) {
82 _data[iDim] = rhs[iDim];
83 }
84 }

◆ Vector() [5/10]

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

Definition at line 90 of file vector.h.

90 :
91 _data{T(indexes)...}
92 { }

◆ Vector() [6/10]

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

Definition at line 96 of file vector.h.

97 {
98 for (unsigned iDim=0; iDim < D; ++iDim) {
99 _data[iDim] = static_cast<T>(v[iDim]);
100 }
101 }

◆ Vector() [7/10]

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

Definition at line 104 of file vector.h.

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

References OLB_PRECONDITION.

◆ Vector() [8/10]

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

Definition at line 113 of file vector.h.

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

References OLB_PRECONDITION.

◆ Vector() [9/10]

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

Definition at line 120 of file vector.h.

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

◆ Vector() [10/10]

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

Construct with entries given by a lambda expression.

Definition at line 129 of file vector.h.

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

Member Function Documentation

◆ begin()

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

Definition at line 171 of file vector.h.

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

◆ data() [1/2]

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

Definition at line 166 of file vector.h.

167 {
168 return _data.data();
169 }

◆ data() [2/2]

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

Definition at line 161 of file vector.h.

162 {
163 return _data.data();
164 }
+ Here is the caller graph for this function:

◆ end()

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

Definition at line 176 of file vector.h.

177 {
178 return _data.end();
179 }
+ Here is the caller graph for this function:

◆ getBlock()

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

Definition at line 201 of file vector.h.

202 {
203 std::size_t currentBlock = 0;
204 bool* dataPtr = nullptr;
205 //registerVar(iBlock, sizeBlock, currentBlock, dataPtr, *_data.data(), D);
206 if (iBlock == currentBlock) {
207 sizeBlock = sizeof(T) * D;
208 dataPtr = (bool*) _data.data();
209 }
210 currentBlock++;
211 return dataPtr;
212 }
+ Here is the caller graph for this function:

◆ getComponentPointer() [1/2]

template<typename T , unsigned D>
constexpr T * olb::Vector< T, D >::getComponentPointer ( unsigned iDim)
inlineconstexprprotected

Definition at line 58 of file vector.h.

59 {
60 return &_data[iDim];
61 }

◆ getComponentPointer() [2/2]

template<typename T , unsigned D>
constexpr const T * olb::Vector< T, D >::getComponentPointer ( unsigned iDim) const
inlineconstexprprotected

Definition at line 54 of file vector.h.

55 {
56 return &_data[iDim];
57 }

◆ getDim()

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

Definition at line 181 of file vector.h.

182 {
183 return D;
184 }

◆ getNblock()

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

Definition at line 196 of file vector.h.

196{ return 1; }

◆ getSerializableSize()

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

Definition at line 197 of file vector.h.

198 {
199 return D * sizeof(T);
200 };
+ Here is the caller graph for this function:

◆ operator=() [1/3]

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

Definition at line 137 of file vector.h.

138 {
139 for (unsigned iDim=0; iDim < D; ++iDim) {
140 this->operator[](iDim) = rhs[iDim];
141 }
142 return *this;
143 }
constexpr const T & operator[](unsigned iDim) const any_platform

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

+ Here is the call graph for this function:

◆ operator=() [2/3]

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

Definition at line 153 of file vector.h.

154 {
155 for (unsigned iDim=0; iDim < D; ++iDim) {
156 _data[iDim] = rhs[iDim];
157 }
158 return *this;
159 }

◆ operator=() [3/3]

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

Definition at line 145 of file vector.h.

146 {
147 for (unsigned iDim=0; iDim < D; ++iDim) {
148 _data[iDim] = rhs[iDim];
149 }
150 return *this;
151 }

◆ withPrefix()

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

Definition at line 186 of file vector.h.

187 {
188 Vector<T,D+1> tmp;
189 tmp[0] = prefix;
190 for (unsigned iDim=0; iDim < D; ++iDim) {
191 tmp[iDim+1] = _data[iDim];
192 }
193 return tmp;
194 }

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