#include <PetscVector.hxx>
Public Types | |
typedef Allocator::value_type | value_type |
typedef Allocator::pointer | pointer |
typedef Allocator::const_pointer | const_pointer |
typedef Allocator::reference | reference |
typedef Allocator::const_reference | const_reference |
Public Member Functions | |
PETScVector () | |
Default constructor. | |
PETScVector (int i, MPI_Comm mpi_communicator=MPI_COMM_WORLD) | |
Main constructor. | |
PETScVector (Vec &petsc_vector) | |
Copy constructor. | |
PETScVector (const PETScVector< T, Allocator > &A) | |
Copy constructor. | |
~PETScVector () | |
Destructor. | |
Vec & | GetPetscVector () |
Returns a reference on the inner petsc vector. | |
const Vec & | GetPetscVector () const |
Returns a const reference on the inner petsc vector. | |
void | SetCommunicator (MPI_Comm mpi_communicator) |
Sets the MPI communicator. | |
void | Clear () |
Clears the vector. | |
void | Resize (int i) |
Changes the length of the vector, and keeps previous values. | |
void | SetData (int i, pointer data) |
void | Nullify () |
Clears the vector without releasing memory. | |
value_type | operator() (int i) const |
Access operator. | |
void | SetBuffer (int i, T value, InsertMode insert_mode=INSERT_VALUES) |
Inserts or adds values into certain locations of a vector. | |
void | Flush () |
Assembles the PETSc vector. | |
void | GetProcessorRange (int &i, int &j) const |
Returns the range of indices owned by this processor. | |
void | Copy (const PETScVector< T, Allocator > &X) |
Duplicates a vector. | |
void | Copy (const Vec &petsc_vector) |
Duplicates a vector. | |
void | Append (const T &x) |
Appends an element to the vector. | |
int | GetDataSize () const |
Returns the number of elements stored. | |
int | GetLocalM () const |
Returns the number of elements stored. | |
void | Zero () |
Sets all elements to zero. | |
void | Fill () |
Fills the vector with 0, 1, 2, ... | |
template<class T0 > | |
void | Fill (const T0 &x) |
Fills the vector with a given value. | |
void | FillRand () |
Fills the vector randomly. | |
value_type | GetNormInf () const |
Returns the infinite norm. | |
int | GetNormInfIndex () const |
Returns the index of the highest absolute value. | |
int | GetM () const |
Returns the number of elements. | |
int | GetLength () const |
Returns the number of elements. | |
int | GetSize () const |
Returns the number of elements stored. | |
pointer | GetData () const |
Returns a pointer to data_ (stored data). | |
const_pointer | GetDataConst () const |
Returns a const pointer to data_ (stored data). | |
void * | GetDataVoid () const |
Returns a pointer of type "void*" to the data array (data_). | |
const void * | GetDataConstVoid () const |
Returns a pointer of type "const void*" to the data array (data_). | |
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 | |
int | m_ |
pointer | data_ |
Static Protected Attributes | |
static Allocator | vect_allocator_ |
PETSc vector class.
Definition at line 41 of file PetscVector.hxx.
Seldon::PETScVector< T, Allocator >::PETScVector | ( | ) | [explicit] |
Seldon::PETScVector< T, Allocator >::PETScVector | ( | int | i, | |
MPI_Comm | mpi_communicator = MPI_COMM_WORLD | |||
) | [explicit] |
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 52 of file PetscVector.cxx.
Seldon::PETScVector< T, Allocator >::PETScVector | ( | Vec & | petsc_vector | ) |
Copy constructor.
Builds a copy of a vector.
[in] | petsc_vector | vector to be copied. |
Definition at line 66 of file PetscVector.cxx.
Seldon::PETScVector< T, Allocator >::PETScVector | ( | const PETScVector< T, Allocator > & | V | ) |
Copy constructor.
Builds a copy of a vector.
[in] | V | vector to be copied. |
Definition at line 79 of file PetscVector.cxx.
void Seldon::PETScVector< T, Allocator >::Append | ( | const T & | x | ) | [inline] |
Appends an element to the vector.
x | element to be appended. |
Definition at line 332 of file PetscVector.cxx.
void Seldon::PETScVector< T, Allocator >::Clear | ( | ) | [inline] |
Clears the vector.
Destructs the vector.
Definition at line 142 of file PetscVector.cxx.
void Seldon::PETScVector< T, Allocator >::Copy | ( | const Vec & | petsc_vector | ) | [inline] |
Duplicates a vector.
petsc_vector | vector to be copied. |
Reimplemented in Seldon::Vector< T, PETScSeq, Allocator >, and Seldon::Vector< T, PETScPar, Allocator >.
Definition at line 307 of file PetscVector.cxx.
void Seldon::PETScVector< T, Allocator >::Copy | ( | const PETScVector< T, Allocator > & | X | ) | [inline] |
Duplicates a vector.
X | vector to be copied. |
Definition at line 293 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 408 of file PetscVector.cxx.
void Seldon::PETScVector< T, Allocator >::FillRand | ( | ) |
Fills the vector randomly.
Definition at line 422 of file PetscVector.cxx.
Vector_Base< T, Allocator >::pointer Seldon::Vector_Base< T, Allocator >::GetData | ( | ) | const [inherited] |
Returns a pointer to data_ (stored data).
Definition at line 156 of file Vector.cxx.
Vector_Base< T, Allocator >::const_pointer Seldon::Vector_Base< T, Allocator >::GetDataConst | ( | ) | const [inherited] |
Returns a const pointer to data_ (stored data).
Definition at line 168 of file Vector.cxx.
const void * Seldon::Vector_Base< T, Allocator >::GetDataConstVoid | ( | ) | const [inherited] |
Returns a pointer of type "const void*" to the data array (data_).
Definition at line 191 of file Vector.cxx.
int Seldon::PETScVector< T, Allocator >::GetDataSize | ( | ) | const |
Returns the number of elements stored.
Definition at line 348 of file PetscVector.cxx.
void * Seldon::Vector_Base< T, Allocator >::GetDataVoid | ( | ) | const [inherited] |
Returns a pointer of type "void*" to the data array (data_).
Definition at line 180 of file Vector.cxx.
int Seldon::Vector_Base< T, Allocator >::GetLength | ( | ) | const [inherited] |
Returns the number of elements.
Reimplemented in Seldon::Vector< FloatDouble, DenseSparseCollection, Allocator< T > >, and Seldon::Vector< T, Collection, Allocator >.
Definition at line 133 of file Vector.cxx.
int Seldon::PETScVector< T, Allocator >::GetLocalM | ( | ) | const |
Returns the number of elements stored.
Definition at line 359 of file PetscVector.cxx.
int Seldon::Vector_Base< T, Allocator >::GetM | ( | ) | const [inherited] |
Returns the number of elements.
Reimplemented in Seldon::Vector< FloatDouble, DenseSparseCollection, Allocator< T > >, and Seldon::Vector< T, Collection, Allocator >.
Definition at line 122 of file Vector.cxx.
PETScVector< T, Allocator >::value_type Seldon::PETScVector< T, Allocator >::GetNormInf | ( | ) | const |
Returns the infinite norm.
Definition at line 447 of file PetscVector.cxx.
int Seldon::PETScVector< T, Allocator >::GetNormInfIndex | ( | ) | const |
Returns the index of the highest absolute value.
Definition at line 462 of file PetscVector.cxx.
const Vec & Seldon::PETScVector< T, Allocator >::GetPetscVector | ( | ) | const |
Returns a const reference on the inner petsc vector.
Definition at line 114 of file PetscVector.cxx.
Vec & Seldon::PETScVector< T, Allocator >::GetPetscVector | ( | ) |
Returns a reference on the inner petsc vector.
Definition at line 103 of file PetscVector.cxx.
void Seldon::PETScVector< T, Allocator >::GetProcessorRange | ( | int & | i, | |
int & | j | |||
) | const [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 277 of file PetscVector.cxx.
int Seldon::Vector_Base< T, Allocator >::GetSize | ( | ) | const [inherited] |
Returns the number of elements stored.
Definition at line 144 of file Vector.cxx.
void Seldon::PETScVector< T, Allocator >::Nullify | ( | ) |
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 195 of file PetscVector.cxx.
PETScVector< T, Allocator >::value_type Seldon::PETScVector< T, Allocator >::operator() | ( | int | i | ) | const [inline] |
Access operator.
i | index. |
Definition at line 213 of file PetscVector.cxx.
void Seldon::PETScVector< T, Allocator >::Resize | ( | int | n | ) | [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 159 of file PetscVector.cxx.
void Seldon::PETScVector< T, Allocator >::SetBuffer | ( | int | i, | |
T | value, | |||
InsertMode | insert_mode = INSERT_VALUES | |||
) | [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 242 of file PetscVector.cxx.
void Seldon::PETScVector< T, Allocator >::SetCommunicator | ( | MPI_Comm | mpi_communicator | ) |
Sets the MPI communicator.
[in] | mpi_communicator | the mpi communicator to be set. |
Definition at line 125 of file PetscVector.cxx.
void Seldon::PETScVector< T, Allocator >::Zero | ( | ) |
Sets all elements to zero.
Definition at line 378 of file PetscVector.cxx.