Vect Class Template Reference
[Vector and Matrix]
#include <Vect.h>

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 Argument:
- T_ data type (double, float, ...)
Public Member Functions | |
| void | Assembly (const Side *sd, T_ *b) |
| Assembly of side 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 Element *el, const T_ *b) |
| Assembly of element vector (as C-array) into Vect instance. | |
| void | Assembly (const Element *el, const Vect< T_ > &b) |
| Assembly of element vector into current instance. | |
| void | From (const SideVect< T_ > &v, size_t nb_dof=0, size_t first_dof=1) |
| Fill vector with a SideVect instance. | |
| void | From (const ElementVect< T_ > &v, size_t nb_dof=0, size_t first_dof=1) |
| Fill vector with a ElementVect instance. | |
| void | From (const NodeVect< T_ > &v, size_t nb_dof=0, size_t first_dof=1) |
| Fill vector with a NodeVect instance. | |
| double | getNorm1 () const |
| Calculate 1-norm of vector. | |
| double | getNorm2 () const |
| Calculate 2-norm (Euclidean 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 | getPrintView (size_t &imin, size_t &imax) const |
| Return window data for vector printing. | |
| size_t | getSize () const |
| Return vector size. | |
| double | getWNorm1 () const |
| Calculate weighted 1-norm of vector (1-Norm divided by size). | |
| double | getWNorm2 () const |
| Calculate weighted 2-norm of vector (2-Norm divided by sqrt(size)). | |
| void | insertBC (const class Mesh &m, const Vect< T_ > &v) |
| Insert boundary conditions. | |
| void | insertBC (const class Mesh &m, const Vect< T_ > &v, const Vect< T_ > &bc) |
| Insert boundary conditions. | |
| Vect< T_ > & | MultAdd (const Vect< T_ > &x, const T_ &a) |
| Multiply by a constant then add to a vector. | |
| T_ | operator() (size_t i, size_t j, size_t k) const |
| Operator () with triple 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) const |
| Operator () with double indexing (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) const |
| Operator () (Constant version). | |
| T_ & | operator() (size_t i) |
| Operator () (Non constant version). | |
| Vect< T_ > & | operator*= (const T_ &a) |
| Operator 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 Vect< T_ > &x) |
| Operator -=. | |
| Vect< T_ > & | operator/= (const T_ &a) |
| Operator operator/=. | |
| Vect< T_ > & | operator= (const SideVect< T_ > &v) |
| Operator =. | |
| Vect< T_ > & | operator= (const ElementVect< T_ > &v) |
| Operator =. | |
| Vect< T_ > & | operator= (const NodeVect< T_ > &v) |
| Operator =. | |
| Vect< T_ > & | operator= (const T_ &a) |
| Operator =. | |
| void | removeBC (const class Mesh &m, NodeVect< T_ > *v) |
| Remove boundary conditions. | |
| void | removeBC (const class Mesh &m, const Vect< T_ > &v) |
| Remove boundary conditions. | |
| void | setPrintView (size_t imin, size_t imax) |
| set a window for vector printing | |
| void | setSize (size_t nx, size_t ny, size_t nz) |
| Set vector size (structured 3-D case). | |
| void | setSize (size_t nx, size_t ny) |
| Set vector size (structured 2-D case). | |
| void | setSize (size_t size) |
| Set vector size. | |
| void | transferBC (const class Mesh &m, const Vect< T_ > &bc) |
| Transfer boundary conditions to the vector. | |
| Vect (const SideVect< T_ > &v, size_t nb_dof, size_t first_dof) | |
| Constructor from a SideVect instance using one dof. | |
| Vect (const SideVect< T_ > &v) | |
| Constructor from a SideVect instance. | |
| Vect (const ElementVect< T_ > &v, size_t nb_dof, size_t first_dof) | |
| Constructor from an ElementVect instance handling one dof. | |
| Vect (const ElementVect< T_ > &v) | |
| Constructor from an ElementVect instance. | |
| Vect (const NodeVect< T_ > &v, size_t nb_dof, size_t first_dof) | |
| Constructor from a NodeVect instance handling one DOF. | |
| Vect (const NodeVect< T_ > &v) | |
| Constructor from a NodeVect instance. | |
| Vect (const class Mesh &m, const Vect< T_ > &v, const BCVect< T_ > &bc) | |
| Constructor using boundary conditions. | |
| Vect (const Side *sd, const Vect< T_ > &v, int opt=0) | |
| Constructor of a side vector. | |
| Vect (const Element *el, const Vect< T_ > &v, int opt=0) | |
| Constructor of an element vector. | |
| Vect (const Vect< T_ > &v) | |
| Copy constructor. | |
| Vect (size_t n, T_ *x) | |
| Creates an instance of class Vect as an image of a C/C++ array. | |
| Vect (size_t nx, size_t ny, size_t nz) | |
| Constructor of a double index grid vector. | |
| Vect (size_t nx, size_t ny) | |
| Constructor of a double index grid vector. | |
| Vect (size_t n) | |
| Constructor setting vector size. | |
| Vect () | |
| Default Constructor : Initialize a zero-length vector. | |
| ~Vect () | |
| Destructor. | |
Constructor & Destructor Documentation
| Vect | ( | size_t | n | ) |
| Vect | ( | size_t | nx, | |
| size_t | ny | |||
| ) |
Constructor of a double index grid vector.
This constructor is to be used for a 2-D grid vector
- Parameters:
-
[in] nx Number of vector components in the x-grid [in] ny Number of vector components in the y-grid
References OFELI::Clear().
| Vect | ( | size_t | nx, | |
| size_t | ny, | |||
| size_t | nz | |||
| ) |
Constructor of a double index grid vector.
This constructor is to be used for a 3-D grid vector
- Parameters:
-
[in] nx Number of vector components in the x-grid [in] ny Number of vector components in the y-grid [in] nz Number of vector components in the z-grid
References OFELI::Clear().
| Vect | ( | size_t | n, | |
| T_ * | x | |||
| ) |
Creates 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 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 [in] opt Option - 0 - All DOF are handled [ default ]
- Any other value - only one DOF is handled (Local vector has as dimension number of degrees of freedom
References Node::getFirstDOF(), Node::getNbDOF(), Element::getNbEq(), Element::getNbNodes(), and Element::getPtrNode().
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 [in] opt Option - = 0 - All DOF are handled [ default ]
- != 0 - only one DOF is handled (Local vector has as dimension number of degrees of freedom
References Node::getFirstDOF(), Node::getNbDOF(), Side::getNbDOF(), Side::getNbNodes(), and Side::getPtrNode().
Constructor using boundary conditions.
Boundary condition values contained in bc are reported to vector v
- Parameters:
-
[in] m Instance of class Mesh [in] v Vector to update [in] bc Vector containing imposed valued at desired DOF
References Node::getCode(), Node::getDOF(), Node::getNbDOF(), Mesh::getNode(), and Mesh::topNode().
Constructor from a NodeVect instance.
The constructed vector is deduced from the NodeVect instance. Resulting entries are ordered node by node, DOF dof by DOF.
- Parameters:
-
[in] v NodeVect instance to copy
References Vect::From().
Constructor from a NodeVect instance handling one DOF.
- Parameters:
-
[in] v NodeVect instance to extract from [in] nb_dof Number of DOF per node [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
References Vect::From().
| Vect | ( | const ElementVect< T_ > & | v | ) |
Constructor from an ElementVect instance.
The constructed vector is deduced from the ElementVect instance. Resulting entries are ordered element by element, DOF by DOF.
- Parameters:
-
[in] v ElementVect instance to extract from
References Vect::From().
| Vect | ( | const ElementVect< T_ > & | v, | |
| size_t | nb_dof, | |||
| size_t | first_dof | |||
| ) |
Constructor from an ElementVect instance handling one dof.
- Parameters:
-
[in] v ElementVect instance to extract from [in] nb_dof Number of DOF per element [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 element is copied in the vector
References Vect::From().
Constructor from a SideVect instance.
The constructed vector is deduced from the SideVect instance. Resulting entries are ordered side by side, DOF dof by DOF.
- Parameters:
-
[in] v Side vector to add
References Vect::From().
Constructor from a SideVect instance using one dof.
- Parameters:
-
[in] v SideVect instance to extract from [in] nb_dof Number of DOF per side [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 side is copied in the vector
References Vect::From().
Member Function Documentation
| void Assembly | ( | const Side * | sd, | |
| T_ * | b | |||
| ) |
Assembly of side vector (as C-array) into Vect instance.
- Parameters:
-
[in] sd Pointer to side [in] b Local vector to assemble (C-Array)
References Node::getDOF(), Node::getNbDOF(), Side::getNbNodes(), and Side::getPtrNode().
Assembly of side vector into Vect instance.
- Parameters:
-
[in] sd Pointer to side [in] b Local vector to assemble (Instance of class Vect)
References Node::getDOF(), Node::getNbDOF(), Side::getNbNodes(), and Side::getPtrNode().
| void Assembly | ( | const Element * | el, | |
| const T_ * | b | |||
| ) |
Assembly of element vector (as C-array) into Vect instance.
- Parameters:
-
[in] el Pointer to element [in] b Local vector to assemble (C-Array)
References Node::getDOF(), Node::getNbDOF(), Element::getNbNodes(), and Element::getPtrNode().
Assembly of element vector into current instance.
- Parameters:
-
[in] el Pointer to element [in] b Local vector to assemble (Instance of class Vect)
References Node::getDOF(), Node::getNbDOF(), Element::getNbNodes(), and Element::getPtrNode().
| void From | ( | const SideVect< T_ > & | v, | |
| size_t | nb_dof = 0, |
|||
| size_t | first_dof = 1 | |||
| ) |
Fill vector with a SideVect instance.
- Parameters:
-
[in] v SideVect instance to extract from [in] nb_dof Number of DOF per side [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 side is copied in the vector
References AbsVect::getNbDOF(), and SideVect::getNbSides().
| void From | ( | const ElementVect< T_ > & | v, | |
| size_t | nb_dof = 0, |
|||
| size_t | first_dof = 1 | |||
| ) |
Fill vector with a ElementVect instance.
- Parameters:
-
[in] v ElementVect instance to extract from [in] nb_dof Number of DOF per element [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 element is copied in the vector
References AbsVect::getNbDOF(), and ElementVect::getNbElements().
| void From | ( | const NodeVect< T_ > & | v, | |
| size_t | nb_dof = 0, |
|||
| size_t | first_dof = 1 | |||
| ) |
Fill vector with a NodeVect instance.
- Parameters:
-
[in] v NodeVect instance to extract from [in] nb_dof Number of DOF per node [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
References AbsVect::getNbDOF(), and NodeVect::getNbNodes().
Referenced by Vect::Vect().
| 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
Referenced by OFELI::operator<<().
Insert boundary conditions.
DOF with imposed boundary conditions are set to zero.
- Parameters:
-
[in] m Mesh instance. [in] v Vect instance from which free degrees of freedom are copied to current instance.
References Side::getCode(), Node::getCode(), Side::getDOF(), Node::getDOF(), Side::getNbDOF(), Node::getNbDOF(), Mesh::getNode(), Mesh::getSide(), Mesh::NodesAreDOF(), Mesh::SidesAreDOF(), Mesh::topNode(), and Mesh::topSide().
Insert boundary conditions.
- Parameters:
-
[in] m Mesh instance. [in] v Vect instance from which free degrees of freedom are copied to current instance. [in] bc Vect instance from which imposed degrees of freedom are copied to current instance.
References Side::getCode(), Node::getCode(), Side::getDOF(), Node::getDOF(), Side::getNbDOF(), Node::getNbDOF(), Mesh::getNode(), Mesh::getSide(), Mesh::NodesAreDOF(), Mesh::SidesAreDOF(), Mesh::topNode(), and Mesh::topSide().
Multiply by a constant then add to a vector.
- Parameters:
-
[in] x Vector to add [in] a Constant to multiply before adding
| T_ operator() | ( | size_t | i, | |
| size_t | j, | |||
| size_t | k | |||
| ) | const |
Operator () with triple 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 | |||
| ) | const |
| T_ & operator() | ( | size_t | i, | |
| size_t | j | |||
| ) |
| 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 | ) |
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]
| Vect< T_ > & operator*= | ( | const T_ & | a | ) |
Operator operator*=.
- Parameters:
-
[in] a Value to multiply by
| Vect< T_ > & operator+= | ( | const T_ & | a | ) |
Operator +=.
Add a constant to current vector entries.
- Parameters:
-
[in] a Value to add to vector entries
Operator +=.
Add vector x to current vector instance.
- Parameters:
-
[in] x Vector to add to instance
| Vect< T_ > & operator-= | ( | const T_ & | a | ) |
Operator -=.
Subtract constant from vector entries.
- Parameters:
-
[in] a Value to subtract from
Operator -=.
- Parameters:
-
[in] x Vector to subtract from
| Vect< T_ > & operator/= | ( | const T_ & | a | ) |
Operator operator/=.
- Parameters:
-
[in] a Value to divide by
Operator =.
Assign a SideVect instance to vector.
- Parameters:
-
[in] v Vector to copy from.
References AbsVect::getNbDOF(), and SideVect::getNbSides().
| Vect< T_ > & operator= | ( | const ElementVect< T_ > & | v | ) |
Operator =.
Assign an ElementVect instance to vector.
- Parameters:
-
[in] v Vector to copy from. ElementVect instance entries are stored element by element
References AbsVect::getNbDOF(), and ElementVect::getNbElements().
Operator =.
Assign a NodeVect instance to vector
- Parameters:
-
[in] v Vector to copy from NodeVect instance entries are stored node by node
References AbsVect::getNbDOF(), and NodeVect::getNbNodes().
| Vect< T_ > & operator= | ( | const T_ & | a | ) |
Operator =.
Assign a constant to vector entries
- Parameters:
-
[in] a Value to set
Remove boundary conditions.
This member function copies to current vector a vector where only non imposed DOF are retained.
References Mesh::getNbDOF(), Mesh::getNode(), and Mesh::topNode().
Remove boundary conditions.
This member function copies to current vector a vector where only non imposed DOF are retained.
References Node::getCode(), Node::getDOF(), Node::getNbDOF(), Mesh::getNode(), and Mesh::topNode().
| 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 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
References OFELI::Clear().
| 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
References OFELI::Clear().
| void setSize | ( | size_t | size | ) |
Set vector size.
- Parameters:
-
[in] size New size value
Transfer boundary conditions to the vector.
- Parameters:
-
[in] m Mesh instance. [in] bc Vect instance from which imposed degrees of freedom are copied to current instance.
References Side::getCode(), Node::getCode(), Side::getNbDOF(), Node::getNbDOF(), Mesh::getNode(), Mesh::getSide(), Mesh::NodesAreDOF(), Mesh::SidesAreDOF(), Mesh::topNode(), and Mesh::topSide().