PETSc vector class. More...
#include <PetscVector.hxx>
Public Member Functions | |
PETScVector () | |
Default constructor. More... | |
PETScVector (int i, MPI_Comm mpi_communicator=MPI_COMM_WORLD) | |
Main constructor. More... | |
PETScVector (Vec &petsc_vector) | |
Copy constructor. More... | |
PETScVector (const PETScVector< T, Allocator > &A) | |
Copy constructor. More... | |
~PETScVector () | |
Destructor. | |
Vec & | GetPetscVector () |
Returns a reference on the inner petsc vector. More... | |
const Vec & | GetPetscVector () const |
void | SetCommunicator (MPI_Comm mpi_communicator) |
Sets the MPI communicator. More... | |
void | Clear () |
Clears the vector. More... | |
void | Resize (int i) |
Changes the length of the vector, and keeps previous values. More... | |
void | SetData (int i, pointer data) |
Changes the length of the vector and sets its data array (low level method). More... | |
void | Nullify () |
Clears the vector without releasing memory. More... | |
value_type | operator() (int i) const |
Access operator. More... | |
void | SetBuffer (int i, T value, InsertMode insert_mode=INSERT_VALUES) |
Inserts or adds values into certain locations of a vector. More... | |
void | Flush () |
Assembles the PETSc vector. | |
void | GetProcessorRange (int &i, int &j) const |
Returns the range of indices owned by this processor. More... | |
void | Copy (const PETScVector< T, Allocator > &X) |
Duplicates a vector. More... | |
void | Copy (const Vec &petsc_vector) |
Duplicates a vector. More... | |
void | Append (const T &x) |
Appends an element to the vector. More... | |
int | GetDataSize () const |
Returns the number of elements stored. More... | |
int | GetLocalM () const |
Returns the number of elements stored. More... | |
void | Zero () |
Sets all elements to zero. More... | |
void | Fill () |
Fills the vector with 0, 1, 2, ... | |
template<class T0 > | |
void | Fill (const T0 &x) |
Fills the vector with a given value. More... | |
void | FillRand () |
Fills the vector randomly. More... | |
value_type | GetNormInf () const |
Returns the infinite norm. More... | |
int | GetNormInfIndex () const |
Returns the index of the highest absolute value. More... | |
long | GetM () const |
Returns the number of elements. More... | |
size_t | GetLength () const |
Returns the number of elements. More... | |
size_t | GetSize () const |
Returns the number of elements stored. More... | |
size_t | GetMemorySize () const |
Returns the memory used by the object in bytes. More... | |
pointer | GetData () const |
Returns a pointer to data_ (stored data). More... | |
const_pointer | GetDataConst () const |
Returns a const pointer to data_ (stored data). More... | |
void * | GetDataVoid () const |
Returns a pointer of type "void*" to the data array (data_). More... | |
const void * | GetDataConstVoid () const |
Returns a pointer of type "const void*" to the data array (data_). More... | |
Public Attributes | |
Vec | petsc_vector_ |
Encapsulated PETSc vector. | |
MPI_Comm | mpi_communicator_ |
The MPI communicator to use. | |
bool | petsc_vector_deallocated_ |
Boolean to indicate if the inner PETSc vector is destroyed or not. | |
Protected Attributes | |
size_t | m_ |
pointer | data_ |
PETSc vector class.
PETSc vector class.
Definition at line 41 of file PetscVector.hxx.
|
inlineexplicit |
Default constructor.
On exit, the vector is empty.
Definition at line 41 of file PetscVectorInline.cxx.
|
inlineexplicit |
Main constructor.
Builds a vector of a given size.
[in] | i | length of the vector. |
[in] | mpi_communicator | MPI communicator to use. |
Definition at line 55 of file PetscVectorInline.cxx.
|
inline |
Copy constructor.
Builds a copy of a vector.
[in] | petsc_vector | vector to be copied. |
Definition at line 69 of file PetscVectorInline.cxx.
|
inline |
Copy constructor.
Builds a copy of a vector.
[in] | V | vector to be copied. |
Definition at line 82 of file PetscVectorInline.cxx.
|
inline |
Appends an element to the vector.
x | element to be appended. |
Definition at line 309 of file PetscVectorInline.cxx.
|
inline |
Clears the vector.
Destructs the vector.
Definition at line 145 of file PetscVectorInline.cxx.
|
inline |
Duplicates a vector.
X | vector to be copied. |
Definition at line 296 of file PetscVectorInline.cxx.
void Seldon::PETScVector< T, Allocator >::Copy | ( | const Vec & | petsc_vector | ) |
Duplicates a vector.
petsc_vector | vector to be copied. |
Definition at line 38 of file PetscVector.cxx.
void Seldon::PETScVector< T, Allocator >::Fill | ( | const T0 & | x | ) |
Fills the vector with a given value.
x | value to fill the vector with. |
Definition at line 97 of file PetscVector.cxx.
void Seldon::PETScVector< T, Allocator >::FillRand |
Fills the vector randomly.
Definition at line 111 of file PetscVector.cxx.
|
inlineinherited |
Returns a pointer to data_ (stored data).
Definition at line 177 of file VectorInline.cxx.
|
inlineinherited |
Returns a const pointer to data_ (stored data).
Definition at line 189 of file VectorInline.cxx.
|
inlineinherited |
Returns a pointer of type "const void*" to the data array (data_).
Definition at line 212 of file VectorInline.cxx.
|
inline |
Returns the number of elements stored.
Definition at line 325 of file PetscVectorInline.cxx.
|
inlineinherited |
Returns a pointer of type "void*" to the data array (data_).
Definition at line 201 of file VectorInline.cxx.
|
inlineinherited |
Returns the number of elements.
Definition at line 142 of file VectorInline.cxx.
|
inline |
Returns the number of elements stored.
Definition at line 336 of file PetscVectorInline.cxx.
|
inlineinherited |
Returns the number of elements.
Definition at line 131 of file VectorInline.cxx.
|
inlineinherited |
Returns the memory used by the object in bytes.
In this method, the type T is assumed to be "static" such that sizeof(T) provides the correct size
Definition at line 165 of file VectorInline.cxx.
PETScVector< T, Allocator >::value_type Seldon::PETScVector< T, Allocator >::GetNormInf |
Returns the infinite norm.
Definition at line 136 of file PetscVector.cxx.
int Seldon::PETScVector< T, Allocator >::GetNormInfIndex |
Returns the index of the highest absolute value.
Definition at line 151 of file PetscVector.cxx.
|
inline |
Returns a reference on the inner petsc vector.
Returns a const reference on the inner petsc vector.
Definition at line 106 of file PetscVectorInline.cxx.
|
inline |
Returns the range of indices owned by this processor.
The vectors are laid out with the first elements on the first processor, next elements on the second, etc. If the current processor is , this method returns in i and in j. If i is set to PETSC_NULL on entry, it is not modified by this function. Same is true for j.
[in,out] | i | the index of the first local element. |
[in,out] | j | the index of the last local element, plus 1. |
Definition at line 280 of file PetscVectorInline.cxx.
|
inlineinherited |
Returns the number of elements stored.
Definition at line 153 of file VectorInline.cxx.
|
inline |
Clears the vector without releasing memory.
On exit, the vector is empty and the memory has not been released. It is useful for low level manipulations on a Vector instance.
Definition at line 198 of file PetscVectorInline.cxx.
|
inline |
Access operator.
i | index. |
Definition at line 216 of file PetscVectorInline.cxx.
|
inline |
Changes the length of the vector, and keeps previous values.
Reallocates the vector to size i. Previous values are kept.
[in] | n | new length of the vector. |
Definition at line 162 of file PetscVectorInline.cxx.
|
inline |
Inserts or adds values into certain locations of a vector.
[in] | i | index where to insert the value. |
[in] | value | the value to insert. |
[in] | insert_mode | either INSERT_VALUES or ADD_VALUES, where ADD_VALUES adds the value to the entry, and INSERT_VALUES replaces existing entry with new value. |
Definition at line 245 of file PetscVectorInline.cxx.
|
inline |
Sets the MPI communicator.
[in] | mpi_communicator | the mpi communicator to be set. |
Definition at line 128 of file PetscVectorInline.cxx.
|
inline |
Changes the length of the vector and sets its data array (low level method).
Reallocates a vector and sets the new data array. It is useful to create a vector from pre-existing data.
[in] | i | new length of the vector. |
[in] | data | the new data array. 'data' contains the new elements of the vector and must therefore contain 'i' elements. |
Definition at line 184 of file PetscVectorInline.cxx.
void Seldon::PETScVector< T, Allocator >::Zero |
Sets all elements to zero.
Definition at line 67 of file PetscVector.cxx.