Warning: this documentation for the development version is under construction.

Seldon::PETScVector< T, Allocator > Class Template Reference

#include <PetscVector.hxx>

Inheritance diagram for Seldon::PETScVector< T, Allocator >:
Seldon::Vector_Base< T, Allocator > Seldon::Vector< T, PETScPar, Allocator > Seldon::Vector< T, PETScSeq, Allocator >

List of all members.

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_

Detailed Description

template<class T, class Allocator>
class Seldon::PETScVector< T, Allocator >

PETSc vector class.

Definition at line 41 of file PetscVector.hxx.


Constructor & Destructor Documentation

template<class T , class Allocator >
Seldon::PETScVector< T, Allocator >::PETScVector (  )  [explicit]

Default constructor.

On exit, the vector is empty.

Definition at line 38 of file PetscVector.cxx.

template<class T , class Allocator >
Seldon::PETScVector< T, Allocator >::PETScVector ( int  i,
MPI_Comm  mpi_communicator = MPI_COMM_WORLD 
) [explicit]

Main constructor.

Builds a vector of a given size.

Parameters:
[in] i length of the vector.
[in] mpi_communicator MPI communicator to use.

Definition at line 52 of file PetscVector.cxx.

template<class T , class Allocator >
Seldon::PETScVector< T, Allocator >::PETScVector ( Vec &  petsc_vector  ) 

Copy constructor.

Builds a copy of a vector.

Parameters:
[in] petsc_vector vector to be copied.

Definition at line 66 of file PetscVector.cxx.

template<class T, class Allocator>
Seldon::PETScVector< T, Allocator >::PETScVector ( const PETScVector< T, Allocator > &  V  ) 

Copy constructor.

Builds a copy of a vector.

Parameters:
[in] V vector to be copied.

Definition at line 79 of file PetscVector.cxx.


Member Function Documentation

template<class T, class Allocator >
void Seldon::PETScVector< T, Allocator >::Append ( const T &  x  )  [inline]

Appends an element to the vector.

Parameters:
x element to be appended.
Warning:
This method will only work if the allocator preserves the elements while reallocating.

Definition at line 332 of file PetscVector.cxx.

template<class T , class Allocator >
void Seldon::PETScVector< T, Allocator >::Clear (  )  [inline]

Clears the vector.

Destructs the vector.

Warning:
On exit, the vector is an empty vector.

Definition at line 142 of file PetscVector.cxx.

template<class T, class Allocator>
void Seldon::PETScVector< T, Allocator >::Copy ( const Vec &  petsc_vector  )  [inline]

Duplicates a vector.

Parameters:
petsc_vector vector to be copied.
Note:
Memory is duplicated: 'X' is therefore independent from the current instance after the copy.

Reimplemented in Seldon::Vector< T, PETScSeq, Allocator >, and Seldon::Vector< T, PETScPar, Allocator >.

Definition at line 307 of file PetscVector.cxx.

template<class T, class Allocator>
void Seldon::PETScVector< T, Allocator >::Copy ( const PETScVector< T, Allocator > &  X  )  [inline]

Duplicates a vector.

Parameters:
X vector to be copied.
Note:
Memory is duplicated: 'X' is therefore independent from the current instance after the copy.

Definition at line 293 of file PetscVector.cxx.

template<class T , class Allocator >
template<class T0 >
void Seldon::PETScVector< T, Allocator >::Fill ( const T0 &  x  ) 

Fills the vector with a given value.

Parameters:
x value to fill the vector with.

Definition at line 408 of file PetscVector.cxx.

template<class T , class Allocator >
void Seldon::PETScVector< T, Allocator >::FillRand (  ) 

Fills the vector randomly.

Note:
The random generator is very basic.

Definition at line 422 of file PetscVector.cxx.

template<class T , class Allocator >
Vector_Base< T, Allocator >::pointer Seldon::Vector_Base< T, Allocator >::GetData (  )  const [inherited]

Returns a pointer to data_ (stored data).

Returns:
A pointer to the data_, i.e. the data array.

Definition at line 156 of file Vector.cxx.

template<class T , class Allocator >
Vector_Base< T, Allocator >::const_pointer Seldon::Vector_Base< T, Allocator >::GetDataConst (  )  const [inherited]

Returns a const pointer to data_ (stored data).

Returns:
A const pointer to the data_, i.e. the data array.

Definition at line 168 of file Vector.cxx.

template<class T , class Allocator >
const void * Seldon::Vector_Base< T, Allocator >::GetDataConstVoid (  )  const [inherited]

Returns a pointer of type "const void*" to the data array (data_).

Returns:
A pointer of type "const void*" to the data array.

Definition at line 191 of file Vector.cxx.

template<class T , class Allocator >
int Seldon::PETScVector< T, Allocator >::GetDataSize (  )  const

Returns the number of elements stored.

Returns:
The number of elements stored in memory.

Definition at line 348 of file PetscVector.cxx.

template<class T , class Allocator >
void * Seldon::Vector_Base< T, Allocator >::GetDataVoid (  )  const [inherited]

Returns a pointer of type "void*" to the data array (data_).

Returns:
A pointer of type "void*" to the data array.

Definition at line 180 of file Vector.cxx.

template<class T , class Allocator >
int Seldon::Vector_Base< T, Allocator >::GetLength (  )  const [inherited]

Returns the number of elements.

Returns:
The length of the vector.

Reimplemented in Seldon::Vector< FloatDouble, DenseSparseCollection, Allocator< T > >, and Seldon::Vector< T, Collection, Allocator >.

Definition at line 133 of file Vector.cxx.

template<class T , class Allocator >
int Seldon::PETScVector< T, Allocator >::GetLocalM (  )  const

Returns the number of elements stored.

Returns:
The number of elements stored in memory.

Definition at line 359 of file PetscVector.cxx.

template<class T , class Allocator >
int Seldon::Vector_Base< T, Allocator >::GetM (  )  const [inherited]

Returns the number of elements.

Returns:
The length of the vector.

Reimplemented in Seldon::Vector< FloatDouble, DenseSparseCollection, Allocator< T > >, and Seldon::Vector< T, Collection, Allocator >.

Definition at line 122 of file Vector.cxx.

template<class T , class Allocator >
PETScVector< T, Allocator >::value_type Seldon::PETScVector< T, Allocator >::GetNormInf (  )  const

Returns the infinite norm.

Returns:
The infinite norm.

Definition at line 447 of file PetscVector.cxx.

template<class T , class Allocator >
int Seldon::PETScVector< T, Allocator >::GetNormInfIndex (  )  const

Returns the index of the highest absolute value.

Returns:
The index of the element that has the highest absolute value.

Definition at line 462 of file PetscVector.cxx.

template<class T , class Allocator >
const Vec & Seldon::PETScVector< T, Allocator >::GetPetscVector (  )  const

Returns a const reference on the inner petsc vector.

Returns:
a const reference on the inner petsc vector.

Definition at line 114 of file PetscVector.cxx.

template<class T , class Allocator >
Vec & Seldon::PETScVector< T, Allocator >::GetPetscVector (  ) 

Returns a reference on the inner petsc vector.

Returns:
a reference on the inner petsc vector.

Definition at line 103 of file PetscVector.cxx.

template<class T , class Allocator >
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 $n_1$ elements on the first processor, next $n_2$ elements on the second, etc. If the current processor is $k$, this method returns $n_k$ in i and $n_{k+1}$ in j. If i is set to PETSC_NULL on entry, it is not modified by this function. Same is true for j.

Parameters:
[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.

template<class T , class Allocator >
int Seldon::Vector_Base< T, Allocator >::GetSize (  )  const [inherited]

Returns the number of elements stored.

Returns:
The length of the vector stored.

Definition at line 144 of file Vector.cxx.

template<class T , class Allocator >
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.

Warning:
Memory is not released.

Definition at line 195 of file PetscVector.cxx.

template<class T , class Allocator >
PETScVector< T, Allocator >::value_type Seldon::PETScVector< T, Allocator >::operator() ( int  i  )  const [inline]

Access operator.

Parameters:
i index.
Returns:
The value of the vector at 'i'.

Definition at line 213 of file PetscVector.cxx.

template<class T , class Allocator >
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.

Parameters:
[in] n new length of the vector.

Definition at line 159 of file PetscVector.cxx.

template<class T, class Allocator >
void Seldon::PETScVector< T, Allocator >::SetBuffer ( int  i,
value,
InsertMode  insert_mode = INSERT_VALUES 
) [inline]

Inserts or adds values into certain locations of a vector.

Warning:
These values may be cached, so 'Flush' must be called after all calls to SetBuffer() have been completed.
Parameters:
[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.

template<class T , class Allocator >
void Seldon::PETScVector< T, Allocator >::SetCommunicator ( MPI_Comm  mpi_communicator  ) 

Sets the MPI communicator.

Parameters:
[in] mpi_communicator the mpi communicator to be set.

Definition at line 125 of file PetscVector.cxx.

template<class T , class Allocator >
void Seldon::PETScVector< T, Allocator >::Zero (  ) 

Sets all elements to zero.

Warning:
It fills the memory with zeros. If the vector stores complex structures, use 'Fill' instead.

Definition at line 378 of file PetscVector.cxx.


The documentation for this class was generated from the following files: