Documentation 6b54b78464
Loading...
Searching...
No Matches
CSysVector< ScalarType > Class Template Reference

Class for holding and manipulating vectors needed by linear solvers. More...

#include <CSysVector.hpp>

Inheritance diagram for CSysVector< ScalarType >:
[legend]

Public Member Functions

 CSysVector ()=default
 Required by CVecExpr.
 
 ~CSysVector ()
 Destructor.
 
 CSysVector (unsigned long size, ScalarType val=0.0)
 Construct from size and value.
 
 CSysVector (unsigned long numBlk, unsigned long numBlkDomain, unsigned long numVar, ScalarType val=0.0)
 Construct from size and value (block version).
 
 CSysVector (unsigned long size, const ScalarType *u_array)
 Construct from array.
 
 CSysVector (unsigned long numBlk, unsigned long numBlkDomain, unsigned long numVar, const ScalarType *u_array)
 Constructor from array (block version).
 
 CSysVector (const CSysVector &u)
 Copy constructor of the class.
 
void swap (CSysVector &other)
 Swap contents with another vector.
 
void Initialize (unsigned long numBlk, unsigned long numBlkDomain, unsigned long numVar, ScalarType val=0.0)
 Initialize the class with a scalar.
 
void Initialize (unsigned long numBlk, unsigned long numBlkDomain, unsigned long numVar, const ScalarType *ptr)
 Initialize the class with an array.
 
template<class T >
void PassiveCopy (const CSysVector< T > &other)
 Set our values (resizing if required) by copying from other, the derivative information is lost.
 
void HtDTransfer (bool trigger=true) const
 Performs the memory copy from host to device.
 
void DtHTransfer (bool trigger=true) const
 Performs the memory copy from device to host.
 
ScalarType * GetDevicePointer () const
 return device pointer that points to the CSysVector values in GPU memory
 
const ScalarType * GetHostPointer () const
 return host pointer that points to the CSysVector values, counterpart of GetDevicePointer
 
unsigned long GetLocSize () const
 return the number of local elements in the CSysVector
 
unsigned long GetNElmDomain () const
 return the number of local elements in the CSysVector without ghost cells
 
unsigned long GetNVar () const
 return the number of variables at each block (typically number per node)
 
unsigned long GetNBlk () const
 return the number of blocks (typically number of nodes locally)
 
unsigned long GetNBlkDomain () const
 return the number of blocks (typically number of nodes locally)
 
ScalarType & operator[] (unsigned long i)
 Access operator with assignment permitted.
 
const ScalarType & operator[] (unsigned long i) const
 
const ScalarType * begin () const
 Iterators for range for loops.
 
const ScalarType * end () const
 
ScalarType & operator() (unsigned long iPoint, unsigned long iVar)
 Access operator with assignment permitted block version.
 
const ScalarType & operator() (unsigned long iPoint, unsigned long iVar) const
 
CSysVector & operator= (const CSysVector &other)
 Assignment operator from another vector.
 
CSysVector & operator= (ScalarType val)
 
template<class T >
CSysVector & operator= (const VecExpr::CVecExpr< T, ScalarType > &expr)
 
CSysVector & operator+= (ScalarType val)
 
template<class T >
CSysVector & operator+= (const VecExpr::CVecExpr< T, ScalarType > &expr)
 
CSysVector & operator-= (ScalarType val)
 
template<class T >
CSysVector & operator-= (const VecExpr::CVecExpr< T, ScalarType > &expr)
 
CSysVector & operator*= (ScalarType val)
 
template<class T >
CSysVector & operator*= (const VecExpr::CVecExpr< T, ScalarType > &expr)
 
CSysVector & operator/= (ScalarType val)
 
template<class T >
CSysVector & operator/= (const VecExpr::CVecExpr< T, ScalarType > &expr)
 
void SetValZero (void)
 Sets to zero all the entries of the vector.
 
template<class T >
ScalarType dot (const VecExpr::CVecExpr< T, ScalarType > &expr) const
 Dot product between "this" and an expression.
 
ScalarType squaredNorm () const
 Squared L2 norm of the vector (via dot with self).
 
ScalarType norm () const
 L2 norm of the vector.
 
ScalarType * GetBlock (unsigned long iPoint)
 Get pointer to a block.
 
const ScalarType * GetBlock (unsigned long iPoint) const
 
void SetBlock_Zero (unsigned long iPoint)
 Set the values to zero for one block.
 
template<class VectorType , bool Overwrite = true>
void SetBlock (unsigned long iPoint, const VectorType &block, ScalarType alpha=1)
 Set "block" to the vector.
 
template<class VectorType >
void AddBlock (unsigned long iPoint, const VectorType &block, ScalarType alpha=1)
 Add "block" to the vector, see SetBlock.
 
template<class VectorType >
void SubtractBlock (unsigned long iPoint, const VectorType &block)
 Subtract "block" from the vector, see AddBlock.
 
template<class VectorType >
void UpdateBlocks (unsigned long iPoint, unsigned long jPoint, const VectorType &block, ScalarType alpha=1)
 Add to iPoint, subtract from jPoint.
 
template<size_t N, class T , class VecTypeSIMD , class F = ScalarType>
void SetBlock (simd::Array< T, N > iPoint, const VecTypeSIMD &vector, simd::Array< F, N > mask=1)
 Vectorized version of SetBlock, sets multiple iPoint's.
 
template<size_t N, class T , class VecTypeSIMD , class F = ScalarType>
void UpdateBlocks (simd::Array< T, N > iPoint, simd::Array< T, N > jPoint, const VecTypeSIMD &vector, simd::Array< F, N > mask=1)
 Vectorized version of UpdateBlocks, updates multiple i/jPoint's.
 
- Public Member Functions inherited from VecExpr::CVecExpr< CSysVector< ScalarType >, ScalarType >
const CSysVector< ScalarType > & derived () const
 Cast the expression to Derived, usually to allow evaluation via operator[].
 

Static Public Member Functions

static const su2matrix< ScalarType > & multiDot (const std::vector< CSysVector > &V, size_t i0, size_t n, const std::vector< CSysVector > &W, size_t m)
 Computes the product of V^T W efficiencly, where V and W are tall matrices stored as vectors of CSysVector.
 

Static Public Attributes

static constexpr bool StoreAsRef = true
 

Related Symbols

(Note that these are not member symbols.)

Squared norm
 

Detailed Description

template<class ScalarType>
class CSysVector< ScalarType >

Class for holding and manipulating vectors needed by linear solvers.

Constructor & Destructor Documentation

◆ CSysVector() [1/6]

template<class ScalarType >
CSysVector< ScalarType >::CSysVector ( )
default

Required by CVecExpr.

Default constructor of the class.

◆ ~CSysVector()

template<class ScalarType >
CSysVector< ScalarType >::~CSysVector ( )

Destructor.

◆ CSysVector() [2/6]

template<class ScalarType >
CSysVector< ScalarType >::CSysVector ( unsigned long  size,
ScalarType  val = 0.0 
)
inlineexplicit

Construct from size and value.

Parameters
[in]size- Number of elements locally.
[in]val- Default value for elements.

◆ CSysVector() [3/6]

template<class ScalarType >
CSysVector< ScalarType >::CSysVector ( unsigned long  numBlk,
unsigned long  numBlkDomain,
unsigned long  numVar,
ScalarType  val = 0.0 
)
inline

Construct from size and value (block version).

Parameters
[in]numBlk- Number of blocks locally.
[in]numBlkDomain- Number of blocks locally (without ghost cells).
[in]numVar- Number of variables in each block.
[in]val- Default value for elements.

◆ CSysVector() [4/6]

template<class ScalarType >
CSysVector< ScalarType >::CSysVector ( unsigned long  size,
const ScalarType *  u_array 
)
inline

Construct from array.

Parameters
[in]size- Number of elements locally.
[in]u_array- Vector stored as array being copied.

◆ CSysVector() [5/6]

template<class ScalarType >
CSysVector< ScalarType >::CSysVector ( unsigned long  numBlk,
unsigned long  numBlkDomain,
unsigned long  numVar,
const ScalarType *  u_array 
)
inline

Constructor from array (block version).

Parameters
[in]numBlk- number of blocks locally
[in]numBlkDomain- number of blocks locally (without g cells)
[in]numVar- number of variables in each block
[in]u_array- vector stored as array being copied

◆ CSysVector() [6/6]

template<class ScalarType >
CSysVector< ScalarType >::CSysVector ( const CSysVector< ScalarType > &  u)
inline

Copy constructor of the class.

Note
Not defined for expressions because we do not know their sizes.
Parameters
[in]u- Vector being copied.

Member Function Documentation

◆ AddBlock()

template<class ScalarType >
template<class VectorType >
void CSysVector< ScalarType >::AddBlock ( unsigned long  iPoint,
const VectorType &  block,
ScalarType  alpha = 1 
)
inline

Add "block" to the vector, see SetBlock.

◆ begin()

template<class ScalarType >
const ScalarType * CSysVector< ScalarType >::begin ( ) const
inline

Iterators for range for loops.

◆ dot()

template<class ScalarType >
template<class T >
ScalarType CSysVector< ScalarType >::dot ( const VecExpr::CVecExpr< T, ScalarType > &  expr) const
inline

Dot product between "this" and an expression.

Parameters
[in]expr- Expression.
Returns
Result of dot product

◆ DtHTransfer()

template<class ScalarType >
void CSysVector< ScalarType >::DtHTransfer ( bool  trigger = true) const

Performs the memory copy from device to host.

Parameters
[in]trigger- boolean value that decides whether to conduct the transfer or not. True by default.

◆ end()

template<class ScalarType >
const ScalarType * CSysVector< ScalarType >::end ( ) const
inline

◆ GetBlock() [1/2]

template<class ScalarType >
ScalarType * CSysVector< ScalarType >::GetBlock ( unsigned long  iPoint)
inline

Get pointer to a block.

Parameters
[in]iPoint- Index of block.
Returns
Pointer to start of block.

◆ GetBlock() [2/2]

template<class ScalarType >
const ScalarType * CSysVector< ScalarType >::GetBlock ( unsigned long  iPoint) const
inline

◆ GetDevicePointer()

template<class ScalarType >
ScalarType * CSysVector< ScalarType >::GetDevicePointer ( ) const
inline

return device pointer that points to the CSysVector values in GPU memory

◆ GetHostPointer()

template<class ScalarType >
const ScalarType * CSysVector< ScalarType >::GetHostPointer ( ) const
inline

return host pointer that points to the CSysVector values, counterpart of GetDevicePointer

◆ GetLocSize()

template<class ScalarType >
unsigned long CSysVector< ScalarType >::GetLocSize ( ) const
inline

return the number of local elements in the CSysVector

◆ GetNBlk()

template<class ScalarType >
unsigned long CSysVector< ScalarType >::GetNBlk ( ) const
inline

return the number of blocks (typically number of nodes locally)

◆ GetNBlkDomain()

template<class ScalarType >
unsigned long CSysVector< ScalarType >::GetNBlkDomain ( ) const
inline

return the number of blocks (typically number of nodes locally)

◆ GetNElmDomain()

template<class ScalarType >
unsigned long CSysVector< ScalarType >::GetNElmDomain ( ) const
inline

return the number of local elements in the CSysVector without ghost cells

◆ GetNVar()

template<class ScalarType >
unsigned long CSysVector< ScalarType >::GetNVar ( ) const
inline

return the number of variables at each block (typically number per node)

◆ HtDTransfer()

template<class ScalarType >
void CSysVector< ScalarType >::HtDTransfer ( bool  trigger = true) const

Performs the memory copy from host to device.

Parameters
[in]trigger- boolean value that decides whether to conduct the transfer or not. True by default.

◆ Initialize() [1/2]

template<class ScalarType >
void CSysVector< ScalarType >::Initialize ( unsigned long  numBlk,
unsigned long  numBlkDomain,
unsigned long  numVar,
const ScalarType *  ptr 
)
inline

Initialize the class with an array.

Note
If ptr==nullptr no copy occurs.
Parameters
[in]numBlk- number of blocks locally
[in]numBlkDomain- number of blocks locally (without g cells)
[in]numVar- number of variables in each block
[in]ptr- pointer to data with which to initialize the vector

◆ Initialize() [2/2]

template<class ScalarType >
void CSysVector< ScalarType >::Initialize ( unsigned long  numBlk,
unsigned long  numBlkDomain,
unsigned long  numVar,
ScalarType  val = 0.0 
)
inline

Initialize the class with a scalar.

Parameters
[in]numBlk- number of blocks locally
[in]numBlkDomain- number of blocks locally (without g cells)
[in]numVar- number of variables in each block
[in]val- default value for elements

◆ multiDot()

template<class ScalarType >
const su2matrix< ScalarType > & CSysVector< ScalarType >::multiDot ( const std::vector< CSysVector< ScalarType > > &  V,
size_t  i0,
size_t  n,
const std::vector< CSysVector< ScalarType > > &  W,
size_t  m 
)
static

Computes the product of V^T W efficiencly, where V and W are tall matrices stored as vectors of CSysVector.

Parameters
[in]V- Tall matrix.
[in]i0- First column of V to consider.
[in]n- Number of columns to consider from V starting at i0.
[in]W- Tall matrix.
[in]m- Number of columns to consider from W.
Returns
n by m matrix with the result of the product.

◆ norm()

template<class ScalarType >
ScalarType CSysVector< ScalarType >::norm ( ) const
inline

L2 norm of the vector.

Returns
L2 norm.

◆ operator()() [1/2]

template<class ScalarType >
ScalarType & CSysVector< ScalarType >::operator() ( unsigned long  iPoint,
unsigned long  iVar 
)
inline

Access operator with assignment permitted block version.

Parameters
[in]iPoint- Index of block.
[in]iVar- Index of variable.
Returns
Value at position (i,j).

◆ operator()() [2/2]

template<class ScalarType >
const ScalarType & CSysVector< ScalarType >::operator() ( unsigned long  iPoint,
unsigned long  iVar 
) const
inline

◆ operator*=() [1/2]

template<class ScalarType >
template<class T >
CSysVector & CSysVector< ScalarType >::operator*= ( const VecExpr::CVecExpr< T, ScalarType > &  expr)
inline

◆ operator*=() [2/2]

template<class ScalarType >
CSysVector & CSysVector< ScalarType >::operator*= ( ScalarType  val)
inline

◆ operator+=() [1/2]

template<class ScalarType >
template<class T >
CSysVector & CSysVector< ScalarType >::operator+= ( const VecExpr::CVecExpr< T, ScalarType > &  expr)
inline

◆ operator+=() [2/2]

template<class ScalarType >
CSysVector & CSysVector< ScalarType >::operator+= ( ScalarType  val)
inline

◆ operator-=() [1/2]

template<class ScalarType >
template<class T >
CSysVector & CSysVector< ScalarType >::operator-= ( const VecExpr::CVecExpr< T, ScalarType > &  expr)
inline

◆ operator-=() [2/2]

template<class ScalarType >
CSysVector & CSysVector< ScalarType >::operator-= ( ScalarType  val)
inline

◆ operator/=() [1/2]

template<class ScalarType >
template<class T >
CSysVector & CSysVector< ScalarType >::operator/= ( const VecExpr::CVecExpr< T, ScalarType > &  expr)
inline

◆ operator/=() [2/2]

template<class ScalarType >
CSysVector & CSysVector< ScalarType >::operator/= ( ScalarType  val)
inline

◆ operator=() [1/3]

template<class ScalarType >
CSysVector & CSysVector< ScalarType >::operator= ( const CSysVector< ScalarType > &  other)
inline

Assignment operator from another vector.

Note
Does not resize as it is meant for use in parallel.
Parameters
[in]other- Another vector.

◆ operator=() [2/3]

template<class ScalarType >
template<class T >
CSysVector & CSysVector< ScalarType >::operator= ( const VecExpr::CVecExpr< T, ScalarType > &  expr)
inline

◆ operator=() [3/3]

template<class ScalarType >
CSysVector & CSysVector< ScalarType >::operator= ( ScalarType  val)
inline

◆ operator[]() [1/2]

template<class ScalarType >
ScalarType & CSysVector< ScalarType >::operator[] ( unsigned long  i)
inline

Access operator with assignment permitted.

Parameters
[in]i- Local index to access.
Returns
Value at position i.

◆ operator[]() [2/2]

template<class ScalarType >
const ScalarType & CSysVector< ScalarType >::operator[] ( unsigned long  i) const
inline

◆ PassiveCopy()

template<class ScalarType >
template<class T >
void CSysVector< ScalarType >::PassiveCopy ( const CSysVector< T > &  other)
inline

Set our values (resizing if required) by copying from other, the derivative information is lost.

Parameters
[in]other- source CSysVector

◆ SetBlock() [1/2]

template<class ScalarType >
template<size_t N, class T , class VecTypeSIMD , class F = ScalarType>
void CSysVector< ScalarType >::SetBlock ( simd::Array< T, N >  iPoint,
const VecTypeSIMD &  vector,
simd::Array< F, N >  mask = 1 
)
inline

Vectorized version of SetBlock, sets multiple iPoint's.

Parameters
[in]iPoint- SIMD integer, the positions to update.
[in]vector- Vector of SIMD scalars.
[in]mask- Optional scale factor (axpy type operation).
Note
Nothing is updated if the mask is 0.

◆ SetBlock() [2/2]

template<class ScalarType >
template<class VectorType , bool Overwrite = true>
void CSysVector< ScalarType >::SetBlock ( unsigned long  iPoint,
const VectorType &  block,
ScalarType  alpha = 1 
)
inline

Set "block" to the vector.

Note
Template param Overwrite can be set to false to update existing values.
Parameters
[in]iPoint- index of the point where set the residual.
[in]block- Value to set to the residual.
[in]alpha- Scale factor (axpy-type operation).

◆ SetBlock_Zero()

template<class ScalarType >
void CSysVector< ScalarType >::SetBlock_Zero ( unsigned long  iPoint)
inline

Set the values to zero for one block.

Parameters
[in]iPoint- Index of the block being set to zero.

◆ SetValZero()

template<class ScalarType >
void CSysVector< ScalarType >::SetValZero ( void  )
inline

Sets to zero all the entries of the vector.

◆ squaredNorm()

template<class ScalarType >
ScalarType CSysVector< ScalarType >::squaredNorm ( ) const
inline

Squared L2 norm of the vector (via dot with self).

Returns
Squared L2 norm.

◆ SubtractBlock()

template<class ScalarType >
template<class VectorType >
void CSysVector< ScalarType >::SubtractBlock ( unsigned long  iPoint,
const VectorType &  block 
)
inline

Subtract "block" from the vector, see AddBlock.

◆ swap()

template<class ScalarType >
void CSysVector< ScalarType >::swap ( CSysVector< ScalarType > &  other)
inline

Swap contents with another vector.

◆ UpdateBlocks() [1/2]

template<class ScalarType >
template<size_t N, class T , class VecTypeSIMD , class F = ScalarType>
void CSysVector< ScalarType >::UpdateBlocks ( simd::Array< T, N >  iPoint,
simd::Array< T, N >  jPoint,
const VecTypeSIMD &  vector,
simd::Array< F, N >  mask = 1 
)
inline

Vectorized version of UpdateBlocks, updates multiple i/jPoint's.

Note
See SIMD overload of SetBlock.

◆ UpdateBlocks() [2/2]

template<class ScalarType >
template<class VectorType >
void CSysVector< ScalarType >::UpdateBlocks ( unsigned long  iPoint,
unsigned long  jPoint,
const VectorType &  block,
ScalarType  alpha = 1 
)
inline

Add to iPoint, subtract from jPoint.

Friends And Related Symbol Documentation

◆ norm()

template<class ScalarType >
Squared norm
related

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Member Data Documentation

◆ StoreAsRef

template<class ScalarType >
constexpr bool CSysVector< ScalarType >::StoreAsRef = true
staticconstexpr

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