Loading...
Searching...
No Matches
dolfin::GenericVector Class Referenceabstract

This class defines a common interface for vectors. More...

`#include <GenericVector.h>`

Inheritance diagram for dolfin::GenericVector:
[legend]
Collaboration diagram for dolfin::GenericVector:
[legend]

## Public Member Functions

virtual | ~GenericVector ()
| Destructor.
virtual void | init (const TensorLayout &tensor_layout)
virtual std::size_t | rank () const
| Return tensor rank (number of dimensions).
virtual std::size_t | size (std::size_t dim) const
| Return size of given dimension.
virtual std::pair< std::int64_t, std::int64_t > | local_range (std::size_t dim) const
| Return local ownership range.
virtual void | get (double *block, const dolfin::la_index *num_rows, const dolfin::la_index *const *rows) const
| Get block of values using global indices.
virtual void | get_local (double *block, const dolfin::la_index *num_rows, const dolfin::la_index *const *rows) const
| Get block of values using local indices.
virtual void | set (const double *block, const dolfin::la_index *num_rows, const dolfin::la_index *const *rows)
| Set block of values using global indices.
virtual void | set_local (const double *block, const dolfin::la_index *num_rows, const dolfin::la_index *const *rows)
| Set block of values using local indices.
virtual void | add (const double *block, const dolfin::la_index *num_rows, const dolfin::la_index *const *rows)
| Add block of values using global indices.
virtual void | add_local (const double *block, const dolfin::la_index *num_rows, const dolfin::la_index *const *rows)
| Add block of values using local indices.
virtual void | add (const double *block, const std::vector< ArrayView< const dolfin::la_index > > &rows)
| Add block of values using global indices.
virtual void | add_local (const double *block, const std::vector< ArrayView< const dolfin::la_index > > &rows)
| Add block of values using local indices.
virtual void | zero ()=0
| Set all entries to zero and keep any sparse structure.
virtual void | apply (std::string mode)=0
| Finalize assembly of tensor.
virtual std::string | str (bool verbose) const =0
| Return informal string representation (pretty-print).
virtual std::shared_ptr< GenericVector > | copy () const =0
| Return copy of vector.
virtual void | init (std::size_t N)=0
| Initialize vector to global size N.
virtual void | init (std::pair< std::size_t, std::size_t > range)=0
| Initialize vector with given local ownership range.
virtual void | init (std::pair< std::size_t, std::size_t > range, const std::vector< std::size_t > &local_to_global_map, const std::vector< la_index > &ghost_indices)=0
virtual std::size_t | size () const =0
| Return global size of vector.
virtual std::size_t | local_size () const =0
| Return local size of vector.
virtual std::pair< std::int64_t, std::int64_t > | local_range () const =0
| Return local ownership range of a vector.
virtual bool | owns_index (std::size_t i) const =0
| Determine whether global vector index is owned by this process.
virtual void | get (double *block, std::size_t m, const dolfin::la_index *rows) const =0
virtual void | get_local (double *block, std::size_t m, const dolfin::la_index *rows) const =0
virtual void | set (const double *block, std::size_t m, const dolfin::la_index *rows)=0
| Set block of values using global indices.
virtual void | set_local (const double *block, std::size_t m, const dolfin::la_index *rows)=0
| Set block of values using local indices.
virtual void | add (const double *block, std::size_t m, const dolfin::la_index *rows)=0
| Add block of values using global indices.
virtual void | add_local (const double *block, std::size_t m, const dolfin::la_index *rows)=0
| Add block of values using local indices.
virtual void | get_local (std::vector< double > &values) const =0
| Get all values on local process.
virtual void | set_local (const std::vector< double > &values)=0
| Set all values on local process.
virtual void | add_local (const Array< double > &values)=0
| Add values to each entry on local process.
virtual void | gather (GenericVector &x, const std::vector< dolfin::la_index > &indices) const =0
virtual void | gather (std::vector< double > &x, const std::vector< dolfin::la_index > &indices) const =0
| Gather entries (given by global indices) into x.
virtual void | gather_on_zero (std::vector< double > &x) const =0
| Gather all entries into x on process 0.
virtual void | axpy (double a, const GenericVector &x)=0
| Add multiple of given vector (AXPY operation).
virtual void | abs ()=0
| Replace all entries in the vector by their absolute values.
virtual double | inner (const GenericVector &x) const =0
| Return inner product with given vector.
virtual double | norm (std::string norm_type) const =0
| Return norm of vector.
virtual double | min () const =0
| Return minimum value of vector.
virtual double | max () const =0
| Return maximum value of vector.
virtual double | sum () const =0
| Return sum of vector.
virtual double | sum (const Array< std::size_t > &rows) const =0
std::shared_ptr< GenericVector > | operator+ (const GenericVector &x)
| Sum two vectors (returns a new vector).
std::shared_ptr< GenericVector > | operator+ (double a)
| Add scalar to a vector (returns a new vector).
std::shared_ptr< GenericVector > | operator* (double a)
| Multiply vector by a scalar (returns a new vector).
virtual const GenericVector & | operator*= (double a)=0
| Multiply vector by given number.
virtual const GenericVector & | operator*= (const GenericVector &x)=0
| Multiply vector by another vector pointwise.
virtual const GenericVector & | operator/= (double a)=0
| Divide vector by given number.
virtual const GenericVector & | operator+= (const GenericVector &x)=0
| Add given vector.
virtual const GenericVector & | operator+= (double a)=0
| Add number to all components of a vector.
virtual const GenericVector & | operator-= (const GenericVector &x)=0
| Subtract given vector.
virtual const GenericVector & | operator-= (double a)=0
| Subtract number from all components of a vector.
virtual const GenericVector & | operator= (const GenericVector &x)=0
| Assignment operator.
virtual const GenericVector & | operator= (double a)=0
| Assignment operator.
virtual double | operator[] (dolfin::la_index i) const
| Get value of given entry.
virtual double | getitem (dolfin::la_index i) const
| Get value of given entry.
virtual void | setitem (dolfin::la_index i, double value)
Public Member Functions inherited from dolfin::GenericTensor
virtual | ~GenericTensor ()
| Destructor.
virtual bool | empty () const =0
| Return true if empty.
virtual GenericLinearAlgebraFactory & | factory () const =0
| Return linear algebra backend factory.
Public Member Functions inherited from dolfin::LinearAlgebraObject
virtual const LinearAlgebraObject * | instance () const
| Return concrete instance / unwrap (const version).
virtual LinearAlgebraObject * | instance ()
| Return concrete instance / unwrap (non-const version).
virtual std::shared_ptr< const LinearAlgebraObject > | shared_instance () const
| Return concrete shared ptr instance / unwrap (const version).
virtual std::shared_ptr< LinearAlgebraObject > | shared_instance ()
| Return concrete shared ptr instance / unwrap (non-const version).
virtual MPI_Comm | mpi_comm () const =0
| Return MPI communicator.
Public Member Functions inherited from dolfin::Variable
| Variable ()
| Create unnamed variable.
| Variable (const std::string name, const std::string label)
| Create variable with given name and label.
| Variable (const Variable &variable)
| Copy constructor.
virtual | ~Variable ()
| Destructor.
const Variable & | operator= (const Variable &variable)
| Assignment operator.
void | rename (const std::string name, const std::string label)
| Rename variable.
std::string | name () const
| Return name.
std::string | label () const
| Return label (description).
std::size_t | id () const

## Additional Inherited Members

Public Attributes inherited from dolfin::Variable
Parameters | parameters
| Parameters.

## Detailed Description

This class defines a common interface for vectors.

## Member Function Documentation

## abs()

virtual void dolfin::GenericVector::abs | ( |  | ) |

pure virtual

Replace all entries in the vector by their absolute values.

Implemented in dolfin::EigenVector, dolfin::PETScVector, dolfin::TpetraVector, and dolfin::Vector.

## add() [1/3]

virtual void dolfin::GenericVector::add | ( | const double * | block,
|  | const dolfin::la_index * | num_rows,
|  | const dolfin::la_index *const * | rows )

inline virtual

Add block of values using global indices.

Implements dolfin::GenericTensor.

## add() [2/3]

virtual void dolfin::GenericVector::add | ( | const double * | block,
|  | const std::vector< ArrayView< const dolfin::la_index > > & | rows )

inline virtual

Add block of values using global indices.

Implements dolfin::GenericTensor.

## add() [3/3]

virtual void dolfin::GenericVector::add | ( | const double * | block,
|  | std::size_t | m,
|  | const dolfin::la_index * | rows )

pure virtual

Add block of values using global indices.

Implemented in dolfin::EigenVector, dolfin::PETScVector, dolfin::TpetraVector, and dolfin::Vector.

## add_local() [1/4]

virtual void dolfin::GenericVector::add_local | ( | const Array< double > & | values | ) |

pure virtual

Add values to each entry on local process.

Implemented in dolfin::EigenVector, dolfin::PETScVector, dolfin::TpetraVector, and dolfin::Vector.

## add_local() [2/4]

virtual void dolfin::GenericVector::add_local | ( | const double * | block,
|  | const dolfin::la_index * | num_rows,
|  | const dolfin::la_index *const * | rows )

inline virtual

Add block of values using local indices.

Implements dolfin::GenericTensor.

## add_local() [3/4]

virtual void dolfin::GenericVector::add_local | ( | const double * | block,
|  | const std::vector< ArrayView< const dolfin::la_index > > & | rows )

inline virtual

Add block of values using local indices.

Implements dolfin::GenericTensor.

## add_local() [4/4]

virtual void dolfin::GenericVector::add_local | ( | const double * | block,
|  | std::size_t | m,
|  | const dolfin::la_index * | rows )

pure virtual

Add block of values using local indices.

Implemented in dolfin::EigenVector, dolfin::PETScVector, dolfin::TpetraVector, and dolfin::Vector.

## apply()

virtual void dolfin::GenericVector::apply | ( | std::string | mode | ) |

pure virtual

Finalize assembly of tensor.

Implements dolfin::GenericTensor.

Implemented in dolfin::EigenVector, dolfin::PETScVector, dolfin::TpetraVector, and dolfin::Vector.

## axpy()

virtual void dolfin::GenericVector::axpy | ( | double | a,
|  | const GenericVector & | x )

pure virtual

Add multiple of given vector (AXPY operation).

Implemented in dolfin::EigenVector, dolfin::PETScVector, dolfin::TpetraVector, and dolfin::Vector.

## copy()

virtual std::shared_ptr< GenericVector > dolfin::GenericVector::copy | ( |  | ) | const

pure virtual

Return copy of vector.

Implemented in dolfin::EigenVector, dolfin::PETScVector, dolfin::TpetraVector, and dolfin::Vector.

## gather() [1/2]

virtual void dolfin::GenericVector::gather | ( | GenericVector & | x,
|  | const std::vector< dolfin::la_index > & | indices ) const

pure virtual

Gather entries (given by global indices) into local vector x

Implemented in dolfin::EigenVector, dolfin::PETScVector, dolfin::TpetraVector, and dolfin::Vector.

## gather() [2/2]

virtual void dolfin::GenericVector::gather | ( | std::vector< double > & | x,
|  | const std::vector< dolfin::la_index > & | indices ) const

pure virtual

Gather entries (given by global indices) into x.

Implemented in dolfin::EigenVector, dolfin::PETScVector, dolfin::TpetraVector, and dolfin::Vector.

## gather_on_zero()

virtual void dolfin::GenericVector::gather_on_zero | ( | std::vector< double > & | x | ) | const

pure virtual

Gather all entries into x on process 0.

Implemented in dolfin::EigenVector, dolfin::PETScVector, dolfin::TpetraVector, and dolfin::Vector.

## get() [1/2]

virtual void dolfin::GenericVector::get | ( | double * | block,
|  | const dolfin::la_index * | num_rows,
|  | const dolfin::la_index *const * | rows ) const

inline virtual

Get block of values using global indices.

Implements dolfin::GenericTensor.

## get() [2/2]

virtual void dolfin::GenericVector::get | ( | double * | block,
|  | std::size_t | m,
|  | const dolfin::la_index * | rows ) const

pure virtual

Get block of values using global indices (values must all live on the local process, ghosts cannot be accessed)

Implemented in dolfin::EigenVector, dolfin::PETScVector, dolfin::TpetraVector, and dolfin::Vector.

## get_local() [1/2]

virtual void dolfin::GenericVector::get_local | ( | double * | block,
|  | std::size_t | m,
|  | const dolfin::la_index * | rows ) const

pure virtual

Get block of values using local indices (values must all live on the local process, ghost are accessible)

Implemented in dolfin::EigenVector, dolfin::PETScVector, dolfin::TpetraVector, and dolfin::Vector.

## get_local() [2/2]

virtual void dolfin::GenericVector::get_local | ( | std::vector< double > & | values | ) | const

pure virtual

Get all values on local process.

Implemented in dolfin::EigenVector, dolfin::PETScVector, dolfin::TpetraVector, and dolfin::Vector.

## init() [1/4]

virtual void dolfin::GenericVector::init | ( | const TensorLayout & | tensor_layout | ) |

inline virtual

Initialize zero tensor using sparsity pattern FIXME: This needs to be implemented on backend side! Remove it!

Implements dolfin::GenericTensor.

Reimplemented in dolfin::EigenVector, dolfin::PETScVector, dolfin::TpetraVector, and dolfin::Vector.

## init() [2/4]

virtual void dolfin::GenericVector::init | ( | std::pair< std::size_t, std::size_t > | range | ) |

pure virtual

Initialize vector with given local ownership range.

Implemented in dolfin::EigenVector, dolfin::PETScVector, dolfin::TpetraVector, and dolfin::Vector.

## init() [3/4]

virtual void dolfin::GenericVector::init | ( | std::pair< std::size_t, std::size_t > | range,
|  | const std::vector< std::size_t > & | local_to_global_map,
|  | const std::vector< la_index > & | ghost_indices )

pure virtual

Initialise vector with given ownership range and with ghost values FIXME: Reimplement using init(const TensorLayout&) and deprecate

Implemented in dolfin::EigenVector, dolfin::PETScVector, dolfin::TpetraVector, and dolfin::Vector.

## init() [4/4]

virtual void dolfin::GenericVector::init | ( | std::size_t | N | ) |

pure virtual

Initialize vector to global size N.

Implemented in dolfin::EigenVector, dolfin::PETScVector, dolfin::TpetraVector, and dolfin::Vector.

## inner()

virtual double dolfin::GenericVector::inner | ( | const GenericVector & | x | ) | const

pure virtual

Return inner product with given vector.

Implemented in dolfin::EigenVector, dolfin::PETScVector, dolfin::TpetraVector, and dolfin::Vector.

## local_range() [1/2]

virtual std::pair< std::int64_t, std::int64_t > dolfin::GenericVector::local_range | ( |  | ) | const

pure virtual

Return local ownership range of a vector.

Implemented in dolfin::EigenVector, dolfin::PETScVector, dolfin::TpetraVector, and dolfin::Vector.

## local_range() [2/2]

virtual std::pair< std::int64_t, std::int64_t > dolfin::GenericVector::local_range | ( | std::size_t | dim | ) | const

inline virtual

Return local ownership range.

Implements dolfin::GenericTensor.

## local_size()

virtual std::size_t dolfin::GenericVector::local_size | ( |  | ) | const

pure virtual

Return local size of vector.

Implemented in dolfin::EigenVector, dolfin::PETScVector, dolfin::TpetraVector, and dolfin::Vector.

## max()

virtual double dolfin::GenericVector::max | ( |  | ) | const

pure virtual

Return maximum value of vector.

Implemented in dolfin::EigenVector, dolfin::PETScVector, dolfin::TpetraVector, and dolfin::Vector.

## min()

virtual double dolfin::GenericVector::min | ( |  | ) | const

pure virtual

Return minimum value of vector.

Implemented in dolfin::EigenVector, dolfin::PETScVector, dolfin::TpetraVector, and dolfin::Vector.

## norm()

virtual double dolfin::GenericVector::norm | ( | std::string | norm_type | ) | const

pure virtual

Return norm of vector.

Implemented in dolfin::EigenVector, dolfin::PETScVector, dolfin::TpetraVector, and dolfin::Vector.

## operator*=() [1/2]

virtual const GenericVector & dolfin::GenericVector::operator*= | ( | const GenericVector & | x | ) |

pure virtual

Multiply vector by another vector pointwise.

Implemented in dolfin::EigenVector, dolfin::PETScVector, dolfin::TpetraVector, and dolfin::Vector.

## operator*=() [2/2]

virtual const GenericVector & dolfin::GenericVector::operator*= | ( | double | a | ) |

pure virtual

Multiply vector by given number.

Implemented in dolfin::EigenVector, dolfin::PETScVector, dolfin::TpetraVector, and dolfin::Vector.

## operator+=() [1/2]

virtual const GenericVector & dolfin::GenericVector::operator+= | ( | const GenericVector & | x | ) |

pure virtual

Add given vector.

Implemented in dolfin::EigenVector, dolfin::PETScVector, dolfin::TpetraVector, and dolfin::Vector.

## operator+=() [2/2]

virtual const GenericVector & dolfin::GenericVector::operator+= | ( | double | a | ) |

pure virtual

Add number to all components of a vector.

Implemented in dolfin::EigenVector, dolfin::PETScVector, dolfin::TpetraVector, and dolfin::Vector.

## operator-=() [1/2]

virtual const GenericVector & dolfin::GenericVector::operator-= | ( | const GenericVector & | x | ) |

pure virtual

Subtract given vector.

Implemented in dolfin::EigenVector, dolfin::PETScVector, dolfin::TpetraVector, and dolfin::Vector.

## operator-=() [2/2]

virtual const GenericVector & dolfin::GenericVector::operator-= | ( | double | a | ) |

pure virtual

Subtract number from all components of a vector.

Implemented in dolfin::EigenVector, dolfin::PETScVector, dolfin::TpetraVector, and dolfin::Vector.

## operator/=()

virtual const GenericVector & dolfin::GenericVector::operator/= | ( | double | a | ) |

pure virtual

Divide vector by given number.

Implemented in dolfin::EigenVector, dolfin::PETScVector, dolfin::TpetraVector, and dolfin::Vector.

## operator=() [1/2]

virtual const GenericVector & dolfin::GenericVector::operator= | ( | const GenericVector & | x | ) |

pure virtual

Assignment operator.

Implemented in dolfin::EigenVector, dolfin::PETScVector, dolfin::TpetraVector, and dolfin::Vector.

## operator=() [2/2]

virtual const GenericVector & dolfin::GenericVector::operator= | ( | double | a | ) |

pure virtual

Assignment operator.

Implemented in dolfin::EigenVector, dolfin::PETScVector, dolfin::TpetraVector, and dolfin::Vector.

## operator[]()

virtual double dolfin::GenericVector::operator[] | ( | dolfin::la_index | i | ) | const

inline virtual

Get value of given entry.

Reimplemented in dolfin::EigenVector.

## owns_index()

virtual bool dolfin::GenericVector::owns_index | ( | std::size_t | i | ) | const

pure virtual

Determine whether global vector index is owned by this process.

Implemented in dolfin::EigenVector, dolfin::PETScVector, dolfin::TpetraVector, and dolfin::Vector.

## rank()

virtual std::size_t dolfin::GenericVector::rank | ( |  | ) | const

inline virtual

Return tensor rank (number of dimensions).

Implements dolfin::GenericTensor.

## set() [1/2]

virtual void dolfin::GenericVector::set | ( | const double * | block,
|  | const dolfin::la_index * | num_rows,
|  | const dolfin::la_index *const * | rows )

inline virtual

Set block of values using global indices.

Implements dolfin::GenericTensor.

## set() [2/2]

virtual void dolfin::GenericVector::set | ( | const double * | block,
|  | std::size_t | m,
|  | const dolfin::la_index * | rows )

pure virtual

Set block of values using global indices.

Implemented in dolfin::EigenVector, dolfin::PETScVector, dolfin::TpetraVector, and dolfin::Vector.

## set_local() [1/3]

virtual void dolfin::GenericVector::set_local | ( | const double * | block,
|  | const dolfin::la_index * | num_rows,
|  | const dolfin::la_index *const * | rows )

inline virtual

Set block of values using local indices.

Implements dolfin::GenericTensor.

## set_local() [2/3]

virtual void dolfin::GenericVector::set_local | ( | const double * | block,
|  | std::size_t | m,
|  | const dolfin::la_index * | rows )

pure virtual

Set block of values using local indices.

Implemented in dolfin::EigenVector, dolfin::PETScVector, dolfin::TpetraVector, and dolfin::Vector.

## set_local() [3/3]

virtual void dolfin::GenericVector::set_local | ( | const std::vector< double > & | values | ) |

pure virtual

Set all values on local process.

Implemented in dolfin::EigenVector, dolfin::PETScVector, dolfin::TpetraVector, and dolfin::Vector.

## setitem()

virtual void dolfin::GenericVector::setitem | ( | dolfin::la_index | i,
|  | double | value )

inline virtual

Set given entry to value. apply("insert") should be called before using using the object.

## size() [1/2]

virtual std::size_t dolfin::GenericVector::size | ( |  | ) | const

pure virtual

Return global size of vector.

Implemented in dolfin::EigenVector, dolfin::PETScVector, dolfin::TpetraVector, and dolfin::Vector.

## size() [2/2]

virtual std::size_t dolfin::GenericVector::size | ( | std::size_t | dim | ) | const

inline virtual

Return size of given dimension.

Implements dolfin::GenericTensor.

## str()

virtual std::string dolfin::GenericVector::str | ( | bool | verbose | ) | const

pure virtual

Return informal string representation (pretty-print).

Implements dolfin::GenericTensor.

Implemented in dolfin::EigenVector, dolfin::PETScVector, dolfin::TpetraVector, and dolfin::Vector.

## sum() [1/2]

virtual double dolfin::GenericVector::sum | ( |  | ) | const

pure virtual

Return sum of vector.

Implemented in dolfin::EigenVector, dolfin::PETScVector, dolfin::TpetraVector, and dolfin::Vector.

## sum() [2/2]

virtual double dolfin::GenericVector::sum | ( | const Array< std::size_t > & | rows | ) | const

pure virtual

Return sum of selected rows in vector. Repeated entries are only summed once.

Implemented in dolfin::EigenVector, dolfin::PETScVector, dolfin::TpetraVector, and dolfin::Vector.

## zero()

virtual void dolfin::GenericVector::zero | ( |  | ) |

pure virtual

Set all entries to zero and keep any sparse structure.

Implements dolfin::GenericTensor.

Implemented in dolfin::EigenVector, dolfin::PETScVector, dolfin::TpetraVector, and dolfin::Vector.

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

- /build/dolfin-wwk1CC/dolfin-2019.2.0~legacy20240219.1c52e83/dolfin/la/GenericVector.h