52 m_nbHaloRows(nbHaloRows)
54 this->m_isAssembled =
false;
55 this->m_mayReadData =
false;
61 #ifdef PROFILING_VECTOR
62 m_totalAssembly = m_tickAssembly = 0.0;
66 VecGetOwnershipRange(this->m_v, &(this->m_lo), &(this->m_hi));
70 m_globalToLocalMapping[this->m_lo + i] = sum;
74 for (
CepsIndex i = 0; i < nbHaloRows; i++, sum++)
75 m_globalToLocalMapping[haloRows[i]] = sum;
78 or (
CepsIndex) m_globalToLocalMapping.size () != sum,
79 "DistributedHaloVector: fatal error, some DsOF were not mapped."
83 this->m_initialized =
true;
84 this->m_globalSize = M;
85 this->m_localSize = m;
99 VecGhostUpdateBegin(
m_v,INSERT_VALUES,SCATTER_FORWARD);
100 VecGhostUpdateEnd (
m_v,INSERT_VALUES,SCATTER_FORWARD);
124 "Invalid access to local data.\n"
125 " Make sure you called DistributedVector::getLocalData() beforehand."
131 std::map<CepsIndex, CepsIndex>::iterator it;
137 "Distributed vector: on process #" <<
ceps::getRank() <<
", trying to access row #"
138 << indices[i] <<
"\nwhich not local or halo."
159 #ifdef PROFILING_VECTOR
160 m_totalAssembly = m_tickAssembly = 0.0;
172 "access to memory not requested"
175 "out-of-bounds index " << index
194 "out-of-bounds index " << index
204 "source vector is not initialized"
216 memcpy(dest,source,size*
sizeof(
CepsReal));
235 "calling vector is not initialized"
240 "vectors are of different sizes"
247 memcpy(dest,source,(hi-lo)*
sizeof(
CepsReal));
252 m_initialized =
true;
260 #ifdef CEPS_USE_PETSC
270 #ifdef CEPS_USE_PETSC
#define CEPS_ABORT_IF(condition, message)
Stops the execution with a message if condition is true. If testing is enabled, only throws a runtime...
float CepsReal
Need single precision floating point.
int32_t CepsInt
Need 32 bit integer.
CepsInt CepsIndex
Index rowid etc.
Extended distributed vectors.
std::map< CepsIndex, CepsIndex > m_globalToLocalMapping
Index mapping.
~DistributedHaloVector() override
Destructor.
void getLocalData() override
Mandatory call before accessing data.
CepsInt getNbHalo()
number of halo values
void scale(CepsMathScalar alpha) override
Multiplies self by alpha.
void abs() override
Sets all coeffs to their absolute value.
CepsReal & operator[](CepsIndex globalIndex) override
Array subscription override.
DistributedHaloVector()
Default constructor.
PetscVector m_localV
Local representation of the halo vector.
void releaseLocalData() override
Mandatory call after accessing data.
CepsIndex m_nbHaloRows
Number of halo values that will be received.
DistributedHaloVector & operator=(DistributedHaloVector &v)
Assignment operator.
void getValues(CepsReal *values, CepsIndex n, const CepsIndex *indices) override
Override of parent DistributedVector::getValues(...)
Structure to hold spatially dependant data and distribute it between process.
CepsMathScalar * m_localData
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.
PetscVector m_v
The underlying vector.
CepsGlobalIndex m_lo
Index of first owned row.
CepsMathScalar * localData()
Point on the local data.
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.
virtual void releaseLocalData()
Release the pointer on the local data.
CepsInt m_globalSize
Global size of vector.
void getLocalRange(CepsGlobalIndex *lo, CepsGlobalIndex *hi) const
Get the range of rows owned by current process.
virtual void abs()
Every component of the vector is replaced by its absolute value.
CepsInt m_localSize
Local size of vector.
CepsUInt getRank()
Returns current processor rank.
MPI_Comm getCommunicator()
Get the communicator.