Index

NAME

FieldsFunc - vector field defined as a C/C++ function or functor


INCLUDE

include "FieldFunc.h"

SYNTAX

 class FieldsFunc : public Fields
 {
 public:
   FieldsFunc (const char* name = NULL) : Fields(name) {}
  ~FieldsFunc ();
   FieldsFunc (const FieldsFunc&);

   virtual bool ok () const { return true; };

   // valuePt is usually used from a Fields* or Fields& or Handle(Fields):
   virtual void valuePt (Ptv(NUMT)& vec, const Ptv(real)& x, real t = DUMMY);

   // operator() is usually used from a FieldsFunc pointer/ref/handle to
   // access functors (problem dependent classes derived from FieldsFunc):
   virtual Ptv(NUMT) operator () (const Ptv(real)& x, real t) const;

   virtual void valueFEM (Ptv(NUMT)& vec, const FiniteElement& fe,
                          real t = DUMMY);

   CLASS_INFO

   VIRTUAL_CAST(FieldsFunc)
 };



KEYWORDS

vector field, explicit function



DESCRIPTION

The  class  implements  a  vector  field  defined  in terms of an
explicit function. The function takes a spatial point and a  time
value as arguments and returns a Ptv value. The time value can be
omitted since the default value is DUMMY (hence  it  is  easy  to
recognize  situations where the time value has not been supplied,
just test if it is equal to "DUMMY).

Here is a description of how  to  implement  an  explicit  vector
fields using this class.  Derive a new class from FieldsFunc.  In
the derived class one implements the virtual functions operator()
and valuePt. Both these functions perform the same task, the only
difference is that operator() is a const-functions and  allows  a
prettier syntax.  This type of FieldsFunc is actually a so called
functor. In the user's class one may  have  references  to  other
problem dependent classes such that data can be accessed.

One  of  the purposes of FieldsFunc is to support an interface to
user defined functions such that all vector fields, whether  they
are  explicit  functions or complicated finite element functions,
have a common interface.  In other words, the programmer can work
with  Fields without knowing the details of the representation of
the field.  Another purpose is to offer a base class for  problem
dependent  functors reflecting  vector fields. (Observe that ten­
sor fields can easily be representd by class  FieldsFunc  -  just
let  the number of components equal the number of distinct compo­
nents in the tensor).

This class contains a pointer to the function and maybe a pointer
to  the  derivate  of  the  function.  If  the latter is missing,
derivates can be calculated by numerical differentiation. If both
pointers  are missing, this object cannot be used on its own, and
it is required that the user derives a class and uses  FieldsFunc
as a base class for a functor.



CONSTRUCTORS AND INITIALIZATION

Constructors  taking pointers to the function, and if desired, to
a function that returns its derivatives are provided. Empty  con­
structors  can  also  be  used, but then the object must later be
initialized (and binded to a function) by the  member  functions,
or  the  explicit  function must be a functor, that is, a virtual
function operator() or valuePt in a class derived  from  "Fields­
Func.



MEMBER FUNCTIONS

valuePt  -  evaluates  the function. This is a non-const function
and it is also virtual in the Field base class.

operator() - same as valuePt, but the function is const.  It  has
no virtual counterpart in class Field.



SEE ALSO

class Fields, class FieldFunc


DEVELOPED BY

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


AUTHOR

Hans Petter Langtangen, SINTEF/UiO