Vect< T_ > Class Template Reference

To handle general purpose vectors. More...

#include <Vect.h>

Inherits vector< T_ >.

Public Member Functions

 Vect ()
 Default Constructor. Initialize a zero-length vector.
 
 Vect (size_t n)
 Constructor setting vector size.
 
 Vect (size_t nx, size_t ny)
 Constructor of a 2-D index vector.
 
 Vect (size_t nx, size_t ny, size_t nz)
 Constructor of a 3-D index vector.
 
 Vect (size_t nx, size_t ny, size_t nz, size_t nt)
 Constructor of a 4-D index vector.
 
 Vect (size_t n, T_ *x)
 Create an instance of class Vect as an image of a C/C++ array.
 
 Vect (Grid &g)
 Constructor with a Grid instance.
 
 Vect (Mesh &m, DOFSupport dof_type=NODE_DOF, int nb_dof=0)
 Constructor with a mesh instance.
 
 Vect (Mesh &m, DOFSupport dof_type, string name, int nb_dof=0, real_t t=0.0)
 Constructor with a mesh instance giving name and time for vector.
 
 Vect (const Element *el, const Vect< T_ > &v)
 Constructor of an element vector.
 
 Vect (const Side *sd, const Vect< T_ > &v)
 Constructor of a side vector.
 
 Vect (const Vect< T_ > &v, const Vect< T_ > &bc)
 Constructor using boundary conditions.
 
 Vect (const Vect< T_ > &v, size_t nb_dof, size_t first_dof)
 Constructor to select some components of a given vector.
 
 Vect (const Vect< T_ > &v)
 Copy constructor.
 
 Vect (const Vect< T_ > &v, size_t n)
 Constructor to select one component from a given 2 or 3-component vector.
 
 Vect (size_t d, const Vect< T_ > &v, const string &name=" ")
 Constructor that extracts some degrees of freedom (components) from given instance of Vect.
 
 ~Vect ()
 Destructor.
 
void set (const T_ *v, size_t n)
 Initialize vector with a c-array.
 
void select (const Vect< T_ > &v, size_t n)
 Select one component from a given multicomponent vector.
 
Vect< T_ > select (size_t n)
 Return vector with selected one component from a given multicomponent vector.
 
void select (const Vect< T_ > &v, size_t nb_dof=0, size_t first_dof=1)
 Initialize vector with another Vect instance.
 
void set (const string &exp, size_t dof=1)
 Initialize vector with an algebraic expression.
 
void set (const string &exp, const Vect< real_t > &x)
 Initialize vector with an algebraic expression.
 
void set (Mesh &ms, const string &exp, size_t dof=1)
 Initialize vector with an algebraic expression with providing mesh data.
 
void set (const Vect< real_t > &x, const string &exp)
 Initialize vector with an algebraic expression.
 
void setMesh (Mesh &m, DOFSupport dof_type=NODE_DOF, size_t nb_dof=0)
 Define mesh class to size vector.
 
void setGrid (Grid &g)
 Define grid class to size vector.
 
size_t size () const
 Return vector (global) size.
 
void setSize (size_t nx, size_t ny=1, size_t nz=1, size_t nt=1)
 Set vector size (for 1-D, 2-D or 3-D cases and 3-D + time)
 
void resize (size_t n)
 Set vector size.
 
void resize (size_t n, T_ v)
 Set vector size and initialize to a constant value.
 
void setDOFType (DOFSupport dof_type)
 Set DOF type of vector.
 
void setDG (int degree=1)
 Set Discontinuous Galerkin type vector.
 
size_t getNbDOF () const
 Return vector number of degrees of freedom.
 
size_t getNb () const
 Return vector number of entities (nodes, elements or sides)
 
MeshgetMesh () const
 Return Mesh instance.
 
GridgetGrid () const
 Return Grid instance.
 
bool WithMesh () const
 Return true if vector contains a Mesh pointer, false if not.
 
bool WithGrid () const
 Return true if vector contains a Grid pointer, false if not.
 
DOFSupport getDOFType () const
 
void setTime (real_t t)
 Set time value for vector.
 
real_t getTime () const
 Get time value for vector.
 
void setName (const string &name)
 Set name of vector.
 
string getName () const
 Get name of vector.
 
real_t Norm (NormType t) const
 Compute a norm of vector.
 
real_t getNorm1 () const
 Calculate 1-norm of vector.
 
real_t getNorm2 () const
 Calculate 2-norm (Euclidean norm) of vector.
 
real_t getNormMax () const
 Calculate Max-norm (Infinite norm) of vector.
 
real_t getWNorm1 () const
 Calculate weighted 1-norm of vector The wighted 1-norm is the 1-Norm of the vector divided by its size.
 
real_t getWNorm2 () const
 Calculate weighted 2-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.
 
size_t getNt () const
 Return number of grid points in the t-direction if grid indexing is set.
 
void setIJK (const string &exp)
 Assign a given function (given by an interpretable algebraic expression) of indices components of vector.
 
void setIJKL (const string &exp)
 Assign a given function (given by an interpretable algebraic expression) of indices components of vector.
 
void setNodeBC (Mesh &m, int code, T_ val, size_t dof)
 Assign a given value to components of vector with given code.
 
void setNodeBC (Mesh &m, int code, T_ val)
 Assign a given value to components of vector with given code.
 
void setSideBC (Mesh &m, int code, T_ val, size_t dof)
 Assign a given value to components of vector corresponding to sides with given code.
 
void setNodeBC (Mesh &m, int code, const string &exp, size_t dof)
 Assign a given function (given by an interpretable algebraic expression) to components of vector with given code.
 
void setNodeBC (Mesh &m, int code, const string &exp)
 Assign a given function (given by an interpretable algebraic expression) to components of vector with given code.
 
void setSideBC (Mesh &m, int code, const string &exp, size_t dof)
 Assign a given function (given by an interpretable algebraic expression) to components of vector corresponding to sides with given code.
 
void setSideBC (Mesh &m, int code, const string &exp)
 Assign a given function (given by an interpretable algebraic expression) to components of vector corresponding to sides with given code.
 
void setNodeBC (int code, T_ val, size_t dof)
 Assign a given value to components of vector with given code.
 
void setNodeBC (int code, T_ val)
 Assign a given value to components of vector with given code.
 
void setNodeBC (int code, const string &exp, size_t dof)
 Assign a given function (given by an interpretable algebraic expression) to components of vector with given code.
 
void setNodeBC (int code, const string &exp)
 Assign a given function (given by an interpretable algebraic expression) to components of vector with given code.
 
void setSideBC (int code, const string &exp, size_t dof)
 Assign a given function (given by an interpre<table algebraic expression) to components of vector with given code.
 
void setSideBC (int code, const string &exp)
 Assign a given function (given by an interpre<table algebraic expression) to components of vector with given code.
 
void setSideBC (int code, T_ val, size_t dof)
 Assign a given value to components of vector with given code.
 
void setSideBC (int code, T_ val)
 Assign a given value to components of vector with given code.
 
void removeBC (const Mesh &ms, const Vect< T_ > &v, int dof=0)
 Remove boundary conditions.
 
void removeBC (const Vect< T_ > &v, int dof=0)
 Remove boundary conditions.
 
void transferBC (const Vect< T_ > &bc, int dof=0)
 Transfer boundary conditions to the vector.
 
void insertBC (Mesh &m, const Vect< T_ > &v, const Vect< T_ > &bc, int dof=0)
 Insert boundary conditions.
 
void insertBC (Mesh &m, const Vect< T_ > &v, int dof=0)
 Insert boundary conditions.
 
void insertBC (const Vect< T_ > &v, const Vect< T_ > &bc, int dof=0)
 Insert boundary conditions.
 
void insertBC (const Vect< T_ > &v, int dof=0)
 Insert boundary conditions.
 
void Assembly (const Element &el, const Vect< T_ > &b)
 Assembly of element vector into current instance.
 
void Assembly (const Element &el, const T_ *b)
 Assembly of element vector (as C-array) into Vect instance.
 
void Assembly (const Side &sd, const Vect< T_ > &b)
 Assembly of side vector into Vect instance.
 
void Assembly (const Side &sd, const T_ *b)
 Assembly of side vector (as C-array) into Vect instance.
 
void getGradient (class Vect< T_ > &v)
 Evaluate the discrete Gradient vector of the current vector.
 
void getGradient (Vect< Point< T_ > > &v)
 Evaluate the discrete Gradient vector of the current vector.
 
void getCurl (Vect< T_ > &v)
 Evaluate the discrete curl vector of the current vector.
 
void getCurl (Vect< Point< T_ > > &v)
 Evaluate the discrete curl vector of the current vector.
 
void getSCurl (Vect< T_ > &v)
 Evaluate the discrete scalar curl in 2-D of the current vector.
 
void getDivergence (Vect< T_ > &v)
 Evaluate the discrete Divergence of the current vector.
 
real_t getAverage (const Element &el, int type) const
 Return average value of vector in a given element.
 
Vect< T_ > & MultAdd (const Vect< T_ > &x, const T_ &a)
 Multiply by a constant then add to a vector.
 
void Axpy (T_ a, const Vect< T_ > &x)
 Add to vector the product of a vector by a scalar.
 
void set (size_t i, T_ val)
 Assign a value to an entry for a 1-D vector.
 
void set (size_t i, size_t j, T_ val)
 Assign a value to an entry for a 2-D vector.
 
void set (size_t i, size_t j, size_t k, T_ val)
 Assign a value to an entry for a 3-D vector.
 
void add (size_t i, T_ val)
 Add a value to an entry for a 1-index vector.
 
void add (size_t i, size_t j, T_ val)
 Add a value to an entry for a 2-index vector.
 
void add (size_t i, size_t j, size_t k, T_ val)
 Assign a value to an entry for a 3-index vector.
 
void clear ()
 Clear vector: Set all its elements to zero.
 
T_ & operator() (size_t i)
 Operator () (Non constant version)
 
T_ operator() (size_t i) const
 Operator () (Constant version)
 
T_ & operator() (size_t i, size_t j)
 Operator () with 2-D indexing (Non constant version, case of a grid vector).
 
T_ operator() (size_t i, size_t j) const
 Operator () with 2-D indexing (Constant version).
 
T_ & operator() (size_t i, size_t j, size_t k)
 Operator () with 3-D indexing (Non constant version).
 
T_ operator() (size_t i, size_t j, size_t k) const
 Operator () with 3-D indexing (Constant version).
 
T_ & operator() (size_t i, size_t j, size_t k, size_t l)
 Operator () with 4-D indexing (Non constant version).
 
T_ operator() (size_t i, size_t j, size_t k, size_t l) const
 Operator () with 4-D indexing (Constant version).
 
Vect< T_ > & operator= (const Vect< T_ > &v)
 Operator = between vectors.
 
void operator= (string s)
 Operator =
 
void setUniform (T_ vmin, T_ vmax, size_t n)
 Initialize vector entries by setting extremal values and interval.
 
Vect< T_ > & operator= (const T_ &a)
 Operator =
 
Vect< T_ > & operator+= (const Vect< T_ > &v)
 Operator +=
 
Vect< T_ > & operator+= (const T_ &a)
 Operator +=
 
Vect< T_ > & operator-= (const Vect< T_ > &v)
 Operator -=
 
Vect< T_ > & operator-= (const T_ &a)
 Operator -=
 
Vect< T_ > & operator*= (const T_ &a)
 Operator *=
 
Vect< T_ > & operator/= (const T_ &a)
 Operator /=
 
void push_back (const T_ &v)
 Add an entry to the vector.
 
const MeshgetMeshPtr () const
 Return reference to Mesh instance.
 
T_ operator, (const Vect< T_ > &v) const
 Return Dot (scalar) product of two vectors.
 
Vect< complex_t > getFFT ()
 Compute FFT transform of vector.
 
Vect< complex_t > getInvFFT ()
 Compute Inverse FFT transform of vector.
 

Detailed Description

template<class T_>
class OFELI::Vect< T_ >

To handle general purpose vectors.

Author
Rachid Touzani

This template class enables defining and manipulating vectors of various data types. It inherits from the class std::vector An instance of class Vect can be:

  • A simple vector of given size
  • A vector with up to three indices, i.e., an entry of the vector can be a(i), a(i,j) or a(i,j,k). This feature is useful, for instance, in the case of a structured grid
  • A vector associate to a finite element mesh. In this case, a constructor uses a reference to the Mesh instance. The size of the vector is by default equal to the number of nodes x the number of degrees of freedom by node. If the degrees of freedom are supported by elements or sides, then the vector is sized accordingly

Operators =, [] and () are overloaded so that one can write for instance:

 Vect<real_t> u(10), v(10);
 v = -1.0;
 u = v;
 u(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.

Template Parameters
T_Data type (real_t, float, complex<real_t>, ...)

Constructor & Destructor Documentation

◆ Vect() [1/14]

template<class T_ >
Vect ( size_t  n)

Constructor setting vector size.

Parameters
[in]nSize of vector

◆ Vect() [2/14]

template<class T_ >
Vect ( size_t  nx,
size_t  ny 
)

Constructor of a 2-D index vector.

This constructor can be used for instance for a 2-D grid vector

Parameters
[in]nxSize for the first index
[in]nySize for the second index
Remarks
The size of resulting vector is nx*ny

◆ Vect() [3/14]

template<class T_ >
Vect ( size_t  nx,
size_t  ny,
size_t  nz 
)

Constructor of a 3-D index vector.

This constructor can be used for instance for a 3-D grid vector

Parameters
[in]nxSize for the first index
[in]nySize for the second index
[in]nzSize for the third index
Remarks
The size of resulting vector is nx*ny*nz

◆ Vect() [4/14]

template<class T_ >
Vect ( size_t  nx,
size_t  ny,
size_t  nz,
size_t  nt 
)

Constructor of a 4-D index vector.

This constructor can be used for instance for a 4-D grid vector

Parameters
[in]nxSize for the first index
[in]nySize for the second index
[in]nzSize for the third index
[in]ntSize for the fourth index
Remarks
The size of resulting vector is nx*ny*nz*nt

◆ Vect() [5/14]

template<class T_ >
Vect ( size_t  n,
T_ *  x 
)

Create an instance of class Vect as an image of a C/C++ array.

Parameters
[in]nDimension of vector to construct
[in]xC-array to copy

◆ Vect() [6/14]

template<class T_ >
Vect ( Grid g)

Constructor with a Grid instance.

The constructed vector has as size the total number of grid nodes

Parameters
[in]gGrid instance

◆ Vect() [7/14]

template<class T_ >
Vect ( Mesh m,
DOFSupport  dof_type = NODE_DOF,
int  nb_dof = 0 
)

Constructor with a mesh instance.

Parameters
[in]mMesh instance
[in]dof_typeType of degrees of freedom. To be given among the enumerated values: NODE_DOF, ELEMENT_DOF, SIDE_DOF or EDGE_DOF (Default: NODE_DOF)
[in]nb_dofNumber of degrees of freedom per node, element or side If nb_dof is set to 0 (default value) the constructor picks this number from the Mesh instance

◆ Vect() [8/14]

template<class T_ >
Vect ( Mesh m,
DOFSupport  dof_type,
string  name,
int  nb_dof = 0,
real_t  t = 0.0 
)

Constructor with a mesh instance giving name and time for vector.

Parameters
[in]mMesh instance
[in]dof_typeType of degrees of freedom. To be given among the enumerated values: NODE_DOF, ELEMENT_DOF, SIDE_DOF or EDGE_DOF
[in]nameName of the vector
[in]nb_dofNumber of degrees of freedom per node, element or side If nb_dof is set to 0 the constructor picks this number from the Mesh instance
[in]tTime value for the vector [Default 0.0]

◆ Vect() [9/14]

template<class T_ >
Vect ( const Element el,
const Vect< T_ > &  v 
)

Constructor of an element vector.

The constructed vector has local numbering of nodes

Parameters
[in]elPointer to Element to localize
[in]vGlobal vector to localize

◆ Vect() [10/14]

template<class T_ >
Vect ( const Side sd,
const Vect< T_ > &  v 
)

Constructor of a side vector.

The constructed vector has local numbering of nodes

Parameters
[in]sdPointer to Side to localize
[in]vGlobal vector to localize

◆ Vect() [11/14]

template<class T_ >
Vect ( const Vect< T_ > &  v,
const Vect< T_ > &  bc 
)

Constructor using boundary conditions.

Boundary condition values contained in bc are reported to vector v

Parameters
[in]vVect instance to update
[in]bcVect instance containing imposed valued at desired DOF

◆ Vect() [12/14]

template<class T_ >
Vect ( const Vect< T_ > &  v,
size_t  nb_dof,
size_t  first_dof 
)

Constructor to select some components of a given vector.

Parameters
[in]vVect instance to extract from
[in]nb_dofNumber of DOF to extract
[in]first_dofFirst DOF to extract For instance, a choice first_dof=2 and nb_dof=1 means that the second DOF of each node is copied in the vector

◆ Vect() [13/14]

template<class T_ >
Vect ( const Vect< T_ > &  v,
size_t  n 
)

Constructor to select one component from a given 2 or 3-component vector.

Parameters
[in]vVect instance to extract from
[in]nComponent to extract (must be > 1 and < 4 or).

◆ Vect() [14/14]

template<class T_ >
Vect ( size_t  d,
const Vect< T_ > &  v,
const string &  name = " " 
)

Constructor that extracts some degrees of freedom (components) from given instance of Vect.

This constructor enables constructing a subvector of a given Vect 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]dInteger number giving the list of degrees of freedom. This number is made of n digits where n is the number of degrees of freedom. Let us give an example: Assume that the instance v has 3 DOF by entity (node, element or side). The choice d=201 means that the constructed instance has 2 DOF where the first DOF is the third one of v, and the second DOF is the first one of f v. Consequently, no digit can be larger than the number of DOF the constructed instance. In this example, a choice d=103 would produce an error message.
[in]vVect instance from which extraction is performed.
[in]nameName to assign to vector instance (Default value is " ").
Warning
Don't give zeros as first digits for the argument d. The number is in this case interpreted as octal !!

Member Function Documentation

◆ add() [1/3]

template<class T_ >
void add ( size_t  i,
size_t  j,
size_t  k,
T_  val 
)

Assign a value to an entry for a 3-index vector.

Parameters
[in]iFirst index in vector (starts at 1)
[in]jSecond index in vector (starts at 1)
[in]kThird index in vector (starts at 1)
[in]valValue to assign

◆ add() [2/3]

template<class T_ >
void add ( size_t  i,
size_t  j,
T_  val 
)

Add a value to an entry for a 2-index vector.

Parameters
[in]iFirst index in vector (starts at 1)
[in]jSecond index in vector (starts at 1)
[in]valValue to assign

◆ add() [3/3]

template<class T_ >
void add ( size_t  i,
T_  val 
)

Add a value to an entry for a 1-index vector.

Parameters
[in]iRank index in vector (starts at 1)
[in]valValue to assign

◆ Assembly() [1/4]

template<class T_ >
void Assembly ( const Element el,
const T_ *  b 
)

Assembly of element vector (as C-array) into Vect instance.

Parameters
[in]elReference to Element instance
[in]bLocal vector to assemble (C-Array)

◆ Assembly() [2/4]

template<class T_ >
void Assembly ( const Element el,
const Vect< T_ > &  b 
)

Assembly of element vector into current instance.

Parameters
[in]elReference to Element instance
[in]bLocal vector to assemble (Instance of class Vect)

◆ Assembly() [3/4]

template<class T_ >
void Assembly ( const Side sd,
const T_ *  b 
)

Assembly of side vector (as C-array) into Vect instance.

Parameters
[in]sdReference to Side instance
[in]bLocal vector to assemble (C-Array)

◆ Assembly() [4/4]

template<class T_ >
void Assembly ( const Side sd,
const Vect< T_ > &  b 
)

Assembly of side vector into Vect instance.

Parameters
[in]sdReference to Side instance
[in]bLocal vector to assemble (Instance of class Vect)

◆ Axpy()

template<class T_ >
void Axpy ( T_  a,
const Vect< T_ > &  x 
)

Add to vector the product of a vector by a scalar.

Parameters
[in]aScalar to premultiply
[in]xVect instance by which a is multiplied. The result is added to current instance

◆ getAverage()

template<class T_ >
real_t getAverage ( const Element el,
int  type 
) const

Return average value of vector in a given element.

Parameters
[in]elElement instance
[in]typeType of element. This is to be chosen among enumerated values: LINE2, TRIANG3, QUAD4 TETRA4, HEXA8, PENTA6

◆ getCurl() [1/2]

template<class T_ >
void getCurl ( Vect< Point< T_ > > &  v)

Evaluate the discrete curl vector of the current vector.

The resulting curl is stored in a Vect instance. This function handles node vectors assuming P1 approximation. The curl is then a constant vector for each element.

Parameters
[in]vVect instance that contains the curl, where v(n,1).x, v(n,2).y and v(n,3).z are respectively the x and y and z curl components at element n.

◆ getCurl() [2/2]

template<class T_ >
void getCurl ( Vect< T_ > &  v)

Evaluate the discrete curl vector of the current vector.

The resulting curl is stored in a Vect instance. This function handles node vectors assuming P1 approximation. The curl is then a constant vector for each element.

Parameters
[in]vVect instance that contains the curl, where v(n,1), v(n,2) and v(n,3) are respectively the x and y and z curl components at element n.

◆ getDivergence()

template<class T_ >
void getDivergence ( Vect< T_ > &  v)

Evaluate the discrete Divergence of the current vector.

The resulting divergence is stored in a Vect instance. This function handles node vectors assuming P1 approximation. The divergence is then a constant vector for each element.

Parameters
[in]vVect instance that contains the divergence.

◆ getDOFType()

template<class T_ >
DOFSupport getDOFType ( ) const

Return DOF type of vector

Returns
dof_type Type of degrees of freedom. Value among the enumerated values: NODE_DOF, ELEMENT_DOF, SIDE_DOF or EDGE_DOF

◆ getFFT()

template<class T_ >
Vect< complex_t > getFFT ( )

Compute FFT transform of vector.

This member function computes the FFT (Fast Fourier Transform) of the vector contained in the instance and returns it

Returns
Vect<complex<double> > instance containing the FFT
Remarks
The size of Vect instance must be a power of two and must not exceed the value of 2^MAX_FFT_SIZE (This value is set in the header "constants.h")
The Vect instance can be either a Vect<double> or Vec<complex<double> >

◆ getGradient() [1/2]

template<class T_ >
void getGradient ( class Vect< T_ > &  v)

Evaluate the discrete Gradient vector of the current vector.

The resulting gradient is stored in a Vect instance. This function handles node vectors assuming P1 approximation. The gradient is then a constant vector for each element.

Parameters
[in]vVect instance that contains the gradient, where v(n,1), v(n,2) and v(n,3) are respectively the x and y and z derivatives at element n.

◆ getGradient() [2/2]

template<class T_ >
void getGradient ( Vect< Point< T_ > > &  v)

Evaluate the discrete Gradient vector of the current vector.

The resulting gradient is stored in an Vect instance. This function handles node vectors assuming P1 approximation. The gradient is then a constant vector for each element.

Parameters
[in]vVect instance that contains the gradient, where v(n,1).x, v(n,2).y and v(n,3).z are respectively the x and y and z derivatives at element n.

◆ getInvFFT()

template<class T_ >
Vect< complex_t > getInvFFT ( )

Compute Inverse FFT transform of vector.

This member function computes the inverse FFT (Fast Fourier Transform) of the vector contained in the instance and returns it

Returns
Vect<complex<double> > instance containing the FFT
Remarks
The size of Vect instance must be a power of two and must not exceed the value of 2^MAX_FFT_SIZE (This value is set in the header "constants.h")
The Vect instance can be either a Vect<double> or Vec<complex<double> >

◆ getNorm1()

template<class T_ >
real_t getNorm1 ( ) const

Calculate 1-norm of vector.

Remarks
This function is available only if the template parameter is double or complex<double>

◆ getNorm2()

template<class T_ >
real_t getNorm2 ( ) const

Calculate 2-norm (Euclidean norm) of vector.

Remarks
This function is available only if the template parameter is double or complex<double>

◆ getNormMax()

template<class T_ >
real_t getNormMax ( ) const

Calculate Max-norm (Infinite norm) of vector.

Remarks
This function is available only if the template parameter is double or complex<double>

◆ getSCurl()

template<class T_ >
void getSCurl ( Vect< T_ > &  v)

Evaluate the discrete scalar curl in 2-D of the current vector.

The resulting curl is stored in a Vect instance. This function handles node vectors assuming P1 approximation. The curl is then a constant vector for each element.

Parameters
[in]vVect instance that contains the scalar curl.

◆ getWNorm2()

template<class T_ >
real_t getWNorm2 ( ) const

Calculate weighted 2-norm of vector.

The weighted 2-norm is the 2-Norm of the vector divided by the square root of its size

◆ insertBC() [1/4]

template<class T_ >
void insertBC ( const Vect< T_ > &  v,
const Vect< T_ > &  bc,
int  dof = 0 
)

Insert boundary conditions.

Parameters
[in]vVect instance from which free degrees of freedom are copied to current instance.
[in]bcVect instance from which imposed degrees of freedom are copied to current instance.
[in]dofParameter to say if all degrees of freedom are concerned (=0, Default) or if only one degree of freedom (dof) is inserted into vector v which has only one degree of freedom by node or side

◆ insertBC() [2/4]

template<class T_ >
void insertBC ( const Vect< T_ > &  v,
int  dof = 0 
)

Insert boundary conditions.

DOF with imposed boundary conditions are set to zero.

Parameters
[in]vVect instance from which free degrees of freedom are copied to current instance.
[in]dofParameter to say if all degrees of freedom are concerned (=0, Default) or if only one degree of freedom (dof) is inserted into vector v which has only one degree of freedom by node or side
Warning
This member function is to be used in the case where a constructor with a Mesh has been used

◆ insertBC() [3/4]

template<class T_ >
void insertBC ( Mesh m,
const Vect< T_ > &  v,
const Vect< T_ > &  bc,
int  dof = 0 
)

Insert boundary conditions.

Parameters
[in]mMesh instance.
[in]vVect instance from which free degrees of freedom are copied to current instance.
[in]bcVect instance from which imposed degrees of freedom are copied to current instance.
[in]dofParameter to say if all degrees of freedom are concerned (=0, Default) or if only one degree of freedom (dof) is inserted into vector v which has only one degree of freedom by node or side

◆ insertBC() [4/4]

template<class T_ >
void insertBC ( Mesh m,
const Vect< T_ > &  v,
int  dof = 0 
)

Insert boundary conditions.

DOF with imposed boundary conditions are set to zero.

Parameters
[in]mMesh instance.
[in]vVect instance from which free degrees of freedom are copied to current instance.
[in]dofParameter to say if all degrees of freedom are concerned (=0, Default) or if only one degree of freedom (dof) is inserted into vector v which has only one degree of freedom by node or side

◆ MultAdd()

template<class T_ >
Vect< T_ > & MultAdd ( const Vect< T_ > &  x,
const T_ &  a 
)

Multiply by a constant then add to a vector.

Parameters
[in]xVect instance to add
[in]aConstant to multiply before adding

◆ Norm()

template<class T_ >
real_t Norm ( NormType  t) const

Compute a norm of vector.

Parameters
[in]tNorm type to compute: To choose among enumerate values: NORM1: 1-norm WNORM1: Weighted 1-norm (Discrete L1-norm) NORM2: 2-norm WNORM2: Weighted 2-norm (Discrete L2-norm) NORM_MAX: max norm (Infinity norm)
Returns
Value of norm
Warning
This function is available for real valued vectors only

◆ operator()() [1/8]

template<class T_ >
T_ & operator() ( size_t  i)

Operator () (Non constant version)

Parameters
[in]iRank index in vector (starts at 1)
  • v(i) starts at v(1) to v(size())
  • v(i) is the same element as v[i-1]

◆ operator()() [2/8]

template<class T_ >
T_ operator() ( size_t  i) const

Operator () (Constant version)

Parameters
[in]iRank index in vector (starts at 1)
  • v(i) starts at v(1) to v(size())
  • v(i) is the same element as v[i-1]

◆ operator()() [3/8]

template<class T_ >
T_ & operator() ( size_t  i,
size_t  j 
)

Operator () with 2-D indexing (Non constant version, case of a grid vector).

Parameters
[in]ifirst index in vector (Number of vector components in the x-grid)
[in]jsecond index in vector (Number of vector components in the y-grid) v(i,j) starts at v(1,1) to v(getNx(),getNy())

◆ operator()() [4/8]

template<class T_ >
T_ operator() ( size_t  i,
size_t  j 
) const

Operator () with 2-D indexing (Constant version).

Parameters
[in]ifirst index in vector (Number of vector components in the x-grid)
[in]jsecond index in vector (Number of vector components in the y-grid) v(i,j) starts at v(1,1) to v(getNx(),getNy())

◆ operator()() [5/8]

template<class T_ >
T_ & operator() ( size_t  i,
size_t  j,
size_t  k 
)

Operator () with 3-D indexing (Non constant version).

Parameters
[in]ifirst index in vector (Number of vector components in the x-grid)
[in]jsecond index in vector (Number of vector components in the y-grid)
[in]kthird index in vector (Number of vector components in the z-grid) v(i,j,k) starts at v(1,1,1) to v(getNx(),getNy(),getNz())

◆ operator()() [6/8]

template<class T_ >
T_ operator() ( size_t  i,
size_t  j,
size_t  k 
) const

Operator () with 3-D indexing (Constant version).

Parameters
[in]ifirst index in vector (Number of vector components in the x-grid)
[in]jsecond index in vector (Number of vector components in the y-grid)
[in]kthird index in vector (Number of vector components in the z-grid) v(i,j,k) starts at v(1,1,1) to v(getNx(),getNy(),getNz())

◆ operator()() [7/8]

template<class T_ >
T_ & operator() ( size_t  i,
size_t  j,
size_t  k,
size_t  l 
)

Operator () with 4-D indexing (Non constant version).

Parameters
[in]ifirst index in vector (Number of vector components in the x-grid)
[in]jsecond index in vector (Number of vector components in the y-grid)
[in]kthird index in vector (Number of vector components in the z-grid)
[in]lfourth index in vector (Number of vector components in the t-grid) v(i,j,k,l) starts at v(1,1,1,1) to v(getNx(),getNy(),getNz(),getNt())

◆ operator()() [8/8]

template<class T_ >
T_ operator() ( size_t  i,
size_t  j,
size_t  k,
size_t  l 
) const

Operator () with 4-D indexing (Constant version).

Parameters
[in]ifirst index in vector (Number of vector components in the x-grid)
[in]jsecond index in vector (Number of vector components in the y-grid)
[in]kthird index in vector (Number of vector components in the z-grid)
[in]lthird index in vector (Number of vector components in the t-grid) v(i,j,k,l) starts at v(1,1,1,1) to v(getNx(),getNy(),getNz(),getNt())

◆ operator*=()

template<class T_ >
Vect< T_ > & operator*= ( const T_ &  a)

Operator *=

Parameters
[in]aValue to multiply by

◆ operator+=() [1/2]

template<class T_ >
Vect< T_ > & operator+= ( const T_ &  a)

Operator +=

Add a constant to current vector entries.

Parameters
[in]aValue to add to vector entries

◆ operator+=() [2/2]

template<class T_ >
Vect< T_ > & operator+= ( const Vect< T_ > &  v)

Operator +=

Add vector x to current vector instance.

Parameters
[in]vVect instance to add to instance

◆ operator,()

template<class T_ >
T_ operator, ( const Vect< 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 Vect<double>

Parameters
[in]vVect instance by which the current instance is multiplied

◆ operator-=() [1/2]

template<class T_ >
Vect< T_ > & operator-= ( const T_ &  a)

Operator -=

Subtract constant from vector entries.

Parameters
[in]aValue to subtract from

◆ operator-=() [2/2]

template<class T_ >
Vect< T_ > & operator-= ( const Vect< T_ > &  v)

Operator -=

Parameters
[in]vVect instance to subtract from

◆ operator/=()

template<class T_ >
Vect< T_ > & operator/= ( const T_ &  a)

Operator /=

Parameters
[in]aValue to divide by

◆ operator=() [1/2]

template<class T_ >
Vect< T_ > & operator= ( const T_ &  a)

Operator =

Assign a constant to vector entries

Parameters
[in]aValue to set

◆ operator=() [2/2]

template<class T_ >
void operator= ( string  s)

Operator =

Assign an algebraic expression to vector entries. This operator has the same effect as the member function set(s)

Parameters
[in]sString defining the algebraic expression as a function of coordinates and time
Warning
A Mesh instance must has been introduced before (e.g. by a constructor)

◆ push_back()

template<class T_ >
void push_back ( const T_ &  v)

Add an entry to the vector.

This function is an overload of the member function push_back of the parent class vector. It adjusts in addition some vector parameters

Parameters
[in]vEntry value to add

◆ removeBC() [1/2]

template<class T_ >
void removeBC ( const Mesh ms,
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]msMesh instance
[in]vVector (Vect instance to copy from)
[in]dofParameter to say if all degrees of freedom are concerned (=0, Default) or if only one degree of freedom (dof) is inserted into vector v which has only one degree of freedom

◆ removeBC() [2/2]

template<class T_ >
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]vVector (Vect instance to copy from)
[in]dofParameter to say if all degrees of freedom are concerned [Default: 0] or if only one degree of freedom (dof) is inserted into vector v which has only one degree of freedom.
Warning
This member function is to be used in the case where a constructor with a Mesh has been used

◆ resize() [1/2]

template<class T_ >
void resize ( size_t  n)

Set vector size.

This function allocates memory for the vector but does not initialize its components

Parameters
[in]nSize of vector

◆ resize() [2/2]

template<class T_ >
void resize ( size_t  n,
T_  v 
)

Set vector size and initialize to a constant value.

This function allocates memory for the vector

Parameters
[in]nSize of vector
[in]vValue to assign to vector entries

◆ select() [1/3]

template<class T_ >
void select ( const Vect< T_ > &  v,
size_t  n 
)

Select one component from a given multicomponent vector.

Parameters
[in]vVect instance to extract from
[in]nComponent to extract (must be > 1 and < 4 or).

◆ select() [2/3]

template<class T_ >
void select ( const Vect< T_ > &  v,
size_t  nb_dof = 0,
size_t  first_dof = 1 
)

Initialize vector with another Vect instance.

Parameters
[in]vVect instance to extract from
[in]nb_dofNumber of DOF per node, element or side (By default, 0: Number of degrees of freedom extracted from the Mesh instance)
[in]first_dofFirst DOF to extract (Default: 1) For instance, a choice first_dof=2 and nb_dof=1 means that the second DOF of each node is copied in the vector

◆ select() [3/3]

template<class T_ >
Vect< T_ > select ( size_t  n)

Return vector with selected one component from a given multicomponent vector.

Parameters
[in]nComponent to extract (must be > 1 and < 4 or).
Returns
Vector with selected component

◆ set() [1/8]

template<class T_ >
void set ( const string &  exp,
const Vect< real_t > &  x 
)

Initialize vector with an algebraic expression.

This function can be used for instance in 1-D

Parameters
[in]expRegular algebraic expression that defines a function of x which are values of vector. This expression must use the variable x as coordinate of vector.
Warning
If the time variable t is involved in the expression, the time value associated to the vector instance must be defined (Default value is 0) either by using the appropriate constructor or by the member function setTime.
Parameters
[in]xVector that defines coordinates

◆ set() [2/8]

template<class T_ >
void set ( const string &  exp,
size_t  dof = 1 
)

Initialize vector with an algebraic expression.

This function is to be used is a Mesh instance is associated to the vector

Parameters
[in]expRegular algebraic expression that defines a function of x, y, z which are coordinates of nodes and t which is the time value.
[in]dofDegree of freedom to which the value is assigned [Default: 1]
Warning
If the time variable t is involved in the expression, the time value associated to the vector instance must be defined (Default value is 0) either by using the appropriate constructor or by the member function setTime.

◆ set() [3/8]

template<class T_ >
void set ( const T_ *  v,
size_t  n 
)

Initialize vector with a c-array.

Parameters
[in]vc-array (pointer) to initialize Vect
[in]nsize of array

◆ set() [4/8]

template<class T_ >
void set ( const Vect< real_t > &  x,
const string &  exp 
)

Initialize vector with an algebraic expression.

Parameters
[in]xVect instance that contains coordinates of points
[in]expRegular algebraic expression that defines a function of x and i which are coordinates. Consider for instance that we want to initialize the Vect instance with the values v[i] = exp(1+x[i]); then, we use this member function as follows v.set("exp("1+x",x);

◆ set() [5/8]

template<class T_ >
void set ( Mesh ms,
const string &  exp,
size_t  dof = 1 
)

Initialize vector with an algebraic expression with providing mesh data.

Parameters
[in]msMesh instance
[in]expRegular algebraic expression that defines a function of x, y and z which are coordinates of nodes.
[in]dofDegree of freedom to which the value is assigned [Default: 1]

◆ set() [6/8]

template<class T_ >
void set ( size_t  i,
size_t  j,
size_t  k,
T_  val 
)

Assign a value to an entry for a 3-D vector.

Parameters
[in]iFirst index in vector (starts at 1)
[in]jSecond index in vector (starts at 1)
[in]kThird index in vector (starts at 1)
[in]valValue to assign

◆ set() [7/8]

template<class T_ >
void set ( size_t  i,
size_t  j,
T_  val 
)

Assign a value to an entry for a 2-D vector.

Parameters
[in]iFirst index in vector (starts at 1)
[in]jSecond index in vector (starts at 1)
[in]valValue to assign

◆ set() [8/8]

template<class T_ >
void set ( size_t  i,
T_  val 
)

Assign a value to an entry for a 1-D vector.

Parameters
[in]iRank index in vector (starts at 1)
[in]valValue to assign

◆ setDG()

template<class T_ >
void setDG ( int  degree = 1)

Set Discontinuous Galerkin type vector.

When the vector is associated to a mesh, this one is sized differently if the DG method is used.

Parameters
[in]degreePolynomial degree of the DG method [Default: 1]

◆ setDOFType()

template<class T_ >
void setDOFType ( DOFSupport  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_typeType of degrees of freedom. Value to be chosen among the enumerated values: NODE_DOF, ELEMENT_DOF, SIDE_DOF or EDGE_DOF

◆ setGrid()

template<class T_ >
void setGrid ( Grid g)

Define grid class to size vector.

Parameters
[in]gGrid instance

◆ setIJK()

template<class T_ >
void setIJK ( const string &  exp)

Assign a given function (given by an interpretable algebraic expression) of indices components of vector.

This function enable assigning a value to vector entries as function of indices

Parameters
[in]expRegular algebraic expression to assign. It must involve the variables i, j and/or k.

◆ setIJKL()

template<class T_ >
void setIJKL ( const string &  exp)

Assign a given function (given by an interpretable algebraic expression) of indices components of vector.

This function enable assigning a value to vector entries as function of indices

Parameters
[in]expRegular algebraic expression to assign. It must involve the variables i, j, k and/or l.

◆ setMesh()

template<class T_ >
void setMesh ( Mesh m,
DOFSupport  dof_type = NODE_DOF,
size_t  nb_dof = 0 
)

Define mesh class to size vector.

Parameters
[in]mMesh instance
[in]dof_typeParameter to precise the type of degrees of freedom. To be chosen among the enumerated values: NODE_DOF, ELEMENT_DOF, SIDE_DOF, EDGE_DOF [Default: NODE_DOF]
[in]nb_dofNumber of degrees of freedom per node, element or side. If nb_dof is set to 0 the constructor picks this number from the Mesh instance [Default: 0]

◆ setNodeBC() [1/8]

template<class T_ >
void setNodeBC ( int  code,
const string &  exp 
)

Assign a given function (given by an interpretable algebraic expression) to components of vector with given code.

Vector components are assumed nodewise. Concerns 1-DOF problems

Parameters
[in]codeCode for which nodes will be assigned prescribed value
[in]expRegular algebraic expression to prescribe
Warning
This member function is to be used in the case where a constructor with a Mesh has been used

◆ setNodeBC() [2/8]

template<class T_ >
void setNodeBC ( int  code,
const string &  exp,
size_t  dof 
)

Assign a given function (given by an interpretable algebraic expression) to components of vector with given code.

Vector components are assumed nodewise

Parameters
[in]codeCode for which nodes will be assigned prescribed value
[in]expRegular algebraic expression to prescribe
[in]dofDegree of Freedom for which the value is assigned [default: 1]
Warning
This member function is to be used in the case where a constructor with a Mesh has been used

◆ setNodeBC() [3/8]

template<class T_ >
void setNodeBC ( int  code,
T_  val 
)

Assign a given value to components of vector with given code.

Vector components are assumed nodewise. Concerns 1-DOF problems

Parameters
[in]codeCode for which nodes will be assigned prescribed value
[in]valValue to prescribe

◆ setNodeBC() [4/8]

template<class T_ >
void setNodeBC ( int  code,
T_  val,
size_t  dof 
)

Assign a given value to components of vector with given code.

Vector components are assumed nodewise

Parameters
[in]codeCode for which nodes will be assigned prescribed value
[in]valValue to prescribe
[in]dofDegree of Freedom for which the value is assigned [default: 1]

◆ setNodeBC() [5/8]

template<class T_ >
void setNodeBC ( Mesh m,
int  code,
const string &  exp 
)

Assign a given function (given by an interpretable algebraic expression) to components of vector with given code.

Vector components are assumed nodewise. Case of 1-DOF problem

Parameters
[in]mInstance of mesh
[in]codeCode for which nodes will be assigned prescribed value
[in]expRegular algebraic expression to prescribe

◆ setNodeBC() [6/8]

template<class T_ >
void setNodeBC ( Mesh m,
int  code,
const string &  exp,
size_t  dof 
)

Assign a given function (given by an interpretable algebraic expression) to components of vector with given code.

Vector components are assumed nodewise

Parameters
[in]mInstance of mesh
[in]codeCode for which nodes will be assigned prescribed value
[in]expRegular algebraic expression to prescribe
[in]dofDegree of Freedom for which the value is assigned

◆ setNodeBC() [7/8]

template<class T_ >
void setNodeBC ( Mesh m,
int  code,
T_  val 
)

Assign a given value to components of vector with given code.

Vector components are assumed nodewise. Here all dofs of nodes with given code will be assigned

Parameters
[in]mMesh instance
[in]codeThe value is assigned if the node has this code
[in]valValue to assign

◆ setNodeBC() [8/8]

template<class T_ >
void setNodeBC ( Mesh m,
int  code,
T_  val,
size_t  dof 
)

Assign a given value to components of vector with given code.

Vector components are assumed nodewise

Parameters
[in]mMesh instance
[in]codeThe value is assigned if the node has this code
[in]valValue to assign
[in]dofDegree of freedom to assign

◆ setSideBC() [1/7]

template<class T_ >
void setSideBC ( int  code,
const string &  exp 
)

Assign a given function (given by an interpre<table algebraic expression) to components of vector with given code.

Vector components are assumed nodewise. Case of 1-DOF problem

Parameters
[in]codeCode for which nodes will be assigned prescribed value
[in]expRegular algebraic expression to prescribe
Warning
This member function is to be used in the case where a constructor with a Mesh has been used

◆ setSideBC() [2/7]

template<class T_ >
void setSideBC ( int  code,
const string &  exp,
size_t  dof 
)

Assign a given function (given by an interpre<table algebraic expression) to components of vector with given code.

Vector components are assumed nodewise

Parameters
[in]codeCode for which nodes will be assigned prescribed value
[in]expRegular algebraic expression to prescribe
[in]dofDegree of Freedom for which the value is assigned
Warning
This member function is to be used in the case where a constructor with a Mesh has been used

◆ setSideBC() [3/7]

template<class T_ >
void setSideBC ( int  code,
T_  val 
)

Assign a given value to components of vector with given code.

Vector components are assumed nodewise. Concerns 1-DOF problems

Parameters
[in]codeCode for which nodes will be assigned prescribed value
[in]valValue to prescribe
Warning
This member function is to be used in the case where a constructor with a Mesh has been used

◆ setSideBC() [4/7]

template<class T_ >
void setSideBC ( int  code,
T_  val,
size_t  dof 
)

Assign a given value to components of vector with given code.

Vector components are assumed nodewise

Parameters
[in]codeCode for which nodes will be assigned prescribed value
[in]valValue to prescribe
[in]dofDegree of Freedom for which the value is assigned
Warning
This member function is to be used in the case where a constructor with a Mesh has been used

◆ setSideBC() [5/7]

template<class T_ >
void setSideBC ( Mesh m,
int  code,
const string &  exp 
)

Assign a given function (given by an interpretable algebraic expression) to components of vector corresponding to sides with given code.

Vector components are assumed nodewise. Case of 1-DOF problem

Parameters
[in]mInstance of mesh
[in]codeCode for which nodes will be assigned prescribed value
[in]expRegular algebraic expression to prescribe

◆ setSideBC() [6/7]

template<class T_ >
void setSideBC ( Mesh m,
int  code,
const string &  exp,
size_t  dof 
)

Assign a given function (given by an interpretable algebraic expression) to components of vector corresponding to sides with given code.

Vector components are assumed nodewise

Parameters
[in]mInstance of mesh
[in]codeCode for which nodes will be assigned prescribed value
[in]expRegular algebraic expression to prescribe
[in]dofDegree of Freedom for which the value is assigned

◆ setSideBC() [7/7]

template<class T_ >
void setSideBC ( Mesh m,
int  code,
T_  val,
size_t  dof 
)

Assign a given value to components of vector corresponding to sides with given code.

Vector components are assumed nodewise

Parameters
[in]mInstance of mesh
[in]codeCode for which nodes will be assigned prescribed value
[in]valValue to prescribe
[in]dofDegree of Freedom for which the value is assigned [default: 1]

◆ setSize()

template<class T_ >
void setSize ( size_t  nx,
size_t  ny = 1,
size_t  nz = 1,
size_t  nt = 1 
)

Set vector size (for 1-D, 2-D or 3-D cases and 3-D + time)

This function allocates memory for the vector but does not initialize its components

Parameters
[in]nxNumber of grid points in x-direction
[in]nyNumber of grid points in y-direction [Default: 1]
[in]nzNumber of grid points in z-direction [Default: 1]
[in]ntNumber of grid points in t-direction [Default: 1]

◆ setUniform()

template<class T_ >
void setUniform ( T_  vmin,
T_  vmax,
size_t  n 
)

Initialize vector entries by setting extremal values and interval.

Parameters
[in]vminMinimal value to assign to the first entry
[in]vmaxMaximal value to assign to the lase entry
[in]nNumber of points (including extremities)
Remarks
The vector has a size of n. It is sized in this function

◆ transferBC()

template<class T_ >
void transferBC ( const Vect< T_ > &  bc,
int  dof = 0 
)

Transfer boundary conditions to the vector.

Parameters
[in]bcVect instance from which imposed degrees of freedom are copied to current instance
[in]dofParameter to say if all degrees of freedom are concerned (=0, Default) or if only one degree of freedom (dof) is inserted into vector v which has only one degree of freedom.

◆ WithGrid()

template<class T_ >
bool WithGrid ( ) const

Return true if vector contains a Grid pointer, false if not.

A Vect instance can be constructed using grid information

◆ WithMesh()

template<class T_ >
bool WithMesh ( ) const

Return true if vector contains a Mesh pointer, false if not.

A Vect instance can be constructed using mesh information