preCICE
Loading...
Searching...
No Matches
precice::utils::petsc::Vector Class Reference

#include <Petsc.hpp>

Collaboration diagram for precice::utils::petsc::Vector:
[legend]

Public Types

enum  LEFTRIGHT { LEFT , RIGHT }

Public Member Functions

 Vector (const std::string &name="")
 Creates a new vector on the given MPI communicator.
 Vector (const Vector &other)
Vectoroperator= (const Vector &other)
 Vector (Vector &&other) noexcept
Vectoroperator= (Vector &&other) noexcept
 Vector (Vec &other, const std::string &name="")
 ~Vector ()
void swap (Vector &other) noexcept
 Swaps the ownership of two vectors.
 operator Vec & ()
 Enables implicit conversion into a reference to a PETSc Vec type.
void init (PetscInt rows)
 Sets the size and calls VecSetFromOptions.
PetscInt getSize () const
PetscInt getLocalSize () const
void setValue (PetscInt row, PetscScalar value)
void arange (double start, double stop)
void fillWithRandoms ()
VectorcopyFrom (precice::span< const double > source)
VectorcopyTo (precice::span< double > destination)
void sort ()
 Sorts the LOCAL partition of the vector.
void assemble ()
std::pair< PetscInt, PetscInt > ownerRange () const
 Returns a pair that mark the beginning and end of the vectors ownership range. Use first and second to access.
void write (const std::string &filename, VIEWERFORMAT format=ASCII) const
 Writes the vector to file.
void read (const std::string &filename, VIEWERFORMAT format=ASCII)
 Reads the vector from file.
void view () const
 Prints the vector.
double l2norm () const
 returns the l2-norm of the vector

Static Public Member Functions

Allocation
static Vector allocate (const std::string &name="")
 Allocates a new vector on the given MPI communicator.
static Vector allocate (Vector &other, const std::string &name="")
static Vector allocate (Vec &other, const std::string &name="")
 Allocated an uninitialized vector of identical shape.
static Vector allocate (Matrix &m, const std::string &name="", LEFTRIGHT type=LEFT)
 Allocates a vector with the same number of rows (default) or columns.
static Vector allocate (Mat &m, const std::string &name="", LEFTRIGHT type=LEFT)
 Allocates a vector with the same number of rows (default) or columns.

Public Attributes

Vec vector = nullptr

Static Private Attributes

static logging::Logger _log

Detailed Description

Definition at line 54 of file Petsc.hpp.

Member Enumeration Documentation

◆ LEFTRIGHT

Enumerator
LEFT 
RIGHT 

Definition at line 58 of file Petsc.hpp.

Constructor & Destructor Documentation

◆ Vector() [1/4]

precice::utils::petsc::Vector::Vector ( const std::string & name = "")
explicit

Creates a new vector on the given MPI communicator.

Definition at line 181 of file Petsc.cpp.

Here is the call graph for this function:

◆ Vector() [2/4]

precice::utils::petsc::Vector::Vector ( const Vector & other)

Copy construction from another vector Duplicates the vector and copies the name

Definition at line 152 of file Petsc.cpp.

Here is the call graph for this function:

◆ Vector() [3/4]

precice::utils::petsc::Vector::Vector ( Vector && other)
noexcept

Move construction Takes ownership of the other vector.

Definition at line 169 of file Petsc.cpp.

Here is the call graph for this function:

◆ Vector() [4/4]

precice::utils::petsc::Vector::Vector ( Vec & other,
const std::string & name = "" )

Constructs the object from another Vec Takes ownership of the other Vec

Definition at line 191 of file Petsc.cpp.

Here is the call graph for this function:

◆ ~Vector()

precice::utils::petsc::Vector::~Vector ( )

Definition at line 197 of file Petsc.cpp.

Member Function Documentation

◆ allocate() [1/5]

Vector precice::utils::petsc::Vector::allocate ( const std::string & name = "")
static

Allocates a new vector on the given MPI communicator.

Definition at line 207 of file Petsc.cpp.

Here is the call graph for this function:

◆ allocate() [2/5]

Vector precice::utils::petsc::Vector::allocate ( Mat & m,
const std::string & name = "",
LEFTRIGHT type = LEFT )
static

Allocates a vector with the same number of rows (default) or columns.

Definition at line 231 of file Petsc.cpp.

Here is the call graph for this function:

◆ allocate() [3/5]

Vector precice::utils::petsc::Vector::allocate ( Matrix & m,
const std::string & name = "",
LEFTRIGHT type = LEFT )
static

Allocates a vector with the same number of rows (default) or columns.

Definition at line 226 of file Petsc.cpp.

Here is the call graph for this function:

◆ allocate() [4/5]

Vector precice::utils::petsc::Vector::allocate ( Vec & other,
const std::string & name = "" )
static

Allocated an uninitialized vector of identical shape.

Definition at line 217 of file Petsc.cpp.

Here is the call graph for this function:

◆ allocate() [5/5]

Vector precice::utils::petsc::Vector::allocate ( Vector & other,
const std::string & name = "" )
static

Allocated an uninitialized vector of identical shape. Duplicates type, row layout etc. (not values) of v.

Definition at line 212 of file Petsc.cpp.

Here is the call graph for this function:

◆ arange()

void precice::utils::petsc::Vector::arange ( double start,
double stop )

Definition at line 290 of file Petsc.cpp.

◆ assemble()

void precice::utils::petsc::Vector::assemble ( )

Definition at line 374 of file Petsc.cpp.

◆ copyFrom()

Vector & precice::utils::petsc::Vector::copyFrom ( precice::span< const double > source)

Definition at line 323 of file Petsc.cpp.

Here is the call graph for this function:

◆ copyTo()

Vector & precice::utils::petsc::Vector::copyTo ( precice::span< double > destination)

Definition at line 340 of file Petsc.cpp.

Here is the call graph for this function:

◆ fillWithRandoms()

void precice::utils::petsc::Vector::fillWithRandoms ( )

Definition at line 306 of file Petsc.cpp.

Here is the call graph for this function:

◆ getLocalSize()

PetscInt precice::utils::petsc::Vector::getLocalSize ( ) const

Definition at line 274 of file Petsc.cpp.

◆ getSize()

PetscInt precice::utils::petsc::Vector::getSize ( ) const

Definition at line 265 of file Petsc.cpp.

◆ init()

void precice::utils::petsc::Vector::init ( PetscInt rows)

Sets the size and calls VecSetFromOptions.

Definition at line 256 of file Petsc.cpp.

◆ l2norm()

double precice::utils::petsc::Vector::l2norm ( ) const

returns the l2-norm of the vector

Definition at line 396 of file Petsc.cpp.

◆ operator Vec &()

precice::utils::petsc::Vector::operator Vec & ( )

Enables implicit conversion into a reference to a PETSc Vec type.

Definition at line 251 of file Petsc.cpp.

◆ operator=() [1/2]

Vector & precice::utils::petsc::Vector::operator= ( const Vector & other)

Copy assignment Destroys the current vector and takes ownership of the other.

Definition at line 162 of file Petsc.cpp.

Here is the call graph for this function:

◆ operator=() [2/2]

Vector & precice::utils::petsc::Vector::operator= ( Vector && other)
noexcept

Move assignment Destroys the current vector and takes ownership of the other.

Definition at line 175 of file Petsc.cpp.

Here is the call graph for this function:

◆ ownerRange()

std::pair< PetscInt, PetscInt > precice::utils::petsc::Vector::ownerRange ( ) const

Returns a pair that mark the beginning and end of the vectors ownership range. Use first and second to access.

Definition at line 383 of file Petsc.cpp.

◆ read()

void precice::utils::petsc::Vector::read ( const std::string & filename,
VIEWERFORMAT format = ASCII )

Reads the vector from file.

Definition at line 403 of file Petsc.cpp.

Here is the call graph for this function:

◆ setValue()

void precice::utils::petsc::Vector::setValue ( PetscInt row,
PetscScalar value )

Definition at line 283 of file Petsc.cpp.

◆ sort()

void precice::utils::petsc::Vector::sort ( )

Sorts the LOCAL partition of the vector.

Definition at line 359 of file Petsc.cpp.

◆ swap()

void precice::utils::petsc::Vector::swap ( Vector & other)
noexcept

Swaps the ownership of two vectors.

Definition at line 245 of file Petsc.cpp.

Here is the call graph for this function:

◆ view()

void precice::utils::petsc::Vector::view ( ) const

Prints the vector.

Definition at line 409 of file Petsc.cpp.

◆ write()

void precice::utils::petsc::Vector::write ( const std::string & filename,
VIEWERFORMAT format = ASCII ) const

Writes the vector to file.

Definition at line 390 of file Petsc.cpp.

Here is the call graph for this function:

Member Data Documentation

◆ _log

precice::logging::Logger precice::utils::petsc::Vector::_log
staticprivate

Definition at line 157 of file Petsc.hpp.

◆ vector

Vec precice::utils::petsc::Vector::vector = nullptr

Definition at line 56 of file Petsc.hpp.


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