Vector
-
class Vector : public godzilla::PetscObjectWrapper<Vec>
Subclassed by godzilla::NestVector
Public Functions
-
void assemble()
Convenience function that does
assembly_begin()andassembly_end()
-
String get_type() const
Get the vector type name.
- Returns:
The vector type
-
Int get_size() const
Returns the global number of elements of the vector.
-
Int get_local_size() const
Returns the local number of elements of the vector.
-
void copy(const IndexSet &is, ScatterMode mode, Vector &reduced)
Copies between a reduced vector and the appropriate elements of a full-space vector.
- Parameters:
is – Index set for the reduced space
mode – Direction of copying (SCATTER_FORWARD or SCATTER_REVERSE)
reduced – Reduced-space vector
-
void assign(const Vector &y)
Assign values of y into this vector.
- Parameters:
y – Vector with values to be assined into this vector
-
Real norm(NormType type) const
Computes the vector norm.
- Parameters:
type – The type of the norm requested
- Returns:
The norm
-
void set_values(Int n, const Int *ix, const Scalar *y, InsertMode mode = INSERT_VALUES)
Inserts or adds values into certain locations of a vector.
- Parameters:
n – Number of elements to insert
ix – Indices where to add/insert
y – Values
mode – Insertion mode
-
void set_values(const std::vector<Int> &ix, const std::vector<Scalar> &y, InsertMode mode = INSERT_VALUES)
Inserts or adds values into certain locations of a vector.
- Parameters:
ix – Indices where to add/insert
y – Values
mode – Insertion mode
-
template<Int N>
inline void set_values(const DenseVector<Int, N> &ix, const DenseVector<Scalar, N> &y, InsertMode mode = INSERT_VALUES) Inserts or adds values into certain locations of a vector.
- Parameters:
ix – Indices where to add/insert
y – Values
mode – Insertion mode
-
void set_values(const DynDenseVector<Int> &ix, const DynDenseVector<Scalar> &y, InsertMode mode = INSERT_VALUES)
Inserts or adds values into certain locations of a vector.
- Parameters:
ix – Indices where to add/insert
y – Values
mode – Insertion mode
-
void set_values_local(const std::vector<Int> &ix, const std::vector<Scalar> &y, InsertMode mode = INSERT_VALUES)
Inserts or adds values into certain locations of a vector, using a local ordering of the nodes.
- Parameters:
ix – Indices where to add/insert
y – Values
mode – Insertion mode
-
template<Int N>
inline void set_values_local(const DenseVector<Int, N> &ix, const DenseVector<Scalar, N> &y, InsertMode mode = INSERT_VALUES) Inserts or adds values into certain locations of a vector, using a local ordering of the nodes.
- Template Parameters:
N – Number of elements in the vectors
- Parameters:
ix – Indices where to add/insert
y – Values
mode – Insertion mode
-
void set_values_local(const DynDenseVector<Int> &ix, const DynDenseVector<Scalar> &y, InsertMode mode = INSERT_VALUES)
Inserts or adds values into certain locations of a vector, using a local ordering of the nodes.
- Parameters:
ix – Indices where to add/insert
y – Values
mode – Insertion mode
-
void set_option(VecOption op, bool flag)
Sets an option for controlling a vector’s behavior.
- Parameters:
op – The option
flag – Turn the option on or off
-
Vector get_sub_vector(const IndexSet &is) const
Gets a vector representing part of this vector.
- Parameters:
is – Index set representing portion of X to extract
-
void restore_sub_vector(const IndexSet &is, Vector &y) const
Restores a subvector extracted by
get_sub_vector- Parameters:
is – Index set representing the subset of X
y – Subvector being restored
-
Range get_ownership_range() const
Returns the range of indices owned by this process.
- Returns:
Range of elements owner by this process
Public Static Functions
-
static Vector create_seq(MPI_Comm comm, Int bs, Int n, const Scalar array[])
Creates a standard, sequential array-style vector, where the user provides the array space to store the vector values.
- Parameters:
comm – MPI communicator
bs – Block size
n – Vector length
array – Memory where the vector elements are to be stored.
-
static Vector create_seq(MPI_Comm comm, Int bs, const std::vector<Scalar> &data)
Creates a standard, sequential array-style vector, where the user provides the array space to store the vector values.
- Parameters:
comm – MPI communicator
bs – Block size
array – Memory where the vector elements are to be stored.
-
static Vector create_mpi(MPI_Comm comm, Int n, Int N)
Creates a parallel vector.
- Parameters:
comm – the MPI communicator to use
n – Local vector length (or PETSC_DECIDE to have calculated if N is given)
N – global vector length (or PETSC_DETERMINE to have calculated if n is given)
-
static Vector create_mpi(MPI_Comm comm, Int bs, Int n, Int N, const Scalar array[])
Creates a parallel, array-style vector, where the user provides the array space to store the vector values.
- Parameters:
comm – the MPI communicator to use
bs – Block size
n – Local vector length, cannot be PETSC_DECIDE
N – Global vector length (or PETSC_DETERMINE to have it calculated)
array – The user-provided array to store the vector values
-
static Vector create_mpi(MPI_Comm comm, Int bs, const std::vector<Scalar> &data, Int N = PETSC_DETERMINE)
Creates a parallel, array-style vector, where the user provides the array space to store the vector values.
- Parameters:
comm – the MPI communicator to use
bs – Block size
data – The user-provided array to store the vector values
N – Global vector length (or PETSC_DETERMINE to have it calculated)
-
static NestVector create_nest(MPI_Comm comm, const std::vector<Vector> &vecs)
Creates a new vector containing several nested subvectors, each stored separately.
- Parameters:
comm – The MPI communicator to use
vecs – The subvectors to be nested
-
void assemble()