To handle general purpose vectors using Petsc. More...
Public Member Functions  
PETScVect ()  
Default Constructor. Initialize a zerolength vector.  
PETScVect (size_t n)  
Constructor setting vector size. More...  
PETScVect (size_t nx, size_t ny)  
Constructor of a 2D index vector. More...  
PETScVect (size_t nx, size_t ny, size_t nz)  
Constructor of a 3D index vector. More...  
PETScVect (size_t n, T_ *x)  
Create an instance of class PETScVect as an image of a C/C++ array. More...  
PETScVect (MPI_Comm comm, size_t n)  
Constructor of a MPI vector using its global size. More...  
PETScVect (Mesh &m, int nb_dof=0, int dof_type=NODE_FIELD)  
Constructor with a mesh instance. More...  
PETScVect (Mesh &m, string name, real_t t=0.0, int nb_dof=0, int dof_type=NODE_FIELD)  
Constructor with a mesh instance giving name and time for vector. More...  
PETScVect (const PETScVect< T_ > &v, const PETScVect< T_ > &bc)  
Constructor using boundary conditions. More...  
PETScVect (const PETScVect< T_ > &v, size_t nb_dof, size_t first_dof)  
Constructor to select some components of a given vector. More...  
PETScVect (const PETScVect< T_ > &v)  
Copy constructor.  
PETScVect (const PETScVect< T_ > &v, size_t n)  
Constructor to select one component from a given 2 or 3component vector. More...  
PETScVect (size_t d, const PETScVect< T_ > &v, const string &name=" ")  
Constructor that extracts some degrees of freedom (components) from given instance of PETScVect. More...  
~PETScVect ()  
Destructor.  
void  set (const T_ *v, size_t n) 
Initialize vector with a carray. More...  
void  setMPI (MPI_Comm comm, size_t n, size_t N) 
Initialize a local vector using MPI. More...  
void  select (const PETScVect< T_ > &v, size_t nb_dof=0, size_t first_dof=1) 
Initialize vector with another PETScVect instance. More...  
void  set (const string &exp, size_t dof=1) 
Initialize vector with an algebraic expression. More...  
void  set (const Mesh &ms, const string &exp, size_t dof=1) 
Initialize vector with an algebraic expression with providing mesh data. More...  
void  set (const PETScVect< real_t > &x, const string &exp) 
Initialize vector with an algebraic expression. More...  
void  setMesh (Mesh &m, int nb_dof=0, int dof_type=NODE_FIELD) 
Define mesh class to size vector. More...  
size_t  size () const 
Return vector (global) size.  
PetscInt  getLocalSize () const 
Return vector local size. More...  
void  setSize (size_t nx, size_t ny=1, size_t nz=1) 
Set vector size (for 1D, 2D or 3D cases) More...  
void  setDOFType (int dof_type) 
Set DOF type of vector. More...  
size_t  getNbDOF () const 
Return vector number of degrees of freedom.  
size_t  getNb () const 
Return vector number of entities (nodes, elements or sides)  
Mesh &  getMesh () const 
Return Mesh instance.  
bool  isWithMesh () const 
Return true if vector contains a Mesh pointer, false if not. More...  
int  getDOFType () const 
void  setTime (real_t t) 
Set time value for vector.  
real_t  getTime () const 
Get time value for vector.  
void  setName (string name) 
Set name of vector.  
string  getName () const 
Get name of vector.  
PetscScalar  getNorm1 () const 
Calculate 1norm of vector.  
PetscScalar  getNorm2 () const 
Calculate 2norm (Euclidean norm) of vector.  
PetscScalar  getWNorm1 () const 
Calculate weighted 1norm of vector The wighted 1norm is the 1Norm of the vector divided by its size.  
PetscScalar  getWNorm2 () const 
Calculate weighted 2norm of vector. More...  
PetscScalar  getNormMax () const 
Calculate Maxnorm (Infinite norm) of vector.  
T_  getMin () const 
Calculate Min value of vector entries.  
T_  getMax () const 
Calculate Max value of vector entries.  
size_t  getNx () const 
Return number of grid points in the x direction if grid indexing is set.  
size_t  getNy () const 
Return number of grid points in the y direction if grid indexing is set.  
size_t  getNz () const 
Return number of grid points in the z direction if grid indexing is set.  
void  setNodeBC (Mesh &m, int code, T_ val, size_t dof=1) 
Assign a given value to components of vector with given code. More...  
void  setNodeBC (Mesh &m, int code, const string &exp, size_t dof=1) 
Assign a given function (given by an interpretable algebraic expression) to components of vector with given code. More...  
void  setNodeBC (int code, T_ val, size_t dof=1) 
Assign a given value to components of vector with given code. More...  
void  setNodeBC (int code, const string &exp, size_t dof=1) 
Assign a given function (given by an interpretable algebraic expression) to components of vector with given code. More...  
void  removeBC (const Mesh &ms, const PETScVect< T_ > &v, int dof=0) 
Remove boundary conditions. More...  
void  removeBC (const Mesh &ms, const Vect< T_ > &v, int dof=0) 
Remove boundary conditions. More...  
void  removeBC (const PETScVect< T_ > &v, int dof=0) 
Remove boundary conditions. More...  
void  removeBC (const Vect< T_ > &v, int dof=0) 
Remove boundary conditions. More...  
void  transferBC (const PETScVect< T_ > &bc, int dof=0) 
Transfer boundary conditions to the vector. More...  
void  insertBC (Mesh &m, const PETScVect< T_ > &v, const PETScVect< T_ > &bc, int dof=0) 
Insert boundary conditions. More...  
void  insertBC (Mesh &m, const PETScVect< T_ > &v, int dof=0) 
Insert boundary conditions. More...  
void  insertBC (const PETScVect< T_ > &v, const PETScVect< T_ > &bc, int dof=0) 
Insert boundary conditions. More...  
void  insertBC (const PETScVect< T_ > &v, int dof=0) 
Insert boundary conditions. More...  
void  Assembly (const Element &el, const T_ *b) 
Assembly of element vector (as Carray) into Vect instance. More...  
void  Assembly (const Side &sd, T_ *b) 
Assembly of side vector (as Carray) into PETScVect instance. More...  
void  getGradient (PETScVect< T_ > &v) 
Evaluate the discrete Gradient vector of the current vector. More...  
void  getGradient (PETScVect< Point< T_ > > &v) 
Evaluate the discrete Gradient vector of the current vector. More...  
void  getCurl (PETScVect< T_ > &v) 
Evaluate the discrete curl vector of the current vector. More...  
void  getCurl (PETScVect< Point< T_ > > &v) 
Evaluate the discrete curl vector of the current vector. More...  
void  getSCurl (PETScVect< T_ > &v) 
Evaluate the discrete scalar curl in 2D of the current vector. More...  
void  getDivergence (PETScVect< T_ > &v) 
Evaluate the discrete Divergence of the current vector. More...  
real_t  getAverage (const Element &el, int type) const 
Return average value of vector in a given element. More...  
void  save (string file, int opt) 
Save vector in a file according to a given format. More...  
PETScVect< T_ > &  MultAdd (const PETScVect< T_ > &x, const T_ &a) 
Multiply by a constant then add to a vector. More...  
void  Axpy (T_ a, const PETScVect< T_ > &x) 
Add to vector the product of a vector by a scalar. More...  
void  set (size_t i, T_ a) 
Assign a value to an entry for a 1D vector. More...  
void  set (size_t i, size_t j, T_ a) 
Assign a value to an entry for a 2D vector. More...  
void  set (size_t i, size_t j, size_t k, T_ a) 
Assign a value to an entry for a 3D vector. More...  
void  add (size_t i, T_ a) 
Add a value to an entry for a 1index vector. More...  
void  add (size_t i, size_t j, T_ a) 
Add a value to an entry for a 2index vector. More...  
void  add (size_t i, size_t j, size_t k, T_ a) 
Assign a value to an entry for a 3index vector. More...  
void  clear () 
Set all vector entries to zero.  
T_  operator[] (size_t i) const 
Operator [] More...  
T_  operator() (size_t i) const 
Operator () More...  
T_  operator() (size_t i, size_t j) const 
Operator () with 2D indexing (Case of a grid vector) More...  
T_  operator() (size_t i, size_t j, size_t k) const 
Operator () with 3D indexing (Case of a grid vector) More...  
PETScVect< T_ > &  operator= (const PETScVect< T_ > &v) 
Operator = between vectors.  
PETScVect< T_ > &  operator= (const T_ &a) 
Operator = More...  
PETScVect< T_ > &  operator+= (const PETScVect< T_ > &v) 
Operator += More...  
PETScVect< T_ > &  operator+= (const T_ &a) 
Operator += More...  
PETScVect< T_ > &  operator= (const PETScVect< T_ > &v) 
Operator = More...  
PETScVect< T_ > &  operator= (const T_ &a) 
Operator = More...  
PETScVect< T_ > &  operator*= (const T_ &a) 
Operator *= More...  
PETScVect< T_ > &  operator/= (const T_ &a) 
Operator /= More...  
const Mesh &  getMeshPtr () const 
Return reference to Mesh instance.  
T_  operator, (const PETScVect< T_ > &v) const 
Return Dot (scalar) product of two vectors. More...  
operator Vec () const  
Casting operator. More...  
void  setAssembly () 
Vector assembly. More...  
void  Insert (const vector< int > &ii, const vector< Point< T_ > > &v) 
Insert values into certain locations of the vector. More...  
void  Add (const vector< int > &ii, const vector< T_ > &v) 
Add values into certain locations of the vector. More...  
Detailed Description
template<class T_>
class OFELI::PETScVect< T_ >
To handle general purpose vectors using Petsc.
This template class enables considering vectors of various data types. Operators =, [] and () are overloaded so that one can write for instance:
PETScVect<double> u(10), v(10); v = 1.0; u = v; u.set(3,2.0);
to set vector v entries to 1, copy vector v into vector u and assign third entry of v to 2. Note that entries of v are here v(1), v(2), ..., v(10), i.e. vector entries start at index 1.
 Remarks
 A PETScVect instance can be 1D, 2D or 3D,
i.e.
one can have 1, 2 or 3 indices. This is set while the vector is constructed. This can be helpful for instance in the case of a structured grid.
 Warning
 This class is available only when OFELI has been installed with Petsc In this case, only vectors used for building and solving linear systems need to be instances of PETScVect.
 Template Parameters

T_ Data type (double, int, complex<double>, ...)
Constructor & Destructor Documentation
PETScVect  (  size_t  n  ) 
Constructor setting vector size.
 Parameters

[in] n Size of vector
PETScVect  (  size_t  nx, 
size_t  ny  
) 
Constructor of a 2D index vector.
This constructor can be used for instance for a 2D grid vector
 Parameters

[in] nx Size for the first index [in] ny Size for the second index
 Remarks
 The size of resulting vector is nx*ny
PETScVect  (  size_t  nx, 
size_t  ny,  
size_t  nz  
) 
Constructor of a 3D index vector.
This constructor can be used for instance for a 3D grid vector
 Parameters

[in] nx Size for the first index [in] ny Size for the second index [in] nz Size for the third index
 Remarks
 The size of resulting vector is
nx*ny*nz
PETScVect  (  size_t  n, 
T_ *  x  
) 
Create an instance of class PETScVect as an image of a C/C++ array.
 Parameters

[in] n Dimension of vector to construct [in] x Carray to copy
PETScVect  (  MPI_Comm  comm, 
size_t  n  
) 
Constructor of a MPI vector using its global size.
 Parameters

[in] comm Communicator which represents all the processs that PETSc knows about [in] n Global size of vector
Constructor with a mesh instance.
 Parameters

[in] m Mesh instance [in] nb_dof Number of degrees of freedom per node, element or side If nb_dof
is set to0
(default value) the constructor picks this number from the Mesh instance[in] dof_type Type of degrees of freedom. To be given among the enumerated values: NODE_FIELD
,ELEMENT_FIELD
,SIDE_FIELD
orEDGE_FIELD
[Default:NODE_FIELD
]
Constructor with a mesh instance giving name and time for vector.
 Parameters

[in] m Mesh instance [in] name Name of the vector [in] t Time value for the vector [in] nb_dof Number of degrees of freedom per node, element or side If nb_dof
is set to0
the constructor picks this number from the Mesh instance[in] dof_type Type of degrees of freedom. To be given among the enumerated values: NODE_FIELD
,ELEMENT_FIELD
,SIDE_FIELD
orEDGE_FIELD
[Default:NODE_FIELD
]
Constructor to select some components of a given vector.
 Parameters

[in] v PETScVect instance to extract from [in] nb_dof Number of DOF to extract [in] first_dof First DOF to extract For instance, a choice first_dof=2
andnb_dof=1
means that the second DOF of each node is copied in the vector
Constructor to select one component from a given 2 or 3component vector.
 Parameters

[in] v PETScVect instance to extract from [in] n Component to extract (must be > 1 and < 4 or).
Constructor that extracts some degrees of freedom (components) from given instance of PETScVect.
This constructor enables constructing a subvector of a given PETScVect instance. It selects a given list of degrees of freedom and put it according to a given order in the instance to construct.
 Parameters

[in] d Integer number giving the list of degrees of freedom. This number is made of n
digits wheren
is the number of degrees of freedom. Let us give an example: Assume that the instancev
has 3 DOF by entity (node, element or side). The choiced=201
means that the constructed instance has 2 DOF where the first DOF is the third one ofv
, and the second DOF is the first one of fv
. Consequently, no digit can be larger than the number of DOF the constructed instance. In this example, a choiced=103
would produce an error message.[in] v PETScVect instance from which extraction is performed. [in] name Name to assign to vector instance [Default: " "].
 Warning
 Don't give zeros as first digits for the argument
d
. The number is in this case interpreted as octal !!
Member Function Documentation
void set  (  const T_ *  v, 
size_t  n  
) 
Initialize vector with a carray.
 Parameters

[in] v carray (pointer) to initialize PETScVect [in] n size of array
void setMPI  (  MPI_Comm  comm, 
size_t  n,  
size_t  N  
) 
Initialize a local vector using MPI.
 Parameters

[in] comm [in] n local size of vector [in] N global size of vector
void select  (  const PETScVect< T_ > &  v, 
size_t  nb_dof = 0 , 

size_t  first_dof = 1 

) 
Initialize vector with another PETScVect instance.
 Parameters

[in] v PETScVect instance to extract from [in] nb_dof Number of DOF per node, element or side (By default, 0: Number of degrees of freedom extracted from the Mesh instance) [in] first_dof First DOF to extract (Default: 1) For instance, a choice first_dof=2
andnb_dof=1
means that the second DOF of each node is copied in the vector
void set  (  const string &  exp, 
size_t  dof = 1 

) 
Initialize vector with an algebraic expression.
 Parameters

[in] exp Regular algebraic expression that defines a function of x, y and z which are coordinates of nodes. [in] dof Degree of freedom to which the value is assigned [Default: 1
]
void set  (  const Mesh &  ms, 
const string &  exp,  
size_t  dof = 1 

) 
Initialize vector with an algebraic expression with providing mesh data.
 Parameters

[in] ms Mesh instance [in] exp Regular algebraic expression that defines a function of x, y and z which are coordinates of nodes. [in] dof Degree of freedom to which the value is assigned [Default: 1
]
Initialize vector with an algebraic expression.
 Parameters

[in] x PETScVect instance that contains coordinates of points [in] exp Regular algebraic expression that defines a function of x and i which are coordinates of nodes and indices starting from 1
.
void setMesh  (  Mesh &  m, 
int  nb_dof = 0 , 

int  dof_type = NODE_FIELD 

) 
Define mesh class to size vector.
 Parameters

[in] m Mesh instance [in] nb_dof Number of degrees of freedom per node, element or side If nb_dof
is set to0
the constructor picks this number from the Mesh instance[in] dof_type Parameter to precise the type of degrees of freedom. To be chosen among the enumerated values: NODE_FIELD
,ELEMENT_FIELD
,SIDE_FIELD
,EDGE_FIELD
[Default:NODE_FIELD
]
PetscInt getLocalSize  (  )  const 
Return vector local size.
Local size is the size on the current processor
void setSize  (  size_t  nx, 
size_t  ny = 1 , 

size_t  nz = 1 

) 
Set vector size (for 1D, 2D or 3D cases)
This function allocates memory for the vector but does not initialize its components
 Parameters

[in] nx Number of grid points in x
direction[in] ny Number of grid points in y
direction [Default:1
][in] nz Number of grid points in z
direction [Default:1
]
void setDOFType  (  int  dof_type  ) 
Set DOF type of vector.
The DOF type combined with number of DOF per component enable determining the size of vector
 Parameters

[in] dof_type Type of degrees of freedom. Value to be chosen among the enumerated values: NODE_FIELD
,ELEMENT_FIELD
,SIDE_FIELD
orEDGE_FIELD
bool isWithMesh  (  )  const 
int getDOFType  (  )  const 
Return DOF type of vector
 Returns
 dof_type Type of degrees of freedom. Value among the enumerated values:
NODE_FIELD
,ELEMENT_FIELD
,SIDE_FIELD
orEDGE_FIELD
PetscScalar getWNorm2  (  )  const 
Calculate weighted 2norm of vector.
The weighted 2norm is the 2Norm of the vector divided by the square root of its size
void setNodeBC  (  Mesh &  m, 
int  code,  
T_  val,  
size_t  dof = 1 

) 
Assign a given value to components of vector with given code.
Vector components are assumed nodewise
 Parameters

[in] m Instance of mesh [in] code Code for which nodes will be assigned prescribed value [in] val Value to prescribe [in] dof Degree of Freedom for which the value is assigned [default: 1
]
void setNodeBC  (  Mesh &  m, 
int  code,  
const string &  exp,  
size_t  dof = 1 

) 
Assign a given function (given by an interpretable algebraic expression) to components of vector with given code.
Vector components are assumed nodewise
 Parameters

[in] m Instance of mesh [in] code Code for which nodes will be assigned prescribed value [in] exp Regular algebraic expression to prescribe [in] dof Degree of Freedom for which the value is assigned [default: 1
]
void setNodeBC  (  int  code, 
T_  val,  
size_t  dof = 1 

) 
Assign a given value to components of vector with given code.
Vector components are assumed nodewise
 Parameters

[in] code Code for which nodes will be assigned prescribed value [in] val Value to prescribe [in] dof Degree of Freedom for which the value is assigned [Default: 1
]
void setNodeBC  (  int  code, 
const string &  exp,  
size_t  dof = 1 

) 
Assign a given function (given by an interpretable algebraic expression) to components of vector with given code.
Vector components are assumed nodewise
 Parameters

[in] code Code for which nodes will be assigned prescribed value [in] exp Regular algebraic expression to prescribe [in] dof Degree of Freedom for which the value is assigned [Default: 1
]
Remove boundary conditions.
This member function copies to current vector a vector where only non imposed DOF are retained.
Remove boundary conditions.
This member function copies to current vector a vector where only non imposed DOF are retained.
void removeBC  (  const PETScVect< T_ > &  v, 
int  dof = 0 

) 
Remove boundary conditions.
This member function copies to current vector a vector where only non imposed DOF are retained.
 Parameters

[in] v Vector (PETScVect instance to copy from) [in] dof Parameter to say if all degrees of freedom are concerned [Default: 0
] or if only one degree of freedom (dof
) is inserted into vectorv
which has only one degree of freedom.
void removeBC  (  const Vect< T_ > &  v, 
int  dof = 0 

) 
Remove boundary conditions.
This member function copies to current vector a vector where only non imposed DOF are retained.
 Parameters

[in] v Vector (Vect instance to copy from) [in] dof Parameter to say if all degrees of freedom are concerned [Default: 0
] or if only one degree of freedom (dof
) is inserted into vectorv
which has only one degree of freedom.
void transferBC  (  const PETScVect< T_ > &  bc, 
int  dof = 0 

) 
Transfer boundary conditions to the vector.
 Parameters

[in] bc PETScVect instance from which imposed degrees of freedom are copied to current instance [in] dof Parameter to say if all degrees of freedom are concerned [Default: 0
] or if only one degree of freedom (dof
) is inserted into vectorv
which has only one degree of freedom.
Insert boundary conditions.
 Parameters

[in] m Mesh instance. [in] v PETScVect instance from which free degrees of freedom are copied to current instance. [in] bc PETScVect instance from which imposed degrees of freedom are copied to current instance. [in] dof Parameter to say if all degrees of freedom are concerned [Default: 0
] or if only one degree of freedom (dof
) is inserted into vectorv
which has only one degree of freedom by node or side
Insert boundary conditions.
DOF with imposed boundary conditions are set to zero.
 Parameters

[in] m Mesh instance. [in] v PETScVect instance from which free degrees of freedom are copied to current instance. [in] dof Parameter to say if all degrees of freedom are concerned [Default: 0
] or if only one degree of freedom (dof
) is inserted into vectorv
which has only one degree of freedom by node or side
Insert boundary conditions.
 Parameters

[in] v PETScVect instance from which free degrees of freedom are copied to current instance. [in] bc PETScVect instance from which imposed degrees of freedom are copied to current instance. [in] dof Parameter to say if all degrees of freedom are concerned [Default: 0
] or if only one degree of freedom (dof
) is inserted into vectorv
which has only one degree of freedom by node or side
void insertBC  (  const PETScVect< T_ > &  v, 
int  dof = 0 

) 
Insert boundary conditions.
DOF with imposed boundary conditions are set to zero.
 Parameters

[in] v PETScVect instance from which free degrees of freedom are copied to current instance. [in] dof Parameter to say if all degrees of freedom are concerned [Default: 0
] or if only one degree of freedom (dof
) is inserted into vectorv
which has only one degree of freedom by node or side
void Assembly  (  const Element &  el, 
const T_ *  b  
) 
Assembly of element vector (as Carray) into Vect instance.
 Parameters

[in] el Reference to element instance [in] b Local vector to assemble (CArray)
void Assembly  (  const Side &  sd, 
T_ *  b  
) 
Assembly of side vector (as Carray) into PETScVect instance.
 Parameters

[in] sd Reference to side instance [in] b Local vector to assemble (CArray)
void getGradient  (  PETScVect< T_ > &  v  ) 
Evaluate the discrete Gradient vector of the current vector.
The resulting gradient is stored in a PETScVect instance This function handles node vectors assuming P_{1} approximation The gradient is then a constant vector for each element.
 Parameters

[in] v Vect instance that contains the gradient, where v(n,1)
,v(n,2)
andv(n,3)
are respectively thex
andy
andz
derivatives at elementn
.
Evaluate the discrete Gradient vector of the current vector.
The resulting gradient is stored in a PETScVect instance This function handles node vectors assuming P_{1} approximation The gradient is then a constant vector for each element.
 Parameters

[in] v Vect instance that contains the gradient, where v(n,1).x
,v(n,2).y
andv(n,3).z
are respectively thex
andy
andz
derivatives at elementn
.
void getCurl  (  PETScVect< T_ > &  v  ) 
Evaluate the discrete curl vector of the current vector.
The resulting curl is stored in a PETScVect instance This function handles node vectors assuming P_{1} approximation The curl is then a constant vector for each element.
 Parameters

[in] v Vect instance that contains the curl, where v(n,1)
,v(n,2)
andv(n,3)
are respectively thex
andy
andz
curl
components at elementn
.
Evaluate the discrete curl vector of the current vector.
The resulting curl is stored in a PETScVect instance This function handles node vectors assuming P_{1} approximation The curl is then a constant vector for each element.
 Parameters

[in] v Vect instance that contains the curl, where v(n,1).x
,v(n,2).y
andv(n,3).z
are respectively thex
andy
andz
curl
components at elementn
.
void getSCurl  (  PETScVect< T_ > &  v  ) 
void getDivergence  (  PETScVect< T_ > &  v  ) 
Return average value of vector in a given element.
 Parameters

[in] el Element instance [in] type Type of element. This is to be chosen among enumerated values: LINE2
,TRIANG3
,QUAD4
TETRA4
,HEXA8
void save  (  string  file, 
int  opt  
) 
Save vector in a file according to a given format.
 Parameters

[in] file Output file where to save the vector [in] opt Option to choose file format to save. This is to be chosen among enumerated values: GMSH
,GNUPLOT
,MATLAB
,TECPLOT
andVTK
Multiply by a constant then add to a vector.
 Parameters

[in] x PETScVect instance to add [in] a Constant to multiply before adding
void Axpy  (  T_  a, 
const PETScVect< T_ > &  x  
) 
Add to vector the product of a vector by a scalar.
 Parameters

[in] a Scalar to premultiply [in] x Vect instance by which a
is multiplied. The result is added to current instance
void set  (  size_t  i, 
T_  a  
) 
Assign a value to an entry for a 1D vector.
 Parameters

[in] i Rank index in vector (starts at 1
)[in] a Value to assign
void set  (  size_t  i, 
size_t  j,  
T_  a  
) 
Assign a value to an entry for a 2D vector.
 Parameters

[in] i First index in vector (starts at 1
)[in] j Second index in vector (starts at 1
)[in] a Value to assign
void set  (  size_t  i, 
size_t  j,  
size_t  k,  
T_  a  
) 
Assign a value to an entry for a 3D vector.
 Parameters

[in] i First index in vector (starts at 1
)[in] j Second index in vector (starts at 1
)[in] k Third index in vector (starts at 1
)[in] a Value to assign
void add  (  size_t  i, 
T_  a  
) 
Add a value to an entry for a 1index vector.
 Parameters

[in] i Rank index in vector (starts at 1
)[in] a Value to assign
void add  (  size_t  i, 
size_t  j,  
T_  a  
) 
Add a value to an entry for a 2index vector.
 Parameters

[in] i First index in vector (starts at 1
)[in] j Second index in vector (starts at 1
)[in] a Value to assign
void add  (  size_t  i, 
size_t  j,  
size_t  k,  
T_  a  
) 
Assign a value to an entry for a 3index vector.
 Parameters

[in] i First index in vector (starts at 1
)[in] j Second index in vector (starts at 1
)[in] k Third index in vector (starts at 1
)[in] a Value to assign
T_ operator[]  (  size_t  i  )  const 
Operator []
 Parameters

[in] i Rank index in vector (starts at 0
)
T_ operator()  (  size_t  i  )  const 
Operator ()
 Parameters

[in] i Rank index in vector (starts at 1
)
v(i)
starts atv(1)
tov(size())

v(i)
is the same element asv[i1]

T_ operator()  (  size_t  i, 
size_t  j  
)  const 
T_ operator()  (  size_t  i, 
size_t  j,  
size_t  k  
)  const 
Operator ()
with 3D indexing (Case of a grid vector)
PETScVect<T_>& operator=  (  const T_ &  a  ) 
Operator =
Assign a constant to vector entries
 Parameters

[in] a Value to set
Operator +=
Add vector x
to current vector instance.
 Parameters

[in] v PETScVect instance to add to instance
PETScVect<T_>& operator+=  (  const T_ &  a  ) 
Operator +=
Add a constant to current vector entries.
 Parameters

[in] a Value to add to vector entries
Operator =
 Parameters

[in] v Vect instance to subtract from
PETScVect<T_>& operator=  (  const T_ &  a  ) 
Operator =
Subtract constant from vector entries.
 Parameters

[in] a Value to subtract from
PETScVect<T_>& operator*=  (  const T_ &  a  ) 
Operator *=
 Parameters

[in] a Value to multiply by
PETScVect<T_>& operator/=  (  const T_ &  a  ) 
Operator /=
 Parameters

[in] a Value to divide by
T_ operator,  (  const PETScVect< T_ > &  v  )  const 
Return Dot (scalar) product of two vectors.
A typical use of this operator is double a = (v,w)
where v
and w
are 2 instances of PETScVect<double>
 Parameters

[in] v PETScVect instance by which the current instance is multiplied
operator Vec  (  )  const 
Casting operator.
This member functions enables casting an instance of class PETScVect into the Petsc
vector type Vec
. This is useful when one wants to usr any Petsc function that is not available in the wrapper (class PETScWrapper) or PETScVect.
void setAssembly  (  ) 
Vector assembly.
This function assembles vector (begins and ends)
void Insert  (  const vector< int > &  ii, 
const vector< Point< T_ > > &  v  
) 
Insert values into certain locations of the vector.
 Parameters

[in] ii Vector containing indices where to insert (Note the indices start from 0 like any Carray) [in] v Vector of values to insert, corresponding to indices in ii. Here the vector has entries of type Point<T_>.
void Add  (  const vector< int > &  ii, 
const vector< T_ > &  v  
) 
Add values into certain locations of the vector.
 Parameters

[in] ii Vector containing indices where to add (Note the indices start from 0 like any Carray) [in] v Vector of values to add, corresponding to indices in ii