Chi-Tech
chi_math::ParallelVector Class Referenceabstract

#include <ParallelVector.h>

Inheritance diagram for chi_math::ParallelVector:
chi_math::ParallelSTLVector chi_math::GhostedParallelSTLVector

Public Member Functions

 ParallelVector (uint64_t local_size, uint64_t global_size, MPI_Comm communicator)
 
 ParallelVector (const ParallelVector &other)
 
 ParallelVector (ParallelVector &&other) noexcept
 
virtual std::unique_ptr< ParallelVectorMakeCopy () const =0
 
virtual std::unique_ptr< ParallelVectorMakeClone () 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 Attributes

const uint64_t local_size_
 
const uint64_t global_size_
 
const int location_id_
 
const int process_count_
 
const MPI_Comm comm_
 

Detailed Description

An abstract implementation of a parallel vector.

Definition at line 21 of file ParallelVector.h.

Constructor & Destructor Documentation

◆ ParallelVector() [1/3]

chi_math::ParallelVector::ParallelVector ( 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 8 of file ParallelVector.cc.

◆ ParallelVector() [2/3]

chi_math::ParallelVector::ParallelVector ( const ParallelVector other)

Copy constructor.

Definition at line 19 of file ParallelVector.cc.

◆ ParallelVector() [3/3]

chi_math::ParallelVector::ParallelVector ( ParallelVector &&  other)
noexcept

Move constructor.

Definition at line 28 of file ParallelVector.cc.

◆ ~ParallelVector()

virtual chi_math::ParallelVector::~ParallelVector ( )
virtualdefault

Member Function Documentation

◆ Assemble()

virtual void chi_math::ParallelVector::Assemble ( )
pure virtual

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.

Implemented in chi_math::ParallelSTLVector.

◆ AXPlusY()

virtual void chi_math::ParallelVector::AXPlusY ( double  a,
const ParallelVector y 
)
pure virtual

Performs x = a*x + y with the current vector being x.

Implemented in chi_math::ParallelSTLVector.

◆ BlockCopyLocalValues() [1/2]

virtual void chi_math::ParallelVector::BlockCopyLocalValues ( const ParallelVector y,
int64_t  y_offset,
int64_t  local_offset,
int64_t  num_values 
)
pure virtual

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.

Implemented in chi_math::ParallelSTLVector.

◆ BlockCopyLocalValues() [2/2]

virtual void chi_math::ParallelVector::BlockCopyLocalValues ( Vec  y,
int64_t  y_offset,
int64_t  local_offset,
int64_t  num_values 
)
pure virtual

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.

Implemented in chi_math::ParallelSTLVector.

◆ BlockSet()

virtual void chi_math::ParallelVector::BlockSet ( const std::vector< double > &  y,
int64_t  local_offset,
int64_t  num_values 
)
pure virtual

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.

Implemented in chi_math::ParallelSTLVector.

◆ CommunicateGhostEntries()

virtual void chi_math::ParallelVector::CommunicateGhostEntries ( )
inlinevirtual

Communicate the current ghost entries, if applicable, to all other processes to update the locally stored ghost data.

Reimplemented in chi_math::GhostedParallelSTLVector.

Definition at line 181 of file ParallelVector.h.

◆ ComputeNorm()

virtual double chi_math::ParallelVector::ComputeNorm ( chi_math::NormType  norm_type) const
pure virtual

Returns the specified norm of the vector.

Implemented in chi_math::ParallelSTLVector.

◆ CopyLocalValues() [1/2]

virtual void chi_math::ParallelVector::CopyLocalValues ( const ParallelVector y)
pure virtual

Sets the local values of one vector equal to another. The sizes must be compatible.

Implemented in chi_math::ParallelSTLVector.

◆ CopyLocalValues() [2/2]

virtual void chi_math::ParallelVector::CopyLocalValues ( Vec  y)
pure virtual

Sets the local values of the vector equal to that of the PETSc vector. The sizes must be compatible.

Implemented in chi_math::ParallelSTLVector.

◆ Data() [1/2]

virtual const double * chi_math::ParallelVector::Data ( ) const
pure virtual

Returns a direct const pointer to the memory array used internally by the vector to store its owned elements

Implemented in chi_math::ParallelSTLVector.

◆ Data() [2/2]

virtual double * chi_math::ParallelVector::Data ( )
pure virtual

Returns a direct pointer to the memory array used internally by the vector to store its owned elements

Implemented in chi_math::ParallelSTLVector.

◆ GlobalSize()

uint64_t chi_math::ParallelVector::GlobalSize ( ) const
inline

Return the global size of the parallel vector.

Definition at line 58 of file ParallelVector.h.

◆ LocalSize()

uint64_t chi_math::ParallelVector::LocalSize ( ) const
inline

Return the size of the locally owned portion of the parallel vector.

Definition at line 55 of file ParallelVector.h.

◆ MakeClone()

virtual std::unique_ptr< ParallelVector > chi_math::ParallelVector::MakeClone ( ) const
pure virtual

Creates a copy of the vector datastructures but NOT the values. The values are defaulted to zero. This routine requires no communication.

Implemented in chi_math::GhostedParallelSTLVector, and chi_math::ParallelSTLVector.

◆ MakeCopy()

virtual std::unique_ptr< ParallelVector > chi_math::ParallelVector::MakeCopy ( ) const
pure virtual

Creates a copy of the vector datastructures AND values. This routine requires no communication.

Implemented in chi_math::GhostedParallelSTLVector, and chi_math::ParallelSTLVector.

◆ MakeLocalVector()

virtual std::vector< double > chi_math::ParallelVector::MakeLocalVector ( )
pure virtual

Return a vector containing the locally owned data.

Implemented in chi_math::ParallelSTLVector.

◆ operator+=()

virtual void chi_math::ParallelVector::operator+= ( const ParallelVector y)
pure virtual

In place adding of vectors. The sizes must be compatible.

Implemented in chi_math::ParallelSTLVector.

◆ operator[]() [1/2]

virtual double chi_math::ParallelVector::operator[] ( int64_t  local_id) const
pure virtual

Read only accessor to the entry at the given local index of the local vector.

Note
This accessor allows access to all locally stored elements, including any data beyond local_size_ that may exist in derived classes.

Implemented in chi_math::ParallelSTLVector.

◆ operator[]() [2/2]

virtual double & chi_math::ParallelVector::operator[] ( int64_t  local_id)
pure virtual

Read/write accessor to the entry at the given local index of the local vector.

Note
This accessor allows access to all locally stored elements, including any data beyond local_size_ that may exist in derived classes.

Implemented in chi_math::ParallelSTLVector.

◆ PlusAY()

virtual void chi_math::ParallelVector::PlusAY ( const ParallelVector y,
double  a 
)
pure virtual

Adds a vector multiplied by scalar a, x=x+a*y. Optimized for a=1.0 and -1.0

Implemented in chi_math::ParallelSTLVector.

◆ PrintStr()

virtual std::string chi_math::ParallelVector::PrintStr ( ) const
pure virtual

Print the local vectors to stings.

Implemented in chi_math::ParallelSTLVector.

◆ Scale()

virtual void chi_math::ParallelVector::Scale ( double  a)
pure virtual

Scales a vector by a scalar

Implemented in chi_math::ParallelSTLVector.

◆ Set() [1/2]

virtual void chi_math::ParallelVector::Set ( const std::vector< double > &  local_vector)
pure virtual

Set the entries of the locally owned portion of the parallel vector to the given STL vector.

Implemented in chi_math::ParallelSTLVector.

◆ Set() [2/2]

virtual void chi_math::ParallelVector::Set ( double  value)
pure virtual

Set the entries of the locally owned portion of the parallel vector to the given value.

Implemented in chi_math::ParallelSTLVector.

◆ SetValue()

virtual void chi_math::ParallelVector::SetValue ( int64_t  global_id,
double  value,
VecOpType  op_type 
)
pure virtual

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.

Implemented in chi_math::ParallelSTLVector.

◆ SetValues()

virtual void chi_math::ParallelVector::SetValues ( const std::vector< int64_t > &  global_ids,
const std::vector< double > &  values,
VecOpType  op_type 
)
pure virtual

Group multiple operations into a single call.

This routine goes through the given global id-value pairs and calls SetValue for each.

Implemented in chi_math::ParallelSTLVector.

◆ Shift()

virtual void chi_math::ParallelVector::Shift ( double  a)
pure virtual

Adds a constant scalar value to all the entries of the vector

Implemented in chi_math::ParallelSTLVector.

Field Documentation

◆ comm_

const MPI_Comm chi_math::ParallelVector::comm_
protected

Definition at line 191 of file ParallelVector.h.

◆ global_size_

const uint64_t chi_math::ParallelVector::global_size_
protected

Definition at line 187 of file ParallelVector.h.

◆ local_size_

const uint64_t chi_math::ParallelVector::local_size_
protected

Definition at line 186 of file ParallelVector.h.

◆ location_id_

const int chi_math::ParallelVector::location_id_
protected

Definition at line 189 of file ParallelVector.h.

◆ process_count_

const int chi_math::ParallelVector::process_count_
protected

Definition at line 190 of file ParallelVector.h.


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