GEOSX
Public Types | Public Member Functions | List of all members
geosx::HypreVector Class Referencefinal

Wrapper class for hypre's ParVector. More...

#include <HypreVector.hpp>

Inheritance diagram for geosx::HypreVector:
Inheritance graph
[legend]

Public Types

using HYPRE_IJVector = hypre_IJVector_struct *
 IJVector pointer alias.
 
using HYPRE_ParVector = hypre_ParVector_struct *
 ParVector pointer alias.
 

Public Member Functions

HYPRE_ParVector const & unwrapped () const
 Returns a pointer to the implementation. More...
 
HYPRE_IJVector const & unwrappedIJ () const
 Returns a pointer to the implementation. More...
 
Constructor/Destructor Methods
 HypreVector ()
 Empty vector constructor. Create an empty (distributed) vector.
 
 HypreVector (HypreVector const &src)
 Copy constructor. More...
 
 HypreVector (HypreVector &&src) noexcept
 Move constructor. More...
 
HypreVectoroperator= (HypreVector const &src)
 Copy assignment. More...
 
HypreVectoroperator= (HypreVector &&src) noexcept
 Move assignment. More...
 
 ~HypreVector ()
 Destructor.
 
VectorBase interface
virtual bool created () const override
 Query vector creation status. More...
 
virtual void createWithLocalSize (localIndex const localSize, MPI_Comm const &comm) override
 Create a vector based on local number of elements. More...
 
virtual void createWithGlobalSize (globalIndex const globalSize, MPI_Comm const &comm) override
 Create a vector based on global number of elements. More...
 
virtual void create (arrayView1d< real64 const > const &localValues, MPI_Comm const &comm) override
 Construct parallel vector from a local array. More...
 
virtual void open () override
 Open the vector for modifying entries.
 
virtual void close () override
 Assemble vector. More...
 
virtual void reset () override
 Reset the matrix to default state.
 
virtual void set (globalIndex const globalRowIndex, real64 const value) override
 Set vector value. More...
 
virtual void add (globalIndex const globalRowIndex, real64 const value) override
 Add into vector value. More...
 
virtual void set (globalIndex const *globalRowIndices, real64 const *values, localIndex size) override
 Set vector values. More...
 
virtual void add (globalIndex const *globalRowIndices, real64 const *values, localIndex const size) override
 Add vector values. More...
 
virtual void set (arraySlice1d< globalIndex const > const &globalRowIndices, arraySlice1d< real64 const > const &values) override
 Set vector values using array1d. More...
 
virtual void add (arraySlice1d< globalIndex const > const &globalRowIndices, arraySlice1d< real64 const > const &values) override
 Add into vector values using array1d. More...
 
virtual void set (real64 const value) override
 Set all elements to a constant value. More...
 
virtual void zero () override
 Set vector elements to zero.
 
virtual void rand (unsigned const seed=1984) override
 Set vector elements to random entries. More...
 
virtual void scale (real64 const scalingFactor) override
 Multiply all elements by scalingFactor. More...
 
virtual void reciprocal () override
 Replace vector elements by their reciprocals. More...
 
virtual real64 dot (HypreVector const &vec) const override
 Dot product with the vector vec. More...
 
virtual void copy (HypreVector const &x) override
 Update vector y as y = x. More...
 
virtual void axpy (real64 const alpha, HypreVector const &x) override
 Update vector y as y = alpha*x + y. More...
 
virtual void axpby (real64 const alpha, HypreVector const &x, real64 const beta) override
 Update vector y as y = alpha*x + beta*y. More...
 
virtual void pointwiseProduct (HypreVector const &x, HypreVector &y) const override
 Compute the componentwise multiplication y = v * x. More...
 
virtual real64 norm1 () const override
 1-norm of the vector. More...
 
virtual real64 norm2 () const override
 2-norm of the vector. More...
 
virtual real64 normInf () const override
 Infinity-norm of the vector. More...
 
virtual globalIndex globalSize () const override
 Returns the global of the vector. More...
 
virtual localIndex localSize () const override
 Returns the local size of the vector. More...
 
virtual globalIndex ilower () const override
 Get lower bound of local partition. More...
 
virtual globalIndex iupper () const override
 Get upper bound of local partition. More...
 
virtual real64 get (globalIndex globalRow) const override
 Get a value by index. More...
 
virtual void get (arraySlice1d< globalIndex const > const &globalRowIndices, arraySlice1d< real64 > const &values) const override
 Get a sequence of values by index. More...
 
virtual localIndex getLocalRowID (globalIndex const globalRowIndex) const override
 Map a global row index to local row index. More...
 
virtual globalIndex getGlobalRowID (localIndex const localRowIndex) const override
 Map a local row index to global row index. More...
 
virtual real64 const * extractLocalVector () const override
 Extract a view of the local portion of the array. More...
 
virtual real64extractLocalVector () override
 Extract a view of the local portion of the array. More...
 
virtual void extract (arrayView1d< real64 > const &localVector) const override
 Extract local solution by copying into a user-provided array. More...
 
virtual MPI_Comm getComm () const override
 Get the communicator used by this vector. More...
 
virtual void print (std::ostream &os=std::cout) const override
 Print the vector in Trilinos format to the terminal. More...
 
virtual void write (string const &filename, LAIOutputFormat const format=LAIOutputFormat::MATRIX_MARKET) const override
 Write the vector to a file. More...
 

Detailed Description

Wrapper class for hypre's ParVector.

This class creates and provides basic support for the HYPRE_ParVector object type used in Hypre using the linear-algebraic system interface (IJ interface).

Definition at line 49 of file HypreVector.hpp.

Constructor & Destructor Documentation

◆ HypreVector() [1/2]

geosx::HypreVector::HypreVector ( HypreVector const &  src)

Copy constructor.

Parameters
srcvector to be copied

◆ HypreVector() [2/2]

geosx::HypreVector::HypreVector ( HypreVector &&  src)
noexcept

Move constructor.

Parameters
srcvector to be moved

Member Function Documentation

◆ add() [1/3]

virtual void geosx::HypreVector::add ( globalIndex const  globalRow,
real64 const  value 
)
overridevirtual

Add into vector value.

Parameters
globalRowglobal row
valueValues to add in given row

Add into vector value at given row.

Implements geosx::VectorBase< HypreVector >.

◆ add() [2/3]

virtual void geosx::HypreVector::add ( globalIndex const *  globalIndices,
real64 const *  values,
localIndex const  size 
)
overridevirtual

Add vector values.

Parameters
globalIndicesglobal row indices
valuesvalues to add in given rows
sizenumber of elements

Add vector values at given elements.

Implements geosx::VectorBase< HypreVector >.

◆ add() [3/3]

virtual void geosx::HypreVector::add ( arraySlice1d< globalIndex const > const &  globalIndices,
arraySlice1d< real64 const > const &  values 
)
overridevirtual

Add into vector values using array1d.

Parameters
globalIndicesglobal rows indices
valuesvalues to add in given rows

Add into vector values at given rows.

Implements geosx::VectorBase< HypreVector >.

◆ axpby()

virtual void geosx::HypreVector::axpby ( real64 const  alpha,
HypreVector const &  x,
real64 const  beta 
)
overridevirtual

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

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

Implements geosx::VectorBase< HypreVector >.

◆ axpy()

virtual void geosx::HypreVector::axpy ( real64 const  alpha,
HypreVector const &  x 
)
overridevirtual

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

Parameters
alphascaling factor for added vector
xvector to add

Implements geosx::VectorBase< HypreVector >.

◆ close()

virtual void geosx::HypreVector::close ( )
overridevirtual

Assemble vector.

Performs parallel communication to scatter assembled entries to appropriate locations

Implements geosx::VectorBase< HypreVector >.

◆ copy()

virtual void geosx::HypreVector::copy ( HypreVector const &  x)
overridevirtual

Update vector y as y = x.

Parameters
xvector to copy

Implements geosx::VectorBase< HypreVector >.

◆ create()

virtual void geosx::HypreVector::create ( arrayView1d< real64 const > const &  localValues,
MPI_Comm const &  comm 
)
overridevirtual

Construct parallel vector from a local array.

Parameters
localValueslocal data to put into vector
commMPI communicator to use

Implements geosx::VectorBase< HypreVector >.

◆ created()

virtual bool geosx::HypreVector::created ( ) const
overridevirtual

Query vector creation status.

Returns
true if vector has been created

Implements geosx::VectorBase< HypreVector >.

◆ createWithGlobalSize()

virtual void geosx::HypreVector::createWithGlobalSize ( globalIndex const  globalSize,
MPI_Comm const &  comm 
)
overridevirtual

Create a vector based on global number of elements.

Parameters
globalSizeGlobal number of elements
commMPI 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.

Implements geosx::VectorBase< HypreVector >.

◆ createWithLocalSize()

virtual void geosx::HypreVector::createWithLocalSize ( localIndex const  localSize,
MPI_Comm const &  comm 
)
overridevirtual

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. For specifying a global size and having automatic partitioning, see createWithGlobalSize().

Implements geosx::VectorBase< HypreVector >.

◆ dot()

virtual real64 geosx::HypreVector::dot ( HypreVector const &  vec) const
overridevirtual

Dot product with the vector vec.

Parameters
vecvector to dot-product with
Returns
dot product

Implements geosx::VectorBase< HypreVector >.

◆ extract()

virtual void geosx::HypreVector::extract ( arrayView1d< real64 > const &  localVector) const
overridevirtual

Extract local solution by copying into a user-provided array.

Parameters
localVectorthe array view to write to (must be properly sized)

Reimplemented from geosx::VectorBase< HypreVector >.

◆ extractLocalVector() [1/2]

virtual real64 const* geosx::HypreVector::extractLocalVector ( ) const
overridevirtual

Extract a view of the local portion of the array.

Returns
pointer to local vector data

Implements geosx::VectorBase< HypreVector >.

◆ extractLocalVector() [2/2]

virtual real64* geosx::HypreVector::extractLocalVector ( )
overridevirtual

Extract a view of the local portion of the array.

Returns
pointer to local vector data

Implements geosx::VectorBase< HypreVector >.

◆ get() [1/2]

virtual real64 geosx::HypreVector::get ( globalIndex  globalRow) const
overridevirtual

Get a value by index.

Parameters
globalRowglobal row index
Returns
value at global index globalRow

Implements geosx::VectorBase< HypreVector >.

◆ get() [2/2]

virtual void geosx::HypreVector::get ( arraySlice1d< globalIndex const > const &  globalIndices,
arraySlice1d< real64 > const &  values 
) const
overridevirtual

Get a sequence of values by index.

Parameters
[in]globalIndicesarray of global row indices
[out]valuesarray of vector values

Implements geosx::VectorBase< HypreVector >.

◆ getComm()

virtual MPI_Comm geosx::HypreVector::getComm ( ) const
overridevirtual

Get the communicator used by this vector.

Returns
the MPI communicator

Implements geosx::VectorBase< HypreVector >.

◆ getGlobalRowID()

virtual globalIndex geosx::HypreVector::getGlobalRowID ( localIndex const  localRow) const
overridevirtual

Map a local row index to global row index.

Parameters
[in]localRowthe local row index
Returns
global row index corresponding to localRow

Implements geosx::VectorBase< HypreVector >.

◆ getLocalRowID()

virtual localIndex geosx::HypreVector::getLocalRowID ( globalIndex const  globalRow) const
overridevirtual

Map a global row index to local row index.

Parameters
[in]globalRowthe global row index
Returns
global row index corresponding to globalRow

Implements geosx::VectorBase< HypreVector >.

◆ globalSize()

virtual globalIndex geosx::HypreVector::globalSize ( ) const
overridevirtual

Returns the global of the vector.

Returns
the global size

Implements geosx::VectorBase< HypreVector >.

◆ ilower()

virtual globalIndex geosx::HypreVector::ilower ( ) const
overridevirtual

Get lower bound of local partition.

Returns
index of the first global row owned by this processor

Implements geosx::VectorBase< HypreVector >.

◆ iupper()

virtual globalIndex geosx::HypreVector::iupper ( ) const
overridevirtual

Get upper bound of local partition.

Returns
next index after last global row owned by that processor
Note
The intention is for [ilower; iupper) to be used as a half-open index range

Implements geosx::VectorBase< HypreVector >.

◆ localSize()

virtual localIndex geosx::HypreVector::localSize ( ) const
overridevirtual

Returns the local size of the vector.

Returns
the local size (on this processor)

Implements geosx::VectorBase< HypreVector >.

◆ norm1()

virtual real64 geosx::HypreVector::norm1 ( ) const
overridevirtual

1-norm of the vector.

Returns
the 1-norm value

Implements geosx::VectorBase< HypreVector >.

◆ norm2()

virtual real64 geosx::HypreVector::norm2 ( ) const
overridevirtual

2-norm of the vector.

Returns
the 2-norm value

Implements geosx::VectorBase< HypreVector >.

◆ normInf()

virtual real64 geosx::HypreVector::normInf ( ) const
overridevirtual

Infinity-norm of the vector.

Returns
the inf-norm value

Implements geosx::VectorBase< HypreVector >.

◆ operator=() [1/2]

HypreVector& geosx::HypreVector::operator= ( HypreVector const &  src)

Copy assignment.

Parameters
srcHypreVector to be copied.
Returns
the new vector.

◆ operator=() [2/2]

HypreVector& geosx::HypreVector::operator= ( HypreVector &&  src)
noexcept

Move assignment.

Parameters
srcHypreVector to be moved.
Returns
the new vector.

◆ pointwiseProduct()

virtual void geosx::HypreVector::pointwiseProduct ( HypreVector const &  x,
HypreVector y 
) const
overridevirtual

Compute the componentwise multiplication y = v * x.

Parameters
xfirst vector (input)
ysecond vector (output)

Implements geosx::VectorBase< HypreVector >.

◆ print()

virtual void geosx::HypreVector::print ( std::ostream &  os = std::cout) const
overridevirtual

Print the vector in Trilinos format to the terminal.

Parameters
osthe output stream to print to

Implements geosx::VectorBase< HypreVector >.

◆ rand()

virtual void geosx::HypreVector::rand ( unsigned const  seed = 1984)
overridevirtual

Set vector elements to random entries.

Parameters
seedthe random number seed to use

Implements geosx::VectorBase< HypreVector >.

◆ reciprocal()

virtual void geosx::HypreVector::reciprocal ( )
overridevirtual

Replace vector elements by their reciprocals.

Note
No guarding is done against division by zero.

Implements geosx::VectorBase< HypreVector >.

◆ scale()

virtual void geosx::HypreVector::scale ( real64 const  scalingFactor)
overridevirtual

Multiply all elements by scalingFactor.

Parameters
scalingFactorscaling Factor

Implements geosx::VectorBase< HypreVector >.

◆ set() [1/4]

virtual void geosx::HypreVector::set ( globalIndex const  globalRow,
real64 const  value 
)
overridevirtual

Set vector value.

Parameters
globalRowglobal row index
valueValue to add at given row

Set vector value at given element.

Implements geosx::VectorBase< HypreVector >.

◆ set() [2/4]

virtual void geosx::HypreVector::set ( globalIndex const *  globalIndices,
real64 const *  values,
localIndex  size 
)
overridevirtual

Set vector values.

Parameters
globalIndicesglobal row indices
valuesValues to add in given rows
sizeNumber of elements

Set vector values at given elements.

Implements geosx::VectorBase< HypreVector >.

◆ set() [3/4]

virtual void geosx::HypreVector::set ( arraySlice1d< globalIndex const > const &  globalIndices,
arraySlice1d< real64 const > const &  values 
)
overridevirtual

Set vector values using array1d.

Parameters
globalIndicesglobal row indices
valuesvalues to add in given rows

Set vector values at given elements.

Implements geosx::VectorBase< HypreVector >.

◆ set() [4/4]

virtual void geosx::HypreVector::set ( real64 const  value)
overridevirtual

Set all elements to a constant value.

Parameters
valuevalue to set vector elements to

Implements geosx::VectorBase< HypreVector >.

◆ unwrapped()

HYPRE_ParVector const& geosx::HypreVector::unwrapped ( ) const

Returns a pointer to the implementation.

Returns
the underlying HYPRE_ParVector object.

◆ unwrappedIJ()

HYPRE_IJVector const& geosx::HypreVector::unwrappedIJ ( ) const

Returns a pointer to the implementation.

Returns
the underlying HYPRE_IJVector object.

◆ write()

virtual void geosx::HypreVector::write ( string const &  filename,
LAIOutputFormat const  format = LAIOutputFormat::MATRIX_MARKET 
) const
overridevirtual

Write the vector to a file.

Parameters
filenamename of the output file
[in]formatoutput format

Implements geosx::VectorBase< HypreVector >.


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