Chi-Tech
|
#include <ParallelSTLVector.h>
Public Member Functions | |
ParallelSTLVector (uint64_t local_size, uint64_t global_size, MPI_Comm communicator) | |
ParallelSTLVector (const ParallelSTLVector &other) | |
ParallelSTLVector (ParallelSTLVector &&other) noexcept | |
std::unique_ptr< ParallelVector > | MakeCopy () const override |
std::unique_ptr< ParallelVector > | MakeClone () const override |
double * | Data () override |
const double * | Data () const override |
const std::vector< double > & | LocalSTLData () const |
std::vector< double > & | LocalSTLData () |
double | operator[] (int64_t local_id) const override |
double & | operator[] (int64_t local_id) override |
std::vector< double > | MakeLocalVector () override |
Return a vector containing the locally owned data. More... | |
void | Set (double value) override |
void | Set (const std::vector< double > &local_vector) override |
void | BlockSet (const std::vector< double > &y, int64_t local_offset, int64_t num_values) override |
void | CopyLocalValues (const ParallelVector &y) override |
void | CopyLocalValues (Vec y) override |
void | BlockCopyLocalValues (const ParallelVector &y, int64_t y_offset, int64_t local_offset, int64_t num_values) override |
void | BlockCopyLocalValues (Vec y, int64_t y_offset, int64_t local_offset, int64_t num_values) override |
void | SetValue (int64_t global_id, double value, VecOpType op_type) override |
void | SetValues (const std::vector< int64_t > &global_ids, const std::vector< double > &values, VecOpType op_type) override |
void | operator+= (const ParallelVector &y) override |
void | PlusAY (const ParallelVector &y, double a) override |
void | AXPlusY (double a, const ParallelVector &y) override |
void | Scale (double a) override |
void | Shift (double a) override |
double | ComputeNorm (chi_math::NormType norm_type) const override |
void | Assemble () override |
std::string | PrintStr () const override |
Print the local vectors to stings. More... | |
Public Member Functions inherited from chi_math::ParallelVector | |
ParallelVector (uint64_t local_size, uint64_t global_size, MPI_Comm communicator) | |
ParallelVector (const ParallelVector &other) | |
ParallelVector (ParallelVector &&other) noexcept | |
virtual std::unique_ptr< ParallelVector > | MakeCopy () const =0 |
virtual std::unique_ptr< ParallelVector > | MakeClone () const =0 |
virtual double * | Data ()=0 |
virtual const double * | Data () const =0 |
uint64_t | LocalSize () const |
Return the size of the locally owned portion of the parallel vector. More... | |
uint64_t | GlobalSize () const |
Return the global size of the parallel vector. More... | |
virtual double | operator[] (int64_t local_id) const =0 |
virtual double & | operator[] (int64_t local_id)=0 |
virtual std::vector< double > | MakeLocalVector ()=0 |
Return a vector containing the locally owned data. More... | |
virtual void | Set (double value)=0 |
virtual void | Set (const std::vector< double > &local_vector)=0 |
virtual void | BlockSet (const std::vector< double > &y, int64_t local_offset, int64_t num_values)=0 |
virtual void | CopyLocalValues (const ParallelVector &y)=0 |
virtual void | CopyLocalValues (Vec y)=0 |
virtual void | BlockCopyLocalValues (const ParallelVector &y, int64_t y_offset, int64_t local_offset, int64_t num_values)=0 |
virtual void | BlockCopyLocalValues (Vec y, int64_t y_offset, int64_t local_offset, int64_t num_values)=0 |
virtual void | SetValue (int64_t global_id, double value, VecOpType op_type)=0 |
virtual void | SetValues (const std::vector< int64_t > &global_ids, const std::vector< double > &values, VecOpType op_type)=0 |
virtual void | operator+= (const ParallelVector &y)=0 |
virtual void | PlusAY (const ParallelVector &y, double a)=0 |
virtual void | AXPlusY (double a, const ParallelVector &y)=0 |
virtual void | Scale (double a)=0 |
virtual void | Shift (double a)=0 |
virtual double | ComputeNorm (chi_math::NormType norm_type) const =0 |
virtual void | Assemble ()=0 |
virtual std::string | PrintStr () const =0 |
Print the local vectors to stings. More... | |
virtual void | CommunicateGhostEntries () |
virtual | ~ParallelVector ()=default |
Protected Types | |
using | Operation = std::pair< int64_t, double > |
Protected Attributes | |
const std::vector< uint64_t > | extents_ |
std::vector< double > | values_ |
std::vector< Operation > | set_cache_ |
std::vector< Operation > | add_cache_ |
Protected Attributes inherited from chi_math::ParallelVector | |
const uint64_t | local_size_ |
const uint64_t | global_size_ |
const int | location_id_ |
const int | process_count_ |
const MPI_Comm | comm_ |
Private Member Functions | |
int | FindOwnerPID (uint64_t global_id) const |
Static Private Member Functions | |
static std::vector< uint64_t > | DefineExtents (uint64_t local_size, int comm_size, MPI_Comm communicator) |
An implementation of a parallel vector.
Definition at line 19 of file ParallelSTLVector.h.
|
protected |
Definition at line 174 of file ParallelSTLVector.h.
chi_math::ParallelSTLVector::ParallelSTLVector | ( | uint64_t | local_size, |
uint64_t | global_size, | ||
MPI_Comm | communicator | ||
) |
Initialize a parallel vector with the given local and global sizes with the given communicator whose entries are set to zero.
Definition at line 23 of file ParallelSTLVector.cc.
chi_math::ParallelSTLVector::ParallelSTLVector | ( | const ParallelSTLVector & | other | ) |
Copy constructor.
Definition at line 32 of file ParallelSTLVector.cc.
|
noexcept |
Move constructor.
Definition at line 37 of file ParallelSTLVector.cc.
|
overridevirtual |
Communicate all operations stored within the operation cache to the corresponding processes that own the respective global indices, and apply the operations.
This routine clears the respective operation cache once completed.
Implements chi_math::ParallelVector.
Definition at line 375 of file ParallelSTLVector.cc.
|
overridevirtual |
Performs x = a*x + y with the current vector being x.
Implements chi_math::ParallelVector.
Definition at line 290 of file ParallelSTLVector.cc.
|
overridevirtual |
Copies a contiguous block of local data (num_values entries) from the source vector (starting at y_offset) to the current vector starting at local_offset.
Implements chi_math::ParallelVector.
Definition at line 157 of file ParallelSTLVector.cc.
|
overridevirtual |
Copies a contiguous block of local data (num_values entries) from the source vector (starting at y_offset) to the current vector starting at local_offset. PETSc flavor.
Implements chi_math::ParallelVector.
Definition at line 188 of file ParallelSTLVector.cc.
|
overridevirtual |
Copies a contiguous block of data from the source STL vector to the current vector starting at local_offset. The input STL vector must have exactly num_values entries.
Implements chi_math::ParallelVector.
Definition at line 111 of file ParallelSTLVector.cc.
|
overridevirtual |
Returns the specified norm of the vector.
Implements chi_math::ParallelVector.
Definition at line 318 of file ParallelSTLVector.cc.
|
overridevirtual |
Sets the local values of one vector equal to another. The sizes must be compatible.
Implements chi_math::ParallelVector.
Definition at line 129 of file ParallelSTLVector.cc.
|
overridevirtual |
Sets the local values of the vector equal to that of the PETSc vector. The sizes must be compatible.
Implements chi_math::ParallelVector.
Definition at line 143 of file ParallelSTLVector.cc.
|
overridevirtual |
Returns a direct const pointer to the memory array used internally by the vector to store its owned elements
Implements chi_math::ParallelVector.
Definition at line 59 of file ParallelSTLVector.cc.
|
overridevirtual |
Returns a direct pointer to the memory array used internally by the vector to store its owned elements.
Implements chi_math::ParallelVector.
Definition at line 58 of file ParallelSTLVector.cc.
|
staticprivate |
Definition at line 492 of file ParallelSTLVector.cc.
|
private |
Definition at line 518 of file ParallelSTLVector.cc.
std::vector< double > & chi_math::ParallelSTLVector::LocalSTLData | ( | ) |
Returns a reference to the local data of the vector.
Definition at line 66 of file ParallelSTLVector.cc.
const std::vector< double > & chi_math::ParallelSTLVector::LocalSTLData | ( | ) | const |
Returns a constant reference to the local data of the vector.
Definition at line 61 of file ParallelSTLVector.cc.
|
overridevirtual |
Creates a copy of the vector datastructures but NOT the values. The values are defaulted to zero. This routine requires no communication.
Implements chi_math::ParallelVector.
Definition at line 49 of file ParallelSTLVector.cc.
|
overridevirtual |
Creates a copy of the vector datastructures AND values. This routine requires no communication.
Implements chi_math::ParallelVector.
Definition at line 44 of file ParallelSTLVector.cc.
|
overridevirtual |
Return a vector containing the locally owned data.
Implements chi_math::ParallelVector.
Definition at line 68 of file ParallelSTLVector.cc.
|
overridevirtual |
In place adding of vectors. The sizes must be compatible.
Implements chi_math::ParallelVector.
Definition at line 253 of file ParallelSTLVector.cc.
|
overridevirtual |
Read only accessor to the entry at the given local index of the local vector.
Implements chi_math::ParallelVector.
Definition at line 74 of file ParallelSTLVector.cc.
|
overridevirtual |
Read/write accessor to the entry at the given local index of the local vector.
Implements chi_math::ParallelVector.
Definition at line 84 of file ParallelSTLVector.cc.
|
overridevirtual |
Adds a vector multiplied by scalar a, x = x + a*y
. Optimized for a=1.0 and -1.0
Implements chi_math::ParallelVector.
Definition at line 268 of file ParallelSTLVector.cc.
|
overridevirtual |
Print the local vectors to stings.
Implements chi_math::ParallelVector.
Definition at line 528 of file ParallelSTLVector.cc.
|
overridevirtual |
Adds a constant scalar value to all the entries of the vector
Implements chi_math::ParallelVector.
Definition at line 305 of file ParallelSTLVector.cc.
|
overridevirtual |
Set the entries of the locally owned portion of the parallel vector to the given STL vector.
Implements chi_math::ParallelVector.
Definition at line 99 of file ParallelSTLVector.cc.
|
overridevirtual |
Set the entries of the locally owned portion of the parallel vector to the given value.
Implements chi_math::ParallelVector.
Definition at line 94 of file ParallelSTLVector.cc.
|
overridevirtual |
Define a set or add operation for the given global id-value pair
This routine adds the global id-value pair to the set operation cache, which upon execution of Assemble, communicates the operations to the appropriate process.
Implements chi_math::ParallelVector.
Definition at line 223 of file ParallelSTLVector.cc.
|
overridevirtual |
Group multiple operations into a single call.
This routine goes through the given global id-value pairs and calls SetValue for each.
Implements chi_math::ParallelVector.
Definition at line 235 of file ParallelSTLVector.cc.
|
overridevirtual |
Returns the specified norm of the vector.
Implements chi_math::ParallelVector.
Definition at line 311 of file ParallelSTLVector.cc.
|
protected |
Definition at line 176 of file ParallelSTLVector.h.
|
protected |
Definition at line 170 of file ParallelSTLVector.h.
|
protected |
Definition at line 175 of file ParallelSTLVector.h.
|
protected |
Definition at line 172 of file ParallelSTLVector.h.