GemaCoreLib
The GeMA Core library
gmResultsRule.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_RULE_H_
25 #define _GEMA_RESULTS_RULE_H_
26 
27 #include "gmCoreConfig.h"
28 
29 #include "gmResultDataSrcInfo.h"
30 #include "gmValueInfo.h"
31 
32 #include <QString>
33 #include <QVariant>
34 #include <QVector>
35 
36 class GmMesh;
37 class GmCellMesh;
38 class GmElementMesh;
39 class GmValueInfo;
40 class GmSimulationData;
41 class GmResultsData;
42 class GmLogCategory;
43 class GmResultsEvalSet;
44 class LuaTable;
45 
51 
52 
55 {
56 public:
57 
58  virtual ~GmResultsRule();
59 
63  int ruleId() const { return _ruleId; }
64 
66  QString id() const { return _id; }
67 
69  QString description() const { return _description; }
70 
72  GmMesh* mesh() const { return _mesh; }
73 
74  int numDataSrcs(int type = -1) const;
75 
76  int dataSrcIndex(GmResultDataSrcType type, int i) const;
77 
78  const GmResultDataSrcInfo* dataSrcInfo(int index) const;
79 
80  void dataSrcInfoChanged(GmAttributeResultDataSrc* info);
81 
82  int dataSrcSize (int index) const;
83  const double* dataSrcValue (int index, int line, QString& err) const;
84  QString strDataSrcValue(int index, int line, QString& err) const;
85  QString explain (int index, int line) const;
86 
87  void print(const GmLogCategory& logger, GmLogLevel level) const;
88 
89  void printData (const GmLogCategory& logger, GmLogLevel level) const;
90  void evalMonitoredData(const GmLogCategory& errLogger) const;
91 
92  static GmResultsRule* loadFromTable(LuaTable& tab, bool monitor, GmSimulationData* data,
93  const GmLogCategory& parseLogger, const GmLogCategory& dataLogger);
94 
95  static GmResultNodeDataSrc* createNodeDataSrc (int trackId, const GmMesh* mesh, const QVariant& v, bool interp, const GmLogCategory& dataLogger,
96  bool* unknown, QString& srcId, QString& err);
97 
98  static GmResultCellDataSrc* createCellDataSrc (int trackId, const GmCellMesh* mesh, const QVariant& v, bool interp, const GmLogCategory& dataLogger,
99  bool* unknown, QString& srcId, QString& err);
100 
101  static GmResultGaussDataSrc* createGaussDataSrc(int trackId, const GmElementMesh* mesh, const QVariant& v, bool interp, const GmLogCategory& dataLogger,
102  bool* unknown, QString& srcId, QString& err);
103 
104 protected:
105  GmResultsRule(int ruleId, QString id, QString description, GmResultsData* resultData);
106 
107 private:
108  Q_DISABLE_COPY(GmResultsRule);
109 
110  GmResultsEvalSet* evalSet(GmResultDataSrcType type) const;
111 
112  template <class T, class AcF>
113  static T* createDataSrc(int trackId, const QVariant& v, const AcF& acGet, bool interp, bool* unknown, QString& srcId, QString& err);
114 
115  bool addNodeDataSrc (int trackId, const GmMesh* mesh, const QVariant& v, const GmLogCategory& dataLogger, QString& err);
116  bool addCellDataSrc (int trackId, const GmCellMesh* mesh, const QVariant& v, const GmLogCategory& dataLogger, QString& err);
117  bool addGaussDataSrc(int trackId, const GmElementMesh* mesh, const QVariant& v, const GmLogCategory& dataLogger, QString& err);
118 
119  static bool parseAndCheckDataSrcFields(GmResultAcDataSrcBase* ds, const GmValueInfo* info, const QVariant& v, QString& err);
120 
121  bool checkForMultipleAffectedNodes(GmAffectedNodes* affNodes) const;
122  bool checkForMultipleGaussRuleSets(int* ruleSet) const;
123 
124  bool createNodeInterpolators (bool* needNatural, QString& err);
125  bool createGaussInterpolators(bool* needNatural, QString& err);
126 
127  bool allocResultBuffers();
128 
129  const double* nodeDataSrcValue (GmResultNodeDataSrc* ds, int line, QString& err) const;
130  const double* cellDataSrcValue (GmResultCellDataSrc* ds, int line, QString& err) const;
131  const double* gaussDataSrcValue(GmResultGaussDataSrc* ds, int line, QString& err) const;
132 
133  void printAttributeData(const GmLogCategory& logger, GmLogLevel level) const;
134  void printEvalSetData (GmResultDataSrcType type, const GmLogCategory& logger, GmLogLevel level) const;
135 
136  void evalMonitoredAttributeData(const GmLogCategory& errLogger) const;
137  void evalMonitoredEvalSetData (GmResultDataSrcType type, const GmLogCategory& errLogger) const;
138 
139  QString formatedNumericDataSrcValue(const GmResultDataSrcInfo* ds, const double* v, QString err) const;
140 
141  int _ruleId;
147 
148  QVector<GmResultDataSrcInfo*> _dataSrcs; // The set of data srcs. Entries are ordered by type following GmResultDataSrcType
149 
155  int _dataSrcPos[GM_RR_DS_NUMTYPES+1];
156 
160 
161  double* _resultBuffer;
162  mutable double* _transformBuffer;
163  mutable int _transformBufferSize;
164 };
165 
166 
167 
168 #endif
169 
int _ruleId
An integer in the range [0, num monitor rules in the model[ that identfies a monitor rule....
Definition: gmResultsRule.h:141
Auxiliar class used to store the definition of a value. It can be used to store informations about st...
Definition: gmValueInfo.h:126
QString _description
A description of the result rule.
Definition: gmResultsRule.h:143
GmResultsEvalSet * _cellEvalSet
The evaluation set for cell data sources.
Definition: gmResultsRule.h:158
A GmResultDataSrc class holding a cell value accessor.
Definition: gmResultDataSrc.h:323
A GmResultDataSrc class holding a node value accessor.
Definition: gmResultDataSrc.h:303
A basic interface with the metadata common to all result data src types. This is the information that...
Definition: gmResultDataSrcInfo.h:50
GmAffectedNodes
Affected node types for node based values (GM_NODE_COORDINATES, GM_NODE_ATTRIBUTE or GM_NODE_STATEVAR...
Definition: gmValueInfo.h:91
Declaration of usefull configuration definitions for the Core library.
Declaration of the GmValueInfo class.
GmResultsEvalSet * _gaussEvalSet
The evaluation set for gauss data sources.
Definition: gmResultsRule.h:159
int _transformBufferSize
The size of _transformBuffer.
Definition: gmResultsRule.h:163
A GmResultDataSrc class holding a Gauss value accessor.
Definition: gmResultDataSrc.h:343
QString description() const
Returns the results rule description.
Definition: gmResultsRule.h:69
GmResultDataSrcType
The types of data srcs stored by a rule.
Definition: gmResultDataSrcInfo.h:34
GmResultsEvalSet * _nodeEvalSet
The evaluation set for node data sources.
Definition: gmResultsRule.h:157
Interface class for accessing and setting values from an "indexable" collection of values.
Definition: gmValueAccessor.h:59
Auxiliar class used to store the complete set of simulation data.
Definition: gmSimulationData.h:51
A calss storing basic information about a result data to be exported (monitored / saved),...
Definition: gmResultDataSrc.h:104
QString id() const
Returns the results rule name.
Definition: gmResultsRule.h:66
double * _transformBuffer
The buffer used to store the result from a "non ac" data src or user transformation function....
Definition: gmResultsRule.h:162
A result rule storing what should be exported, when it should be exported and to where it should be e...
Definition: gmResultsRule.h:54
A class storing the evaluation points for a set of rules.
Definition: gmResultsEvalSet.h:46
int ruleId() const
Returns the ruleId. This value is a unique index between 0 and the number of monitor rules in the mod...
Definition: gmResultsRule.h:63
Base interface class for CellMesh type plugins.
Definition: gmCellMesh.h:39
GmMesh * mesh() const
Returns the mesh that contains the associated data. Can be NULL.
Definition: gmResultsRule.h:72
The number of data src types above.
Definition: gmResultDataSrcInfo.h:43
double * _resultBuffer
The buffer used by xxxDataSrcValue() functions for returning interpolated data. Its size is the bigge...
Definition: gmResultsRule.h:161
Auxiliar class used to store the complete set of results data for a simulation.
Definition: gmResultsData.h:51
GmMesh * _mesh
The mesh that this result rule is tied to (can be NULL for attribute rules)
Definition: gmResultsRule.h:145
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
A class implementing the GmResultDataSrcInfo interface, storing the metadata and id for a result data...
Definition: gmResultDataSrc.h:43
#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
Declaration of the GmResultDataSrcInfo interface and GmAttributeResultDataSrcInfo class.
QString _id
The result rule id (name)
Definition: gmResultsRule.h:142
GmLogLevel
Available log levels list.
Definition: gmLog.h:36
Class representing a category with multiple logging levels.
Definition: gmLog.h:58
Base interface for FEM (finite element) meshes.
Definition: gmElementMesh.h:40
Base interface class for Mesh type plugins.
Definition: gmMesh.h:44
GmResultsData * _resultData
The result data object used to provide values for result attributes.
Definition: gmResultsRule.h:144
GmValueAccessor * _coordAc
The accessor used for accessing node coordinates.
Definition: gmResultsRule.h:146