GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
gmResultsEvalSet.h
Go to the documentation of this file.
1/************************************************************************
2**
3** Copyright (C) 2014 by Carlos Augusto Teixera Mendes
4** All rights reserved.
5**
6** This file is part of the "GeMA" software. It's use should respect
7** the terms in the license agreement that can be found together
8** with this source code.
9** It is provided AS IS, with NO WARRANTY OF ANY KIND,
10** INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR
11** A PARTICULAR PURPOSE.
12**
13************************************************************************/
14
24#ifndef _GEMA_RESULTS_EVALSET_H_
25#define _GEMA_RESULTS_EVALSET_H_
26
27#include "gmCoreConfig.h"
28
29#include "gmValueInfo.h"
30#include "gmVector.h"
31
32class GmMesh;
33class GmCellMesh;
34class GmNodeSet;
35class GmCellBoundary;
36class GmLogCategory;
37class GmSpatialIndex;
39class LuaTable;
40
42
43#include "QVector"
44
47{
48public:
49
50 // Aggregation options for values evaluated at Gauss points
52 {
60 // -------------------------------------------------
61 // IMPORTANT: No Adding below this line. When changing the enum,
62 // also change the aggregationRuleStr() implementation.
63 //--------------------------------------------------
64 GM_NUM_EVALSET_AGGR_RULES
65 };
66
68
69 bool prepare(GmSpatialIndex* si, bool natural, GmAffectedNodes nodeTypes,
70 QString ruleId, const GmLogCategory& logger);
71
72 bool hasIpBasedLines() const;
73 bool hasPosBasedLines() const;
74
76 int numLines() const
77 {
78 assert(_numNodeLines >= 0 && _numCellLines >= 0); // prepare() has been called
79 return _numNodeLines + _numCellLines + _numPoints;
80 }
81
83 bool isNodeBased(int line) const
84 {
85 assert(_numNodeLines >= 0 && _numCellLines >= 0); // prepare() has been called
86 assert(line >= 0 && line < numLines());
87 return line < _numNodeLines;
88 }
89
91 bool isIpBased(int line) const
92 {
93 assert(_numNodeLines >= 0 && _numCellLines >= 0); // prepare() has been called
94 assert(line >= 0 && line < numLines());
95 return (_evalAt != -1) && (line >= _numNodeLines) && line < (_numNodeLines + _numCellLines);
96 }
97
101 bool isPosBased(int line) const { return !isNodeBased(line) && !isIpBased(line); }
102
104 bool isUserPointBased(int line) const
105 {
106 assert(_numNodeLines >= 0 && _numCellLines >= 0); // prepare() has been called
107 assert(line >= 0 && line < numLines());
108 return line >= (_numNodeLines + _numCellLines);
109 }
110
112 bool isSimple() const { return !_nodes && (!_cells || _allCellsFromGroup) && !_points; }
113
115 const QStringList& simpleGroups() const { return _cellGroups; }
116
117 int nodeIndex (int line) const;
118 int cellIpIndex(int line, int* ip, int* ruleSet = NULL) const;
119 int cellPos (int line, bool naturalCoord, GmVector& coord) const;
120
122 GmEvalSetAggregationRule aggregationRule() const { return _evalAggr; }
123
126 {
127 assert(rule >= 0 && rule < GM_NUM_EVALSET_AGGR_RULES);
128 static const char* ruleNames[GM_NUM_EVALSET_AGGR_RULES] = { "none", "min", "max", "avg", "sum", "minnorm", "maxnorm"}; // Order MUST match enum order
129 return ruleNames[rule];
130 }
131
133 const char* aggregationRuleStr() const { return aggregationRuleStr(_evalAggr); }
134
135 QString explain(int line) const;
136 void explainToIndex(GmResultsTrackedIndexData* indexData, int line) const;
137
142 bool changed() const { return _changed; }
143
145 void resetChanges() { _changed = false; }
146
147 void print(const GmLogCategory& logger, GmLogLevel level) const;
148
149 static GmResultsEvalSet* loadFromTable(LuaTable& tab, GmMesh* mesh, QString tabPrefix,
150 QString ruleId, bool nodeBased, int defEvalAt,
151 int ruleSet, const GmLogCategory& logger);
152private:
153 Q_DISABLE_COPY(GmResultsEvalSet);
154
155 GmResultsEvalSet(GmMesh* mesh, bool nodeBased, int defEvalAt, int defRuleSet);
156
157 bool parseNodes (LuaTable& tab, const GmMesh* mesh, QString& err);
158 bool parseCells (LuaTable& tab, const GmCellMesh* mesh, bool userRuleSet, QString& err);
159 bool parsePoints(LuaTable& tab, const GmMesh* mesh, QString& err);
160
161 bool buildIpIndex (QString& err);
162 bool buildPointIndex(GmSpatialIndex* si, bool natural, QString& err);
163
164 bool cellData(int line, int* cellId, GmVector& coord) const;
165
169
170 // Data storing node definitions
172 int* _nodes;
176
177 // Data storing cell definitions
179 int* _cells;
187
188 // Data storing extra point definitions
191
192 // Control data
193 bool _changed;
200};
201
202
203
204#endif
205
This class stores a set of cell edges or cell faces that together form a piece of the boundary of a m...
Definition gmCellBoundary.h:44
Base interface class for CellMesh type plugins.
Definition gmCellMesh.h:40
A Gauss index interface always indexing ALL the elements in either the full mesh or in the given mesh...
Definition gmGaussIndex.h:312
Class representing a category with multiple logging levels.
Definition gmLog.h:58
Base interface class for Mesh type plugins.
Definition gmMesh.h:48
This class stores a set of nodes belonging to a mesh. The nodes can belong to the mesh boundary but t...
Definition gmNodeSet.h:34
A class storing the evaluation points for a set of rules.
Definition gmResultsEvalSet.h:47
int _evalAt
The evaluation point for cell values. If -1, the centroid will be used. If -2, all integration points...
Definition gmResultsEvalSet.h:181
QVector< GmCellBoundary * > _cellBorders
The named cell borders included in _cells.
Definition gmResultsEvalSet.h:184
int * _cells
The subset of mesh cells in the cell result set. Can be NULL. Entries are kept ordered by Lua model i...
Definition gmResultsEvalSet.h:179
int _numNodes
The number of entries in _nodes.
Definition gmResultsEvalSet.h:173
bool _allMeshCells
Should the data be evaluated at all mesh cells? If true, _cells will be NULL.
Definition gmResultsEvalSet.h:178
int _numPoints
The number of points in _points.
Definition gmResultsEvalSet.h:190
const char * aggregationRuleStr() const
Returns a string version for the configured aggregation rule.
Definition gmResultsEvalSet.h:133
GmValueAccessor * _nodeAc
The accessor used for handling centroid queries.
Definition gmResultsEvalSet.h:167
GmVector * _points
The set of configured extra points where data should be evaluated.
Definition gmResultsEvalSet.h:189
bool _allCellsFromGroup
Set to true if all the cells in _cells came from the groups in _cellGroups.
Definition gmResultsEvalSet.h:186
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 cel...
Definition gmResultsEvalSet.h:112
GmEvalSetAggregationRule _evalAggr
The aggregation rule for _evalAt = -3.
Definition gmResultsEvalSet.h:182
const QStringList & simpleGroups() const
The set of cell groups if isSimple() is true (might be empty if the entire mesh is used)
Definition gmResultsEvalSet.h:115
int _numCells
The number of entries in _cells.
Definition gmResultsEvalSet.h:180
int * _nodes
The subset of mesh nodes in the node result set. Can be NULL. Entries are kept ordered by Lua model i...
Definition gmResultsEvalSet.h:172
int _nodeDim
The node coordinate dimension.
Definition gmResultsEvalSet.h:168
bool isNodeBased(int line) const
Returns true if the given line is associated with a node line.
Definition gmResultsEvalSet.h:83
void resetChanges()
Resets the cahnge flag, setting it to false.
Definition gmResultsEvalSet.h:145
int numLines() const
Returns the number of lines associated with this evaluation set.
Definition gmResultsEvalSet.h:76
bool changed() const
Returns the value of the changed flag. This flag is set to true on the constructor or when a mesh cha...
Definition gmResultsEvalSet.h:142
GmVector * _pointNaturalCoordinates
The set of points translated to natural coordinates.
Definition gmResultsEvalSet.h:199
bool isUserPointBased(int line) const
Returns true if the given line is associated with a user given point.
Definition gmResultsEvalSet.h:104
GmMesh * _mesh
The mesh that this evaluation set is tied to.
Definition gmResultsEvalSet.h:166
GmEvalSetAggregationRule aggregationRule() const
Returns the configured aggregation rule for ip based cell values.
Definition gmResultsEvalSet.h:122
QVector< GmNodeSet * > _nodeSets
The named node sets included in _nodes.
Definition gmResultsEvalSet.h:174
int _ruleSet
The rule set if _evalAt is associated to integration points.
Definition gmResultsEvalSet.h:183
int * _pointCells
The cell index associated with each extra point. Size equal to _numPoints.
Definition gmResultsEvalSet.h:198
bool _allMeshNodes
Should the data be evaluated at all mesh nodes? If true, _nodes will be NULL.
Definition gmResultsEvalSet.h:171
int _numNodeLines
The number of lines associated with the node part. Set to -1 before prepare()
Definition gmResultsEvalSet.h:195
bool isIpBased(int line) const
Returns true if the given line is associated with a cell integration point.
Definition gmResultsEvalSet.h:91
int _numCellLines
The number of lines associated with the cell part. Set to -1 before prepare()
Definition gmResultsEvalSet.h:196
QStringList _cellGroups
The named cell groups included in _cells.
Definition gmResultsEvalSet.h:185
bool isPosBased(int line) const
Returns true if the given line is associated with a user point or with a cell centroid.
Definition gmResultsEvalSet.h:101
GmFixedMeshSetGaussIndex * _ipIndex
The index used to translate line indices into cell + ip number pairs.
Definition gmResultsEvalSet.h:197
GmAffectedNodes _nodeTypes
The types of nodes returned when _allMeshNodes is true.
Definition gmResultsEvalSet.h:194
QVector< GmCellBoundary * > _nodeBorders
The named cell borders included in _nodes.
Definition gmResultsEvalSet.h:175
GmEvalSetAggregationRule
Definition gmResultsEvalSet.h:52
@ GM_EVALSET_MINNORM
Returns the value with minimum norm.
Definition gmResultsEvalSet.h:58
@ GM_EVALSET_AVG
Returns the average of the values (for each component when dealing with vectors/matrices)
Definition gmResultsEvalSet.h:56
@ GM_EVALSET_MIN
Returns the minimum value (for each component when dealing with vectors/matrices)
Definition gmResultsEvalSet.h:54
@ GM_EVALSET_NONE
No aggregation rule.
Definition gmResultsEvalSet.h:53
@ GM_EVALSET_MAX
Returns the maximum value (for each component when dealing with vectors/matrices)
Definition gmResultsEvalSet.h:55
@ GM_EVALSET_MAXNORM
Returns the value with maximum norm.
Definition gmResultsEvalSet.h:59
@ GM_EVALSET_SUM
Returns the sum of the values (for each component when dealing with vectors/matrices)
Definition gmResultsEvalSet.h:57
bool _changed
Has the eval set data changed since the last call to resetChanges()? Set to true on the constructor.
Definition gmResultsEvalSet.h:193
static const char * aggregationRuleStr(GmEvalSetAggregationRule rule)
Returns a string version for the given aggregation rule.
Definition gmResultsEvalSet.h:125
Base interface class for Spatial Index type plugins.
Definition gmSpatialIndex.h:66
Interface class for accessing and setting values from an "indexable" collection of values.
Definition gmValueAccessor.h:60
Declaration of useful configuration definitions for the Core library.
#define GMC_API_EXPORT
Macro for controlling if the class is being exported (GEMA_CORE_LIB defined) or imported (GEMA_CORE_L...
Definition gmCoreConfig.h:35
GmLogLevel
Available log levels list.
Definition gmLog.h:36
Declaration of the GmValueInfo class.
GmAffectedNodes
Affected node types for node based values (GM_NODE_COORDINATES, GM_NODE_ATTRIBUTE or GM_NODE_STATEVAR...
Definition gmValueInfo.h:97
Declaration of the GmVector class.
arma::vec GmVector
The basic type for a GeMA vector object. Currently based on an Armadillo vector.
Definition gmVector.h:34
The index data for a result rule, storing "evaluation point" data for node, cell or gauss based indic...
Definition gmResultsTrackedData.h:65