23 #ifndef _GEMA_USER_FUNCTION_H_ 24 #define _GEMA_USER_FUNCTION_H_ 90 : _src(src), _unit(u), _dim(dim), _history(history), _interpType(interpType), _interpParam(interpParam) {}
130 void addParameter(
QString src,
Unit unit,
int dim = -1,
int history = -1,
QVariant _interpParam
The optional parameters of the interpolation.
Definition: gmUserFunction.h:220
Auxiliar class used to store the definition of a value. It can be used to store informations about st...
Definition: gmValueInfo.h:126
The parameter should return the current time.
Definition: gmUserFunction.h:174
const double * par(int i) const
Returns the it'h input parameter as a vector of doubles.
Definition: gmUserFunction.h:271
The parameter should return the mesh name (Lua functions only)
Definition: gmUserFunction.h:173
void * _accessor
The accessor object used to retrieve the parameter value. Can be NULL, a value, cell or gauss accesso...
Definition: gmUserFunction.h:214
QString _src
The value source for this parameter.
Definition: gmUserFunction.h:92
int numPars() const
Returns the number of input parameters.
Definition: gmUserFunction.h:261
int _ipRuleSet
The integration rule set used by gauss attribute parameters or -1 if there is no such parameter type.
Definition: gmUserFunction.h:224
GmPluginObjectFactory * cFunctionFactory() const
Returns the stored C function factory (that can be used to instance a new GmPhysicsUserFunctions obje...
Definition: gmUserFunction.h:128
bool _nodeBased
Set to true if this is a node based parameter evaluated for a cell.
Definition: gmUserFunction.h:217
Means that the function calculates cell values (attributes or properties)
Definition: gmUserFunction.h:53
int _size
The number of values associated with this parameter (depends on the value returned by the accessor an...
Definition: gmUserFunction.h:216
double scalarPar(int i) const
Returns the it'h input parameter as a single double.
Definition: gmUserFunction.h:274
const GmMesh * _mesh
The mesh that will supply function parameters.
Definition: gmUserFunction.h:190
Unit _unit
The expected unit for the value.
Definition: gmUserFunction.h:93
int parSize(int i) const
Returns the size of the i'th parameter.
Definition: gmUserFunction.h:277
Class responsible for evaluating a UserFunction over a node / cell.
Definition: gmUserFunction.h:148
~ParamContext()
Destructor.
Definition: gmUserFunction.cpp:847
GmInterpolatorType _interpType
The interpolator type used for aggregating node values (if needed) or for interpolating Gauss values ...
Definition: gmUserFunction.h:219
The GmGaussAccessor class is a proxy object to a value accesor implementing a more convenient interfa...
Definition: gmGaussAccessor.h:38
const GmMesh * mesh() const
Returns the mesh that holds the attribute being evaluated.
Definition: gmUserFunction.h:242
ParamContextType _type
The parameter type.
Definition: gmUserFunction.h:213
Declaration of usefull configuration definitions for the Core library.
QString _id
Unique id for this value function.
Definition: gmUserFunction.h:138
bool(GmPhysicsUserFunctions::* GmCUserMethod)(const GmUserFunctionContext *context, double *out)
A pointer to a C function exported from a physics plugin to evaluate the value of some attribute / pr...
Definition: gmUserFunction.h:75
Factory class exported by every plugin object.
Definition: gmPluginObjectFactory.h:36
bool loadCFunction(GmSimulationData *simData, const GmMesh *mesh, QString &err)
Load internal parameters needed to call a C function.
Definition: gmUserFunction.cpp:711
Declaration of the GmValueInfo class.
const GmUserFunction * _functionInfo
Information about the function that will be evaluated.
Definition: gmUserFunction.h:188
Base interface for mesh cells.
Definition: gmCell.h:81
GmInterpolatorType _interpType
How do we interpolate node attributes for element functions?
Definition: gmUserFunction.h:96
GmUserFunctionType _type
The type of function stored.
Definition: gmUserFunction.h:139
The parameter is the result of a gauss attribute accessor.
Definition: gmUserFunction.h:169
void evalParameter(int index, const GmVector *coord, int ip, const GmValueAccessor *coordAccessor, const GmSimulationData *simData, const GmMesh *mesh, double *result, bool warnOnInvalidIndex, QString &err) const
Evaluates the parameter at the position index and fills result with the values using the configured a...
Definition: gmUserFunction.cpp:901
Declaration of the GmTLBuffer class.
QList< GmUserFunctionParameter > _parameters
The list of function parameters.
Definition: gmUserFunction.h:140
Unit _timeUnit
The unit for recovering time for type == CURRENT_TIME/DELTA_TIME_PARAM.
Definition: gmUserFunction.h:218
~GmUserFunctionEvaluator()
Destructor.
Definition: gmUserFunction.cpp:267
ParamContext()
Default constructor.
Definition: gmUserFunction.cpp:834
const GmVector * _coord
Point of aggregation when node attributes are evaluated on behalf of a cell.
Definition: gmUserFunction.h:295
bool _warnOnInvalidIndex
Should we emit the invalid index warning?
Definition: gmUserFunction.h:193
Interface class for accessing and setting values from an "indexable" collection of values.
Definition: gmValueAccessor.h:59
Auxiliar class storing the information needed to collect a parameter value.
Definition: gmUserFunction.h:196
const GmValueInfo * _resultInfo
Information about the expected function result.
Definition: gmUserFunction.h:189
const QList< GmUserFunctionParameter > & parameterList() const
Returns the list of parameters passed to the function.
Definition: gmUserFunction.h:110
Auxiliar class used to store the complete set of simulation data.
Definition: gmSimulationData.h:51
Base interface class for Physics type plugins to export user functions that can be used to provide at...
Definition: gmPhysics.h:158
void setId(int index)
Set the current node / cell id.
Definition: gmUserFunction.h:286
const double * eval(int index, const GmVector *coord, int ip, QString &err) const
Evaluates the function to retrieve data from the node/cell identified by its index.
Definition: gmUserFunction.cpp:590
GmTLS< double ** > * _input
Per thread local buffer used to hold input parameters for C functions.
Definition: gmUserFunction.h:230
const GmValueInfo * resultInfo() const
Information about the returned result.
Definition: gmUserFunction.h:255
int _id
The attribute / cell id.
Definition: gmUserFunction.h:294
ParamContextType
Auxiliar enum to store the type of paramaeter stored in ParamContext.
Definition: gmUserFunction.h:165
GmTLS< LuaFunction * > * _luaFunction
The lua function to be called or NULL for C functions. Has a per thread value with a function per Lua...
Definition: gmUserFunction.h:141
const GmVector * coord() const
Returns the evaluation point used when aggregating node attributes for a cell.
Definition: gmUserFunction.h:249
The parameter is the result of a cell attribute / property accessor.
Definition: gmUserFunction.h:168
No interpolation needed. Not valid to construct an interpolator object but usefull when defining user...
Definition: gmInterpolator.h:132
T & localData(int tid)
Returns the given thread local data as a modifiable reference.
Definition: gmThreadLocalStorage.h:163
void setContext(ParamContextType type, void *ac, int size, int dim, bool nodeBased, GmInterpolatorType interpType, QVariant interpParam, Unit timeUnit)
Sets the parameter context. Takes ownership of the received accessor (NULL for standard parameters th...
Definition: gmUserFunction.cpp:863
const GmUserFunction * userFunction() const
Returns the user function associated with this evaluator.
Definition: gmUserFunction.h:160
bool acceptsInterpolatorType(const GmCell *c, GmInterpolatorType type) const
Checks if the given interpolator type is acceptable for the real cell object type.
Definition: gmUserFunction.cpp:816
int id() const
Returns the id of the node / cell that has an attribute / property beeing evaluated.
Definition: gmUserFunction.h:239
GmInterpolatorType
Available interpolation methods. Not every method is suitable for every kind of interpolator class....
Definition: gmInterpolator.h:62
GmPhysicsUserFunctions * _cObj
The object that contains the C method or NULL for Lua functions.
Definition: gmUserFunction.h:226
int _dim
A "bound" dimension for returning a scalar when _src is multidimensional (or -1 instead)
Definition: gmUserFunction.h:94
GmUserFunctionParameter(QString src, Unit u, int dim, int history, GmInterpolatorType interpType, QVariant interpParam)
Basic constructor.
Definition: gmUserFunction.h:89
int _dim
The access index for vectors/matrices. May be -1 for complete vector/matrix.
Definition: gmUserFunction.h:215
The GmCellAccessor class is a proxy object to a value accesor implementing a more convenient interfac...
Definition: gmCellAccessor.h:66
QString _cFuncName
The name of the C function to be called (or empty for Lua functions)
Definition: gmUserFunction.h:142
const double * callFunction(int index, const GmVector *coord, int npars, LuaEnv *env, QString &err) const
Calls the user function (in Lua or C). Expects parameters to be in place (Lua stack or _input vector)
Definition: gmUserFunction.cpp:644
GmValueInfo * info() const
Returns the info object tied to the parameter accessor.
Definition: gmUserFunction.cpp:884
void setCoord(const GmVector *coord)
Set the evaluation point used when aggregating node attributes for a cell. The coordinate values depe...
Definition: gmUserFunction.h:292
GmUserFunctionType type() const
Returns the type of function stored inside ths object.
Definition: gmUserFunction.h:107
LuaFunction * luaFunction() const
Returns the stored Lua function (associated with the current thread) or NULL for C functions.
Definition: gmUserFunction.h:116
GmCUserMethod _cMethod
The C method or NULL for Lua functions.
Definition: gmUserFunction.h:227
The parameter should return the integration point natural coordinates.
Definition: gmUserFunction.h:171
Means that the function calculates nodal values (attributes)
Definition: gmUserFunction.h:52
The parameter should return the node / cell Id.
Definition: gmUserFunction.h:172
GmTLBuffer< double, true > _result
Per thread local buffer used to store function results.
Definition: gmUserFunction.h:231
QString _cFuncPlugin
The name of the plugin that contains _cFuncName (or empty for Lua functions)
Definition: gmUserFunction.h:143
#define GMC_API_EXPORT
Macro for controling if the class is being exported (GEMA_CORE_LIB defined) or imported (GEMA_CORE_LI...
Definition: gmCoreConfig.h:35
bool _evalNeedsCoord
Set to true if the function evaluation needs user coordinates.
Definition: gmUserFunction.h:192
QString cFunctionName() const
Returns the name of the stored C function or an empty string for Lua functions.
Definition: gmUserFunction.h:119
int resultSize() const
Returns the size of the returned value.
Definition: gmUserFunction.h:258
GmTLS< GmUserFunctionContext * > * _cContext
Per thread context objects passed to C methods or NULL for Lua functions.
Definition: gmUserFunction.h:228
Auxiliar structure for storing function parameter information.
Definition: gmUserFunction.h:83
int size() const
Returns the number of values (doubles) associated to this definition.
Definition: gmValueInfo.h:168
QVariant _interpParam
Optional interpolation parameters.
Definition: gmUserFunction.h:97
Class representing a category with multiple logging levels.
Definition: gmLog.h:58
const GmSimulationData * _simData
The simulation data object used for retrieving time information.
Definition: gmUserFunction.h:187
The parameter is the result of a node attribute / state var / coordinate accessor.
Definition: gmUserFunction.h:167
The parameter should return the difference from the current time to the last one.
Definition: gmUserFunction.h:175
GmUserFunctionEvaluator * _eval
The evaluation context used to retrieve remaining information provided by the context.
Definition: gmUserFunction.h:296
GmUserFunctionParameter()
Default constructor. Needed to allow storing objects in lists.
Definition: gmUserFunction.h:86
QString id() const
Returns the object id.
Definition: gmUserFunction.h:104
int _history
The state accessed by this parameter (0 = current state, 1 = previous, etc..)
Definition: gmUserFunction.h:95
ParamContext * _parInfo
A vector with a parameter info for each function parameter.
Definition: gmUserFunction.h:223
The context received by C methods giving access to parameters data and metadata.
Definition: gmUserFunction.h:235
GmUserFunctionType
Type of a user function.
Definition: gmUserFunction.h:50
bool setEvaluationContext(const GmValueInfo *resultInfo, GmSimulationData *simData, const GmMesh *mesh, const GmLogCategory &logger, QString &err)
Prepares the object to enable function evaluations.
Definition: gmUserFunction.cpp:315
bool isCFunction() const
Returns true if the stored function is a C function.
Definition: gmUserFunction.h:113
Declaration of the GmCell class.
arma::vec GmVector
The basic type for a GeMA vector object. Currently based on an Armadillo vector.
Definition: gmVector.h:34
void pushParameter(int index, const GmVector *coord, int ip, const GmValueAccessor *coordAccessor, const GmSimulationData *simData, const GmMesh *mesh, LuaEnv *env, bool warnOnInvalidIndex, QString &err) const
Evaluates the parameter at the position index and pushes the values in the Lua stack using the config...
Definition: gmUserFunction.cpp:1037
GmUserFunctionContext(GmUserFunctionEvaluator *eval)
Private constructor.
Definition: gmUserFunction.h:283
bool parseParameterType(QString parName, ParamContextType *parType, GmValueInfo **info, QString &err)
Fills parType and info from the parameter name. On errors, fills err and returns false.
Definition: gmUserFunction.cpp:749
Base interface class for Mesh type plugins.
Definition: gmMesh.h:44
QString cFunctionPlugin() const
Returns the name of the stored C function plugin or an empty string for Lua functions.
Definition: gmUserFunction.h:122
const GmValueAccessor * _coordAccessor
An accessor to read coordinate values needed when interpolating values over cells.
Definition: gmUserFunction.h:191
Class used to store the definition of a user function and its parameters.
Definition: gmUserFunction.h:78
The parameter should return the integration point cartesian coordinates.
Definition: gmUserFunction.h:170
GmPluginObjectFactory * _cFuncFactory
The factory used to instance a GmPhysicsUserFunctions if needed (or NULL for Lua functions)
Definition: gmUserFunction.h:144
Declaration of the GmInterpolator and GmInterpolatorObject classes.
GmUserFunctionEvaluator(const GmUserFunction *ufInfo)
Constructor. Gets as parameter the user function definition.
Definition: gmUserFunction.cpp:246
const GmUserFunction * functionInfo() const
Information about the user function parameters.
Definition: gmUserFunction.h:252