CEPS  24.01
Cardiac ElectroPhysiology Simulator
DistributedVector Class Reference

Detailed Description

Structure to hold spatially dependant data and distribute it between process.

See also
DistributedMatrix

Access to data must be done between calls to getLocalData() and releaseLocalData().

Definition at line 55 of file DistributedVector.hpp.

#include <DistributedVector.hpp>

Inheritance diagram for DistributedVector:
[legend]

Public Member Functions

 DistributedVector ()
 Default Constructor. More...
 
 DistributedVector (const DistributedVector &v)
 Copy constructor. More...
 
DistributedVectoroperator= (const DistributedVector &v)
 Assignment operator. More...
 
 DistributedVector (CepsInt M, CepsInt m)
 Constructor with sizes. More...
 
 DistributedVector (DistributedVector &templateVector, CepsBool copyValues, CepsBool isSequential=false)
 Constructor with the same structure as the given vector. More...
 
 DistributedVector (std::shared_ptr< DistributedVector > templateVector, CepsBool copyValues, CepsBool isSequential=false)
 Constructor with the same structure as the given vector. More...
 
 DistributedVector (DMatPtr mat, CepsGlobalIndex row)
 Build vector from a matrix row. More...
 
virtual ~DistributedVector ()
 Destructor. More...
 
CepsString getUnit () const
 Units of data. More...
 
void setUnit (const CepsString &u)
 Units of data. More...
 
CepsMathScalarlocalData ()
 Point on the local data. More...
 
void setSize (CepsInt M, CepsInt m)
 Set distributed vector size. More...
 
void getSize (CepsInt *globalSize) const
 Get the global size of the vector. More...
 
CepsInt getSize () const
 Get the global size of the vector. More...
 
void getLocalSize (CepsInt *localSize) const
 Get the number of rows owned by current process. More...
 
CepsInt getLocalSize () const
 Get the local size of the vector. More...
 
void getLocalRange (CepsGlobalIndex *lo, CepsGlobalIndex *hi) const
 Get the range of rows owned by current process. More...
 
virtual void getLocalData ()
 Enables direct access to the stored local values. More...
 
virtual void releaseLocalData ()
 Release the pointer on the local data. More...
 
const PetscVector & getVector () const
 The underlying vector. More...
 
void setValue (CepsMathScalar value, CepsGlobalIndex i)
 Sets or replaces a single value. More...
 
void addValue (CepsMathScalar value, CepsGlobalIndex i)
 Adds given scalar to the currently existing value or set it if not. More...
 
void ignoreOffProcEntries (CepsBool ignore)
 Sets whether the values on rows that are not owned by current process will be ignored or not. More...
 
void setValues (const CepsMathScalar *values, CepsInt n, const CepsGlobalIndex *indices)
 Sets n multiple values. More...
 
void setValuesLocal (DistributedVector &values, CepsInt n, const CepsGlobalIndex *indices=nullptr)
 Sets n multiple local values. More...
 
void setValuesLocal (const CepsMathScalar *values, CepsInt n, const CepsGlobalIndex *indices=nullptr)
 Sets n multiple local values. More...
 
void setValuesLocal (const CepsVector< CepsMathScalar > &values, const CepsVector< CepsGlobalIndex > &indices)
 Sets multiple local values, PetscVector version. More...
 
void addValues (const CepsMathScalar *values, CepsInt n, const CepsGlobalIndex *indices)
 Add multiple values to already existing values. More...
 
void addValuesLocal (DistributedVector &values, CepsInt n, const CepsGlobalIndex *indices=nullptr)
 Add multiple local values to already existing values. More...
 
void addValuesLocal (const CepsMathScalar *values, CepsInt n, const CepsGlobalIndex *indices=nullptr)
 Add multiple local values to already existing values. More...
 
virtual void getValues (CepsMathScalar *values, CepsInt n, const CepsGlobalIndex *indices)
 Read values in the vector. More...
 
void addSubVector (const CepsMathDynamic1D &subVector, const CepsVector< CepsGlobalIndex > &rowIndices)
 Adds a vector in a distributed vector. More...
 
void insertSubVector (const CepsMathDynamic1D &subVector, const CepsVector< CepsGlobalIndex > &rowIndices)
 Insert (i.e. set) a vector in a distributed vector. More...
 
CepsVector< CepsMathScalargetSubVector (const CepsVector< CepsGlobalIndex > &rowIndices)
 Get some local data from the distributed vector. More...
 
void zero ()
 Fills vector with zeros. More...
 
void fill (CepsMathScalar value)
 Fills vector with given value. More...
 
void duplicate (DistributedVector &dest, CepsBool copyValues) const
 Shares the non-zero structure, and optionally values. More...
 
void beginAssembly ()
 Start distributed vector assembly. More...
 
void endAssembly ()
 Wait for the distributed vector assembly to finish. More...
 
void finalize ()
 Calls both beginAssembly() and endAssembly() More...
 
CepsBool isAssembled () const
 true if vector has been assembled More...
 
CepsBool sameSize (const DistributedVector &vec) const
 Compares global sizes. More...
 
CepsBool sameLocalRange (const DistributedVector &vec) const
 Compares local ranges. More...
 
CepsBool equals (const DistributedVector &vec, CepsMathScalar errorFactor=1.0) const
 Whether two vector have the (exact!) same values on all process. More...
 
CepsBool approxEquals (const DistributedVector &vec, CepsMathScalar epsilon) const
 Whether two vector have the approximately the same values on all process, with epsilon tolerance. More...
 
void checkNanOrInf (CepsString message="")
 Stops if there are coefficients that are nan or inf. More...
 
void add (const DistributedVector &x)
 Adds x to current vector. More...
 
void addScaled (const DistributedVector &x, CepsMathScalar alpha)
 Adds alpha*x to current vector. More...
 
virtual void scale (CepsMathScalar alpha)
 Multiplies self by alpha. More...
 
virtual void pointWiseScale (const DistributedVector &x, CepsBool divide=false)
 Perform a point wise multiplication or division on this vector by another vector. More...
 
virtual void mult (const DistributedMatrix &A, const DistributedVector &x)
 Sets current vector to result of product A*x. More...
 
virtual void abs ()
 Every component of the vector is replaced by its absolute value. More...
 
CepsMathScalar dot (DistributedVector &x)
 Computes the inner product of current vector by x. More...
 
CepsMathScalar lInfNorm () const
 $l^inf$-norm of vector More...
 
CepsMathScalar l1Norm () const
 $l^1$-norm of vector More...
 
CepsMathScalar l2Norm () const
 $l^2$-norm of vector More...
 
void view () const
 Display vector on standard output. More...
 
virtual CepsMathScalaroperator[] (CepsGlobalIndex globalIndex)
 Direct access to the values of a vector. More...
 
virtual CepsMathScalar operator[] (CepsGlobalIndex globalIndex) const
 Direct read-only access to the values of a vector. More...
 
DistributedVectoroperator+= (const DistributedVector &v)
 Short addition with other vector. More...
 
DistributedVectoroperator+= (const CepsMathScalar &scalar)
 Short addition with scalar. More...
 
DistributedVectoroperator-= (const DistributedVector &v)
 Short substraction with other vector. More...
 
DistributedVectoroperator-= (const CepsMathScalar &scalar)
 Short substraction with scalar. More...
 
DistributedVectoroperator*= (const CepsMathScalar &scalar)
 Short mult by scalar. More...
 
void fillFromVector (const CepsVector< CepsMathScalar > &data)
 Fills the distributed vector with data stored in a vector on process 0. More...
 

Protected Member Functions

void checkAndSetSizes (CepsInt gSize, CepsInt lSize)
 Check if calling vector has had its sizes set. If not, set sizes. More...
 
void createEmptyVector ()
 Inits the underlying vector. Use setSize afterwards. More...
 

Protected Attributes

CepsString m_unit
 Unit of the data. More...
 
PetscVector m_v
 The underlying vector. More...
 
CepsGlobalIndex m_lo
 Index of first owned row. More...
 
CepsGlobalIndex m_hi
 Index of row right after last owned row. More...
 
CepsInt m_globalSize
 Global size of vector. More...
 
CepsInt m_localSize
 Local size of vector. More...
 
CepsMathScalarm_localData
 
CepsBool m_mayReadData
 
CepsBool m_isAssembled
 Whether this vector is assembled or not. More...
 
CepsBool m_initialized
 Whether this vector is ready to be used or not. More...
 
CepsBool m_vecCreated
 Underlying vec created. More...
 

Friends

class DistributedMatrix
 
class TestDistributedVector
 

Constructor & Destructor Documentation

◆ DistributedVector() [1/6]

DistributedVector::DistributedVector ( )

Default Constructor.

Definition at line 31 of file PETScVector.cpp.

◆ DistributedVector() [2/6]

DistributedVector::DistributedVector ( const DistributedVector v)

Copy constructor.

Definition at line 49 of file PETScVector.cpp.

◆ DistributedVector() [3/6]

DistributedVector::DistributedVector ( CepsInt  M,
CepsInt  m 
)

Constructor with sizes.

Parameters
[in]Mvector global size.
[in]mnumber of rows owned by current process.

Definition at line 56 of file PETScVector.cpp.

◆ DistributedVector() [4/6]

DistributedVector::DistributedVector ( DistributedVector templateVector,
CepsBool  copyValues,
CepsBool  isSequential = false 
)

Constructor with the same structure as the given vector.

Parameters
[in]templateVectorthe vector to use as a template
[in]copyValueswhether to copy or not the values from template.
[in]isSequentialif this flag is true, the resulting vector will be sequential. Default to false

Definition at line 95 of file PETScVector.cpp.

◆ DistributedVector() [5/6]

DistributedVector::DistributedVector ( std::shared_ptr< DistributedVector templateVector,
CepsBool  copyValues,
CepsBool  isSequential = false 
)

Constructor with the same structure as the given vector.

Parameters
[in]templateVectorthe vector to use as a template
[in]copyValueswhether to copy or not the values from template.
[in]isSequentialif this flag is true, the resulting vector will be sequential. Default to false

Definition at line 63 of file PETScVector.cpp.

◆ DistributedVector() [6/6]

DistributedVector::DistributedVector ( DMatPtr  mat,
CepsGlobalIndex  row 
)

Build vector from a matrix row.

Parameters
[in]matthe source matrix
[in]rowthe row to get

Definition at line 127 of file PETScVector.cpp.

◆ ~DistributedVector()

DistributedVector::~DistributedVector ( )
virtual

Destructor.

If a vector is allocated on the stack in the main program (where PETSc is initialized), then its destructor will be called after PETSc finalize and cause a segfault. There are two solutions: 1 - Create the vector with 'new' and free it with 'delete' 2 - Control the scope of the local vector with '{' '}'

Definition at line 165 of file PETScVector.cpp.

Member Function Documentation

◆ abs()

void DistributedVector::abs ( )
virtual

Every component of the vector is replaced by its absolute value.

Reimplemented in DistributedHaloVector.

Definition at line 701 of file PETScVector.cpp.

◆ add()

void DistributedVector::add ( const DistributedVector x)

Adds x to current vector.

Parameters
[in]xvector to add to current vector

PETSc implementation: x cannot be the same vector as current vector, i.e. one cannot do
this += this
Calls addScaled since PETSc does not give an equivalent

Definition at line 612 of file PETScVector.cpp.

◆ addScaled()

void DistributedVector::addScaled ( const DistributedVector x,
CepsMathScalar  alpha 
)

Adds alpha*x to current vector.

Parameters
[in]xvector to add to current vector
[in]alphascale factor

PETSc implementation: x cannot be the same vector as current vector, i.e. one cannot do
this += a*this

Definition at line 619 of file PETScVector.cpp.

◆ addSubVector()

void DistributedVector::addSubVector ( const CepsMathDynamic1D subVector,
const CepsVector< CepsGlobalIndex > &  rowIndices 
)

Adds a vector in a distributed vector.

See also
DistributedVector::insertSubVector(...)
Parameters
[in]subVectorthe small vector of size N to add
[in]rowIndicesan array of size N that holds the global indices of each row. It indicates in which rows the values must be added.

Definition at line 70 of file DistributedVector.cpp.

◆ addValue()

void DistributedVector::addValue ( CepsMathScalar  value,
CepsGlobalIndex  i 
)

Adds given scalar to the currently existing value or set it if not.

Parameters
[in]valuethe scalar
[in]ivector row

Definition at line 266 of file PETScVector.cpp.

◆ addValues()

void DistributedVector::addValues ( const CepsMathScalar values,
CepsInt  n,
const CepsGlobalIndex indices 
)

Add multiple values to already existing values.

Parameters
[in]valuesthe values to add
[in]nnumber of rows (indices array size)
[in]indicesindices of the rows where each value will be added

Definition at line 356 of file PETScVector.cpp.

◆ addValuesLocal() [1/2]

void DistributedVector::addValuesLocal ( const CepsMathScalar values,
CepsInt  n,
const CepsGlobalIndex indices = nullptr 
)

Add multiple local values to already existing values.

Parameters
[in]valuesarray of values to add
[in]nthe number of rows (indices array size)
[in]indicesindices of the rows where each value will be set. If nullptr, the values are copied contiguously from m_lo to m_lo + n.

Definition at line 395 of file PETScVector.cpp.

◆ addValuesLocal() [2/2]

void DistributedVector::addValuesLocal ( DistributedVector values,
CepsInt  n,
const CepsGlobalIndex indices = nullptr 
)

Add multiple local values to already existing values.

Parameters
[in]valuesdistributed vector holding values to add
[in]nthe number of rows (indices array size)
[in]indicesindices of the rows where each value will be set. If nullptr, the values are copied contiguously from m_lo to m_lo + n.

Definition at line 367 of file PETScVector.cpp.

◆ approxEquals()

CepsBool DistributedVector::approxEquals ( const DistributedVector vec,
CepsMathScalar  epsilon 
) const

Whether two vector have the approximately the same values on all process, with epsilon tolerance.

See also
Precision::ceps::approxEquals(...)
Parameters
[in]vecthe vector to check equality against
[in]epsilontolerance
Returns
true if both vector hold the same data.

Definition at line 575 of file PETScVector.cpp.

◆ beginAssembly()

void DistributedVector::beginAssembly ( )

Start distributed vector assembly.

As the assembly takes some time to finish (data migration), code not related to this vector can be executed between this method and the call to DistributedVector::endAssembly()

Definition at line 485 of file PETScVector.cpp.

◆ checkAndSetSizes()

void DistributedVector::checkAndSetSizes ( CepsInt  gSize,
CepsInt  lSize 
)
protected

Check if calling vector has had its sizes set. If not, set sizes.

Parameters
[in]gSizeglobal size
[in]lSizelocal size

Definition at line 810 of file PETScVector.cpp.

◆ checkNanOrInf()

void DistributedVector::checkNanOrInf ( CepsString  message = "")

Stops if there are coefficients that are nan or inf.

Definition at line 57 of file DistributedVector.cpp.

◆ createEmptyVector()

void DistributedVector::createEmptyVector ( )
protected

Inits the underlying vector. Use setSize afterwards.

Definition at line 827 of file PETScVector.cpp.

◆ dot()

CepsMathScalar DistributedVector::dot ( DistributedVector x)

Computes the inner product of current vector by x.

PETSc implementation: here x can also be current vector, in that case use l2Norm instead.

Definition at line 708 of file PETScVector.cpp.

◆ duplicate()

void DistributedVector::duplicate ( DistributedVector dest,
CepsBool  copyValues 
) const

Shares the non-zero structure, and optionally values.

Parameters
destthe destination vector
copyValuesalso copy numerical values

Definition at line 466 of file PETScVector.cpp.

◆ endAssembly()

void DistributedVector::endAssembly ( )

Wait for the distributed vector assembly to finish.

See also
beginAssembly()

Definition at line 496 of file PETScVector.cpp.

◆ equals()

CepsBool DistributedVector::equals ( const DistributedVector vec,
CepsMathScalar  errorFactor = 1.0 
) const

Whether two vector have the (exact!) same values on all process.

See also
Precision::equal(...)
Parameters
[in]vecthe vector to check equality against
[in]errorFactoran estimate of the error accumulated through iterative computation. Default to 1.0
Returns
true if both vector hold the same data.

Definition at line 536 of file PETScVector.cpp.

◆ fill()

void DistributedVector::fill ( CepsMathScalar  value)

Fills vector with given value.

Definition at line 459 of file PETScVector.cpp.

◆ fillFromVector()

void DistributedVector::fillFromVector ( const CepsVector< CepsMathScalar > &  data)

Fills the distributed vector with data stored in a vector on process 0.

Definition at line 178 of file DistributedVector.cpp.

◆ finalize()

void DistributedVector::finalize ( )

Calls both beginAssembly() and endAssembly()

Definition at line 507 of file PETScVector.cpp.

◆ getLocalData()

void DistributedVector::getLocalData ( )
virtual

Enables direct access to the stored local values.

Methods like DistributedVector::getValues(...) must still be used to read the values. DistributedVector::releaseLocalData() must be used after reading the values.

See also
DistributedVector::releaseLocalData()

Reimplemented in DistributedHaloVector.

Definition at line 243 of file PETScVector.cpp.

◆ getLocalRange()

void DistributedVector::getLocalRange ( CepsGlobalIndex lo,
CepsGlobalIndex hi 
) const

Get the range of rows owned by current process.

Parameters
[out]lowill hold the first local row
[out]hiwill hold last + 1 local row

Definition at line 235 of file PETScVector.cpp.

◆ getLocalSize() [1/2]

CepsInt DistributedVector::getLocalSize ( ) const

Get the local size of the vector.

Definition at line 227 of file PETScVector.cpp.

◆ getLocalSize() [2/2]

void DistributedVector::getLocalSize ( CepsInt localSize) const

Get the number of rows owned by current process.

Parameters
[out]localSizewill hold the local vector size

Definition at line 218 of file PETScVector.cpp.

◆ getSize() [1/2]

CepsInt DistributedVector::getSize ( ) const

Get the global size of the vector.

Definition at line 210 of file PETScVector.cpp.

◆ getSize() [2/2]

void DistributedVector::getSize ( CepsInt globalSize) const

Get the global size of the vector.

Parameters
[out]globalSizewill hold the vector size

Definition at line 201 of file PETScVector.cpp.

◆ getSubVector()

CepsVector< CepsMathScalar > DistributedVector::getSubVector ( const CepsVector< CepsGlobalIndex > &  rowIndices)

Get some local data from the distributed vector.

Parameters
[in]rowIndicesglobal indices of the rows to get

Definition at line 432 of file PETScVector.cpp.

◆ getUnit()

CepsString DistributedVector::getUnit ( ) const
inline

Units of data.

Definition at line 39 of file DistributedVector.cpp.

◆ getValues()

void DistributedVector::getValues ( CepsMathScalar values,
CepsInt  n,
const CepsGlobalIndex indices 
)
virtual

Read values in the vector.

Parameters
[out]valueswhere to store the read values. Must be allocated before calling this method.
[in]nthe number of rows to read
[in]indicesglobal row indices to get

Reimplemented in DistributedHaloVector.

Definition at line 418 of file PETScVector.cpp.

◆ getVector()

const PetscVector & DistributedVector::getVector ( ) const

The underlying vector.

Definition at line 177 of file PETScVector.cpp.

◆ ignoreOffProcEntries()

void DistributedVector::ignoreOffProcEntries ( CepsBool  ignore)

Sets whether the values on rows that are not owned by current process will be ignored or not.

It globally increases performance when assembling the vector but can be risky if we are not sure about data locality !

Parameters
ignorewhether to ignore off-process entries or not

Definition at line 273 of file PETScVector.cpp.

◆ insertSubVector()

void DistributedVector::insertSubVector ( const CepsMathDynamic1D subVector,
const CepsVector< CepsGlobalIndex > &  rowIndices 
)

Insert (i.e. set) a vector in a distributed vector.

See also
DistributedVector::addSubVector(...)
Parameters
[in]subVectorthe small vector of size N to insert
[in]rowIndicesan array of size N that holds the global indices of each row in which to insert values.

Definition at line 80 of file DistributedVector.cpp.

◆ isAssembled()

CepsBool DistributedVector::isAssembled ( ) const

true if vector has been assembled

PETSc implementation: PETSc currently does not give a vector's equivalent to matrix MatAssembled(), which means that we must implement an unreliable way of keeping track of vector assembly. For now, users should keep track of vector assembly themselves.

Definition at line 51 of file DistributedVector.cpp.

◆ l1Norm()

CepsMathScalar DistributedVector::l1Norm ( ) const

$l^1$-norm of vector

Definition at line 724 of file PETScVector.cpp.

◆ l2Norm()

CepsMathScalar DistributedVector::l2Norm ( ) const

$l^2$-norm of vector

Definition at line 732 of file PETScVector.cpp.

◆ lInfNorm()

CepsMathScalar DistributedVector::lInfNorm ( ) const

$l^inf$-norm of vector

Definition at line 716 of file PETScVector.cpp.

◆ localData()

CepsMathScalar * DistributedVector::localData ( )

Point on the local data.

Warning: use this method only if you are very sure of what you are doing ! This method must be used with DistributedVector::getLocalData() and DistributedVector::releaseLocalData()

Definition at line 183 of file PETScVector.cpp.

◆ mult()

void DistributedVector::mult ( const DistributedMatrix A,
const DistributedVector x 
)
virtual

Sets current vector to result of product A*x.

Matrix A and vector x are not modified

PETSc implementation: x vector cannot be the same as current vector.

Parameters
Ainput matrix
xa distributed vector

Definition at line 667 of file PETScVector.cpp.

◆ operator*=()

DistributedVector & DistributedVector::operator*= ( const CepsMathScalar scalar)

Short mult by scalar.

Definition at line 799 of file PETScVector.cpp.

◆ operator+=() [1/2]

DistributedVector & DistributedVector::operator+= ( const CepsMathScalar scalar)

Short addition with scalar.

Definition at line 767 of file PETScVector.cpp.

◆ operator+=() [2/2]

DistributedVector & DistributedVector::operator+= ( const DistributedVector v)

Short addition with other vector.

Definition at line 749 of file PETScVector.cpp.

◆ operator-=() [1/2]

DistributedVector & DistributedVector::operator-= ( const CepsMathScalar scalar)

Short substraction with scalar.

Definition at line 793 of file PETScVector.cpp.

◆ operator-=() [2/2]

DistributedVector & DistributedVector::operator-= ( const DistributedVector v)

Short substraction with other vector.

Definition at line 774 of file PETScVector.cpp.

◆ operator=()

DistributedVector & DistributedVector::operator= ( const DistributedVector v)

Assignment operator.

Definition at line 94 of file DistributedVector.cpp.

◆ operator[]() [1/2]

CepsReal & DistributedVector::operator[] ( CepsGlobalIndex  globalIndex)
inlinevirtual

Direct access to the values of a vector.

Parameters
[in]globalIndexglobal row index
Returns
this[globalIndex]

Reimplemented in DistributedHaloVector.

Definition at line 102 of file DistributedVector.cpp.

◆ operator[]() [2/2]

CepsReal DistributedVector::operator[] ( CepsGlobalIndex  globalIndex) const
inlinevirtual

Direct read-only access to the values of a vector.

Parameters
[in]globalIndexglobal row index
Returns
this[globalIndex]

Reimplemented in DistributedHaloVector.

Definition at line 118 of file DistributedVector.cpp.

◆ pointWiseScale()

void DistributedVector::pointWiseScale ( const DistributedVector x,
CepsBool  divide = false 
)
virtual

Perform a point wise multiplication or division on this vector by another vector.

Parameters
xthe vector of factors
dividedivide or multiply

Definition at line 641 of file PETScVector.cpp.

◆ releaseLocalData()

void DistributedVector::releaseLocalData ( )
virtual

Release the pointer on the local data.

See also
DistributedVector::getLocalData()

Reimplemented in DistributedHaloVector.

Definition at line 251 of file PETScVector.cpp.

◆ sameLocalRange()

CepsBool DistributedVector::sameLocalRange ( const DistributedVector vec) const

Compares local ranges.

Parameters
[in]vecthe distributed vector to compare with
Returns
true if both vectors have the same data repartition (if the process owns the same rows of the vectors).

Definition at line 527 of file PETScVector.cpp.

◆ sameSize()

CepsBool DistributedVector::sameSize ( const DistributedVector vec) const

Compares global sizes.

Parameters
[in]vecthe vector to compare with
Returns
true if both vectors have the same global size.

Definition at line 521 of file PETScVector.cpp.

◆ scale()

void DistributedVector::scale ( CepsMathScalar  alpha)
virtual

Multiplies self by alpha.

Parameters
[in]alphascale factor

Reimplemented in DistributedHaloVector.

Definition at line 635 of file PETScVector.cpp.

◆ setSize()

void DistributedVector::setSize ( CepsInt  M,
CepsInt  m 
)

Set distributed vector size.

Parameters
[in]Mvector global size
[in]mvector local rows owned by the process

Definition at line 190 of file PETScVector.cpp.

◆ setUnit()

void DistributedVector::setUnit ( const CepsString u)
inline

Units of data.

Definition at line 45 of file DistributedVector.cpp.

◆ setValue()

void DistributedVector::setValue ( CepsMathScalar  value,
CepsGlobalIndex  i 
)

Sets or replaces a single value.

Parameters
[in]valuethe scalar
[in]ivector row

Definition at line 259 of file PETScVector.cpp.

◆ setValues()

void DistributedVector::setValues ( const CepsMathScalar values,
CepsInt  n,
const CepsGlobalIndex indices 
)

Sets n multiple values.

Parameters
[in]nthe number of rows (indices array size)
[in]indicesglobal indices of the rows where each value will be set
[in]valuesthe values to set

Definition at line 281 of file PETScVector.cpp.

◆ setValuesLocal() [1/3]

void DistributedVector::setValuesLocal ( const CepsMathScalar values,
CepsInt  n,
const CepsGlobalIndex indices = nullptr 
)

Sets n multiple local values.

Parameters
[in]valuesarray of values to set
[in]nthe number of rows (indices array size)
[in]indicesindices of the rows where each value will be set. If nullptr, the values are copied contiguously from m_lo to m_lo + n.

Definition at line 317 of file PETScVector.cpp.

◆ setValuesLocal() [2/3]

void DistributedVector::setValuesLocal ( const CepsVector< CepsMathScalar > &  values,
const CepsVector< CepsGlobalIndex > &  indices 
)

Sets multiple local values, PetscVector version.

Parameters
[in]valuesarray of values to set
[in]indicesindices of the rows where each value will be set.

Definition at line 339 of file PETScVector.cpp.

◆ setValuesLocal() [3/3]

void DistributedVector::setValuesLocal ( DistributedVector values,
CepsInt  n,
const CepsGlobalIndex indices = nullptr 
)

Sets n multiple local values.

Parameters
valuesdistributed vector holding values to set
nthe number of rows (indices array size)
indicesindices of the rows where each value will be set. If nullptr, the values are copied contiguously from m_lo to m_lo + n.

Definition at line 292 of file PETScVector.cpp.

◆ view()

void DistributedVector::view ( ) const

Display vector on standard output.

Definition at line 740 of file PETScVector.cpp.

◆ zero()

void DistributedVector::zero ( )

Fills vector with zeros.

Definition at line 452 of file PETScVector.cpp.

Friends And Related Function Documentation

◆ DistributedMatrix

friend class DistributedMatrix
friend

Definition at line 60 of file DistributedVector.hpp.

◆ TestDistributedVector

friend class TestDistributedVector
friend

Definition at line 513 of file DistributedVector.hpp.

Field Documentation

◆ m_globalSize

CepsInt DistributedVector::m_globalSize
protected

Global size of vector.

Definition at line 536 of file DistributedVector.hpp.

◆ m_hi

CepsGlobalIndex DistributedVector::m_hi
protected

Index of row right after last owned row.

Definition at line 535 of file DistributedVector.hpp.

◆ m_initialized

CepsBool DistributedVector::m_initialized
protected

Whether this vector is ready to be used or not.

Definition at line 560 of file DistributedVector.hpp.

◆ m_isAssembled

CepsBool DistributedVector::m_isAssembled
protected

Whether this vector is assembled or not.

Definition at line 553 of file DistributedVector.hpp.

◆ m_lo

CepsGlobalIndex DistributedVector::m_lo
protected

Index of first owned row.

Definition at line 534 of file DistributedVector.hpp.

◆ m_localData

CepsMathScalar* DistributedVector::m_localData
protected

A direct access to the data allocated for this vector. DistributedVector::getLocalData() must be called before reading any values. DistributedVector::releaseLocalData() must be called after reading the values.

Definition at line 546 of file DistributedVector.hpp.

◆ m_localSize

CepsInt DistributedVector::m_localSize
protected

Local size of vector.

Definition at line 537 of file DistributedVector.hpp.

◆ m_mayReadData

CepsBool DistributedVector::m_mayReadData
protected

True if and only if DistributedVector::getLocalData() (or DistributedVector::getLocalAndGhostData() ) was called

Definition at line 552 of file DistributedVector.hpp.

◆ m_unit

CepsString DistributedVector::m_unit
protected

Unit of the data.

Definition at line 532 of file DistributedVector.hpp.

◆ m_v

PetscVector DistributedVector::m_v
protected

The underlying vector.

Definition at line 533 of file DistributedVector.hpp.

◆ m_vecCreated

CepsBool DistributedVector::m_vecCreated
protected

Underlying vec created.

Definition at line 561 of file DistributedVector.hpp.


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