KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
|
This function allows to call a function method of type f(x, y, z, t) implemented in python. More...
#include <python_function_callback_utility.h>
Public Member Functions | |
Life Cycle | |
PythonGenericFunctionUtility (const std::string &rFunctionBody, Parameters LocalSystem=Parameters{}) | |
Default constructor. More... | |
Public Member Functions inherited from Kratos::GenericFunctionUtility | |
GenericFunctionUtility (const std::string &rFunctionBody, Parameters LocalSystem=Parameters{}) | |
Default constructor. More... | |
GenericFunctionUtility (GenericFunctionUtility const &rOther) | |
Copy constructor. More... | |
~GenericFunctionUtility () override | |
Destructor. More... | |
Pointer | Clone () |
This method clones the current function instance. More... | |
bool | UseLocalSystem () override |
This method returns if it depends on space. More... | |
double | RotateAndCallFunction (const double x, const double y, const double z, const double t, const double X=0.0, const double Y=0.0, const double Z=0.0) override |
This method rotates and calls the evaluation function. More... | |
KRATOS_CLASS_POINTER_DEFINITION (GenericFunctionUtility) | |
Counted pointer of GenericFunctionUtility. More... | |
Public Member Functions inherited from Kratos::BasicGenericFunctionUtility | |
BasicGenericFunctionUtility (const std::string &rFunctionBody) | |
Default constructor. More... | |
BasicGenericFunctionUtility (BasicGenericFunctionUtility const &rOther) | |
Copy constructor. More... | |
virtual | ~BasicGenericFunctionUtility () |
Destructor. More... | |
Pointer | Clone () |
This method clones the current function instance. More... | |
bool | DependsOnSpace () |
This method returns if it depends on space. More... | |
std::string | FunctionBody () |
This method returns the function body. More... | |
double | CallFunction (const double x, const double y, const double z, const double t, const double X=0.0, const double Y=0.0, const double Z=0.0) |
This calls the evaluation function. More... | |
KRATOS_CLASS_POINTER_DEFINITION (BasicGenericFunctionUtility) | |
Counted pointer of BasicGenericFunctionUtility. More... | |
Type definitions | |
typedef std::size_t | IndexType |
The index type definition. More... | |
KRATOS_CLASS_POINTER_DEFINITION (PythonGenericFunctionUtility) | |
Counted pointer of PythonGenericFunctionUtility. More... | |
Additional Inherited Members | |
Public Types inherited from Kratos::GenericFunctionUtility | |
typedef std::size_t | IndexType |
The index type definition. More... | |
Public Types inherited from Kratos::BasicGenericFunctionUtility | |
typedef std::size_t | IndexType |
The index type definition. More... | |
Protected Member Functions inherited from Kratos::BasicGenericFunctionUtility | |
void | InitializeParser () |
This method initializes the parser classes. More... | |
Protected Attributes inherited from Kratos::BasicGenericFunctionUtility | |
array_1d< double, 7 > | mValues = ZeroVector(7) |
std::vector< te_expr * > | mpTinyExpr = std::vector<te_expr*>(1, nullptr) |
The variables values considered on the function. More... | |
std::string | mFunctionBody |
The function parser. More... | |
bool | mDependsOnSpace = true |
The function body. More... | |
This function allows to call a function method of type f(x, y, z, t) implemented in python.
The functions can be constructed by providing a python-defined method of the type
class aux_object_cpp_callback: def init(self, function_string ): #TODO: check python version self.compiled_function = compile(function_string, '', 'eval', optimize=2)
def f(self,x,y,z,t,X,Y,Z): return eval(self.compiled_function)
The object is then insantiated as aux_function = PythonGenericFunctionUtility(aux_object_cpp_callback(self.function_string))
Optionally one can specify a rotation matrix and an origin so that the function can be defined in a rotated system of coordinates
typedef std::size_t Kratos::PythonGenericFunctionUtility::IndexType |
The index type definition.
|
inline |
Default constructor.
rFunctionBody | The string defining the function |
LocalSystem | The parameters defining the local system |
Kratos::PythonGenericFunctionUtility::KRATOS_CLASS_POINTER_DEFINITION | ( | PythonGenericFunctionUtility | ) |
Counted pointer of PythonGenericFunctionUtility.