ScalarFunctionDerivative Class Reference

#include <ScalarFunctionDerivative.hpp>

Inheritance diagram for ScalarFunctionDerivative:

Inheritance graph
[legend]
Collaboration diagram for ScalarFunctionDerivative:

Collaboration graph
[legend]

List of all members.

Public Types

enum  Direction { x, y, z }
enum  Type {
  cfunction, constant, convection, dgfunction,
  femfunction, linearBasis, spectral, unaryMinus,
  modulo, sum, difference, product,
  division, power, min, max,
  gt, ge, lt, le,
  ne, eq, and_, or_,
  xor_, not_, derivate, integrate,
  normal, domainCharacteristic, meshCharacteristic, objectCharacteristic,
  composed, references, FEM0, undefined
}

Public Member Functions

real_t operator() (const TinyVector< 3, real_t > &X) const
bool canBeSimplified () const
 ScalarFunctionDerivative (const ScalarFunctionDerivative::Direction &direction, ConstReferenceCounting< ScalarFunctionBase > functionToDerive)
 ScalarFunctionDerivative (const ScalarFunctionDerivative &f)
 ~ScalarFunctionDerivative ()
void setName (const std::string &name)
const std::string & name () const
const Typetype () const
real_t operator() (const real_t &x, const real_t &y, const real_t &z) const
virtual real_t dx (const TinyVector< 3, real_t > &x) const
virtual real_t dy (const TinyVector< 3, real_t > &x) const
virtual real_t dz (const TinyVector< 3, real_t > &x) const

Protected Attributes

const Type __type
std::string __name

Private Member Functions

std::ostream & __put (std::ostream &os) const

Private Attributes

const Direction __direction
ConstReferenceCounting
< ScalarFunctionBase
__functionToDerive

Friends

std::ostream & operator<< (std::ostream &os, const ScalarFunctionBase &scalarFunction)


Detailed Description

Definition at line 35 of file ScalarFunctionDerivative.hpp.


Member Enumeration Documentation

Enumerator:
x 
y 
z 

Definition at line 39 of file ScalarFunctionDerivative.hpp.

00039                  {
00040     x,
00041     y,
00042     z
00043   };

enum ScalarFunctionBase::Type [inherited]

Enumerator:
cfunction 
constant 
convection 
dgfunction 
femfunction 
linearBasis 
spectral 
unaryMinus 
modulo 
sum 
difference 
product 
division 
power 
min 
max 
gt 
ge 
lt 
le 
ne 
eq 
and_ 
or_ 
xor_ 
not_ 
derivate 
integrate 
normal 
domainCharacteristic 
meshCharacteristic 
objectCharacteristic 
composed 
references 
FEM0 
undefined 

Definition at line 40 of file ScalarFunctionBase.hpp.

00040             {
00041     cfunction,
00042     constant,
00043     convection,
00044     dgfunction,
00045     femfunction,
00046     linearBasis,
00047     spectral,
00048     unaryMinus,
00049 
00050     modulo,
00051     sum,
00052     difference,
00053     product,
00054     division,
00055     power,
00056 
00057     min,
00058     max,
00059 
00060     gt,
00061     ge,
00062     lt,
00063     le,
00064     ne,
00065     eq,
00066     and_,
00067     or_,
00068     xor_,
00069 
00070     not_,
00071 
00072     derivate,
00073     integrate,
00074 
00075     normal,
00076 
00077     domainCharacteristic,
00078     meshCharacteristic,
00079     objectCharacteristic,
00080 
00081     composed,
00082     references,
00083 
00084     FEM0,
00085 
00086     undefined
00087   };


Constructor & Destructor Documentation

ScalarFunctionDerivative::ScalarFunctionDerivative ( const ScalarFunctionDerivative::Direction direction,
ConstReferenceCounting< ScalarFunctionBase functionToDerive 
)

Constructor

Parameters:
direction direction of derivation
functionToDerive the function to derive

Definition at line 77 of file ScalarFunctionDerivative.cpp.

References __functionToDerive, ScalarFunctionBase::femfunction, ErrorHandler::normal, and ScalarFunctionBase::spectral.

00079   : ScalarFunctionBase(ScalarFunctionBase::derivate),
00080     __direction(direction)
00081 {
00082   switch(functionToDerive->type()) {
00083   case ScalarFunctionBase::femfunction:
00084   case ScalarFunctionBase::spectral: {
00085     const ScalarFunctionBase* f = functionToDerive;
00086     __functionToDerive = f;
00087     break;
00088   }
00089   default:
00090   if (functionToDerive->type() != ScalarFunctionBase::femfunction) {
00091     std::stringstream errorMsg;
00092 
00093     errorMsg << "cannot compute derivative of non discrete functions :-(\n";
00094     errorMsg << "the function " << (*functionToDerive) << " is not of that kind"
00095              << std::ends;
00096 
00097     throw ErrorHandler(__FILE__,__LINE__,
00098                        errorMsg.str(),
00099                        ErrorHandler::normal);
00100 
00101   }
00102   }
00103 }

ScalarFunctionDerivative::ScalarFunctionDerivative ( const ScalarFunctionDerivative f  ) 

Copy constructor

Parameters:
f the function to copy

Definition at line 106 of file ScalarFunctionDerivative.cpp.

00107   : ScalarFunctionBase(f),
00108     __direction(f.__direction),
00109     __functionToDerive(f.__functionToDerive)
00110 {
00111   ;
00112 }

ScalarFunctionDerivative::~ScalarFunctionDerivative (  ) 

Destructor

Definition at line 115 of file ScalarFunctionDerivative.cpp.

00116 {
00117   ;
00118 }


Member Function Documentation

std::ostream & ScalarFunctionDerivative::__put ( std::ostream &  os  )  const [private, virtual]

Writes the function to a stream

Parameters:
os output stream
Returns:
os

Implements ScalarFunctionBase.

Definition at line 25 of file ScalarFunctionDerivative.cpp.

References __direction, __functionToDerive, ErrorHandler::unexpected, x, y, and z.

00026 {
00027   switch(__direction) {
00028   case ScalarFunctionDerivative::x: {
00029     os << "dx(";
00030     break;
00031   }
00032   case ScalarFunctionDerivative::y: {
00033     os << "dy(";
00034     break;
00035   }
00036   case ScalarFunctionDerivative::z: {
00037     os << "dz(";
00038     break;
00039   }
00040   default: {
00041     throw ErrorHandler(__FILE__,__LINE__,
00042                        "unknown derivative direction",
00043                        ErrorHandler::unexpected);
00044   }
00045   }
00046   os << *__functionToDerive << ')';
00047   return os;
00048 }

real_t ScalarFunctionDerivative::operator() ( const TinyVector< 3, real_t > &  X  )  const [virtual]

Evaluates the derivative at point $ X $

Returns:
$ \partial_i f(X) $

Implements ScalarFunctionBase.

Definition at line 53 of file ScalarFunctionDerivative.cpp.

References __direction, __functionToDerive, ErrorHandler::unexpected, x, y, and z.

00054 {
00055   switch(__direction) {
00056   case ScalarFunctionDerivative::x: {
00057     return __functionToDerive->dx(X);
00058   }
00059   case ScalarFunctionDerivative::y: {
00060     return __functionToDerive->dy(X);
00061     break;
00062   }
00063   case ScalarFunctionDerivative::z: {
00064     return __functionToDerive->dz(X);
00065     break;
00066   }
00067   default: {
00068     throw ErrorHandler(__FILE__,__LINE__,
00069                        "unknown derivative direction",
00070                        ErrorHandler::unexpected);
00071   }
00072   }
00073   return 0;
00074 }

bool ScalarFunctionDerivative::canBeSimplified (  )  const [inline, virtual]

Checks if the function can be simplified

Returns:
false

Implements ScalarFunctionBase.

Definition at line 72 of file ScalarFunctionDerivative.hpp.

00073   {
00074     return false;
00075   }

void ScalarFunctionBase::setName ( const std::string &  name  )  [inline, inherited]

Sets the name of the function

Parameters:
name name to give to this function

Definition at line 109 of file ScalarFunctionBase.hpp.

References ScalarFunctionBase::__name.

Referenced by FunctionExpressionVariable::execute().

00110   {
00111     __name = name;
00112   }

const std::string& ScalarFunctionBase::name (  )  const [inline, inherited]

Gets the name of the function

Returns:
__name

Definition at line 119 of file ScalarFunctionBase.hpp.

References ScalarFunctionBase::__name.

00120   {
00121     return __name;
00122   }

const Type& ScalarFunctionBase::type (  )  const [inline, inherited]

real_t ScalarFunctionBase::operator() ( const real_t &  x,
const real_t &  y,
const real_t &  z 
) const [inline, inherited]

Evaluates the function at point $ (x,y,z) $

Parameters:
x $ x $
y $ y $
z $ z $
Returns:
$ f(x,y,z) $

Definition at line 162 of file ScalarFunctionBase.hpp.

00165   {
00166     return this->operator()(TinyVector<3, real_t>(x,y,z));    
00167   }

virtual real_t ScalarFunctionBase::dx ( const TinyVector< 3, real_t > &  x  )  const [inline, virtual, inherited]

Evaluates first derivative of the function

Parameters:
x position of evaluation
Returns:
$ \partial_x f $ at position $ x $

Definition at line 185 of file ScalarFunctionBase.hpp.

References ErrorHandler::normal.

00186   {
00187     std::stringstream errorMsg;
00188 
00189     errorMsg << "cannot compute derivative of non discrete functions :-(\n";
00190     errorMsg << "the function " << (*this) << " is not of that kind"
00191              << std::ends;
00192 
00193     throw ErrorHandler(__FILE__,__LINE__,
00194                        errorMsg.str(),
00195                        ErrorHandler::normal);
00196     return 0;
00197   }

virtual real_t ScalarFunctionBase::dy ( const TinyVector< 3, real_t > &  x  )  const [inline, virtual, inherited]

Evaluates second derivative of the function

Parameters:
x position of evaluation
Returns:
$ \partial_y f $ at position $ x $

Definition at line 206 of file ScalarFunctionBase.hpp.

References ErrorHandler::normal.

00207   {
00208     std::stringstream errorMsg;
00209 
00210     errorMsg << "cannot compute derivative of non discrete functions :-(\n";
00211     errorMsg << "the function " << (*this) << " is not of that kind"
00212              << std::ends;
00213 
00214     throw ErrorHandler(__FILE__,__LINE__,
00215                        errorMsg.str(),
00216                        ErrorHandler::normal);
00217     return 0;
00218   }

virtual real_t ScalarFunctionBase::dz ( const TinyVector< 3, real_t > &  x  )  const [inline, virtual, inherited]

Evaluates third derivative of the function

Parameters:
x position of evaluation
Returns:
$ \partial_z f $ at position $ x $

Definition at line 227 of file ScalarFunctionBase.hpp.

References ErrorHandler::normal.

00228   {
00229     std::stringstream errorMsg;
00230 
00231     errorMsg << "cannot compute derivative of non discrete functions :-(\n";
00232     errorMsg << "the function " << (*this) << " is not of that kind"
00233              << std::ends;
00234 
00235     throw ErrorHandler(__FILE__,__LINE__,
00236                        errorMsg.str(),
00237                        ErrorHandler::normal);
00238     return 0;
00239   }


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const ScalarFunctionBase scalarFunction 
) [friend, inherited]

Writes the function scalarFunction to the stream os

Parameters:
os the output stream
scalarFunction the function to write
Returns:
os

Definition at line 142 of file ScalarFunctionBase.hpp.

00144   {
00145     if (scalarFunction.__name.size()>0) {
00146       os << scalarFunction.__name;
00147       return os;
00148     } else {
00149       return scalarFunction.__put(os);
00150     }
00151   }


Member Data Documentation

direction of derivation

Definition at line 46 of file ScalarFunctionDerivative.hpp.

Referenced by __put(), and operator()().

function to derive

Definition at line 48 of file ScalarFunctionDerivative.hpp.

Referenced by __put(), operator()(), and ScalarFunctionDerivative().

const Type ScalarFunctionBase::__type [protected, inherited]

type of the function

Definition at line 90 of file ScalarFunctionBase.hpp.

Referenced by ScalarFunctionBase::type().

std::string ScalarFunctionBase::__name [protected, inherited]

name of the function

Definition at line 92 of file ScalarFunctionBase.hpp.

Referenced by ScalarFunctionBase::name(), and ScalarFunctionBase::setName().


The documentation for this class was generated from the following files:

Generated on Wed Nov 19 00:12:58 2008 for FreeFEM3D (aka ff3d) by  doxygen 1.5.6