GemaCoreLib
The GeMA Core library
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 
32 class GmMesh;
33 class GmCellMesh;
34 class GmNodeSet;
35 class GmCellBoundary;
36 class GmLogCategory;
37 class GmSpatialIndex;
39 class LuaTable;
40 
42 
43 #include "QVector"
44 
47 {
48 public:
49 
51 
52  bool prepare(GmSpatialIndex* si, bool natural, GmAffectedNodes nodeTypes,
53  QString ruleId, const GmLogCategory& logger);
54 
55  bool hasIpBasedLines() const;
56  bool hasPosBasedLines() const;
57 
59  int numLines() const
60  {
61  assert(_numNodeLines >= 0 && _numCellLines >= 0); // prepare() has been called
62  return _numNodeLines + _numCellLines + _numPoints;
63  }
64 
66  bool isNodeBased(int line) const
67  {
68  assert(_numNodeLines >= 0 && _numCellLines >= 0); // prepare() has been called
69  assert(line >= 0 && line < numLines());
70  return line < _numNodeLines;
71  }
72 
74  bool isIpBased(int line) const
75  {
76  assert(_numNodeLines >= 0 && _numCellLines >= 0); // prepare() has been called
77  assert(line >= 0 && line < numLines());
78  return (_evalAt != -1) && (line >= _numNodeLines) && line < (_numNodeLines + _numCellLines);
79  }
80 
84  bool isPosBased(int line) const { return !isNodeBased(line) && !isIpBased(line); }
85 
87  bool isUserPointBased(int line) const
88  {
89  assert(_numNodeLines >= 0 && _numCellLines >= 0); // prepare() has been called
90  assert(line >= 0 && line < numLines());
91  return line >= (_numNodeLines + _numCellLines);
92  }
93 
94  int nodeIndex (int line) const;
95  int cellIpIndex(int line, int* ip, int* ruleSet = NULL) const;
96  int cellPos (int line, bool naturalCoord, GmVector& coord) const;
97 
98  QString explain(int line) const;
99  void explainToIndex(GmResultTrackedIndexData* indexData, int line) const;
100 
105  bool changed() const { return _changed; }
106 
108  void resetChanges() { _changed = false; }
109 
110  void print(const GmLogCategory& logger, GmLogLevel level) const;
111 
112  static GmResultsEvalSet* loadFromTable(LuaTable& tab, GmMesh* mesh, QString tabPrefix,
113  QString ruleId, bool nodeBased, int defEvalAt,
114  int ruleSet, const GmLogCategory& logger);
115 private:
116  Q_DISABLE_COPY(GmResultsEvalSet);
117 
118  GmResultsEvalSet(GmMesh* mesh, bool nodeBased, int defEvalAt, int defRuleSet);
119 
120  bool parseNodes (LuaTable& tab, const GmMesh* mesh, QString& err);
121  bool parseCells (LuaTable& tab, const GmCellMesh* mesh, bool userRuleSet, QString& err);
122  bool parsePoints(LuaTable& tab, const GmMesh* mesh, QString& err);
123 
124  bool buildIpIndex (QString& err);
125  bool buildPointIndex(GmSpatialIndex* si, bool natural, QString& err);
126 
127  bool cellData(int line, int* cellId, GmVector& coord) const;
128 
131  int _nodeDim;
132 
133  // Data storing node definitions
135  int* _nodes;
136  int _numNodes;
139 
140  // Data storing cell definitions
142  int* _cells;
143  int _numCells;
144  int _evalAt;
145  int _ruleSet;
148 
149  // Data storing extra point definitions
152 
153  // Control data
154  bool _changed;
158  GmFixedMeshSetGaussIndex* _ipIndex;
159  int* _pointCells;
161 };
162 
163 
164 
165 #endif
166 
bool _allMeshNodes
Should the data be evaluated at all mesh nodes? If true, _nodes will be NULL.
Definition: gmResultsEvalSet.h:134
int _ruleSet
The rule set if _evalAt is associated to integration points.
Definition: gmResultsEvalSet.h:145
int _numPoints
The number of points in _points.
Definition: gmResultsEvalSet.h:151
GmVector * _points
The set of configured extra points where data should be evaluated.
Definition: gmResultsEvalSet.h:150
bool _changed
Has the eval set data changed since the last call to resetChanges()? Set to true on the constructor.
Definition: gmResultsEvalSet.h:154
bool isNodeBased(int line) const
Returns true if the given line is associated with a node line.
Definition: gmResultsEvalSet.h:66
GmAffectedNodes
Affected node types for node based values (GM_NODE_COORDINATES, GM_NODE_ATTRIBUTE or GM_NODE_STATEVAR...
Definition: gmValueInfo.h:91
QStringList _cellGroups
The named cell groups included in _cells.
Definition: gmResultsEvalSet.h:147
int _numNodeLines
The number of lines associated with the node part. Set to -1 before prepare()
Definition: gmResultsEvalSet.h:156
Declaration of usefull configuration definitions for the Core library.
GmVector * _pointNaturalCoordinates
The set of points translated to natural coordinates.
Definition: gmResultsEvalSet.h:160
Declaration of the GmValueInfo class.
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:43
This class stores a set of nodes belonging to a mesh. The nodes can belong to the mesh boundary but t...
Definition: gmNodeSet.h:32
int _evalAt
The evaluation point for cell values. If -1, the centroid will be used. If -2, all integration points...
Definition: gmResultsEvalSet.h:144
int * _nodes
The subset of mesh nodes in the node result set. Can be NULL.
Definition: gmResultsEvalSet.h:135
GmAffectedNodes _nodeTypes
The types of nodes returned when _allMeshNodes is true.
Definition: gmResultsEvalSet.h:155
The index data for a result rule, storing "evaluation point" data for node, cell or gauss based indic...
Definition: gmResultTrackedData.h:64
A Gauss index interface always indexing ALL the elements in either the full mesh or in the given mesh...
Definition: gmGaussIndex.h:311
Interface class for accessing and setting values from an "indexable" collection of values.
Definition: gmValueAccessor.h:59
bool isIpBased(int line) const
Returns true if the given line is associated with a cell integration point.
Definition: gmResultsEvalSet.h:74
GmMesh * _mesh
The mesh that this evaluation set is tied to.
Definition: gmResultsEvalSet.h:129
A class storing the evaluation points for a set of rules.
Definition: gmResultsEvalSet.h:46
int _numNodes
The number of entries in _nodes.
Definition: gmResultsEvalSet.h:136
Base interface class for CellMesh type plugins.
Definition: gmCellMesh.h:39
Base interface class for Spatial Index type plugins.
Definition: gmSpatialIndex.h:37
bool isUserPointBased(int line) const
Returns true if the given line is associated with a user given point.
Definition: gmResultsEvalSet.h:87
int _numCells
The number of entries in _cells.
Definition: gmResultsEvalSet.h:143
QVector< GmCellBoundary * > _cellBorders
The named cell borders included in _cells.
Definition: gmResultsEvalSet.h:146
int _numCellLines
The number of lines associated with the cell part. Set to -1 before prepare()
Definition: gmResultsEvalSet.h:157
void print(const GmMatrix &m, const GmLogCategory &logger, GmLogLevel level, int fieldWidth, char format, int precision)
Prints the matrix using the specified logger, level and precision fields.
Definition: gmMatrixUtils.cpp:34
bool _allMeshCells
Should the data be evaluated at all mesh cells? If true, _cells will be NULL.
Definition: gmResultsEvalSet.h:141
Declaration of the GmVector class.
int numLines() const
Returns the number of lines associated with this evaluation set.
Definition: gmResultsEvalSet.h:59
#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
int _nodeDim
The node coordinate dimension.
Definition: gmResultsEvalSet.h:131
int * _cells
The subset of mesh cells in the cell result set. Can be NULL.
Definition: gmResultsEvalSet.h:142
GmValueAccessor * _nodeAc
The accessor used for handling centroid queries.
Definition: gmResultsEvalSet.h:130
QVector< GmNodeSet * > _nodeSets
The named node sets included in _nodes.
Definition: gmResultsEvalSet.h:137
void resetChanges()
Resets the cahnge flag, setting it to false.
Definition: gmResultsEvalSet.h:108
GmLogLevel
Available log levels list.
Definition: gmLog.h:36
Class representing a category with multiple logging levels.
Definition: gmLog.h:58
int * _pointCells
<The index used to translate line indices into nell + ip number pairs
Definition: gmResultsEvalSet.h:159
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:105
arma::vec GmVector
The basic type for a GeMA vector object. Currently based on an Armadillo vector.
Definition: gmVector.h:34
Base interface class for Mesh type plugins.
Definition: gmMesh.h:44
QVector< GmCellBoundary * > _nodeBorders
The named cell borders included in _nodes.
Definition: gmResultsEvalSet.h:138
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:84