Note: this is documentation for an old release. View the latest documentation at docs.fenicsproject.org/v0.1.0/v0.9.0/cpp
DOLFINx  0.1.0
DOLFINx C++ interface
Public Member Functions | List of all members
dolfinx::la::PETScVector Class Reference

A simple wrapper for a PETSc vector pointer (Vec). Its main purpose is to assist with memory/lifetime management of PETSc Vec objects. More...

#include <PETScVector.h>

Public Member Functions

 PETScVector (const common::IndexMap &map, int bs)
 Create vector. More...
 
 PETScVector (const PETScVector &x)=delete
 
 PETScVector (PETScVector &&x)
 Move constructor.
 
 PETScVector (Vec x, bool inc_ref_count)
 Create holder of a PETSc Vec object/pointer. The Vec x object should already be created. If inc_ref_count is true, the reference counter of the Vec object will be increased. The Vec reference count will always be decreased upon destruction of the the PETScVector. More...
 
virtual ~PETScVector ()
 Destructor.
 
PETScVectoroperator= (const PETScVector &x)=delete
 
PETScVectoroperator= (PETScVector &&x)
 Move Assignment operator.
 
PETScVector copy () const
 Create a copy of the vector. More...
 
std::int64_t size () const
 Return global size of vector.
 
std::int32_t local_size () const
 Return local size of vector (belonging to this process)
 
std::array< std::int64_t, 2 > local_range () const
 Return ownership range for calling rank.
 
MPI_Comm mpi_comm () const
 Return MPI communicator.
 
PetscReal norm (la::Norm type) const
 Compute norm of vector. More...
 
void set_options_prefix (std::string options_prefix)
 Sets the prefix used by PETSc when searching the options database.
 
std::string get_options_prefix () const
 Returns the prefix used by PETSc when searching the options database.
 
void set_from_options ()
 Call PETSc function VecSetFromOptions on the underlying Vec object.
 
Vec vec () const
 Return pointer to PETSc Vec object.
 

Detailed Description

A simple wrapper for a PETSc vector pointer (Vec). Its main purpose is to assist with memory/lifetime management of PETSc Vec objects.

Access the underlying PETSc Vec pointer using the function vec() and use the full PETSc interface.

Constructor & Destructor Documentation

◆ PETScVector() [1/2]

PETScVector::PETScVector ( const common::IndexMap map,
int  bs 
)

Create vector.

Collective

Parameters
[in]mapIndex map describing the parallel layout
[in]bsthe block size

◆ PETScVector() [2/2]

PETScVector::PETScVector ( Vec  x,
bool  inc_ref_count 
)

Create holder of a PETSc Vec object/pointer. The Vec x object should already be created. If inc_ref_count is true, the reference counter of the Vec object will be increased. The Vec reference count will always be decreased upon destruction of the the PETScVector.

Collective

Parameters
[in]xThe PETSc Vec
[in]inc_ref_countTrue if the reference count of x should be incremented

Member Function Documentation

◆ copy()

PETScVector PETScVector::copy ( ) const

Create a copy of the vector.

Collective

◆ norm()

PetscReal PETScVector::norm ( la::Norm  type) const

Compute norm of vector.

Collective

Parameters
[in]typeThe norm type
Returns
The norm of the vector

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