To handle general purpose vectors. More...
Inherits valarray< 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 double index vector. | |
| Vect (size_t nx, size_t ny, size_t nz) | |
| Constructor of a triple index vector. | |
| Vect (size_t n, T_ *x) | |
| Create an instance of class Vect as an image of a C/C++ array. | |
| Vect (const class Mesh &m, int nb_dof=0, int dof_type=NODE_FIELD) | |
| Constructor with a mesh instance. | |
| Vect (const class Mesh &m, string name, double t=0.0, int nb_dof=0, int dof_type=NODE_FIELD) | |
| Constructor with a mesh instance giving name and time for vector. | |
| Vect (const class Element *el, const Vect< T_ > &v) | |
| Constructor of an element vector. | |
| Vect (const class 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 | set (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 Vect< double > &x, const string &exp) |
| Initialize vector with an algebraic expression. | |
| void | setMesh (const class Mesh &m, int nb_dof=0, int dof_type=NODE_FIELD) |
| void | setSize (size_t size) |
| Set vector size. | |
| void | setSize (size_t nx, size_t ny) |
| Set vector size (structured 2-D case) | |
| void | setSize (size_t nx, size_t ny, size_t nz) |
| Set vector size (structured 3-D case) | |
| size_t | getSize () const |
| Return vector size. | |
| size_t | getNbDOF () const |
| Return vector number of degrees of freedom. | |
| size_t | getNb () const |
| Return vector number of entities (nodes, elements or sides) | |
| const Mesh & | getMesh () const |
| Return Mesh instance. | |
| int | getDOFType () const |
| void | setTime (double t) |
| Set time value for vector. | |
| double | getTime () const |
| Get time value for vector. | |
| void | setName (string name) |
| Set name of vector. | |
| string | getName () const |
| Get name of vector. | |
| double | getNorm1 () const |
| Calculate 1-norm of vector. | |
| double | getNorm2 () const |
| Calculate 2-norm (Euclidean norm) of vector. | |
| double | getWNorm1 () const |
| Calculate weighted 1-norm of vector. The wighted 1-norm is the 1-Norm of the vector divided by its size. | |
| double | getWNorm2 () const |
| Calculate weighted 2-norm of vector. | |
| double | getNormMax () const |
| Calculate Max-norm (Infinite norm) of vector. | |
| 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 (class Mesh &m, int code, T_ val, size_t dof=1) |
| Assign a given value to components of vector with given code. | |
| void | setNodeBC (class 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. | |
| void | setNodeBC (int code, T_ val, size_t dof=1) |
| Assign a given value to components of vector with given code. | |
| 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. | |
| void | removeBC (const Vect< T_ > &v) |
| Remove boundary conditions. | |
| void | transferBC (const Vect< T_ > &bc) |
| Transfer boundary conditions to the vector. | |
| void | insertBC (class Mesh &m, const Vect< T_ > &v, const Vect< T_ > &bc) |
| Insert boundary conditions. | |
| void | insertBC (class Mesh &m, const Vect< T_ > &v) |
| Insert boundary conditions. | |
| void | insertBC (const Vect< T_ > &v, const Vect< T_ > &bc) |
| Insert boundary conditions. | |
| void | insertBC (const Vect< T_ > &v) |
| Insert boundary conditions. | |
| void | Assembly (const class Element *el, const Vect< T_ > &b) |
| Assembly of element vector into current instance. | |
| void | Assembly (const class Element *el, const T_ *b) |
| Assembly of element vector (as C-array) into Vect instance. | |
| void | Assembly (const class Side *sd, const Vect< T_ > &b) |
| Assembly of side vector into Vect instance. | |
| void | Assembly (const class Side *sd, 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. | |
| void | save (string file, int opt) |
| Save vector in a file according to a given format. | |
| 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. | |
| 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 double indexing (Non constant version, case of a grid vector). | |
| T_ | operator() (size_t i, size_t j) const |
| Operator () with double indexing (Constant version). | |
| T_ & | operator() (size_t i, size_t j, size_t k) |
| Operator () with triple indexing (Non constant version). | |
| T_ | operator() (size_t i, size_t j, size_t k) const |
| Operator () with triple indexing (Constant version). | |
| Vect< T_ > & | operator= (const Vect< T_ > &v) |
| Operator = between vectors. | |
| Vect< T_ > & | operator= (const T_ &a) |
| Operator =. | |
| Vect< T_ > & | operator+= (const Vect< T_ > &x) |
| Operator +=. | |
| Vect< T_ > & | operator+= (const T_ &a) |
| Operator +=. | |
| Vect< T_ > & | operator-= (const Vect< T_ > &x) |
| Operator -=. | |
| Vect< T_ > & | operator-= (const T_ &a) |
| Operator -=. | |
| Vect< T_ > & | operator*= (const T_ &a) |
| Operator *=. | |
| Vect< T_ > & | operator/= (const T_ &a) |
| Operator /=. | |
| void | setPrintView (size_t imin, size_t imax) |
| Set a window for vector printing. | |
| void | getPrintView (size_t &imin, size_t &imax) const |
| Return window data for vector printing. | |
Detailed Description
template<class T_>
class OFELI::Vect< T_ >
To handle general purpose vectors.
This template class enables considering vectors of various data types. Operators =, [] and () are overloaded so that one can write for instance:
Vect<double> 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 (double, float, complex<double>, ...)
Constructor & Destructor Documentation
| Vect | ( | size_t | n | ) |
Constructor setting vector size.
- Parameters:
-
[in] n Size of vector
| Vect | ( | size_t | nx, |
| size_t | ny | ||
| ) |
Constructor of a double index vector.
This constructor can be used for instance for a 2-D 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
| Vect | ( | size_t | nx, |
| size_t | ny, | ||
| size_t | nz | ||
| ) |
Constructor of a triple index vector.
This constructor can be used for instance for a 3-D 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
| Vect | ( | size_t | n, |
| T_ * | x | ||
| ) |
Create an instance of class Vect as an image of a C/C++ array.
- Parameters:
-
[in] n Dimension of vector to construct [in] x C-array to copy
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 to 0(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_FIELDorEDGE_FIELD(Default:NODE_FIELD)
| Vect | ( | const class Mesh & | m, |
| string | name, | ||
| double | t = 0.0, |
||
| int | nb_dof = 0, |
||
| int | dof_type = 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 to 0the 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_FIELDorEDGE_FIELD(Default:NODE_FIELD)
Constructor of an element vector.
The constructed vector has local numbering of nodes
- Parameters:
-
[in] el Pointer to Element to localize [in] v Global vector to localize
Constructor of a side vector.
The constructed vector has local numbering of nodes
- Parameters:
-
[in] sd Pointer to Side to localize [in] v Global vector to localize
Constructor to select some components of a given vector.
- Parameters:
-
[in] v Vect 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 and nb_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 3-component vector.
- Parameters:
-
[in] v Vect 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 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] d Integer 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] v Vect instance from which extraction is performed. [in] name Name 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
| void set | ( | const T_ * | v, |
| size_t | n | ||
| ) |
Initialize vector with a c-array.
- Parameters:
-
[in] v c-array (pointer) to initialize Vect [in] n size of array
Initialize vector with another Vect instance.
- Parameters:
-
[in] v Vect 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 and nb_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]
Initialize vector with an algebraic expression.
- Parameters:
-
[in] x Vect 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.
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 to 0the 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)
| void setSize | ( | size_t | size | ) |
Set vector size.
- Parameters:
-
[in] size New size value
| void setSize | ( | size_t | nx, |
| size_t | ny | ||
| ) |
Set vector size (structured 2-D case)
- Parameters:
-
[in] nx Number of grid points in x-direction [in] ny Number of grid points in y-direction
| void setSize | ( | size_t | nx, |
| size_t | ny, | ||
| size_t | nz | ||
| ) |
Set vector size (structured 3-D case)
- Parameters:
-
[in] nx Number of grid points in x-direction [in] ny Number of grid points in y-direction [in] nz Number of grid points in z-direction
| 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_FIELDorEDGE_FIELD
| double 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
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]
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.
- Parameters:
-
[in] v Vector (Vect instance to copy from)
| void transferBC | ( | const Vect< T_ > & | bc | ) |
Transfer boundary conditions to the vector.
- Parameters:
-
[in] bc Vect instance from which imposed degrees of freedom are copied to current instance.
Insert boundary conditions.
DOF with imposed boundary conditions are set to zero.
- Parameters:
-
[in] v Vect instance from which free degrees of freedom are copied to current instance.
Assembly of element vector into current instance.
- Parameters:
-
[in] el Pointer to element [in] b Local vector to assemble (Instance of class Vect)
Assembly of element vector (as C-array) into Vect instance.
- Parameters:
-
[in] el Pointer to element [in] b Local vector to assemble (C-Array)
Assembly of side vector (as C-array) into Vect instance.
- Parameters:
-
[in] sd Pointer to side [in] b Local vector to assemble (C-Array)
| 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] v Vect 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.
| 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] v Vect 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.
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] v Vect 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.
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] v Vect 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.
| void getDivergence | ( | Vect< T_ > & | v | ) |
| void save | ( | string | file, |
| int | opt | ||
| ) |
Save vector in a file according to a given format.
void save(const Mesh &ms, const string &file, int opt)
- 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 VTK
Multiply by a constant then add to a vector.
- Parameters:
-
[in] x Vect instance to add [in] a Constant to multiply before adding
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
| T_& operator() | ( | size_t | i | ) |
Operator () (Non constant version).
- Parameters:
-
[in] i Rank 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]
| T_ operator() | ( | size_t | i | ) | const |
Operator () (Constant version).
- Parameters:
-
[in] i Rank 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]
| T_& operator() | ( | size_t | i, |
| size_t | j | ||
| ) |
| T_ operator() | ( | size_t | i, |
| size_t | j | ||
| ) | const |
| T_& operator() | ( | size_t | i, |
| size_t | j, | ||
| size_t | k | ||
| ) |
Operator () with triple indexing (Non constant version).
| T_ operator() | ( | size_t | i, |
| size_t | j, | ||
| size_t | k | ||
| ) | const |
Operator () with triple indexing (Constant version).
| Vect<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] x Vect instance to add to instance
| Vect<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] x Vect instance to subtract from
| Vect<T_>& operator-= | ( | const T_ & | a | ) |
Operator -=.
Subtract constant from vector entries.
- Parameters:
-
[in] a Value to subtract from
| Vect<T_>& operator*= | ( | const T_ & | a | ) |
Operator *=.
- Parameters:
-
[in] a Value to multiply by
| Vect<T_>& operator/= | ( | const T_ & | a | ) |
Operator /=.
- Parameters:
-
[in] a Value to divide by
| void setPrintView | ( | size_t | imin, |
| size_t | imax | ||
| ) |
Set a window for vector printing.
- Parameters:
-
[in] imin first vector index to view [in] imax last vector index to view
| void getPrintView | ( | size_t & | imin, |
| size_t & | imax | ||
| ) | const |
Return window data for vector printing.
- Parameters:
-
[out] imin first vector index to view [out] imax last vector index to view
- OFELI
- Vect