OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
Vector< T, PETSC_BASE > Class Template Reference

PETSC vector for linear algebra. More...

Detailed Description

template<typename T>
class Vector< T, PETSC_BASE >

PETSC vector for linear algebra.

This vector wrap the PETSC vector for solving linear systems

Definition at line 106 of file Vector_petsc.hpp.

#include <Vector_petsc.hpp>

Public Member Functions

 Vector (const Vector< T, PETSC_BASE > &v)
 Copy the vector. More...
 
 Vector (Vector< T, PETSC_BASE > &&v)
 Copy the vector. More...
 
 ~Vector ()
 Destroy the vector. More...
 
 Vector (size_t n, size_t n_row_local)
 Create a vector with n elements. More...
 
 Vector ()
 Create a vector with 0 elements. More...
 
void resize (size_t row, size_t l_row)
 Resize the Vector. More...
 
void insert (size_t i, T val)
 Return a reference to the vector element. More...
 
PetscScalar & insert (size_t i)
 Return a reference to the vector element. More...
 
const PetscScalar & insert (size_t i) const
 Return a reference to the vector element. More...
 
const PetscScalar & operator() (size_t i) const
 Return a reference to the vector element. More...
 
PetscScalar & operator() (size_t i)
 Return a reference to the vector element. More...
 
const Vec & getVec () const
 Get the PETSC Vector object. More...
 
Vec & getVec ()
 Get the PETSC Vector object. More...
 
void update ()
 Update the Vector with the PETSC object. More...
 
Vector< T, PETSC_BASE > & operator= (const Vector< T, PETSC_BASE > &v)
 Copy the vector. More...
 
Vector< T, PETSC_BASE > & operator= (Vector< T, PETSC_BASE > &&v)
 Copy the vector. More...
 
void setZero ()
 Set to zero all the entries. More...
 
bool write (std::string out, size_t opt=VTK_WRITER)
 

Private Member Functions

void setPetsc () const
 Set the Eigen internal vector. More...
 

Private Attributes

size_t n_row
 Number of row the petsc vector has.
 
size_t n_row_local
 Number of local rows.
 
bool v_created = false
 Indicate if v has been allocated.
 
Vec v
 Mutable vector.
 
openfpm::vector< rval< PetscScalar, PETSC_RVAL >, HeapMemory, memory_traits_interow_val
 Mutable row value vector.
 
std::unordered_map< size_t, size_t > map
 Global to local map.
 
invalid
 invalid
 

Constructor & Destructor Documentation

◆ Vector() [1/4]

template<typename T >
Vector< T, PETSC_BASE >::Vector ( const Vector< T, PETSC_BASE > &  v)
inline

Copy the vector.

Parameters
vvector to copy

Definition at line 156 of file Vector_petsc.hpp.

◆ Vector() [2/4]

template<typename T >
Vector< T, PETSC_BASE >::Vector ( Vector< T, PETSC_BASE > &&  v)
inline

Copy the vector.

Parameters
vvector to copy

Definition at line 167 of file Vector_petsc.hpp.

◆ ~Vector()

template<typename T >
Vector< T, PETSC_BASE >::~Vector ( )
inline

Destroy the vector.

Definition at line 177 of file Vector_petsc.hpp.

◆ Vector() [3/4]

template<typename T >
Vector< T, PETSC_BASE >::Vector ( size_t  n,
size_t  n_row_local 
)
inline

Create a vector with n elements.

Parameters
nglobal number of elements in the vector
n_row_localnumber

Definition at line 189 of file Vector_petsc.hpp.

◆ Vector() [4/4]

template<typename T >
Vector< T, PETSC_BASE >::Vector ( )
inline

Create a vector with 0 elements.

Definition at line 201 of file Vector_petsc.hpp.

Member Function Documentation

◆ getVec() [1/2]

template<typename T >
const Vec& Vector< T, PETSC_BASE >::getVec ( ) const
inline

Get the PETSC Vector object.

Returns
the PETSC Vector

Definition at line 322 of file Vector_petsc.hpp.

◆ getVec() [2/2]

template<typename T >
Vec& Vector< T, PETSC_BASE >::getVec ( )
inline

Get the PETSC Vector object.

Returns
the PETSC Vector

Definition at line 334 of file Vector_petsc.hpp.

◆ insert() [1/3]

template<typename T >
void Vector< T, PETSC_BASE >::insert ( size_t  i,
val 
)
inline

Return a reference to the vector element.

Parameters
ielement
valvalue

Definition at line 228 of file Vector_petsc.hpp.

◆ insert() [2/3]

template<typename T >
PetscScalar& Vector< T, PETSC_BASE >::insert ( size_t  i)
inline

Return a reference to the vector element.

Parameters
ielement
Returns
reference to the element vector

Definition at line 246 of file Vector_petsc.hpp.

◆ insert() [3/3]

template<typename T >
const PetscScalar& Vector< T, PETSC_BASE >::insert ( size_t  i) const
inline

Return a reference to the vector element.

Parameters
ielement
Returns
reference to the element vector

Definition at line 264 of file Vector_petsc.hpp.

◆ operator()() [1/2]

template<typename T >
const PetscScalar& Vector< T, PETSC_BASE >::operator() ( size_t  i) const
inline

Return a reference to the vector element.

Warning
The element must exist
Parameters
ielement
Returns
reference to the element vector

Definition at line 284 of file Vector_petsc.hpp.

◆ operator()() [2/2]

template<typename T >
PetscScalar& Vector< T, PETSC_BASE >::operator() ( size_t  i)
inline

Return a reference to the vector element.

Warning
The element must exist
Parameters
ielement
Returns
reference to the element vector

Definition at line 305 of file Vector_petsc.hpp.

◆ operator=() [1/2]

template<typename T >
Vector<T,PETSC_BASE>& Vector< T, PETSC_BASE >::operator= ( const Vector< T, PETSC_BASE > &  v)
inline

Copy the vector.

Parameters
vvector to copy

Definition at line 383 of file Vector_petsc.hpp.

◆ operator=() [2/2]

template<typename T >
Vector<T,PETSC_BASE>& Vector< T, PETSC_BASE >::operator= ( Vector< T, PETSC_BASE > &&  v)
inline

Copy the vector.

Parameters
vvector to copy

Definition at line 396 of file Vector_petsc.hpp.

◆ resize()

template<typename T >
void Vector< T, PETSC_BASE >::resize ( size_t  row,
size_t  l_row 
)
inline

Resize the Vector.

Parameters
rownumbers of row
l_rownumber of local row

Definition at line 214 of file Vector_petsc.hpp.

◆ setPetsc()

template<typename T >
void Vector< T, PETSC_BASE >::setPetsc ( ) const
inlineprivate

Set the Eigen internal vector.

Definition at line 133 of file Vector_petsc.hpp.

◆ setZero()

template<typename T >
void Vector< T, PETSC_BASE >::setZero ( )
inline

Set to zero all the entries.

Definition at line 408 of file Vector_petsc.hpp.

◆ update()

template<typename T >
void Vector< T, PETSC_BASE >::update ( )
inline

Update the Vector with the PETSC object.

Definition at line 344 of file Vector_petsc.hpp.


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