Template Numerical Library version\ main:4e58ea6
Loading...
Searching...
No Matches
TNL::Containers::HypreVector Class Reference

Wrapper for Hypre's sequential vector. More...

#include <TNL/Containers/HypreVector.h>

Public Types

using ConstViewType = typename VectorType::ConstViewType
 
using DeviceType = HYPRE_Device
 
using IndexType = HYPRE_Int
 
using RealType = HYPRE_Real
 
using ValueType = RealType
 
using VectorType = Containers::Vector< RealType, DeviceType, IndexType >
 
using ViewType = typename VectorType::ViewType
 

Public Member Functions

 HypreVector (const HypreVector &other)=delete
 
 HypreVector (hypre_Vector *handle, bool take_ownership=true)
 Convert Hypre's format to HypreVector.
 
 HypreVector (HypreVector &&other) noexcept
 
 HypreVector (RealType *data, IndexType size)
 
 HypreVector (ViewType view)
 
void bind (hypre_Vector *handle, bool take_ownership=true)
 Convert Hypre's format to HypreSeqVector.
 
void bind (HypreVector &vector)
 
void bind (RealType *data, IndexType size)
 Drop previously set data (deallocate if the vector was the owner) and bind to the given data (i.e., the vector does not become the owner).
 
void bind (VectorType &vector)
 
void bind (ViewType view)
 
ConstViewType getConstView () const
 
const RealType * getData () const noexcept
 
RealType * getData () noexcept
 
IndexType getSize () const
 
ViewType getView ()
 
 operator const hypre_Vector * () const noexcept
 
 operator HYPRE_Vector () const noexcept
 
 operator hypre_Vector * () noexcept
 
HypreVectoroperator= (const HypreVector &other)=delete
 
HypreVectoroperator= (HypreVector &&other) noexcept
 
void reset ()
 Reset the vector to empty state.
 
void resize (IndexType size)
 Equivalent to setSize.
 
void resize (IndexType size, RealType value)
 Equivalent to setSize followed by setValue.
 
void setSize (IndexType size)
 Set the new vector size.
 
void setValue (RealType value)
 Set all elements of the vector to value.
 

Protected Attributes

bool owns_handle = true
 
hypre_Vector * v = nullptr
 

Detailed Description

Constructor & Destructor Documentation

◆ HypreVector()

TNL::Containers::HypreVector::HypreVector ( hypre_Vector * handle,
bool take_ownership = true )
inlineexplicit

Convert Hypre's format to HypreVector.

Parameters
handleis the Hypre vector handle.
take_ownershipindicates if the vector should take ownership of the handle, i.e. whether to call hypre_VectorDestroy when it does not need it anymore.

Member Function Documentation

◆ bind()

void TNL::Containers::HypreVector::bind ( hypre_Vector * handle,
bool take_ownership = true )
inline

Convert Hypre's format to HypreSeqVector.

Parameters
handleis the Hypre vector handle.
take_ownershipindicates if the vector should take ownership of the handle, i.e. whether to call hypre_VectorDestroy when it does not need it anymore.

◆ setSize()

void TNL::Containers::HypreVector::setSize ( IndexType size)
inline

Set the new vector size.

  • if the vector previously owned data, they are deallocated
  • new size is set
  • the vector is initialized with hypre_SeqVectorInitialize (i.e., data are allocated)

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