![]() |
GemaCoreLib
The GeMA Core library
|
A result rule storing what should be exported, when it should be exported and to where it should be exported. More...
#include <gmResultsRule.h>
Public Member Functions | |
virtual | ~GmResultsRule () |
Destructor. | |
int | ruleId () const |
Returns the ruleId. This value is a unique index between 0 and the number of monitor rules in the model for a monitor rule or -1 for a save rule. | |
QString | id () const |
Returns the results rule name. | |
QString | description () const |
Returns the results rule description. | |
GmMesh * | mesh () const |
Returns the mesh that contains the associated data. Can be NULL. | |
int | numDataSrcs (int type=-1) const |
Returns the number of datasrcs in this rule if type is -1 or the number of data srcs of a specific type if type is a GmResultDataSrcType enum value. | |
int | dataSrcIndex (GmResultDataSrcType type, int i) const |
Returns the data src index of the ith data src of the given type. | |
const GmResultDataSrcInfo * | dataSrcInfo (int index) const |
Returns the data src metadata given its index (between 0 and numDataSrcs()) | |
void | dataSrcInfoChanged (GmAttributeResultDataSrc *info) |
A helper function used by the results data control code to notify the rule that one of its attribute data srcs had its metadata changed due to an attribute being finally registered at the orchestration. Should not be called by user code. | |
int | dataSrcSize (int index) const |
Returns the number of result lines that exist for a data src, given its index. | |
const double * | dataSrcValue (int index, int line, QString &err) const |
Returns the line'th result associated with the data src identified by its index. As with any GeMA accessor, the returned buffer is valid only until the next call to dataSrcValue(). More... | |
QString | strDataSrcValue (int index, int line, QString &err) const |
Returns the line'th string result associated with the data src identified by its index. More... | |
QString | explain (int index, int line) const |
Explains the evaluation point associated with the line'th result associated with the data src identified by its index. Results are a string like "node 5" or "cell 4 @ ip 2") | |
void | print (const GmLogCategory &logger, GmLogLevel level) const |
Prints the rule description to the appointed logger / level. | |
void | printData (const GmLogCategory &logger, GmLogLevel level) const |
void | evalMonitoredData (const GmLogCategory &errLogger) const |
Evaluates rule data, emitting monitoredValueChanged() and monitoredIndexChanged() signals on behalf of the stored result data object. | |
Static Public Member Functions | |
static GmResultsRule * | loadFromTable (LuaTable &tab, bool monitor, GmSimulationData *data, const GmLogCategory &parseLogger, const GmLogCategory &dataLogger) |
Parses either a monitor or a save rule definition from the given Lua table, returning a results rule object. More... | |
static GmResultNodeDataSrc * | createNodeDataSrc (int trackId, const GmMesh *mesh, const QVariant &v, bool interp, const GmLogCategory &dataLogger, bool *unknown, QString &srcId, QString &err) |
Aux function to create a new node data src from a "nodeData" entry, which can be a string or a Lua table. On error, returns false and fills err. More... | |
static GmResultCellDataSrc * | createCellDataSrc (int trackId, const GmCellMesh *mesh, const QVariant &v, bool interp, const GmLogCategory &dataLogger, bool *unknown, QString &srcId, QString &err) |
Aux function to create a new cell data src from a "cellData" entry. See comments on GmResultsRule::createNodeDataSrc(). More... | |
static GmResultGaussDataSrc * | createGaussDataSrc (int trackId, const GmElementMesh *mesh, const QVariant &v, bool interp, const GmLogCategory &dataLogger, bool *unknown, QString &srcId, QString &err) |
Aux function to create a new cell data src from a "gaussData" entry. See comments on GmResultsRule::createNodeDataSrc(). | |
Protected Member Functions | |
GmResultsRule (int ruleId, QString id, QString description, GmResultsData *resultData) | |
Constructor. | |
Private Member Functions | |
Q_DISABLE_COPY (GmResultsRule) | |
GmResultsEvalSet * | evalSet (GmResultDataSrcType type) const |
Returns the eval set associated with the given type. | |
bool | addNodeDataSrc (int trackId, const GmMesh *mesh, const QVariant &v, const GmLogCategory &dataLogger, QString &err) |
Aux function to add a new node data src to the rule from its "nodeData" entry, which can be a string or a Lua table. On error, returns false and fills err. More... | |
bool | addCellDataSrc (int trackId, const GmCellMesh *mesh, const QVariant &v, const GmLogCategory &dataLogger, QString &err) |
Aux function to add a new cell data src to the rule from its "cellData" entry, which can be a string or a Lua table. On error, returns false and fills err. More... | |
bool | addGaussDataSrc (int trackId, const GmElementMesh *mesh, const QVariant &v, const GmLogCategory &dataLogger, QString &err) |
Aux function to add a new Gauss data src to the rule from its "gaussData" entry, which can be a string or a Lua table. On error, returns false and fills err. More... | |
bool | checkForMultipleAffectedNodes (GmAffectedNodes *affNodes) const |
Checks that the configured node data srcs have the same affected nodes property. Returns true if the set is multiple, false if not. Either way, fills affNodes with the "union" of the data sources affected nodes. | |
bool | checkForMultipleGaussRuleSets (int *ruleSet) const |
Checks that the configured gauss data srcs have the same integration rule set. Returns true if the set is multiple, false if not. When the set is not multiple, fills ruleSet with the common rule number. | |
bool | createNodeInterpolators (bool *needNatural, QString &err) |
Creates interpolators for transfering data from node attributes to cell points (for cell meshes) or to arbitrary points (for node meshes). Fills needNatural with true if any of the node data interpolators needs natural coordinates. Returns true on success or false on error (filling errr with a message). More... | |
bool | createGaussInterpolators (bool *needNatural, QString &err) |
Creates interpolators for transfering data from Gauss attributes to cell points (centroid or user given). Fills needNatural with true if any of the Gauss data interpolators needs natural coordinates. Returns true on success or false on error (filling errr with a message). More... | |
bool | allocResultBuffers () |
Allocate space for the result buffers used to store interpolated results and/or returned results from translation functions. More... | |
const double * | nodeDataSrcValue (GmResultNodeDataSrc *ds, int line, QString &err) const |
Returns the line'th result associated with the given node data src. More... | |
const double * | cellDataSrcValue (GmResultCellDataSrc *ds, int line, QString &err) const |
Returns the line'th result associated with the given cell data src. More... | |
const double * | gaussDataSrcValue (GmResultGaussDataSrc *ds, int line, QString &err) const |
Returns the line'th result associated with the given Gauss data src. More... | |
void | printAttributeData (const GmLogCategory &logger, GmLogLevel level) const |
void | printEvalSetData (GmResultDataSrcType type, const GmLogCategory &logger, GmLogLevel level) const |
void | evalMonitoredAttributeData (const GmLogCategory &errLogger) const |
Evaluates rule attribute data, emitting monitoredValueChanged() signal on behalf of the stored result data object. More... | |
void | evalMonitoredEvalSetData (GmResultDataSrcType type, const GmLogCategory &errLogger) const |
Evaluates rule eval set data, emitting monitoredValueChanged() and monitoredIndexChanged() signals on behalf of the stored result data object. More... | |
QString | formatedNumericDataSrcValue (const GmResultDataSrcInfo *ds, const double *v, QString err) const |
Returns the numeric result value in v string formated. | |
Static Private Member Functions | |
template<class T , class AcF > | |
static T * | createDataSrc (int trackId, const QVariant &v, const AcF &acGet, bool interp, bool *unknown, QString &srcId, QString &err) |
Generic implementation for createXxxDataSrc functions. T is the data src type and AcF is the function used to return an accessor for the parsed id. It receives as parameters the id name, the requested history and unit. Keep in mind that the needed mesh and logger should already be known to acGet. | |
static bool | parseAndCheckDataSrcFields (GmResultAcDataSrcBase *ds, const GmValueInfo *info, const QVariant &v, QString &err) |
Parse additional common DataSrc values: format, resultDim and transform. Also checks the basic information stored in the data src against the src metadata. | |
Private Attributes | |
int | _ruleId |
An integer in the range [0, num monitor rules in the model[ that identfies a monitor rule. -1 for save rules. | |
QString | _id |
The result rule id (name) | |
QString | _description |
A description of the result rule. | |
GmResultsData * | _resultData |
The result data object used to provide values for result attributes. | |
GmMesh * | _mesh |
The mesh that this result rule is tied to (can be NULL for attribute rules) | |
GmValueAccessor * | _coordAc |
The accessor used for accessing node coordinates. | |
QVector< GmResultDataSrcInfo * > | _dataSrcs |
int | _dataSrcPos [GM_RR_DS_NUMTYPES+1] |
A vector storing the position in _dataSrcs of the first entry of each type, with the last entry storing the number of data srcs. That means that the first entry is always 0 and for each type t, _dataSrcPos[t] gives the index while _dataSrcPos[t+1] - _dataSrcPos[t] gives the number of entries of type t in _dataSrcs. | |
GmResultsEvalSet * | _nodeEvalSet |
The evaluation set for node data sources. | |
GmResultsEvalSet * | _cellEvalSet |
The evaluation set for cell data sources. | |
GmResultsEvalSet * | _gaussEvalSet |
The evaluation set for gauss data sources. | |
double * | _resultBuffer |
The buffer used by xxxDataSrcValue() functions for returning interpolated data. Its size is the biggest data src accessor dimension size. | |
double * | _transformBuffer |
The buffer used to store the result from a "non ac" data src or user transformation function. Its size is the biggest data src size. | |
int | _transformBufferSize |
The size of _transformBuffer. | |
A result rule storing what should be exported, when it should be exported and to where it should be exported.
Nodes Node No - Cell centroid Yes Interpolator Cell Gauss point Yes Interpolator
Cells Cell centroid No Mesh type Cell Gauss point No Mesh type
Gauss points Cell centroid Yes Interpolator Cell Gauss point No Yes
TODO: If, for a data src class, all the source interpolators are the same, we could use a single interpolator and do all line calculations in a single operation, which is much faster than multiple single interpolations (weights are the same for every data src)
TODO: Use NC2P interpolators (needs some extra configuration parameters)
|
private |
Aux function to add a new cell data src to the rule from its "cellData" entry, which can be a string or a Lua table. On error, returns false and fills err.
If there exists both a cell attribute and a porperty with the same name, preference is given to cell attributes.
The given logger is used for accessor creation only. It should not be used for error messages.
|
private |
Aux function to add a new Gauss data src to the rule from its "gaussData" entry, which can be a string or a Lua table. On error, returns false and fills err.
The given logger is used for accessor creation only. It should not be used for error messages.
|
private |
Aux function to add a new node data src to the rule from its "nodeData" entry, which can be a string or a Lua table. On error, returns false and fills err.
The given logger is used for accessor creation only. It should not be used for error messages.
|
private |
Allocate space for the result buffers used to store interpolated results and/or returned results from translation functions.
The buffer is alocated with a size big enough for the result value of any of the data sources.
|
private |
Returns the line'th result associated with the given cell data src.
As with any GeMA accessor, the returned buffer is valid only until the next call to any xxxDataSrcValue() method. The dimension filter, if any, IS applied by this call. Returns NULL on errors. Should fill err for an anexpected error, such as an interpolation error, keeping it empty if the value can not be evaluated (is not defined) at the given line.
|
static |
Aux function to create a new cell data src from a "cellData" entry. See comments on GmResultsRule::createNodeDataSrc().
If there exists both a cell attribute and a porperty with the same name, preference is given to cell attributes.
|
private |
Creates interpolators for transfering data from Gauss attributes to cell points (centroid or user given). Fills needNatural with true if any of the Gauss data interpolators needs natural coordinates. Returns true on success or false on error (filling errr with a message).
Interpolators created by this function are stored in the data src objects.
|
static |
Aux function to create a new node data src from a "nodeData" entry, which can be a string or a Lua table. On error, returns false and fills err.
In case of errors, fills err and returns NULL. The given logger is used for accessor creation only. It is not used for error messages. The srcId parameter will be filled with the requested id, as much as possible, even on errors. If different from NULL, unknown will be filled with true if there was an error getting an accessor for the requested id. Otherwise it will be filled with false.
The interp parameter controls wheter interpolation definition information will be read from v or not (this is used by GmFileIO routines that do not need interpolation methods).
|
private |
Creates interpolators for transfering data from node attributes to cell points (for cell meshes) or to arbitrary points (for node meshes). Fills needNatural with true if any of the node data interpolators needs natural coordinates. Returns true on success or false on error (filling errr with a message).
Interpolators created by this function are stored in the data src objects.
const double * GmResultsRule::dataSrcValue | ( | int | index, |
int | line, | ||
QString & | err | ||
) | const |
Returns the line'th result associated with the data src identified by its index. As with any GeMA accessor, the returned buffer is valid only until the next call to dataSrcValue().
Returns NULL, filling err on errors (an error on a user transformation function, for example). Returns NULL, keeping err empty if the value can not be evaluated at the given line.
|
private |
Evaluates rule attribute data, emitting monitoredValueChanged() signal on behalf of the stored result data object.
If the attribute is not available yet, its value will not be broadcasted. If evaluating an attribute results in an error, a message is logged and the value is not broadcasted.
|
private |
Evaluates rule eval set data, emitting monitoredValueChanged() and monitoredIndexChanged() signals on behalf of the stored result data object.
If a value line is not available (missing gauss point or no ghost data, for example), a value of zero will be sent in its place (to always keep the vector size consistent with the index size). If evaluating a value line results in an error, a message is logged and the entire value is not broadcasted.
|
private |
Returns the line'th result associated with the given Gauss data src.
As with any GeMA accessor, the returned buffer is valid only until the next call to any xxxDataSrcValue() method. The dimension filter, if any, IS applied by this call. Returns NULL on errors. Should fill err for an anexpected error, such as an interpolation error, keeping it empty if the value can not be evaluated (is not defined) at the given line.
|
static |
Parses either a monitor or a save rule definition from the given Lua table, returning a results rule object.
The first logger, parseLogger, is used to emmit messages during rule parsing. The second logger, dataLogger, is used by rules to print data messages and so is also used to create the rule accessors.
|
private |
Returns the line'th result associated with the given node data src.
As with any GeMA accessor, the returned buffer is valid only until the next call to any xxxDataSrcValue() method. The dimension filter, if any, IS applied by this call. Returns NULL on errors. Should fill err for an anexpected error, such as an interpolation error, keeping it empty if the value can not be evaluated (is not defined) at the given line.
Returns the line'th string result associated with the data src identified by its index.
Returns a NULL string (isNull() is true), filling err on errors. Returns a NULL string, keeping err empty, if the value can not be evaluated at the given line.