Index

NAME

BasisFuncAtPt  -  finite  element  basis functions evaluated at a
point


INCLUDE

include "BasisFuncAtPt.h"

SYNTAX

 class BasisFuncAtPt
 {
 private:
   Ptv(real)  loc_eval_pt;  // local evaluation point for basis functions

   int        nbf;          // no of trial functions
   int        ngf;          // no of geometry functions (for element mapping)
   int        nsd;
   int        eval_derivatives;  // =1: evaluate Ni and 1st order derivatives

   Vec(real)    Ni;       // basis (trial) functions at an evaluation point
   Handle(Mat(real)) h_djNi;       // derivatives of Ni, global coordinates
   Handle(Mat(real)) h_djNi_loc;   // derivatives of Ni, local  coordinates
   Handle(Vec(real)) h_Ni_g;       // geometry functions
   Handle(Mat(real)) h_djNi_g_loc; // derivatives of geometry Ni, local  coord.
   Handle(ArrayGen(real)) h_d2Ni;  // 2nd order derivatives of Ni, global coord.
   Handle(ArrayGen(real)) h_d2Ni_loc; // 2nd order deriv. of Ni, local  coord.
                            // no need for 2nd ord. deriv. of geometry func.

   Handle(Mat(real)) h_jacobi;     // Jacobi matrix
   Handle(Mat(real)) h_inv_jacobi; // inverse Jacobi matrix
   real       det_jacobi;          // determinant of  jacobi

   ElementType el_tp;       // enum variable to identify the type of element
   real       det_side_J;   // side-element jacobi
   Ptv(real)  nv;           // normal-vector to a side (its length=det_side_J)
   Vec(real)  scratch;      // needed for calc.  inv_jacobi  when nsd>3

   void calcJacobiEtcT3n2d (const Mat(real)& elmcoor); // special case for T3
   void calcJacobiEtcT4n3d (const Mat(real)& elmcoor); // special case for T4
   void calcJacobiEtc (const Mat(real)& elmcoor); // J, J^{-1}, det J
   bool redim ();
   bool derivOk (const char* function_name, int deriv_order) const;

   bool       initialized;  // indicates whether Ni, djNi etc are computed
 public:
   static long int ncalls_calcJacobi;   // for statistics and efficiency
   static long int ncalls_initAtPoint;  // evaluation if verbose > 0

 public:
   BasisFuncAtPt();
   BasisFuncAtPt(const BasisFuncAtPt& b);
  ~BasisFuncAtPt() {}

   bool ok () const;
   bool redim  (HandleElmDefs& elmdef);  // update for a new element

   void initAtPoint
    (
     const Ptv(real)&     eval_pt,
           HandleElmDefs& elmdef,
     const Mat(real)&     elmcoor,
           int            current_side
    );
   void updateJacobi (const Mat(real)& elmcoor);
   void operator = (const BasisFuncAtPt& b);
   bool evaluatedAt (const Ptv(real)& loc_pt);

   real   N (int i) const;
   real  dN (int i, int dir) const;
   real d2N (int i, int dir1, int dir2) const;

   real  dNloc (int i, int dir) const;

   friend  class FiniteElement;

 protected:
   const Mat(real)& JacobiMatrix () const    { return *h_jacobi; }
   const Mat(real)& invJacobiMatrix () const { return *h_inv_jacobi; }
   const Vec(real)& N() const                { return Ni; }
   const Mat(real)& dNgloc() const           { return *h_djNi_g_loc; }
   const Mat(real)& dNloc() const            { return *h_djNi_loc; }
   const Vec(real)& Ng() const               { return *h_Ni_g; }
   const Mat(real)& dN() const               { return *h_djNi; }
   const ArrayGen(real)& d2N() const         { return *h_d2Ni; }
   void  copyJacobiEtc (const BasisFuncAtPt& b);
   void  unInitialize ();
   void  evalDerivatives (int i);

 public:

   real detJ () const;
   real detSideJ () const;
   void getNormalVectorOnSide (Ptv(real)& vec) const;
 };

 inline real BasisFuncAtPt:: N (int i) const
 {
 #ifdef SAFETY_CHECKS
   Ni.indexOk (i,"BasisFuncAtPt::N");
 #endif

   return Ni(i);
 }

 inline real BasisFuncAtPt:: dN (int i, int dir) const
 {
 #ifdef SAFETY_CHECKS
   derivOk("dN",1);
   h_djNi->indexOk (i,dir,"BasisFuncAtPt::dN");
 #endif

   return h_djNi()(i,dir);
 }

 inline real BasisFuncAtPt:: dNloc (int i, int dir) const
 {
 #ifdef SAFETY_CHECKS
   derivOk("dNloc",1);
   h_djNi_loc->indexOk (i,dir,"BasisFuncAtPt::dNloc");
 #endif

   return h_djNi_loc()(i,dir);
 }

 inline real BasisFuncAtPt:: d2N (int i, int dir1, int dir2) const
 {
 #ifdef SAFETY_CHECKS
   derivOk("d2N",2);
   h_d2Ni->indexOk (i,dir1,dir2,"BasisFuncAtPt::d2N");
 #endif

   return h_d2Ni()(i,dir1,dir2);
 }

 inline real BasisFuncAtPt:: detJ () const
 {
   return det_jacobi;
 }



KEYWORDS

basis functions, shape functions, numerical integration



DESCRIPTION

The class represent data associated with the finite element basis
functions  evaluated at a point in an element. These data include
the basis function values, the values of  the  derivatives  (with
respect to local and global coordinates), the values of the func­
tions used in the geometric mapping (for isoparametric  functions
these  functions  coincides  with  the  basis functions), and the
Jacobi matrix (plus inverse) associated with the  geometric  map­
ping.  The class is used by class FiniteElement.

One  can  think  of  using an array of BasisFuncAtPt objects such
that each object represents the basis function data at a  numeri­
cal integration point.  It is then possible to evaluate all basis
function data once and for all if all the elements are  equal  in
type and shape.



CONSTRUCTORS AND INITIALIZATION

There  is a copy constructor and a constructor without arguments.
The latter must be followed by a call to redim before the  object
is  initialized.   The  redim  function will only redimension the
data structures according to  the  current  element  information.
initAtPoint  performs  all  evaluations  of  basis functions, the
Jacobian etc.  We refer to class FiniteElement  for  examples  on
how BasisFuncAtPt is used in finite element computations.



MEMBER FUNCTIONS

redim - redimensions the internal data structures.

initAtPoint  -  evaluates all the basis functions, Jacobian etc.,
at the current evaluation point.

updateJacobi - updates the values in the data structures that are
affected  by  the  shape  (and  not the type) of the element. For
example, the Jacobi matrix is affected by  the  shape  while  the
basis  functions  themselves  are only dependent upon the element
type. The function is included for enabling efficient  coding  of
finite element algorithms on grids consisting of only one element
type. Instead of calling initAtPoint for every element, one  sim­
ply calls updateJacobi.

operator=  -  assignment  operator, makes it easy to copy objects
from an array VecSimplest(BasisFuncAtPt).

evaluatedAt - returns a true value if the current object's  basis
function  data were based on the local point given as argument to
this function.  The function makes it easy to check  whether  the
object is properly filled or not.

N - returns the value of the basis function.

dN - returns the value of the derivative of the basis function in
global coordinates.

dNloc - returns the value of the derivative of the basis function
in local coordinates.

d2N  -  returns  the  value of the second order derivative of the
basis function.

detJ - returns the determinant of the Jacobi matrix.

detSideJ - returns the area of a surface element used in  surface
integration.

getNormalVectorOnSide - returns the outward unit normal vector if
the current evaluation point is at a side in the element.


EXAMPLE

See the source code of class FiniteElement.



SEE ALSO

class FiniteElement.


DEVELOPED BY

SINTEF Applied Mathematics, Oslo, Norway, and University of Oslo,
Dept. of Mathematics, Norway


AUTHOR

Hans Petter Langtangen, SINTEF/UiO. Optimizations and some repro­
gramming by Klas Samuelsson, UiO.