GEOS
Protected Types | Protected Attributes | Friends | List of all members
geos::VectorBase< VECTOR > Class Template Referenceabstract

Common base template for all vector wrapper types. More...

#include <VectorBase.hpp>

Protected Types

using Vector = VECTOR
 Alias for VECTOR.
 

Protected Member Functions

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 create (localIndex const localSize, MPI_Comm const &comm)
 Create a vector based on local number of elements. More...
 
void setName (string const &name)
 Set a name for the vector (mainly used during various logging). More...
 
Open/close methods
virtual arrayView1d< real64open ()
 Open the vector for modifying entries. More...
 
virtual void close ()=0
 Close vector for modification. More...
 
virtual void touch ()=0
 Notify the vector about external modification through direct data pointer. More...
 
virtual void reset ()
 Reset the vector to default state.
 
Modification methods
virtual void set (real64 const value)=0
 Set all elements to a constant value. More...
 
virtual void zero ()
 Set vector elements to zero.
 
virtual void rand (unsigned const seed)=0
 Set vector elements to random entries. More...
 
Algebraic Operations
virtual void scale (real64 const factor)=0
 Multiply all elements by factor. 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 component-wise 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...
 
arrayView1d< real64 const > values () const
 
virtual MPI_Comm comm () 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 = true
 Flag indicating whether the vector is closed.
 
array1d< real64m_values
 Actual storage for the local vector values.
 

Friends

std::ostream & operator<< (std::ostream &os, Vector const &vec)
 Stream insertion operator for all vector types. More...
 

Detailed Description

template<typename VECTOR>
class geos::VectorBase< VECTOR >

Common base template for all vector wrapper types.

Template Parameters
VECTORderived 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 48 of file VectorBase.hpp.

Member Function Documentation

◆ axpby()

template<typename VECTOR >
virtual void geos::VectorBase< VECTOR >::axpby ( real64 const  alpha,
Vector const &  x,
real64 const  beta 
)
protectedpure virtual

Update vector y as y = alpha*x + beta*y.

Parameters
alphascaling factor for added vector
xvector to add
betascaling factor for self vector

Implemented in geos::PetscVector, geos::HypreVector, and geos::EpetraVector.

◆ axpy()

template<typename VECTOR >
virtual void geos::VectorBase< VECTOR >::axpy ( real64 const  alpha,
Vector const &  x 
)
protectedpure virtual

Update vector y as y = alpha*x + y.

Parameters
alphascaling factor for added vector
xvector to add

Implemented in geos::PetscVector, geos::HypreVector, and geos::EpetraVector.

◆ close()

template<typename VECTOR >
virtual void geos::VectorBase< VECTOR >::close ( )
protectedpure virtual

Close vector for modification.

After calling this method, the view obtained via open() should not be used.

Implemented in geos::EpetraVector, geos::PetscVector, and geos::HypreVector.

◆ closed()

template<typename VECTOR >
bool geos::VectorBase< VECTOR >::closed ( ) const
inlineprotected

Query vector closed status.

Returns
true if vector has been opened and has not been closed since; false otherwise

Definition at line 64 of file VectorBase.hpp.

◆ comm()

template<typename VECTOR >
virtual MPI_Comm geos::VectorBase< VECTOR >::comm ( ) const
protectedpure virtual

Get the communicator used by this vector.

Returns
the MPI communicator

Implemented in geos::EpetraVector, geos::PetscVector, and geos::HypreVector.

◆ copy()

template<typename VECTOR >
virtual void geos::VectorBase< VECTOR >::copy ( Vector const &  x)
protectedpure virtual

Update vector y as y = x.

Parameters
xvector to copy
Note
Unlike copy assignment operator, this method expects both vectors to be created and have identical parallel distributions, and never reallocates memory.

Implemented in geos::PetscVector, geos::HypreVector, and geos::EpetraVector.

◆ create()

template<typename VECTOR >
virtual void geos::VectorBase< VECTOR >::create ( localIndex const  localSize,
MPI_Comm const &  comm 
)
inlineprotectedvirtual

Create a vector based on local number of elements.

Parameters
localSizelocal number of elements
commMPI communicator to use

Create a vector based on local number of elements. Global size is the sum across processors.

Reimplemented in geos::EpetraVector, geos::PetscVector, and geos::HypreVector.

Definition at line 93 of file VectorBase.hpp.

◆ created()

template<typename VECTOR >
virtual bool geos::VectorBase< VECTOR >::created ( ) const
protectedpure virtual

Query vector creation status.

Returns
true if vector has been created

Implemented in geos::EpetraVector, geos::PetscVector, and geos::HypreVector.

◆ dot()

template<typename VECTOR >
virtual real64 geos::VectorBase< VECTOR >::dot ( Vector const &  vec) const
protectedpure virtual

Dot product with the vector vec.

Parameters
vecvector to dot-product with
Returns
dot product

Implemented in geos::PetscVector, geos::HypreVector, and geos::EpetraVector.

◆ globalSize()

template<typename VECTOR >
virtual globalIndex geos::VectorBase< VECTOR >::globalSize ( ) const
protectedpure virtual

Returns the global of the vector.

Returns
the global size

Implemented in geos::EpetraVector, geos::PetscVector, and geos::HypreVector.

◆ ilower()

template<typename VECTOR >
virtual globalIndex geos::VectorBase< VECTOR >::ilower ( ) const
protectedpure virtual

Get lower bound of local partition.

Returns
index of the first global row owned by this processor

Implemented in geos::EpetraVector, geos::PetscVector, and geos::HypreVector.

◆ iupper()

template<typename VECTOR >
virtual globalIndex geos::VectorBase< VECTOR >::iupper ( ) const
protectedpure virtual

Get upper bound of local partition.

Returns
next index after last global row owned by that processor
Note
[ v.ilower(); v.iupper() ) is a half-open index range

Implemented in geos::EpetraVector, geos::PetscVector, and geos::HypreVector.

◆ localSize()

template<typename VECTOR >
virtual localIndex geos::VectorBase< VECTOR >::localSize ( ) const
protectedpure virtual

Returns the local size of the vector.

Returns
the local size (on this processor)

Implemented in geos::EpetraVector, geos::PetscVector, and geos::HypreVector.

◆ norm1()

template<typename VECTOR >
virtual real64 geos::VectorBase< VECTOR >::norm1 ( ) const
protectedpure virtual

1-norm of the vector.

Returns
the 1-norm value

Implemented in geos::EpetraVector, geos::PetscVector, and geos::HypreVector.

◆ norm2()

template<typename VECTOR >
virtual real64 geos::VectorBase< VECTOR >::norm2 ( ) const
protectedpure virtual

2-norm of the vector.

Returns
the 2-norm value

Implemented in geos::EpetraVector, geos::PetscVector, and geos::HypreVector.

◆ normInf()

template<typename VECTOR >
virtual real64 geos::VectorBase< VECTOR >::normInf ( ) const
protectedpure virtual

Infinity-norm of the vector.

Returns
the inf-norm value

Implemented in geos::EpetraVector, geos::PetscVector, and geos::HypreVector.

◆ open()

template<typename VECTOR >
virtual arrayView1d< real64 > geos::VectorBase< VECTOR >::open ( )
inlineprotectedvirtual

Open the vector for modifying entries.

Returns
an array view to assemble local values into

Reimplemented in geos::EpetraVector, geos::PetscVector, and geos::HypreVector.

Definition at line 129 of file VectorBase.hpp.

◆ pointwiseProduct()

template<typename VECTOR >
virtual void geos::VectorBase< VECTOR >::pointwiseProduct ( Vector const &  x,
Vector y 
) const
protectedpure virtual

Compute the component-wise multiplication y = v * x.

Parameters
xfirst vector (input)
ysecond vector (output)

Implemented in geos::PetscVector, geos::HypreVector, and geos::EpetraVector.

◆ print()

template<typename VECTOR >
virtual void geos::VectorBase< VECTOR >::print ( std::ostream &  os = std::cout) const
protectedpure virtual

Print the vector in Trilinos format to the terminal.

Parameters
osthe output stream to print to

Implemented in geos::EpetraVector, geos::PetscVector, and geos::HypreVector.

◆ rand()

template<typename VECTOR >
virtual void geos::VectorBase< VECTOR >::rand ( unsigned const  seed)
protectedpure virtual

Set vector elements to random entries.

Parameters
seedthe random number seed to use

Implemented in geos::EpetraVector, geos::PetscVector, and geos::HypreVector.

◆ ready()

template<typename VECTOR >
bool geos::VectorBase< VECTOR >::ready ( ) const
inlineprotected

Query vector ready status.

Returns
true if vector has been created and is currently closed

Definition at line 76 of file VectorBase.hpp.

◆ reciprocal()

template<typename VECTOR >
virtual void geos::VectorBase< VECTOR >::reciprocal ( )
protectedpure virtual

Replace vector elements by their reciprocals.

Note
No guarding is done against division by zero.

Implemented in geos::EpetraVector, geos::PetscVector, and geos::HypreVector.

◆ scale()

template<typename VECTOR >
virtual void geos::VectorBase< VECTOR >::scale ( real64 const  factor)
protectedpure virtual

Multiply all elements by factor.

Parameters
factorscaling factor

Implemented in geos::EpetraVector, geos::PetscVector, and geos::HypreVector.

◆ set()

template<typename VECTOR >
virtual void geos::VectorBase< VECTOR >::set ( real64 const  value)
protectedpure virtual

Set all elements to a constant value.

Parameters
valuevalue to set vector elements to

Implemented in geos::EpetraVector, geos::PetscVector, and geos::HypreVector.

◆ setName()

template<typename VECTOR >
void geos::VectorBase< VECTOR >::setName ( string const &  name)
inlineprotected

Set a name for the vector (mainly used during various logging).

Parameters
namethe name

Definition at line 113 of file VectorBase.hpp.

◆ touch()

template<typename VECTOR >
virtual void geos::VectorBase< VECTOR >::touch ( )
protectedpure virtual

Notify the vector about external modification through direct data pointer.

This method MUST be called after any changes to vector values performed through direct pointer access, so that the underlying Array object can be made aware of external changes in a specific memory space.

Implemented in geos::EpetraVector, geos::PetscVector, and geos::HypreVector.

◆ values()

template<typename VECTOR >
arrayView1d< real64 const > geos::VectorBase< VECTOR >::values ( ) const
inlineprotected
Returns
a const access view to local vector values

Definition at line 305 of file VectorBase.hpp.

◆ write()

template<typename VECTOR >
virtual void geos::VectorBase< VECTOR >::write ( string const &  filename,
LAIOutputFormat const  format = LAIOutputFormat::MATRIX_MARKET 
) const
protectedpure virtual

Write the vector to a file.

Parameters
filenamename of the output file
[in]formatoutput format

Implemented in geos::EpetraVector, geos::PetscVector, and geos::HypreVector.

Friends And Related Function Documentation

◆ operator<<

template<typename VECTOR >
std::ostream& operator<< ( std::ostream &  os,
Vector const &  vec 
)
friend

Stream insertion operator for all vector types.

Parameters
osthe output stream to print to
vecthe vector to print
Returns
reference to os

Definition at line 346 of file VectorBase.hpp.


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