GEOSX
|
Common base template for all vector wrapper types. More...
#include <VectorBase.hpp>
Protected Types | |
using | Vector = VECTOR |
Alias for VECTOR. | |
Protected Member Functions | |
Constructors/destructor/assignment | |
VectorBase () | |
Constructs a vector in default state. | |
VectorBase (VectorBase const &)=default | |
Copy constructor. | |
VectorBase (VectorBase &&)=default | |
Move constructor. | |
VectorBase & | operator= (VectorBase const &)=default |
Copy assignment. More... | |
VectorBase & | operator= (VectorBase &&)=default |
Move assignment. More... | |
~VectorBase ()=default | |
Destructor. | |
Status query methods | |
bool | closed () const |
Query vector closed status. More... | |
virtual bool | created () const =0 |
Query vector creation status. More... | |
bool | ready () const |
Query vector ready status. More... | |
Create Methods | |
virtual void | createWithLocalSize (localIndex const localSize, MPI_Comm const &comm)=0 |
Create a vector based on local number of elements. More... | |
virtual void | createWithGlobalSize (globalIndex const globalSize, MPI_Comm const &comm)=0 |
Create a vector based on global number of elements. More... | |
virtual void | create (arrayView1d< real64 const > const &localValues, MPI_Comm const &comm)=0 |
Construct parallel vector from a local array. More... | |
Open/close methods | |
virtual void | open ()=0 |
Open the vector for modifying entries. | |
virtual void | close ()=0 |
Assemble vector. More... | |
virtual void | reset () |
Reset the matrix to default state. | |
Add/Set Methods | |
virtual void | set (globalIndex const globalRow, real64 const value)=0 |
Set vector value. More... | |
virtual void | add (globalIndex const globalRow, real64 const value)=0 |
Add into vector value. More... | |
virtual void | set (globalIndex const *globalIndices, real64 const *values, localIndex const size)=0 |
Set vector values. More... | |
virtual void | add (globalIndex const *globalIndices, real64 const *values, localIndex const size)=0 |
Add vector values. More... | |
virtual void | set (arraySlice1d< globalIndex const > const &globalIndices, arraySlice1d< real64 const > const &values)=0 |
Set vector values using array1d. More... | |
virtual void | add (arraySlice1d< globalIndex const > const &globalIndices, arraySlice1d< real64 const > const &values)=0 |
Add into vector values using array1d. More... | |
virtual void | set (real64 const value)=0 |
Set all elements to a constant value. More... | |
virtual void | zero ()=0 |
Set vector elements to zero. | |
virtual void | rand (unsigned const seed=1984)=0 |
Set vector elements to random entries. More... | |
Algebraic Operations | |
virtual void | scale (real64 const scalingFactor)=0 |
Multiply all elements by scalingFactor. More... | |
virtual void | reciprocal ()=0 |
Replace vector elements by their reciprocals. More... | |
virtual real64 | dot (Vector const &vec) const =0 |
Dot product with the vector vec. More... | |
virtual void | copy (Vector const &x)=0 |
Update vector y as y = x . More... | |
virtual void | axpy (real64 const alpha, Vector const &x)=0 |
Update vector y as y = alpha*x + y . More... | |
virtual void | axpby (real64 const alpha, Vector const &x, real64 const beta)=0 |
Update vector y as y = alpha*x + beta*y . More... | |
virtual void | pointwiseProduct (Vector const &x, Vector &y) const =0 |
Compute the componentwise multiplication y = v * x . More... | |
virtual real64 | norm1 () const =0 |
1-norm of the vector. More... | |
virtual real64 | norm2 () const =0 |
2-norm of the vector. More... | |
virtual real64 | normInf () const =0 |
Infinity-norm of the vector. More... | |
Accessor Methods | |
virtual globalIndex | globalSize () const =0 |
Returns the global of the vector. More... | |
virtual localIndex | localSize () const =0 |
Returns the local size of the vector. More... | |
virtual globalIndex | ilower () const =0 |
Get lower bound of local partition. More... | |
virtual globalIndex | iupper () const =0 |
Get upper bound of local partition. More... | |
virtual real64 | get (globalIndex globalRow) const =0 |
Get a value by index. More... | |
virtual void | get (arraySlice1d< globalIndex const > const &globalIndices, arraySlice1d< real64 > const &values) const =0 |
Get a sequence of values by index. More... | |
virtual localIndex | getLocalRowID (globalIndex const globalRow) const =0 |
Map a global row index to local row index. More... | |
virtual globalIndex | getGlobalRowID (localIndex const localRow) const =0 |
Map a local row index to global row index. More... | |
virtual real64 const * | extractLocalVector () const =0 |
Extract a view of the local portion of the array. More... | |
virtual real64 * | extractLocalVector ()=0 |
Extract a view of the local portion of the array. More... | |
virtual void | extract (arrayView1d< real64 > const &localVector) const |
Extract local solution by copying into a user-provided array. More... | |
virtual MPI_Comm | getComm () const =0 |
Get the communicator used by this vector. More... | |
I/O Methods | |
virtual void | print (std::ostream &os=std::cout) const =0 |
Print the vector in Trilinos format to the terminal. More... | |
virtual void | write (string const &filename, LAIOutputFormat const format=LAIOutputFormat::MATRIX_MARKET) const =0 |
Write the vector to a file. More... | |
Protected Attributes | |
bool | m_closed |
Flag indicating whether the vector is closed. | |
Friends | |
std::ostream & | operator<< (std::ostream &os, Vector const &vec) |
Stream insertion operator for all vector types. More... | |
Common base template for all vector wrapper types.
VECTOR | derived vector type |
This class template provides a common interface for all derived vector wrapper types. Most methods are pure abstract in order to get the compiler to enforce a common interface in all derived classes; however there is no runtime polymorphism or virtual dispatch - derived classes are not related between each other, and pointers/references to base should never be used - the destructor is protected to enforce that.
As an added benefit, the documentation for vector interface also lives here and does not need to be duplicated across vector wrappers. Derived classes should still document specific functions in case a particular LA package's behavior deviates from expectations or has unexpected performance impacts. In that case, @copydoc
tag can be used to copy over the documentation.
Definition at line 47 of file VectorBase.hpp.
|
protectedpure virtual |
Add into vector value.
globalRow | global row |
value | Values to add in given row |
Add into vector value at given row.
Implemented in geosx::HypreVector, geosx::PetscVector, and geosx::EpetraVector.
|
protectedpure virtual |
Add vector values.
globalIndices | global row indices |
values | values to add in given rows |
size | number of elements |
Add vector values at given elements.
Implemented in geosx::HypreVector, geosx::PetscVector, and geosx::EpetraVector.
|
protectedpure virtual |
Add into vector values using array1d.
globalIndices | global rows indices |
values | values to add in given rows |
Add into vector values at given rows.
Implemented in geosx::HypreVector, geosx::PetscVector, and geosx::EpetraVector.
|
protectedpure virtual |
Update vector y
as y
= alpha*x + beta*y
.
alpha | scaling factor for added vector |
x | vector to add |
beta | scaling factor for self vector |
Implemented in geosx::HypreVector, geosx::PetscVector, and geosx::EpetraVector.
|
protectedpure virtual |
Update vector y
as y
= alpha*x + y
.
alpha | scaling factor for added vector |
x | vector to add |
Implemented in geosx::HypreVector, geosx::PetscVector, and geosx::EpetraVector.
|
protectedpure virtual |
Assemble vector.
Performs parallel communication to scatter assembled entries to appropriate locations
Implemented in geosx::HypreVector, geosx::PetscVector, and geosx::EpetraVector.
|
inlineprotected |
Query vector closed status.
true
if vector has been opened and has not been closed since; false
otherwise Definition at line 104 of file VectorBase.hpp.
|
protectedpure virtual |
Update vector y
as y
= x
.
x | vector to copy |
Implemented in geosx::HypreVector, geosx::PetscVector, and geosx::EpetraVector.
|
protectedpure virtual |
Construct parallel vector from a local array.
localValues | local data to put into vector |
comm | MPI communicator to use |
Implemented in geosx::HypreVector, geosx::PetscVector, and geosx::EpetraVector.
|
protectedpure virtual |
Query vector creation status.
true
if vector has been created Implemented in geosx::HypreVector, geosx::PetscVector, and geosx::EpetraVector.
|
protectedpure virtual |
Create a vector based on global number of elements.
globalSize | Global number of elements |
comm | MPI communicator to use |
Create a vector based on global number of elements. Every processors gets the same number of local elements except proc 0, which gets any remainder elements as well if the split can't be done evenly.
Implemented in geosx::HypreVector, geosx::PetscVector, and geosx::EpetraVector.
|
protectedpure virtual |
Create a vector based on local number of elements.
localSize | local number of elements |
comm | MPI communicator to use |
Create a vector based on local number of elements. Global size is the sum across processors. For specifying a global size and having automatic partitioning, see createWithGlobalSize().
Implemented in geosx::HypreVector, geosx::PetscVector, and geosx::EpetraVector.
|
protectedpure virtual |
Dot product with the vector vec.
vec | vector to dot-product with |
Implemented in geosx::HypreVector, geosx::PetscVector, and geosx::EpetraVector.
|
inlineprotectedvirtual |
Extract local solution by copying into a user-provided array.
localVector | the array view to write to (must be properly sized) |
Definition at line 423 of file VectorBase.hpp.
|
protectedpure virtual |
Extract a view of the local portion of the array.
Implemented in geosx::HypreVector, geosx::PetscVector, and geosx::EpetraVector.
|
protectedpure virtual |
Extract a view of the local portion of the array.
Implemented in geosx::HypreVector, geosx::PetscVector, and geosx::EpetraVector.
|
protectedpure virtual |
Get a value by index.
globalRow | global row index |
globalRow
Implemented in geosx::HypreVector, geosx::PetscVector, and geosx::EpetraVector.
|
protectedpure virtual |
Get a sequence of values by index.
[in] | globalIndices | array of global row indices |
[out] | values | array of vector values |
Implemented in geosx::HypreVector, geosx::PetscVector, and geosx::EpetraVector.
|
protectedpure virtual |
Get the communicator used by this vector.
Implemented in geosx::HypreVector, geosx::PetscVector, and geosx::EpetraVector.
|
protectedpure virtual |
Map a local row index to global row index.
[in] | localRow | the local row index |
localRow
Implemented in geosx::HypreVector, geosx::PetscVector, and geosx::EpetraVector.
|
protectedpure virtual |
Map a global row index to local row index.
[in] | globalRow | the global row index |
globalRow
Implemented in geosx::HypreVector, geosx::PetscVector, and geosx::EpetraVector.
|
protectedpure virtual |
Returns the global of the vector.
Implemented in geosx::HypreVector, geosx::PetscVector, and geosx::EpetraVector.
|
protectedpure virtual |
Get lower bound of local partition.
Implemented in geosx::HypreVector, geosx::PetscVector, and geosx::EpetraVector.
|
protectedpure virtual |
Get upper bound of local partition.
Implemented in geosx::HypreVector, geosx::PetscVector, and geosx::EpetraVector.
|
protectedpure virtual |
Returns the local size of the vector.
Implemented in geosx::HypreVector, geosx::PetscVector, and geosx::EpetraVector.
|
protectedpure virtual |
1-norm of the vector.
Implemented in geosx::HypreVector, geosx::PetscVector, and geosx::EpetraVector.
|
protectedpure virtual |
2-norm of the vector.
Implemented in geosx::HypreVector, geosx::PetscVector, and geosx::EpetraVector.
|
protectedpure virtual |
Infinity-norm of the vector.
Implemented in geosx::HypreVector, geosx::PetscVector, and geosx::EpetraVector.
|
protecteddefault |
Copy assignment.
|
protecteddefault |
Move assignment.
|
protectedpure virtual |
Compute the componentwise multiplication y
= v * x
.
x | first vector (input) |
y | second vector (output) |
Implemented in geosx::HypreVector, geosx::PetscVector, and geosx::EpetraVector.
|
protectedpure virtual |
Print the vector in Trilinos format to the terminal.
os | the output stream to print to |
Implemented in geosx::HypreVector, geosx::EpetraVector, and geosx::PetscVector.
|
protectedpure virtual |
Set vector elements to random entries.
seed | the random number seed to use |
Implemented in geosx::HypreVector, geosx::PetscVector, and geosx::EpetraVector.
|
inlineprotected |
Query vector ready status.
true
if vector has been created and is currently closed Definition at line 116 of file VectorBase.hpp.
|
protectedpure virtual |
Replace vector elements by their reciprocals.
Implemented in geosx::HypreVector, geosx::PetscVector, and geosx::EpetraVector.
|
protectedpure virtual |
Multiply all elements by scalingFactor.
scalingFactor | scaling Factor |
Implemented in geosx::HypreVector, geosx::PetscVector, and geosx::EpetraVector.
|
protectedpure virtual |
Set vector value.
globalRow | global row index |
value | Value to add at given row |
Set vector value at given element.
Implemented in geosx::HypreVector, geosx::PetscVector, and geosx::EpetraVector.
|
protectedpure virtual |
Set vector values.
globalIndices | global row indices |
values | Values to add in given rows |
size | Number of elements |
Set vector values at given elements.
Implemented in geosx::HypreVector, geosx::PetscVector, and geosx::EpetraVector.
|
protectedpure virtual |
Set vector values using array1d.
globalIndices | global row indices |
values | values to add in given rows |
Set vector values at given elements.
Implemented in geosx::HypreVector, geosx::PetscVector, and geosx::EpetraVector.
|
protectedpure virtual |
Set all elements to a constant value.
value | value to set vector elements to |
Implemented in geosx::HypreVector, geosx::PetscVector, and geosx::EpetraVector.
|
protectedpure virtual |
Write the vector to a file.
filename | name of the output file | |
[in] | format | output format |
Implemented in geosx::HypreVector, geosx::EpetraVector, and geosx::PetscVector.
|
friend |
Stream insertion operator for all vector types.
os | the output stream to print to |
vec | the vector to print |
os
Definition at line 467 of file VectorBase.hpp.