|
OOFEM 3.0
|
#include <pythonexpression.h>
Public Member Functions | |
| PythonExpression (int n, Domain *d) | |
| virtual | ~PythonExpression () |
| Destructor. | |
| void | initializeFrom (InputRecord &ir) override |
| void | giveInputRecord (DynamicInputRecord &ir) override |
| void | evaluate (FloatArray &answer, const std ::map< std ::string, FunctionArgument > &valDict, GaussPoint *gp=nullptr, double param=0.) override |
| void | evaluateVelocity (FloatArray &answer, const std ::map< std ::string, FunctionArgument > &valDict) |
| void | evaluateAcceleration (FloatArray &answer, const std ::map< std ::string, FunctionArgument > &valDict) |
| double | evaluateAtTime (double t) override |
| double | evaluateVelocityAtTime (double t) override |
| double | evaluateAccelerationAtTime (double t) override |
| const char * | giveClassName () const override |
| const char * | giveInputRecordName () const override |
| Public Member Functions inherited from oofem::Function | |
| Function (int n, Domain *d) | |
| virtual | ~Function () |
| Destructor. | |
| virtual double | evaluate (TimeStep *tStep, ValueModeType mode) |
| virtual double | evaluate (const std ::map< std ::string, FunctionArgument > &valDict) |
| double | giveFunctionParameter (int paramID) |
| void | saveContext (DataStream &stream, ContextMode mode) override |
| void | restoreContext (DataStream &stream, ContextMode mode) override |
| Public Member Functions inherited from oofem::FEMComponent | |
| FEMComponent (int n, Domain *d) | |
| virtual | ~FEMComponent ()=default |
| Virtual destructor. | |
| Domain * | giveDomain () const |
| virtual void | setDomain (Domain *d) |
| int | giveNumber () const |
| void | setNumber (int num) |
| virtual void | updateLocalNumbering (EntityRenumberingFunctor &f) |
| virtual void | initializeFrom (InputRecord &ir, int priority) |
| virtual void | initializeFinish () |
| virtual void | postInitialize () |
| Performs post initialization steps. Called after all components are created and initialized. | |
| virtual int | checkConsistency () |
| virtual void | printOutputAt (FILE *file, TimeStep *tStep) |
| virtual void | printYourself () |
| Prints receiver state on stdout. Useful for debugging. | |
| virtual Interface * | giveInterface (InterfaceType t) |
| std::string | errorInfo (const char *func) const |
| Returns string for prepending output (used by error reporting macros). | |
Private Member Functions | |
| PyObject * | getDict (const std ::map< std ::string, FunctionArgument > &valDict) |
| Helper function to convert the std::map to a Python dictionary. | |
| void | getArray (FloatArray &answer, PyObject **func, const std ::map< std ::string, FunctionArgument > &valDict) |
| Helper function to run given function for given value dictionary. | |
| double | getScalar (PyObject *func, double time) |
| Helper function to run given function for given time. | |
| double | pyObj2double (PyObject *obj) |
| void | readFile2String (const std ::string &path, std ::string &content) |
Private Attributes | |
| std::string | fExpression |
| Expression for the function value or path to python script. | |
| std::string | dfdtExpression = "0" |
| Expression for first time derivative or path to python script. | |
| std::string | d2fdt2Expression = "0" |
| Expression for second time derivative or path to python script. | |
| PyObject * | f |
| PyObject * | dfdt |
| PyObject * | d2fdt2 |
| PyObject * | main_dict = nullptr |
Additional Inherited Members | |
| Public Attributes inherited from oofem::Function | |
| Domain * | funcDomain |
| int | parameterType |
| Protected Attributes inherited from oofem::FEMComponent | |
| int | number |
| Component number. | |
| Domain * | domain |
| Link to domain object, useful for communicating with other FEM components. | |
Class representing user defined functions as Python expressions
Definition at line 61 of file pythonexpression.h.
| oofem::PythonExpression::PythonExpression | ( | int | n, |
| Domain * | d ) |
Constructor. Creates load time function with given number, belonging to given domain.
Definition at line 52 of file pythonexpression.C.
References oofem::Function::Function().
|
virtual |
|
overridevirtual |
Returns the value of the function for given input.
| valDict | Map with inputs. |
| answer | Function value. |
Reimplemented from oofem::Function.
Definition at line 192 of file pythonexpression.C.
References f, and getArray().
| void oofem::PythonExpression::evaluateAcceleration | ( | FloatArray & | answer, |
| const std ::map< std ::string, FunctionArgument > & | valDict ) |
Definition at line 206 of file pythonexpression.C.
References d2fdt2, and getArray().
|
overridevirtual |
Returns the second time derivative of the function at given time.
| t | Time. |
Implements oofem::Function.
Definition at line 250 of file pythonexpression.C.
References d2fdt2, and getScalar().
|
overridevirtual |
Returns the value of the function at given time.
| t | Time. |
Reimplemented from oofem::Function.
Definition at line 239 of file pythonexpression.C.
References f, and getScalar().
| void oofem::PythonExpression::evaluateVelocity | ( | FloatArray & | answer, |
| const std ::map< std ::string, FunctionArgument > & | valDict ) |
Definition at line 199 of file pythonexpression.C.
References dfdt, and getArray().
|
overridevirtual |
Returns the first time derivative of the function at given time.
| t | Time. |
Implements oofem::Function.
Definition at line 244 of file pythonexpression.C.
References dfdt, and getScalar().
|
private |
Helper function to run given function for given value dictionary.
Definition at line 161 of file pythonexpression.C.
References getDict(), main_dict, pyObj2double(), oofem::FloatArray::resize(), and RETURN_VARIABLE.
Referenced by evaluate(), evaluateAcceleration(), and evaluateVelocity().
|
private |
Helper function to convert the std::map to a Python dictionary.
Definition at line 130 of file pythonexpression.C.
References oofem::FloatArray::giveSize(), oofem::IntArray::giveSize(), OOFEM_ERROR, oofem::FunctionArgument::type, oofem::FunctionArgument::val0, oofem::FunctionArgument::val1, oofem::FunctionArgument::val2, and oofem::FunctionArgument::val3.
Referenced by getArray().
|
private |
Helper function to run given function for given time.
Definition at line 213 of file pythonexpression.C.
References main_dict, OOFEM_ERROR, pyObj2double(), and RETURN_VARIABLE.
Referenced by evaluateAccelerationAtTime(), evaluateAtTime(), and evaluateVelocityAtTime().
|
inlineoverridevirtual |
Implements oofem::FEMComponent.
Definition at line 114 of file pythonexpression.h.
|
overridevirtual |
Setups the input record string of receiver.
| input | Dynamic input record to be filled by receiver. |
Reimplemented from oofem::FEMComponent.
Definition at line 120 of file pythonexpression.C.
References _IFT_PythonExpression_d2fdt2, _IFT_PythonExpression_dfdt, _IFT_PythonExpression_f, d2fdt2Expression, dfdtExpression, fExpression, and oofem::DynamicInputRecord::setField().
|
inlineoverridevirtual |
Implements oofem::FEMComponent.
Definition at line 115 of file pythonexpression.h.
References _IFT_PythonExpression_Name.
|
overridevirtual |
Reads the fields
Reimplemented from oofem::FEMComponent.
Definition at line 61 of file pythonexpression.C.
References _IFT_PythonExpression_d2fdt2, _IFT_PythonExpression_d2fdt2file, _IFT_PythonExpression_dfdt, _IFT_PythonExpression_dfdtfile, _IFT_PythonExpression_f, _IFT_PythonExpression_ffile, d2fdt2, d2fdt2Expression, dfdt, dfdtExpression, f, fExpression, oofem::InputRecord::hasField(), IR_GIVE_FIELD, IR_GIVE_OPTIONAL_FIELD, main_dict, OOFEM_WARNING, and readFile2String().
|
private |
Definition at line 256 of file pythonexpression.C.
Referenced by getArray(), and getScalar().
|
private |
Definition at line 270 of file pythonexpression.C.
References OOFEM_ERROR.
Referenced by initializeFrom().
|
private |
Definition at line 74 of file pythonexpression.h.
Referenced by evaluateAcceleration(), evaluateAccelerationAtTime(), and initializeFrom().
|
private |
Expression for second time derivative or path to python script.
Definition at line 69 of file pythonexpression.h.
Referenced by giveInputRecord(), and initializeFrom().
|
private |
Definition at line 73 of file pythonexpression.h.
Referenced by evaluateVelocity(), evaluateVelocityAtTime(), and initializeFrom().
|
private |
Expression for first time derivative or path to python script.
Definition at line 67 of file pythonexpression.h.
Referenced by giveInputRecord(), and initializeFrom().
|
private |
Definition at line 72 of file pythonexpression.h.
Referenced by evaluate(), evaluateAtTime(), and initializeFrom().
|
private |
Expression for the function value or path to python script.
Definition at line 65 of file pythonexpression.h.
Referenced by giveInputRecord(), and initializeFrom().
|
private |
Definition at line 76 of file pythonexpression.h.
Referenced by getArray(), getScalar(), and initializeFrom().