38 #include <vtkPointLocator.h>
43 using PetscVector = Vec;
97 std::shared_ptr<DistributedVector> templateVector,
555 #ifdef PROFILING_VECTOR
566 using DVecPtr = std::shared_ptr<DistributedVector>;
std::basic_string< CepsChar > CepsString
C++ format string.
Eigen::Matrix< CepsScalar, Eigen::Dynamic, 1 > CepsMathDynamic1D
Dynamic 1D array, eigen format.
CepsScalar CepsMathScalar
Real numbers.
std::vector< _Type, _Alloc > CepsVector
C++ vector.
CepsIndex CepsGlobalIndex
Many uses. Has to be signed for PETSc.
int32_t CepsInt
Need 32 bit integer.
std::shared_ptr< DistributedMatrix > DMatPtr
Short typedef for pointer on dist matrix.
DistributedVector operator-(const DistributedVector &lhs, const DistributedVector &rhs)
vector-vector
DistributedVector operator+(const DistributedVector &lhs, const DistributedVector &rhs)
Addition of vectors.
std::shared_ptr< DistributedVector > DVecPtr
Short typedef for pointer on distributed vector.
DistributedVector operator*(const DistributedVector &lhs, const CepsMathScalar &scalar)
vector*scalar
Sparse matrix distributed between process.
Structure to hold spatially dependant data and distribute it between process.
CepsMathScalar * m_localData
void insertSubVector(const CepsMathDynamic1D &subVector, const CepsVector< CepsGlobalIndex > &rowIndices)
Insert (i.e. set) a vector in a distributed vector.
CepsString getUnit() const
Units of data.
virtual CepsMathScalar & operator[](CepsGlobalIndex globalIndex)
Direct access to the values of a vector.
DistributedVector()
Default Constructor.
void setValuesLocal(DistributedVector &values, CepsInt n, const CepsGlobalIndex *indices=nullptr)
Sets n multiple local values.
virtual ~DistributedVector()
Destructor.
CepsBool equals(const DistributedVector &vec, CepsMathScalar errorFactor=1.0) const
Whether two vector have the (exact!) same values on all process.
void finalize()
Calls both beginAssembly() and endAssembly()
void view() const
Display vector on standard output.
virtual void getLocalData()
Enables direct access to the stored local values.
CepsBool m_initialized
Whether this vector is ready to be used or not.
CepsBool m_isAssembled
Whether this vector is assembled or not.
virtual void getValues(CepsMathScalar *values, CepsInt n, const CepsGlobalIndex *indices)
Read values in the vector.
PetscVector m_v
The underlying vector.
CepsGlobalIndex m_lo
Index of first owned row.
CepsBool sameLocalRange(const DistributedVector &vec) const
Compares local ranges.
CepsBool approxEquals(const DistributedVector &vec, CepsMathScalar epsilon) const
Whether two vector have the approximately the same values on all process, with epsilon tolerance.
DistributedVector & operator*=(const CepsMathScalar &scalar)
Short mult by scalar.
CepsMathScalar l1Norm() const
-norm of vector
void setValue(CepsMathScalar value, CepsGlobalIndex i)
Sets or replaces a single value.
void createEmptyVector()
Inits the underlying vector. Use setSize afterwards.
void zero()
Fills vector with zeros.
void add(const DistributedVector &x)
Adds x to current vector.
void addSubVector(const CepsMathDynamic1D &subVector, const CepsVector< CepsGlobalIndex > &rowIndices)
Adds a vector in a distributed vector.
CepsMathScalar l2Norm() const
-norm of vector
friend class TestDistributedVector
void endAssembly()
Wait for the distributed vector assembly to finish.
DistributedVector & operator+=(const DistributedVector &v)
Short addition with other vector.
DistributedVector & operator-=(const DistributedVector &v)
Short substraction with other vector.
CepsString m_unit
Unit of the data.
CepsMathScalar lInfNorm() const
-norm of vector
void addValues(const CepsMathScalar *values, CepsInt n, const CepsGlobalIndex *indices)
Add multiple values to already existing values.
const PetscVector & getVector() const
The underlying vector.
CepsMathScalar dot(DistributedVector &x)
Computes the inner product of current vector by x.
CepsMathScalar * localData()
Point on the local data.
void addValuesLocal(DistributedVector &values, CepsInt n, const CepsGlobalIndex *indices=nullptr)
Add multiple local values to already existing values.
void duplicate(DistributedVector &dest, CepsBool copyValues) const
Shares the non-zero structure, and optionally values.
CepsGlobalIndex m_hi
Index of row right after last owned row.
void ignoreOffProcEntries(CepsBool ignore)
Sets whether the values on rows that are not owned by current process will be ignored or not.
void fillFromVector(const CepsVector< CepsMathScalar > &data)
Fills the distributed vector with data stored in a vector on process 0.
CepsInt getSize() const
Get the global size of the vector.
virtual void releaseLocalData()
Release the pointer on the local data.
void checkAndSetSizes(CepsInt gSize, CepsInt lSize)
Check if calling vector has had its sizes set. If not, set sizes.
CepsVector< CepsMathScalar > getSubVector(const CepsVector< CepsGlobalIndex > &rowIndices)
Get some local data from the distributed vector.
CepsBool m_vecCreated
Underlying vec created.
CepsBool isAssembled() const
true if vector has been assembled
void setUnit(const CepsString &u)
Units of data.
CepsInt m_globalSize
Global size of vector.
void getLocalRange(CepsGlobalIndex *lo, CepsGlobalIndex *hi) const
Get the range of rows owned by current process.
void fill(CepsMathScalar value)
Fills vector with given value.
virtual void pointWiseScale(const DistributedVector &x, CepsBool divide=false)
Perform a point wise multiplication or division on this vector by another vector.
void setSize(CepsInt M, CepsInt m)
Set distributed vector size.
virtual void abs()
Every component of the vector is replaced by its absolute value.
virtual void mult(const DistributedMatrix &A, const DistributedVector &x)
Sets current vector to result of product A*x.
virtual void scale(CepsMathScalar alpha)
Multiplies self by alpha.
CepsInt m_localSize
Local size of vector.
void beginAssembly()
Start distributed vector assembly.
CepsInt getLocalSize() const
Get the local size of the vector.
DistributedVector & operator=(const DistributedVector &v)
Assignment operator.
void addValue(CepsMathScalar value, CepsGlobalIndex i)
Adds given scalar to the currently existing value or set it if not.
CepsBool sameSize(const DistributedVector &vec) const
Compares global sizes.
void setValues(const CepsMathScalar *values, CepsInt n, const CepsGlobalIndex *indices)
Sets n multiple values.
void checkNanOrInf(CepsString message="")
Stops if there are coefficients that are nan or inf.
void addScaled(const DistributedVector &x, CepsMathScalar alpha)
Adds alpha*x to current vector.