Public Member Functions | |
Vector () | |
Vector (const unsigned int n) | |
template<typename Number > | |
Vector (const ::Vector< Number > &v) | |
Vector (const Vector &v) | |
Vector (const MPI::Vector &v) | |
Vector & | operator= (const Vector &v) |
Vector & | operator= (const MPI::Vector &v) |
Vector & | operator= (const PetscScalar s) |
template<typename number > | |
Vector & | operator= (const ::Vector< number > &v) |
void | reinit (const unsigned int N, const bool fast=false) |
void | reinit (const Vector &v, const bool fast=false) |
Protected Member Functions | |
void | create_vector (const unsigned int n) |
Implementation of a sequential vector class based on PETSC. All the functionality is actually in the base class, except for the calls to generate a sequential vector. This is possible since PETSc only works on an abstract vector type and internally distributes to functions that do the actual work depending on the actual vector type (much like using virtual functions). Only the functions creating a vector of specific type differ, and are implemented in this particular class.
PETScWrappers::Vector::Vector | ( | ) |
Default constructor. Initialize the vector as empty.
Constructor. Set dimension to n
and initialize all elements with zero.
The constructor is made explicit to avoid accidents like this: v=0;
. Presumably, the user wants to set every element of the vector to zero, but instead, what happens is this call: v=Vector<number>(0);
, i.e. the vector is replaced by one of length zero.
PETScWrappers::Vector::Vector | ( | const ::Vector< Number > & | v | ) | [inline, explicit] |
Copy-constructor from deal.II vectors. Sets the dimension to that of the given vector, and copies all elements.
PETScWrappers::Vector::Vector | ( | const Vector & | v | ) |
Copy-constructor the values from a PETSc wrapper vector class.
PETScWrappers::Vector::Vector | ( | const MPI::Vector & | v | ) | [explicit] |
Copy-constructor: copy the values from a PETSc wrapper parallel vector class.
Note that due to the communication model of MPI, all processes have to actually perform this operation, even if they do not use the result. It is not sufficient if only one processor tries to copy the elements from the other processors over to its own process space.
Copy the given vector. Resize the present vector if necessary.
Vector& PETScWrappers::Vector::operator= | ( | const MPI::Vector & | v | ) |
Copy all the elements of the parallel vector v
into this local vector. Note that due to the communication model of MPI, all processes have to actually perform this operation, even if they do not use the result. It is not sufficient if only one processor tries to copy the elements from the other processors over to its own process space.
Vector& PETScWrappers::Vector::operator= | ( | const PetscScalar | s | ) |
Set all components of the vector to the given number s
. Simply pass this down to the base class, but we still need to declare this function to make the example given in the discussion about making the constructor explicit work.
Since the semantics of assigning a scalar to a vector are not immediately clear, this operator should really only be used if you want to set the entire vector to zero. This allows the intuitive notation v=0
. Assigning other values is deprecated and may be disallowed in the future.
Reimplemented from PETScWrappers::VectorBase.
Vector& PETScWrappers::Vector::operator= | ( | const ::Vector< number > & | v | ) | [inline] |
Copy the values of a deal.II vector (as opposed to those of the PETSc vector wrapper class) into this object.
Change the dimension of the vector to N
. It is unspecified how resizing the vector affects the memory allocation of this object; i.e., it is not guaranteed that resizing it to a smaller size actually also reduces memory consumption, or if for efficiency the same amount of memory is used for less data.
If fast
is false, the vector is filled by zeros. Otherwise, the elements are left an unspecified state.
Change the dimension to that of the vector v
. The same applies as for the other reinit() function.
The elements of v
are not copied, i.e. this function is the same as calling reinit (v.size(), fast)
.
Create a vector of length n
. For this class, we create a sequential vector. n
denotes the total size of the vector to be created.