OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
oofem::PythonExpression Class Reference

Class representing user defined functions as Python expressions. More...

#include <pythonexpression.h>

+ Inheritance diagram for oofem::PythonExpression:
+ Collaboration diagram for oofem::PythonExpression:

Public Member Functions

 PythonExpression (int n, Domain *d)
 Constructor. More...
 
virtual ~PythonExpression ()
 Destructor. More...
 
virtual IRResultType initializeFrom (InputRecord *ir)
 Reads the fields. More...
 
virtual void giveInputRecord (DynamicInputRecord &ir)
 Setups the input record string of receiver. More...
 
virtual void evaluate (FloatArray &answer, std::map< std::string, FunctionArgument > &valDict)
 
virtual void evaluateVelocity (FloatArray &answer, std::map< std::string, FunctionArgument > &valDict)
 
virtual void evaluateAcceleration (FloatArray &answer, std::map< std::string, FunctionArgument > &valDict)
 
virtual double evaluateAtTime (double t)
 Returns the value of the function at given time. More...
 
virtual double evaluateVelocityAtTime (double t)
 Returns the first time derivative of the function at given time. More...
 
virtual double evaluateAccelerationAtTime (double t)
 Returns the second time derivative of the function at given time. More...
 
virtual const char * giveClassName () const
 
virtual const char * giveInputRecordName () const
 
- Public Member Functions inherited from oofem::Function
 Function (int n, Domain *d)
 Constructor. More...
 
virtual ~Function ()
 Destructor. More...
 
double evaluate (TimeStep *tStep, ValueModeType mode)
 Returns the value of load time function at given time. More...
 
virtual void evaluate (FloatArray &answer, const std::map< std::string, FunctionArgument > &valDict, GaussPoint *gp=NULL, double param=0.)
 Returns the value of the function for given input. More...
 
virtual double evaluate (const std::map< std::string, FunctionArgument > &valDict)
 Returns the (scalar) value of the function for given input. More...
 
double giveFunctionParameter (int paramID)
 
- Public Member Functions inherited from oofem::FEMComponent
 FEMComponent (int n, Domain *d)
 Regular constructor, creates component with given number and belonging to given domain. More...
 
virtual ~FEMComponent ()
 Virtual destructor. More...
 
DomaingiveDomain () const
 
virtual void setDomain (Domain *d)
 Sets associated Domain. More...
 
int giveNumber () const
 
void setNumber (int num)
 Sets number of receiver. More...
 
virtual void updateLocalNumbering (EntityRenumberingFunctor &f)
 Local renumbering support. More...
 
virtual contextIOResultType saveContext (DataStream &stream, ContextMode mode, void *obj=NULL)
 Stores receiver state to output stream. More...
 
virtual contextIOResultType restoreContext (DataStream &stream, ContextMode mode, void *obj=NULL)
 Restores the receiver state previously written in stream. More...
 
virtual int checkConsistency ()
 Allows programmer to test some internal data, before computation begins. More...
 
virtual void printOutputAt (FILE *file, TimeStep *tStep)
 Prints output of receiver to stream, for given time step. More...
 
virtual void printYourself ()
 Prints receiver state on stdout. Useful for debugging. More...
 
virtual InterfacegiveInterface (InterfaceType t)
 Interface requesting service. More...
 
std::string errorInfo (const char *func) const
 Returns string for prepending output (used by error reporting macros). More...
 

Private Member Functions

PyObjectgetDict (std::map< std::string, FunctionArgument > &valDict)
 Helper function to convert the std::map to a Python dictionary. More...
 
void getArray (FloatArray &answer, PyObject *func, std::map< std::string, FunctionArgument > &valDict)
 Helper function to run given function for given value dictionary. More...
 
double getScalar (PyObject *func, double time)
 Helper function to run given function for given time. More...
 

Private Attributes

std::string fExpression
 Expression for the function value. More...
 
std::string dfdtExpression
 Expression for first time derivative. More...
 
std::string d2fdt2Expression
 Expression for second time derivative. More...
 
PyObjectf
 
PyObjectdfdt
 
PyObjectd2fdt2
 
PyObjectmain_dict
 

Additional Inherited Members

- Public Attributes inherited from oofem::Function
DomainfuncDomain
 
int parameterType
 
- Protected Attributes inherited from oofem::FEMComponent
int number
 Component number. More...
 
Domaindomain
 Link to domain object, useful for communicating with other FEM components. More...
 

Detailed Description

Class representing user defined functions as Python expressions.

Definition at line 58 of file pythonexpression.h.

Constructor & Destructor Documentation

oofem::PythonExpression::PythonExpression ( int  n,
Domain d 
)

Constructor.

Creates load time function with given number, belonging to given domain.

Parameters
nLoad time function number.
dDomain to which new object will belongs..

Definition at line 50 of file pythonexpression.C.

oofem::PythonExpression::~PythonExpression ( )
virtual

Destructor.

Todo:
Is this right?

Definition at line 52 of file pythonexpression.C.

References main_dict.

Member Function Documentation

void oofem::PythonExpression::evaluate ( FloatArray answer,
std::map< std::string, FunctionArgument > &  valDict 
)
virtual

Definition at line 144 of file pythonexpression.C.

References f, and getArray().

void oofem::PythonExpression::evaluateAcceleration ( FloatArray answer,
std::map< std::string, FunctionArgument > &  valDict 
)
virtual

Definition at line 158 of file pythonexpression.C.

References d2fdt2, and getArray().

double oofem::PythonExpression::evaluateAccelerationAtTime ( double  t)
virtual

Returns the second time derivative of the function at given time.

Parameters
tTime.
Returns
$ f''(t) $.

Implements oofem::Function.

Definition at line 202 of file pythonexpression.C.

References d2fdt2, and getScalar().

double oofem::PythonExpression::evaluateAtTime ( double  t)
virtual

Returns the value of the function at given time.

Parameters
tTime.
Returns
$ f(t) $.

Reimplemented from oofem::Function.

Definition at line 191 of file pythonexpression.C.

References f, and getScalar().

void oofem::PythonExpression::evaluateVelocity ( FloatArray answer,
std::map< std::string, FunctionArgument > &  valDict 
)
virtual

Definition at line 151 of file pythonexpression.C.

References dfdt, and getArray().

double oofem::PythonExpression::evaluateVelocityAtTime ( double  t)
virtual

Returns the first time derivative of the function at given time.

Parameters
tTime.
Returns
$ f'(t) $.

Implements oofem::Function.

Definition at line 196 of file pythonexpression.C.

References dfdt, and getScalar().

void oofem::PythonExpression::getArray ( FloatArray answer,
PyObject func,
std::map< std::string, FunctionArgument > &  valDict 
)
private

Helper function to run given function for given value dictionary.

Definition at line 123 of file pythonexpression.C.

References getDict(), main_dict, oofem::FloatArray::resize(), and RETURN_VARIABLE.

Referenced by evaluate(), evaluateAcceleration(), and evaluateVelocity().

double oofem::PythonExpression::getScalar ( PyObject func,
double  time 
)
private

Helper function to run given function for given time.

Definition at line 165 of file pythonexpression.C.

References main_dict, OOFEM_ERROR, and RETURN_VARIABLE.

Referenced by evaluateAccelerationAtTime(), evaluateAtTime(), and evaluateVelocityAtTime().

virtual const char* oofem::PythonExpression::giveClassName ( ) const
inlinevirtual
Returns
Class name of the receiver.

Implements oofem::FEMComponent.

Definition at line 107 of file pythonexpression.h.

void oofem::PythonExpression::giveInputRecord ( DynamicInputRecord input)
virtual

Setups the input record string of receiver.

Parameters
inputDynamic input record to be filled by receiver.

Reimplemented from oofem::FEMComponent.

Definition at line 82 of file pythonexpression.C.

References _IFT_PythonExpression_d2fdt2, _IFT_PythonExpression_dfdt, _IFT_PythonExpression_f, d2fdt2Expression, dfdtExpression, fExpression, oofem::FEMComponent::giveInputRecord(), and oofem::DynamicInputRecord::setField().

virtual const char* oofem::PythonExpression::giveInputRecordName ( ) const
inlinevirtual
Returns
Input record name of the receiver.

Implements oofem::FEMComponent.

Definition at line 108 of file pythonexpression.h.

References _IFT_PythonExpression_Name.

IRResultType oofem::PythonExpression::initializeFrom ( InputRecord ir)
virtual

Reads the fields.

  • f(t) (required)
  • dfdt(t) (optional)
  • d2fdt2(t) (optional)
Todo:
Check this stuff; Is this OK to do? We need a way to fetch the global dictionary..

Reimplemented from oofem::FEMComponent.

Definition at line 59 of file pythonexpression.C.

References _IFT_PythonExpression_d2fdt2, _IFT_PythonExpression_dfdt, _IFT_PythonExpression_f, d2fdt2, d2fdt2Expression, dfdt, dfdtExpression, f, fExpression, oofem::FEMComponent::initializeFrom(), IR_GIVE_FIELD, IR_GIVE_OPTIONAL_FIELD, and main_dict.

Member Data Documentation

PyObject* oofem::PythonExpression::d2fdt2
private
std :: string oofem::PythonExpression::d2fdt2Expression
private

Expression for second time derivative.

Definition at line 66 of file pythonexpression.h.

Referenced by giveInputRecord(), and initializeFrom().

PyObject* oofem::PythonExpression::dfdt
private

Definition at line 69 of file pythonexpression.h.

Referenced by evaluateVelocity(), evaluateVelocityAtTime(), and initializeFrom().

std :: string oofem::PythonExpression::dfdtExpression
private

Expression for first time derivative.

Definition at line 64 of file pythonexpression.h.

Referenced by giveInputRecord(), and initializeFrom().

PyObject* oofem::PythonExpression::f
private

Definition at line 68 of file pythonexpression.h.

Referenced by evaluate(), evaluateAtTime(), and initializeFrom().

std :: string oofem::PythonExpression::fExpression
private

Expression for the function value.

Definition at line 62 of file pythonexpression.h.

Referenced by giveInputRecord(), and initializeFrom().

PyObject* oofem::PythonExpression::main_dict
private

Definition at line 72 of file pythonexpression.h.

Referenced by getArray(), getScalar(), initializeFrom(), and ~PythonExpression().


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

This page is part of the OOFEM documentation. Copyright (c) 2011 Borek Patzak
Project e-mail: info@oofem.org
Generated at Tue Jan 2 2018 20:07:39 for OOFEM by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2011