GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
GmResultsEvalSet Class Reference

A class storing the evaluation points for a set of rules. More...

#include <gmResultsEvalSet.h>

Collaboration diagram for GmResultsEvalSet:

Public Types

enum  GmEvalSetAggregationRule {
  GM_EVALSET_NONE , GM_EVALSET_MIN , GM_EVALSET_MAX , GM_EVALSET_AVG ,
  GM_EVALSET_SUM , GM_EVALSET_MINNORM , GM_EVALSET_MAXNORM , GM_NUM_EVALSET_AGGR_RULES
}
 

Public Member Functions

 ~GmResultsEvalSet ()
 Destructor.
 
bool prepare (GmSpatialIndex *si, bool natural, GmAffectedNodes nodeTypes, QString ruleId, const GmLogCategory &logger)
 Initializes internal structures needed for answering further queries. On errors, uses the logger to emmit errors and returns false.
 
bool hasIpBasedLines () const
 Returns true if the evaluation set has lines that should be evaluated over integration points. Unlike the other functions, this function CAN be called before prepare() is called.
 
bool hasPosBasedLines () const
 Returns true if the evaluation set has lines that should be evaluated over user points or over the cell centroid. Unlike the other functions, this function CAN be called before prepare() is called.
 
int numLines () const
 Returns the number of lines associated with this evaluation set.
 
bool isNodeBased (int line) const
 Returns true if the given line is associated with a node line.
 
bool isIpBased (int line) const
 Returns true if the given line is associated with a cell integration point.
 
bool isPosBased (int line) const
 Returns true if the given line is associated with a user point or with a cell centroid.
 
bool isUserPointBased (int line) const
 Returns true if the given line is associated with a user given point.
 
bool isSimple () const
 Returns true if the eval set is the full set of mesh nodes, full set of mesh cells or is given by cell groups.
 
const QStringListsimpleGroups () const
 The set of cell groups if isSimple() is true (might be empty if the entire mesh is used)
 
int nodeIndex (int line) const
 Returns the node index asscoiated with the given line. isNodeBased() must be true. Ghost nodes are always returned with the ghost bit set. Returned values are iterated in Lua model order even if the mesh had its nodes renumbered.
 
int cellIpIndex (int line, int *ip, int *ruleSet=NULL) const
 Returns the cell + ip index asscoiated with the given line. isIpBased() must be true. If ruleSet is not NULL, fill it with the expected ruleSet number. If an aggregation rule is being used, ip will return a negative value. Returned values are iterated in Lua model order even if the mesh had its cells renumbered.
 
int cellPos (int line, bool naturalCoord, GmVector &coord) const
 Returns the cell + position coordinate asscoiated with the given line. The coordinate is returned in natural coordinates if naturalCoord is true. For this, the equivalent flag must have been provided to the prepare() call. The vector size must be compatible with the coordinate result.
 
GmEvalSetAggregationRule aggregationRule () const
 Returns the configured aggregation rule for ip based cell values.
 
const char * aggregationRuleStr () const
 Returns a string version for the configured aggregation rule.
 
QString explain (int line) const
 Explains the evaluation point associated with a line (like "node 5" or "cell 4 @ ip 2")
 
void explainToIndex (GmResultsTrackedIndexData *indexData, int line) const
 Simmilar to explain() but instead of returning a string, adds the data to the given track index object.
 
bool changed () const
 Returns the value of the changed flag. This flag is set to true on the constructor or when a mesh change triggers a change in the eval set contents. It is cleared by a call to resetChanges()
 
void resetChanges ()
 Resets the cahnge flag, setting it to false.
 
void print (const GmLogCategory &logger, GmLogLevel level) const
 Prints the basic evaluation set data to the given logger.
 

Static Public Member Functions

static const char * aggregationRuleStr (GmEvalSetAggregationRule rule)
 Returns a string version for the given aggregation rule.
 
static GmResultsEvalSetloadFromTable (LuaTable &tab, GmMesh *mesh, QString tabPrefix, QString ruleId, bool nodeBased, int defEvalAt, int ruleSet, const GmLogCategory &logger)
 Parses either a monitor or a save rule definition from the given Lua table, returning an evaluation set object.
 

Private Member Functions

 Q_DISABLE_COPY (GmResultsEvalSet)
 
 GmResultsEvalSet (GmMesh *mesh, bool nodeBased, int defEvalAt, int defRuleSet)
 Constructor. Marks the set as changed.
 
bool parseNodes (LuaTable &tab, const GmMesh *mesh, QString &err)
 Parse node definitions filling the related object attributes. On error, returns false, filling err.
 
bool parseCells (LuaTable &tab, const GmCellMesh *mesh, bool userRuleSet, QString &err)
 Parse cell definitions filling the related object attributes. On error, returns false, filling err.
 
bool parsePoints (LuaTable &tab, const GmMesh *mesh, QString &err)
 Parse point definitions filling the related object attributes. On error, returns false, filling err.
 
bool buildIpIndex (QString &err)
 Builds the information needed for working with multiple IPs per cell.
 
bool buildPointIndex (GmSpatialIndex *si, bool natural, QString &err)
 For every user given point, finds its surrounding cell and translates the cartesian coordinate to a natural one if requested.
 
bool cellData (int line, int *cellId, GmVector &coord) const
 Simillar to cellPos() but filling coord with cartesian coordinates only for point lines. The cellId is filled with the cell. Returns true if this is a cell centroid line, false for a user point line.
 

Private Attributes

GmMesh_mesh
 The mesh that this evaluation set is tied to.
 
GmValueAccessor_nodeAc
 The accessor used for handling centroid queries.
 
int _nodeDim
 The node coordinate dimension.
 
bool _allMeshNodes
 Should the data be evaluated at all mesh nodes? If true, _nodes will be NULL.
 
int * _nodes
 The subset of mesh nodes in the node result set. Can be NULL. Entries are kept ordered by Lua model index.
 
int _numNodes
 The number of entries in _nodes.
 
QVector< GmNodeSet * > _nodeSets
 The named node sets included in _nodes.
 
QVector< GmCellBoundary * > _nodeBorders
 The named cell borders included in _nodes.
 
bool _allMeshCells
 Should the data be evaluated at all mesh cells? If true, _cells will be NULL.
 
int * _cells
 The subset of mesh cells in the cell result set. Can be NULL. Entries are kept ordered by Lua model index.
 
int _numCells
 The number of entries in _cells.
 
int _evalAt
 The evaluation point for cell values. If -1, the centroid will be used. If -2, all integration points will be used. If -3, an aggregation rule will be used over all integration points. Otherwise, stores the ip index.
 
GmEvalSetAggregationRule _evalAggr
 The aggregation rule for _evalAt = -3.
 
int _ruleSet
 The rule set if _evalAt is associated to integration points.
 
QVector< GmCellBoundary * > _cellBorders
 The named cell borders included in _cells.
 
QStringList _cellGroups
 The named cell groups included in _cells.
 
bool _allCellsFromGroup
 Set to true if all the cells in _cells came from the groups in _cellGroups.
 
GmVector_points
 The set of configured extra points where data should be evaluated.
 
int _numPoints
 The number of points in _points.
 
bool _changed
 Has the eval set data changed since the last call to resetChanges()? Set to true on the constructor.
 
GmAffectedNodes _nodeTypes
 The types of nodes returned when _allMeshNodes is true.
 
int _numNodeLines
 The number of lines associated with the node part. Set to -1 before prepare()
 
int _numCellLines
 The number of lines associated with the cell part. Set to -1 before prepare()
 
GmFixedMeshSetGaussIndex_ipIndex
 The index used to translate line indices into cell + ip number pairs.
 
int * _pointCells
 The cell index associated with each extra point. Size equal to _numPoints.
 
GmVector_pointNaturalCoordinates
 The set of points translated to natural coordinates.
 

Detailed Description

A class storing the evaluation points for a set of rules.

Member Enumeration Documentation

◆ GmEvalSetAggregationRule

Enumerator
GM_EVALSET_NONE 

No aggregation rule.

GM_EVALSET_MIN 

Returns the minimum value (for each component when dealing with vectors/matrices)

GM_EVALSET_MAX 

Returns the maximum value (for each component when dealing with vectors/matrices)

GM_EVALSET_AVG 

Returns the average of the values (for each component when dealing with vectors/matrices)

GM_EVALSET_SUM 

Returns the sum of the values (for each component when dealing with vectors/matrices)

GM_EVALSET_MINNORM 

Returns the value with minimum norm.

GM_EVALSET_MAXNORM 

Returns the value with maximum norm.

Member Function Documentation

◆ loadFromTable()

GmResultsEvalSet * GmResultsEvalSet::loadFromTable ( LuaTable & tab,
GmMesh * mesh,
QString tabPrefix,
QString ruleId,
bool nodeBased,
int defEvalAt,
int ruleSet,
const GmLogCategory & logger )
static

Parses either a monitor or a save rule definition from the given Lua table, returning an evaluation set object.

If nodeBased is true, we are reading an evaluation set tied to node data. Otherwise it is tied to cell (or gauss) data. defEvalAt should be either -1 for a default cell evaluation point equal to the cell centroid or -2 for the default being the evaluation at each cell integration point.

ruleSet should be -1 for accepting cell definitions tied to a user given rule set (or 0 by default). If different from -1, the given rule set will be used and the user can not provide the ruleSet clause (ignored).

If the given table is nil, the default evaluation set will be over the whole mesh nodes or cells (depending on nodeBased).

The tabPrefix and ruleId strings are used by error messages, which are created
using the following format: "Error while parsing %1.nodes table for %2: %3.", where %1 is the tabPrefix (ex: nodeEvalSet), and %2 the ruleId (ex: monitor rule 'xxx').

The logger object is used to emmit messages during rule parsing.

◆ parseCells()

bool GmResultsEvalSet::parseCells ( LuaTable & tab,
const GmCellMesh * mesh,
bool userRuleSet,
QString & err )
private

Parse cell definitions filling the related object attributes. On error, returns false, filling err.

userRuleSet should be true if the user can change the default rule set with a ruleSet definition, or false to ignore ruleSet fields.

◆ prepare()

bool GmResultsEvalSet::prepare ( GmSpatialIndex * si,
bool natural,
GmAffectedNodes nodeTypes,
QString ruleId,
const GmLogCategory & logger )

Initializes internal structures needed for answering further queries. On errors, uses the logger to emmit errors and returns false.

Parameters
siThe spatial index used for mapping points to cells. Can be NULL if the user didn't supplied extra points.
naturalShould be set to true if any of the data srcs require interpolation and the interpolation method requires natural coordinates (shape) or, for cell attributes, if the mesh is an element mesh. This is used for user given points only.
nodeTypesUsed if the result set defines that the whole mesh should be used to define if only geometry nodes, ghost nodes or both should be considered.
ruleIdThe rule id used on error messages
loggerThe logger
Returns
Returns true on success, false on errors (reported through the logger)

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