OFELI's Logo

An Object Oriented Finite Element Library

LocalVect< T_, N_ > Class Template Reference

Handles small size vectors like element vectors. More...

#include <LocalVect.h>

Public Member Functions

 LocalVect ()
 Default constructor.
 
 LocalVect (const T_ *a)
 Constructor using a C-array.
 
 LocalVect (const Element *el)
 Constructor using Element pointer.
 
 LocalVect (const Side *sd)
 Constructor using Side pointer.
 
 LocalVect (const LocalVect< T_, N_ > &v)
 Copy constructor.
 
 LocalVect (const Element *el, const Vect< T_ > &v, int opt=0)
 Constructor of an element vector from a global Vect instance. More...
 
 LocalVect (const Element &el, const Vect< T_ > &v, int opt=0)
 Constructor of an element vector from a global Vect instance. More...
 
 LocalVect (const Side *sd, const Vect< T_ > &v, int opt=0)
 Constructor of a side vector from a global Vect instance. More...
 
 ~LocalVect ()
 Destructor.
 
void getLocal (const Element &el, const Vect< T_ > &v, int type)
 Localize an element vector from a global Vect instance. More...
 
void Localize (const Element *el, const Vect< T_ > &v, size_t k=0)
 Localize an element vector from a global Vect instance. More...
 
void Localize (const Side *sd, const Vect< T_ > &v, size_t k=0)
 Localize a side vector from a global Vect instance. More...
 
T_ & operator[] (size_t i)
 Operator [] (Non constant version). More...
 
T_ operator[] (size_t i) const
 Operator [] (Constant version). More...
 
T_ & operator() (size_t i)
 Operator () (Non constant version). More...
 
T_ operator() (size_t i) const
 Operator () (Constant version). More...
 
ElementEl ()
 Return pointer to Element if vector was constructed using an element and nullptr otherwise.
 
SideSd ()
 Return pointer to Side if vector was constructed using a side and nullptr otherwise.
 
LocalVect< T_, N_ > & operator= (const LocalVect< T_, N_ > &v)
 Operator = More...
 
LocalVect< T_, N_ > & operator= (const T_ &x)
 Operator = More...
 
LocalVect< T_, N_ > & operator+= (const LocalVect< T_, N_ > &v)
 Operator += More...
 
LocalVect< T_, N_ > & operator+= (const T_ &a)
 Operator += More...
 
LocalVect< T_, N_ > & operator-= (const LocalVect< T_, N_ > &v)
 Operator -= More...
 
LocalVect< T_, N_ > & operator-= (const T_ &a)
 Operator -= More...
 
LocalVect< T_, N_ > & operator*= (const T_ &a)
 Operator *= More...
 
LocalVect< T_, N_ > & operator/= (const T_ &a)
 Operator /= More...
 
T_ * get ()
 Return pointer to vector as a C-Array.
 
T_ operator, (const LocalVect< T_, N_ > &v) const
 Return Dot (scalar) product of two vectors. More...
 

Detailed Description

template<class T_, size_t N_>
class OFELI::LocalVect< T_, N_ >

Handles small size vectors like element vectors.

The template class LocalVect treats small size vectors. Typically, this class is recommended to store element and side arrays. Operators =, [] and () are overloaded so that one can write for instance:

     LocalVect<double,10> u, v;
     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. Notice that entries of v are here v(1), v(2), ..., v(10), i.e. vector entries start at index 1.
Internally, no dynamic storage is used.

Template Parameters
T_Data type (double, float, complex<double>, ...)
N_Vector size
Author
Rachid Touzani

Constructor & Destructor Documentation

◆ LocalVect() [1/3]

LocalVect ( const Element el,
const Vect< T_ > &  v,
int  opt = 0 
)

Constructor of an element vector from a global Vect instance.

The constructed vector has local numbering of nodes

Parameters
[in]elPointer to Element to localize
[in]vGlobal vector to localize
[in]optOption for DOF treatment
  • = 0, Normal case [Default]
  • Any other value : only one DOF is handled (Local vector has as dimension number of degrees of freedom)

◆ LocalVect() [2/3]

LocalVect ( const Element el,
const Vect< T_ > &  v,
int  opt = 0 
)

Constructor of an element vector from a global Vect instance.

The constructed vector has local numbering of nodes

Parameters
[in]elReference to Element instance to localize
[in]vGlobal vector to localize
[in]optOption for DOF treatment
  • = 0, Normal case [Default]
  • Any other value : only one DOF is handled (Local vector has as dimension number of degrees of freedom)

◆ LocalVect() [3/3]

LocalVect ( const Side sd,
const Vect< T_ > &  v,
int  opt = 0 
)

Constructor of a side vector from a global Vect instance.

The constructed vector has local numbering of nodes

Parameters
[in]sdPointer to Side to localize
[in]vGlobal vector to localize
[in]optOption for DOF treatment
  • = 0, Normal case [Default]
  • Any other value : only one DOF is handled (Local vector has as dimension number of degrees of freedom)

Member Function Documentation

◆ getLocal()

void getLocal ( const Element el,
const Vect< T_ > &  v,
int  type 
)

Localize an element vector from a global Vect instance.

The constructed vector has local numbering of nodes This function is called by the constructor: LocalVect(const Element *el, const Vect<T_> &v)

Parameters
[in]elPointer to Element to localize
[in]vGlobal vector to localize
[in]typeType of element. This is to be chosen among enumerated values: LINE2, TRIANG3, QUAD4, TETRA4, HEXA8, PENTA6

◆ Localize() [1/2]

void Localize ( const Element el,
const Vect< T_ > &  v,
size_t  k = 0 
)

Localize an element vector from a global Vect instance.

The constructed vector has local numbering of nodes This function is called by the constructor: LocalVect(const Element *el, const Vect<T_> &v)

Parameters
[in]elPointer to Side to localize
[in]vGlobal vector to localize
[in]kDegree of freedom to localize [Default: All degrees of freedom are stored]

◆ Localize() [2/2]

void Localize ( const Side sd,
const Vect< T_ > &  v,
size_t  k = 0 
)

Localize a side vector from a global Vect instance.

The constructed vector has local numbering of nodes This function is called by the constructor: LocalVect(const Side *sd, const Vect<T_> &v)

Parameters
[in]sdPointer to Side to localize
[in]vGlobal vector to localize
[in]kDegree of freedom to localize [Default: All degrees of freedom are stored]

◆ operator()() [1/2]

T_ & operator() ( size_t  i)

Operator () (Non constant version).

v(i) starts at v(1) to v(size()). v(i) is the same element as v[i-1]

◆ operator()() [2/2]

T_ operator() ( size_t  i) const

Operator () (Constant version).

v(i) starts at v(1) to v(size()) v(i) is the same element as v[i-1]

◆ operator*=()

LocalVect< T_, N_ > & operator*= ( const T_ &  a)

Operator *=

Multiply vector by constant a

◆ operator+=() [1/2]

LocalVect< T_, N_ > & operator+= ( const LocalVect< T_, N_ > &  v)

Operator +=

Add vector v to this instance

◆ operator+=() [2/2]

LocalVect< T_, N_ > & operator+= ( const T_ &  a)

Operator +=

Add constant a to vector entries

◆ operator,()

T_ operator, ( const LocalVect< T_, N_ > &  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 LocalVect<double,n>

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

◆ operator-=() [1/2]

LocalVect< T_, N_ > & operator-= ( const LocalVect< T_, N_ > &  v)

Operator -=

Subtract vector v from this instance

◆ operator-=() [2/2]

LocalVect< T_, N_ > & operator-= ( const T_ &  a)

Operator -=

Subtract constant a from vector entries

◆ operator/=()

LocalVect< T_, N_ > & operator/= ( const T_ &  a)

Operator /=

Divide vector by constant a

◆ operator=() [1/2]

LocalVect< T_, N_ > & operator= ( const LocalVect< T_, N_ > &  v)

Operator =

Copy a LocalVect instance to the current one

◆ operator=() [2/2]

LocalVect< T_, N_ > & operator= ( const T_ &  x)

Operator =

Assign value x to all vector entries

◆ operator[]() [1/2]

T_ & operator[] ( size_t  i)

Operator [] (Non constant version).

v[i] starts at v[0] to v[size()-1]

◆ operator[]() [2/2]

T_ operator[] ( size_t  i) const

Operator [] (Constant version).

v[i] starts at v[0] to v[size()-1]






Copyright © 1998-2022 Rachid Touzani