OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
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.
 
 Vector (Vector< T, PETSC_BASE > &&v)
 Copy the vector.
 
 ~Vector ()
 Destroy the vector.
 
 Vector (size_t n, size_t n_row_local)
 Create a vector with n elements.
 
 Vector ()
 Create a vector with 0 elements.
 
void resize (size_t row, size_t l_row)
 Resize the Vector.
 
void insert (size_t i, T val)
 Return a reference to the vector element.
 
PetscScalar & insert (size_t i)
 Return a reference to the vector element.
 
const PetscScalar & insert (size_t i) const
 Return a reference to the vector element.
 
const PetscScalar & operator() (size_t i) const
 Return a reference to the vector element.
 
PetscScalar & operator() (size_t i)
 Return a reference to the vector element.
 
const Vec & getVec () const
 Get the PETSC Vector object.
 
Vec & getVec ()
 Get the PETSC Vector object.
 
void update ()
 Update the Vector with the PETSC object.
 
Vector< T, PETSC_BASE > & operator= (const Vector< T, PETSC_BASE > &v)
 Copy the vector.
 
Vector< T, PETSC_BASE > & operator= (Vector< T, PETSC_BASE > &&v)
 Copy the vector.
 
void setZero ()
 Set to zero all the entries.
 
bool write (std::string out, size_t opt=VTK_WRITER)
 

Private Member Functions

void setPetsc () const
 Set the Eigen internal vector.
 

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 >
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.

◆ getVec() [2/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.

◆ insert() [1/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() [2/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.

◆ insert() [3/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.

◆ operator()() [1/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()() [2/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=() [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.

◆ write()

template<typename T >
bool Vector< T, PETSC_BASE >::write ( std::string  out,
size_t  opt = VTK_WRITER 
)
inline

Definition at line 421 of file Vector_petsc.hpp.

Field Documentation

◆ invalid

template<typename T >
T Vector< T, PETSC_BASE >::invalid
private

invalid

Definition at line 127 of file Vector_petsc.hpp.

◆ map

template<typename T >
std::unordered_map<size_t,size_t> Vector< T, PETSC_BASE >::map
mutableprivate

Global to local map.

Definition at line 124 of file Vector_petsc.hpp.

◆ n_row

template<typename T >
size_t Vector< T, PETSC_BASE >::n_row
private

Number of row the petsc vector has.

Definition at line 109 of file Vector_petsc.hpp.

◆ n_row_local

template<typename T >
size_t Vector< T, PETSC_BASE >::n_row_local
private

Number of local rows.

Definition at line 112 of file Vector_petsc.hpp.

◆ row_val

template<typename T >
openfpm::vector<rval<PetscScalar,PETSC_RVAL>,HeapMemory, memory_traits_inte > Vector< T, PETSC_BASE >::row_val
mutableprivate

Mutable row value vector.

Definition at line 121 of file Vector_petsc.hpp.

◆ v

template<typename T >
Vec Vector< T, PETSC_BASE >::v
mutableprivate

Mutable vector.

Definition at line 118 of file Vector_petsc.hpp.

◆ v_created

template<typename T >
bool Vector< T, PETSC_BASE >::v_created = false
mutableprivate

Indicate if v has been allocated.

Definition at line 115 of file Vector_petsc.hpp.


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