GemaCoreLib
The GeMA Core library
gmValueInfo.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 
23 #ifndef _GEMA_VALUE_INFO_H_
24 #define _GEMA_VALUE_INFO_H_
25 
26 #include "gmCoreConfig.h"
27 #include "gmLog.h"
28 
29 class LuaTable;
30 class GmValueAccessor;
31 
32 #include <QString>
33 #include <unit.h>
34 
37 {
48  // --- DO NOT INSERT ANYTHING BELLOW THIS LINE ---
49  GM_NUM_VALUESET_KIND
50 };
51 
54 {
63 };
64 
67 {
71 };
72 
75 {
79 };
80 
83 {
88 };
89 
92 {
96 };
97 
98 #define GM_VALUE_INFO_DEFAULT_FORMAT_WIDTH 12
99 #define GM_VALUE_INFO_DEFAULT_FORMAT 'f'
100 #define GM_VALUE_INFO_DEFAULT_FORMAT_PREC 2
101 #define GM_VALUE_INFO_DEFAULT_FORMAT_STR "12.2f"
102 
103 
106 {
107  GmBcTagInfo(int size);
108  ~GmBcTagInfo();
109 
114  int* _tags;
115  bool _ignoreDef;
116  bool _ignoreZero;
117 private:
118  Q_DISABLE_COPY(GmBcTagInfo)
119 };
120 
121 
127 {
128 public:
129  GmValueInfo(QString id, QString description, Unit unit, GmValueSetKind kind,
130  GmDimType dimType = GM_SCALAR_VALUE, int nlin = 1, int ncol = 1);
131  GmValueInfo(const GmValueInfo &);
132 
133  virtual ~GmValueInfo();
134 
136  QString id() const { return _id; }
137 
139  QString description() const { return _description; }
140 
142  Unit unit() const { return _unit; }
143 
145  GmValueSetKind kind() const { return _setKind; }
146 
148  QString kindStr() const { return dataKindToStr(_setKind); }
149 
151  bool isNodeBased() const { return _setKind == GM_NODE_COORDINATES || _setKind == GM_NODE_ATTRIBUTE || _setKind == GM_NODE_STATEVAR; }
152 
154  GmStorageType storageType() const { return _storageType; }
155 
157  QString storageTypeStr() const { return storageTypeToStr(_storageType); }
158 
160  GmDimType dimType() const { return _dimType; }
161 
165  QString dimTypeStr() const { return dimTypeToStr(_dimType, _nlin, _ncol); }
166 
168  int size() const { return _nlin * _ncol; }
169 
171  int nlin() const { return _nlin; }
172 
174  int ncol() const { return _ncol; }
175 
180  bool isScalar() const { return _dimType == GM_SCALAR_VALUE; }
181 
183  const double* defValue() const { return _defValue; }
184 
186  double defScalarValue() const { assert(_dimType == GM_SCALAR_VALUE); return *_defValue; }
187 
189  bool defIsFunction() const { return !_defFunction.isEmpty(); }
190 
192  QString defFunction() const { return _defFunction; }
193 
195  bool canStoreFunctions() const { return _canStoreFunction; }
196 
198  GmAllocMode allocMode() const { return _allocMode; }
199 
201  QString allocModeStr() const { return allocModeToStr(_allocMode); }
202 
204  GmAllocStrategy allocStrategy() const { return _allocStrategy; }
205 
207  QString allocStrategyStr() const { return allocStrategyToStr(_allocStrategy); }
208 
210  GmAffectedNodes affectedNodes() const { return _affectedNodes; }
211 
213  QString affectedNodesStr() const { return affectedNodesToStr(_affectedNodes); }
214 
218  int history() const { return _history; }
219 
223  int ruleSet() const { return _ruleSet; }
224 
229  const GmBcTagInfo* tagInfo() const { return _tagInfo; }
230 
232  char format() const { return _format; }
233 
235  int fieldWidth() const { return _fieldWidth; }
236 
238  int precision() const { return _precision; }
239 
240  QString formatStr() const;
241 
243  const QMap<QString, double>& constantMap() const { return _constantMap; }
244 
246  void setUnit(Unit unit) { _unit = unit; }
247 
255  void setStorageType(GmStorageType storageType) { _storageType = storageType; }
256 
257  void setDimType(GmDimType type, int nlin = 1, int ncol = 1);
258 
259  void setDefValue(const double* val);
260  void setDefFunction(QString functionId);
261 
270  void setCanStoreFunctions(bool mode) { _canStoreFunction = mode; }
271 
279  void setAllocMode(GmAllocMode mode) { _allocMode = mode; }
280 
288  void setAllocStrategy(GmAllocStrategy strategy) { _allocStrategy = strategy; }
289 
297  void setAffectedNodes(GmAffectedNodes affNodes) { assert(isNodeBased()); _affectedNodes = affNodes; }
298 
313  void setHistory(int mode) { _history = mode; }
314 
323  void setRuleSet(int ruleSet) { _ruleSet = ruleSet; }
324 
329  void setTagInfo(GmBcTagInfo* info) { delete _tagInfo; _tagInfo = info; }
330 
332  void setFormat(int fieldWidth, char format, int precision)
333  {
334  _fieldWidth = fieldWidth;
335  _format = format;
336  _precision = precision;
337  }
338 
343  void setConstantMap(const QMap<QString, double>& map) { assert(isScalar()); _constantMap = map; }
344 
345  void print(const GmLogCategory& logger, GmLogLevel level) const;
346 
347  static QString dataKindToStr (GmValueSetKind kind);
348  static QString storageTypeToStr (GmStorageType type);
349  static QString dimTypeToStr (GmDimType type, int nlin = -1, int ncol = -1);
350  static QString allocModeToStr (GmAllocMode mode);
351  static QString allocStrategyToStr(GmAllocStrategy strategy);
352  static QString affectedNodesToStr(GmAffectedNodes affNodes);
353 
354  static GmValueInfo* loadFromTable (LuaTable& tab, GmValueSetKind kind);
355  static QList<GmValueInfo*> loadFromTableList(LuaTable& tab, GmValueSetKind kind);
356 
357 private:
358  GmValueInfo& operator=(const GmValueInfo &);
359 
369 
370  double* _defValue;
372  int _nlin;
373  int _ncol;
375  int _history;
376  int _ruleSet;
379  char _format;
381 
383 };
384 
385 #endif
386 
387 
QString affectedNodesStr() const
Returns a string representation of the affected nodes type.
Definition: gmValueInfo.h:213
Auxiliar class used to store the definition of a value. It can be used to store informations about st...
Definition: gmValueInfo.h:126
void setAffectedNodes(GmAffectedNodes affNodes)
Updates the affected nodes information. For node based values only.
Definition: gmValueInfo.h:297
QString _id
Value id.
Definition: gmValueInfo.h:360
bool _ignoreDef
Should we ignore NODE values (component) equal to the default value?
Definition: gmValueInfo.h:115
char _format
Format type ('f', 'g', 'e', 'G' or 'E') used when printing values of this type.
Definition: gmValueInfo.h:379
This value set stores attributes attached to nodes.
Definition: gmValueInfo.h:39
QString id() const
Returns the value id.
Definition: gmValueInfo.h:136
GmAllocStrategy allocStrategy() const
Returns the allocation strategy for the stored data. Default = auto.
Definition: gmValueInfo.h:204
Values are a signed 32 bits integer.
Definition: gmValueInfo.h:57
GmAllocStrategy
Allocation strategy for the stored data.
Definition: gmValueInfo.h:82
int _ruleSet
The integration rule set that this value is bound to. Used only by values with kind == GM_GAUSS_ATTRI...
Definition: gmValueInfo.h:376
bool _ignoreZero
Should we ignore NODE zero values (component)?
Definition: gmValueInfo.h:116
double defScalarValue() const
Returns the default value for scalar data types.
Definition: gmValueInfo.h:186
GmDimType
Value dimension type.
Definition: gmValueInfo.h:66
GmAffectedNodes
Affected node types for node based values (GM_NODE_COORDINATES, GM_NODE_ATTRIBUTE or GM_NODE_STATEVAR...
Definition: gmValueInfo.h:91
int _ncol
The number of columns in a matrix type (1 for scalars or arrays)
Definition: gmValueInfo.h:373
int nlin() const
Returns the number of lines in a vector type or in a matrix type or 1 for scalars.
Definition: gmValueInfo.h:171
Declaration of usefull configuration definitions for the Core library.
QString dimTypeStr() const
Returns a string representation of the dimension type: scalar, vector(n), matrix(m,...
Definition: gmValueInfo.h:165
void setAllocStrategy(GmAllocStrategy strategy)
Updates the allocation strategy used for allocating space for the data values.
Definition: gmValueInfo.h:288
Sparse data is stored as a linked list.
Definition: gmValueInfo.h:86
bool _canStoreFunction
Can values of this type be represented by functions?
Definition: gmValueInfo.h:374
This value set stores properties attached to a boundary (edge or face) for a boundary condition.
Definition: gmValueInfo.h:45
GmStorageType storageType() const
The desired storage type for data values. Might not be how the data is really stored....
Definition: gmValueInfo.h:154
int precision() const
Returns the number of decimal places used when printing values of this type.
Definition: gmValueInfo.h:238
bool isNodeBased() const
Returns true if the set kind is a node based set (node coordinates, attributes or state vars)
Definition: gmValueInfo.h:151
Values are a double.
Definition: gmValueInfo.h:55
int _nlin
The number of lines in a vector type or in a matrix type (1 for scalars)
Definition: gmValueInfo.h:372
GmAllocMode _allocMode
How should values of this type be allocated?
Definition: gmValueInfo.h:366
char format() const
Returns the format type ('f', 'g', 'e', 'G' or 'E') used when printing values of this type.
Definition: gmValueInfo.h:232
GmValueSetKind
Type describing what kind of information is stored by a values set.
Definition: gmValueInfo.h:36
A helper struct to store bc tag information.
Definition: gmValueInfo.h:105
Specifies that this value exists over mesh and ghost nodes.
Definition: gmValueInfo.h:95
const GmBcTagInfo * tagInfo() const
Returns the boundary condition tag information that this value is associated with or NULL if the obje...
Definition: gmValueInfo.h:229
GmStorageType
The desired storage type for the data.
Definition: gmValueInfo.h:53
Interface class for accessing and setting values from an "indexable" collection of values.
Definition: gmValueAccessor.h:59
QString description() const
Returns the value description.
Definition: gmValueInfo.h:139
int fieldWidth() const
Returns the field width used when printing values of this type.
Definition: gmValueInfo.h:235
void setAllocMode(GmAllocMode mode)
Updates the mode used for allocating space for the data values.
Definition: gmValueInfo.h:279
This value set stores attributes attached to cells.
Definition: gmValueInfo.h:41
int ncol() const
Returns the number of columns in a matrix type or 1 for scalars or arrays.
Definition: gmValueInfo.h:174
void setConstantMap(const QMap< QString, double > &map)
Defines the map used to translate constant names into scalar values.
Definition: gmValueInfo.h:343
The data is NOT sparse but should be allocated only when the first non default value is written.
Definition: gmValueInfo.h:78
This value set stores attributes attached to Gauss points.
Definition: gmValueInfo.h:42
GmStorageType _storageType
The desired type used to store values. Might not be equal to the type really used by a value set.
Definition: gmValueInfo.h:364
int _fieldWidth
Field width used when printing values of this type.
Definition: gmValueInfo.h:378
void setCanStoreFunctions(bool mode)
Updates weather the values associated to this definition can or cannot be functions.
Definition: gmValueInfo.h:270
Specifies that this value exists over common geometry mesh nodes only.
Definition: gmValueInfo.h:93
int _history
Does this value requires/ accepts history? -1 = no, 0 = multiple, n > 0 = 'n' rolling states.
Definition: gmValueInfo.h:375
Unit _unit
Unit in which the values are given.
Definition: gmValueInfo.h:362
The data is NOT sparse and space should be fully preallocated.
Definition: gmValueInfo.h:76
QString kindStr() const
Returns a string representation of the data kind.
Definition: gmValueInfo.h:148
QString _defFunction
A default function name if the default is a function.
Definition: gmValueInfo.h:371
GmAffectedNodes affectedNodes() const
For node based values, returns whether values are stored for nodes, ghost nodes or both (default = no...
Definition: gmValueInfo.h:210
This value set stores properties attached to a property set.
Definition: gmValueInfo.h:43
double * _defValue
Default value used for initializing/sparse values. Valid only if _defFunction is empty (0....
Definition: gmValueInfo.h:370
QMap< QString, double > _constantMap
A map associating constant names to values. Used for creating enumerated scalar values.
Definition: gmValueInfo.h:382
Sparse data is stored as run lenght encoded blocks.
Definition: gmValueInfo.h:87
This value set stores attributes attached to discontinuity sets.
Definition: gmValueInfo.h:46
bool isScalar() const
Checks the dimType to see if the value is a scalar value. This cannot be infered by size() == 1 since...
Definition: gmValueInfo.h:180
int * _tags
The set of tags. Vector size is ALWAYS equal to the associated value info object dimension....
Definition: gmValueInfo.h:114
Values are a unsigned 16 bits integer.
Definition: gmValueInfo.h:61
QString storageTypeStr() const
Returns a string representation of the desired storage type.
Definition: gmValueInfo.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
Values are a signed 8 bits integer.
Definition: gmValueInfo.h:59
Values are a unsigned 32 bits integer.
Definition: gmValueInfo.h:60
Values are a single precision float.
Definition: gmValueInfo.h:56
GmAffectedNodes _affectedNodes
Is this value stored for ghost nodes? Valid only if kind == GM_NODE_COORDINATES, GM_NODE_ATTRIBUTE or...
Definition: gmValueInfo.h:368
int ruleSet() const
Returns the integration rule set that this value is bound to. Used only by values with kind == GM_GAU...
Definition: gmValueInfo.h:223
QString allocModeStr() const
Returns a string representation of the alloc mode.
Definition: gmValueInfo.h:201
void setTagInfo(GmBcTagInfo *info)
Defines the boundary condition tag info that this value is associated with. Takes ownership of the in...
Definition: gmValueInfo.h:329
#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
GmBcTagInfo * _tagInfo
The tag information associated with this value. Can be NULL. Valid only if kind == GM_BC_NODE_PROPERT...
Definition: gmValueInfo.h:377
const double * defValue() const
Returns the default value used for initializing/sparse values. If the default is a function,...
Definition: gmValueInfo.h:183
bool defIsFunction() const
Is the default value a function?
Definition: gmValueInfo.h:189
int size() const
Returns the number of values (doubles) associated to this definition.
Definition: gmValueInfo.h:168
GmLogLevel
Available log levels list.
Definition: gmLog.h:36
This value set stores properties attached to a node for a boundary condition.
Definition: gmValueInfo.h:44
QString _description
Value description.
Definition: gmValueInfo.h:361
Class representing a category with multiple logging levels.
Definition: gmLog.h:58
Means that the value is a 2D matrix of numbers.
Definition: gmValueInfo.h:70
GmDimType dimType() const
Returns the dimension type associated to this definition (scalar, vector or matrix)
Definition: gmValueInfo.h:160
Specifies that this value exists over ghost nodes only.
Definition: gmValueInfo.h:94
Means that the value is a 1D vector of numbers.
Definition: gmValueInfo.h:69
QString allocStrategyStr() const
Returns a string representation of the alloc strategy.
Definition: gmValueInfo.h:207
void setRuleSet(int ruleSet)
Defines the integration rule set that this value is bound to. Used only by values with kind == GM_GAU...
Definition: gmValueInfo.h:323
The data is sparse.
Definition: gmValueInfo.h:77
Unit unit() const
Returns the unit in which the value is expressed.
Definition: gmValueInfo.h:142
void setFormat(int fieldWidth, char format, int precision)
Updates the format used to print values of this type.
Definition: gmValueInfo.h:332
Other kinds of value set used by the Gui / extensions.
Definition: gmValueInfo.h:47
This value set stores coordinates attached to nodes.
Definition: gmValueInfo.h:38
GmAllocStrategy _allocStrategy
Allocation strategy for the stored data.
Definition: gmValueInfo.h:367
Values are a signed 16 bits integer.
Definition: gmValueInfo.h:58
GmAllocMode allocMode() const
Returns how the values associated with this definition should be allocated. Default = auto.
Definition: gmValueInfo.h:198
void setUnit(Unit unit)
Updates the value definition unit. USe with care. Changes the way how values are interpreted,...
Definition: gmValueInfo.h:246
QString defFunction() const
Returns the name of the function used as default.
Definition: gmValueInfo.h:192
GmValueSetKind _setKind
What kind of information is stored.
Definition: gmValueInfo.h:363
void setStorageType(GmStorageType storageType)
Updates the requested storage type of values bound to this definition.
Definition: gmValueInfo.h:255
Values are a unsigned 8 bits integer.
Definition: gmValueInfo.h:62
This value set stores state variables attached to nodes.
Definition: gmValueInfo.h:40
bool canStoreFunctions() const
Returns true if values associated to this definition can be expressed as functions....
Definition: gmValueInfo.h:195
Means that the value is a scalar number.
Definition: gmValueInfo.h:68
Framework defined strategy.
Definition: gmValueInfo.h:84
void setHistory(int mode)
Defines if this value should store only one value (default) or several versions of the value,...
Definition: gmValueInfo.h:313
GmValueSetKind kind() const
Returns the kind of information associated to this definition.
Definition: gmValueInfo.h:145
int _precision
Number of decimal places used when printing values of this type.
Definition: gmValueInfo.h:380
GmAllocMode
Type describing how the data space should be allocated.
Definition: gmValueInfo.h:74
GmDimType _dimType
The dimension type of the values.
Definition: gmValueInfo.h:365
Sparse data is stored in a hash table.
Definition: gmValueInfo.h:85
int history() const
Returns -1 if the value does not have history support, 0 for unlimited history levels and n > 0 for a...
Definition: gmValueInfo.h:218
Declaration of support functions and macros for information logging.