GenericVector.h

Note

The documentation on this page was automatically extracted from the DOLFIN C++ code and may need to be edited or expanded.

class GenericVector

Parent class(es)

This class defines a common interface for vectors.

void init(const TensorLayout &tensor_layout)

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

std::size_t rank() const

Return tensor rank (number of dimensions)

std::size_t size(std::size_t dim) const

Return size of given dimension

std::pair<std::int64_t, std::int64_t> local_range(std::size_t dim) const

Return local ownership range

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

Get block of values using global indices

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

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

Set block of values using global indices

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

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

Add block of values using global indices

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

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

Add block of values using global indices

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

Add block of values using local indices

void zero() = 0

Set all entries to zero and keep any sparse structure

void apply(std::string mode) = 0

Finalize assembly of tensor

std::string str(bool verbose) const = 0

Return informal string representation (pretty-print)

std::shared_ptr<GenericVector> copy() const = 0

Return copy of vector

void init(MPI_Comm comm, std::size_t N) = 0

Initialize vector to global size N

void init(MPI_Comm comm, std::pair<std::size_t, std::size_t> range) = 0

Initialize vector with given local ownership range

void init(MPI_Comm comm, 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

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

std::size_t size() const = 0

Return global size of vector

std::size_t local_size() const = 0

Return local size of vector

std::pair<std::int64_t, std::int64_t> local_range() const = 0

Return local ownership range of a vector

bool owns_index(std::size_t i) const = 0

Determine whether global vector index is owned by this process

void get(double *block, std::size_t m, const dolfin::la_index *rows) const = 0

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

void get_local(double *block, std::size_t m, const dolfin::la_index *rows) const = 0

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

void set(const double *block, std::size_t m, const dolfin::la_index *rows) = 0

Set block of values using global indices

void set_local(const double *block, std::size_t m, const dolfin::la_index *rows) = 0

Set block of values using local indices

void add(const double *block, std::size_t m, const dolfin::la_index *rows) = 0

Add block of values using global indices

void add_local(const double *block, std::size_t m, const dolfin::la_index *rows) = 0

Add block of values using local indices

void get_local(std::vector<double> &values) const = 0

Get all values on local process

void set_local(const std::vector<double> &values) = 0

Set all values on local process

void add_local(const Array<double> &values) = 0

Add values to each entry on local process

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

Gather entries into local vector x

void gather(std::vector<double> &x, const std::vector<dolfin::la_index> &indices) const = 0

Gather entries into x

void gather_on_zero(std::vector<double> &x) const = 0

Gather all entries into x on process 0

void axpy(double a, const GenericVector &x) = 0

Add multiple of given vector (AXPY operation)

void abs() = 0

Replace all entries in the vector by their absolute values

double inner(const GenericVector &x) const = 0

Return inner product with given vector

double norm(std::string norm_type) const = 0

Return norm of vector

double min() const = 0

Return minimum value of vector

double max() const = 0

Return maximum value of vector

double sum() const = 0

Return sum of vector

double sum(const Array<std::size_t> &rows) const = 0

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

const GenericVector &operator*=(double a) = 0

Multiply vector by given number

const GenericVector &operator*=(const GenericVector &x) = 0

Multiply vector by another vector pointwise

const GenericVector &operator/=(double a) = 0

Divide vector by given number

const GenericVector &operator+=(const GenericVector &x) = 0

Add given vector

const GenericVector &operator+=(double a) = 0

Add number to all components of a vector

const GenericVector &operator-=(const GenericVector &x) = 0

Subtract given vector

const GenericVector &operator-=(double a) = 0

Subtract number from all components of a vector

const GenericVector &operator=(const GenericVector &x) = 0

Assignment operator

const GenericVector &operator=(double a) = 0

Assignment operator

double operator[](dolfin::la_index i) const

Get value of given entry

double getitem(dolfin::la_index i) const

Get value of given entry

void setitem(dolfin::la_index i, double value)

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