GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
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
29class LuaTable;
30class GmValueAccessor;
31
32#include <QString>
33#include <unit.h>
34
52
55{
64 // --- DO NOT INSERT ANYTHING BELLOW THIS LINE ---
65 // IMPORTANT: When adding an entry to this enum or if changing enum order, please make sure
66 // to update the sizeofStorageType() function
67 GM_NUM_STORAGE_TYPE
68};
69
77
85
94
102
103#define GM_VALUE_INFO_DEFAULT_FORMAT_WIDTH 12
104#define GM_VALUE_INFO_DEFAULT_FORMAT 'f'
105#define GM_VALUE_INFO_DEFAULT_FORMAT_PREC 2
106#define GM_VALUE_INFO_DEFAULT_FORMAT_STR "12.2f"
107
108
111{
112 GmBcTagInfo(int size);
113 ~GmBcTagInfo();
114
119 int* _tags;
122private:
123 Q_DISABLE_COPY(GmBcTagInfo)
124};
125
126
132{
133public:
134 GmValueInfo(QString id, QString description, Unit unit, GmValueSetKind kind,
135 GmDimType dimType = GM_SCALAR_VALUE, int nlin = 1, int ncol = 1);
136 GmValueInfo(const GmValueInfo &);
137
138 virtual ~GmValueInfo();
139
141 QString id() const { return _id; }
142
144 QString description() const { return _description; }
145
147 Unit unit() const { return _unit; }
148
150 GmValueSetKind kind() const { return _setKind; }
151
153 QString kindStr() const { return dataKindToStr(_setKind); }
154
156 bool isNodeBased() const { return _setKind == GM_NODE_COORDINATES || _setKind == GM_NODE_ATTRIBUTE || _setKind == GM_NODE_STATEVAR; }
157
159 bool isCellBased() const { return _setKind == GM_CELL_ATTRIBUTE || _setKind == GM_CELL_STATEVAR || _setKind == GM_GAUSS_ATTRIBUTE; }
160
162 GmStorageType storageType() const { return _storageType; }
163
164 int sizeofStorageType() const;
165
167 QString storageTypeStr() const { return storageTypeToStr(_storageType); }
168
170 GmDimType dimType() const { return _dimType; }
171
175 QString dimTypeStr() const { return dimTypeToStr(_dimType, _nlin, _ncol); }
176
178 int size() const { return _nlin * _ncol; }
179
181 int nlin() const { return _nlin; }
182
184 int ncol() const { return _ncol; }
185
190 bool isScalar() const { return _dimType == GM_SCALAR_VALUE; }
191
193 const double* defValue() const { return _defValue; }
194
196 double defScalarValue() const { assert(_dimType == GM_SCALAR_VALUE); return *_defValue; }
197
199 bool defIsFunction() const { return !_defFunction.isEmpty(); }
200
202 QString defFunction() const { return _defFunction; }
203
205 bool canStoreFunctions() const { return _canStoreFunction; }
206
208 GmAllocMode allocMode() const { return _allocMode; }
209
211 QString allocModeStr() const { return allocModeToStr(_allocMode); }
212
214 GmAllocStrategy allocStrategy() const { return _allocStrategy; }
215
217 QString allocStrategyStr() const { return allocStrategyToStr(_allocStrategy); }
218
220 GmAffectedNodes affectedNodes() const { return _affectedNodes; }
221
223 QString affectedNodesStr() const { return affectedNodesToStr(_affectedNodes); }
224
228 int history() const { return _history; }
229
233 int ruleSet() const { return _ruleSet; }
234
240 int pack() const { return _pack; }
241
246 const GmBcTagInfo* tagInfo() const { return _tagInfo; }
247
249 char format() const { return _format; }
250
252 int fieldWidth() const { return _fieldWidth; }
253
255 int precision() const { return _precision; }
256
257 QString formatStr() const;
258
260 const QMap<QString, double>& constantMap() const { return _constantMap; }
261
269 void setKind(GmValueSetKind kind) { _setKind = kind; }
270
272 void setUnit(Unit unit) { _unit = unit; }
273
281 void setStorageType(GmStorageType storageType) { _storageType = storageType; }
282
283 void setDimType(GmDimType type, int nlin = 1, int ncol = 1);
284
285 void setDefValue(const double* val);
286 void setDefFunction(QString functionId);
287
296 void setCanStoreFunctions(bool mode) { _canStoreFunction = mode; }
297
305 void setAllocMode(GmAllocMode mode) { _allocMode = mode; }
306
314 void setAllocStrategy(GmAllocStrategy strategy) { _allocStrategy = strategy; }
315
323 void setAffectedNodes(GmAffectedNodes affNodes) { assert(isNodeBased()); _affectedNodes = affNodes; }
324
339 void setHistory(int mode) { _history = mode; }
340
349 void setRuleSet(int ruleSet) { _ruleSet = ruleSet; }
350
362 void setPack(int packId) { assert(packId >= -1); _pack = packId; }
363
368 void setTagInfo(GmBcTagInfo* info) { delete _tagInfo; _tagInfo = info; }
369
371 void setFormat(int fieldWidth, char format, int precision)
372 {
373 _fieldWidth = fieldWidth;
374 _format = format;
375 _precision = precision;
376 }
377
382 void setConstantMap(const QMap<QString, double>& map) { assert(isScalar()); _constantMap = map; }
383
384 void print(const GmLogCategory& logger, GmLogLevel level) const;
385
386 static QString dataKindToStr (GmValueSetKind kind);
387 static QString storageTypeToStr (GmStorageType type);
388 static QString dimTypeToStr (GmDimType type, int nlin = -1, int ncol = -1);
389 static QString allocModeToStr (GmAllocMode mode);
390 static QString allocStrategyToStr(GmAllocStrategy strategy);
391 static QString affectedNodesToStr(GmAffectedNodes affNodes);
392
393 static GmValueInfo* loadFromTable (LuaTable& tab, GmValueSetKind kind);
394 static QList<GmValueInfo*> loadFromTableList(LuaTable& tab, GmValueSetKind kind);
395
396private:
397 GmValueInfo& operator=(const GmValueInfo &);
398
408
409 double* _defValue;
411 int _nlin;
412 int _ncol;
416 int _pack;
419 char _format;
421
423};
424
425#endif
426
427
Class representing a category with multiple logging levels.
Definition gmLog.h:58
Interface class for accessing and setting values from an "indexable" collection of values.
Definition gmValueAccessor.h:60
Auxiliar class used to store the definition of a value. It can be used to store informations about st...
Definition gmValueInfo.h:132
int _precision
Number of decimal places used when printing values of this type.
Definition gmValueInfo.h:420
void setAllocMode(GmAllocMode mode)
Updates the mode used for allocating space for the data values.
Definition gmValueInfo.h:305
void setPack(int packId)
Updates the pack to which this value belongs. Used to combine values in an interleaved buffer....
Definition gmValueInfo.h:362
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:349
GmBcTagInfo * _tagInfo
The tag information associated with this value. Can be NULL. Valid only if kind == GM_BC_NODE_PROPERT...
Definition gmValueInfo.h:417
int _nlin
The number of lines in a vector type or in a matrix type (1 for scalars)
Definition gmValueInfo.h:411
GmAffectedNodes affectedNodes() const
For node based values, returns whether values are stored for nodes, ghost nodes or both (default = no...
Definition gmValueInfo.h:220
bool isCellBased() const
Returns true if the set kind is a cell based set (cell or gauss attributes)
Definition gmValueInfo.h:159
GmStorageType storageType() const
The desired storage type for data values. Might not be how the data is really stored....
Definition gmValueInfo.h:162
void setTagInfo(GmBcTagInfo *info)
Defines the boundary condition tag info that this value is associated with. Takes ownership of the in...
Definition gmValueInfo.h:368
void setCanStoreFunctions(bool mode)
Updates weather the values associated to this definition can or cannot be functions.
Definition gmValueInfo.h:296
bool defIsFunction() const
Is the default value a function?
Definition gmValueInfo.h:199
Unit unit() const
Returns the unit in which the value is expressed.
Definition gmValueInfo.h:147
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:228
QMap< QString, double > _constantMap
A map associating constant names to values. Used for creating enumerated scalar values.
Definition gmValueInfo.h:422
GmAllocMode allocMode() const
Returns how the values associated with this definition should be allocated. Default = auto.
Definition gmValueInfo.h:208
void setUnit(Unit unit)
Updates the value definition unit. Use with care. Changes the way how values are interpreted,...
Definition gmValueInfo.h:272
bool canStoreFunctions() const
Returns true if values associated to this definition can be expressed as functions....
Definition gmValueInfo.h:205
int ncol() const
Returns the number of columns in a matrix type or 1 for scalars or arrays.
Definition gmValueInfo.h:184
void setAffectedNodes(GmAffectedNodes affNodes)
Updates the affected nodes information. For node based values only.
Definition gmValueInfo.h:323
void setHistory(int mode)
Defines if this value should store only one value (default) or several versions of the value,...
Definition gmValueInfo.h:339
QString _description
Value description.
Definition gmValueInfo.h:400
QString id() const
Returns the value id.
Definition gmValueInfo.h:141
QString dimTypeStr() const
Returns a string representation of the dimension type: scalar, vector(n), matrix(m,...
Definition gmValueInfo.h:175
GmValueSetKind _setKind
What kind of information is stored.
Definition gmValueInfo.h:402
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:233
int _ncol
The number of columns in a matrix type (1 for scalars or arrays)
Definition gmValueInfo.h:412
int precision() const
Returns the number of decimal places used when printing values of this type.
Definition gmValueInfo.h:255
void setFormat(int fieldWidth, char format, int precision)
Updates the format used to print values of this type.
Definition gmValueInfo.h:371
char _format
Format type ('f', 'g', 'e', 'G' or 'E') used when printing values of this type.
Definition gmValueInfo.h:419
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:190
void setAllocStrategy(GmAllocStrategy strategy)
Updates the allocation strategy used for allocating space for the data values.
Definition gmValueInfo.h:314
QString affectedNodesStr() const
Returns a string representation of the affected nodes type.
Definition gmValueInfo.h:223
QString _id
Value id.
Definition gmValueInfo.h:399
int _fieldWidth
Field width used when printing values of this type.
Definition gmValueInfo.h:418
const double * defValue() const
Returns the default value used for initializing/sparse values. If the default is a function,...
Definition gmValueInfo.h:193
int _ruleSet
The integration rule set that this value is bound to. Used only by values with kind == GM_GAUSS_ATTRI...
Definition gmValueInfo.h:415
QString _defFunction
A default function name if the default is a function.
Definition gmValueInfo.h:410
QString allocModeStr() const
Returns a string representation of the alloc mode.
Definition gmValueInfo.h:211
QString allocStrategyStr() const
Returns a string representation of the alloc strategy.
Definition gmValueInfo.h:217
Unit _unit
Unit in which the values are given.
Definition gmValueInfo.h:401
const GmBcTagInfo * tagInfo() const
Returns the boundary condition tag information that this value is associated with or NULL if the obje...
Definition gmValueInfo.h:246
bool isNodeBased() const
Returns true if the set kind is a node based set (node coordinates, attributes or state vars)
Definition gmValueInfo.h:156
int _pack
The number of the pack in which this value is stored when working with interleaved groups of values.
Definition gmValueInfo.h:416
int size() const
Returns the number of values (doubles) associated to this definition.
Definition gmValueInfo.h:178
GmDimType _dimType
The dimension type of the values.
Definition gmValueInfo.h:404
GmAllocStrategy allocStrategy() const
Returns the allocation strategy for the stored data. Default = auto.
Definition gmValueInfo.h:214
QString description() const
Returns the value description.
Definition gmValueInfo.h:144
QString defFunction() const
Returns the name of the function used as default.
Definition gmValueInfo.h:202
GmDimType dimType() const
Returns the dimension type associated to this definition (scalar, vector or matrix)
Definition gmValueInfo.h:170
int fieldWidth() const
Returns the field width used when printing values of this type.
Definition gmValueInfo.h:252
double defScalarValue() const
Returns the default value for scalar data types.
Definition gmValueInfo.h:196
int _history
Does this value requires/ accepts history? -1 = no, 0 = multiple, n > 0 = 'n' rolling states.
Definition gmValueInfo.h:414
GmValueSetKind kind() const
Returns the kind of information associated to this definition.
Definition gmValueInfo.h:150
GmAllocMode _allocMode
How should values of this type be allocated?
Definition gmValueInfo.h:405
int pack() const
Returns the pack number for this value. A value > 0 defines a pack id. A value of 0 means that the va...
Definition gmValueInfo.h:240
double * _defValue
Default value used for initializing/sparse values. Valid only if _defFunction is empty (0....
Definition gmValueInfo.h:409
void setKind(GmValueSetKind kind)
Updates the value set kind. Use with care.
Definition gmValueInfo.h:269
QString kindStr() const
Returns a string representation of the data kind.
Definition gmValueInfo.h:153
void setStorageType(GmStorageType storageType)
Updates the requested storage type of values bound to this definition.
Definition gmValueInfo.h:281
QString storageTypeStr() const
Returns a string representation of the desired storage type.
Definition gmValueInfo.h:167
void setConstantMap(const QMap< QString, double > &map)
Defines the map used to translate constant names into scalar values.
Definition gmValueInfo.h:382
GmAllocStrategy _allocStrategy
Allocation strategy for the stored data.
Definition gmValueInfo.h:406
char format() const
Returns the format type ('f', 'g', 'e', 'G' or 'E') used when printing values of this type.
Definition gmValueInfo.h:249
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:403
bool _canStoreFunction
Can values of this type be represented by functions?
Definition gmValueInfo.h:413
int nlin() const
Returns the number of lines in a vector type or in a matrix type or 1 for scalars.
Definition gmValueInfo.h:181
GmAffectedNodes _affectedNodes
Is this value stored for ghost nodes? Valid only if kind == GM_NODE_COORDINATES, GM_NODE_ATTRIBUTE or...
Definition gmValueInfo.h:407
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
Declaration of support functions and macros for information logging.
GmLogLevel
Available log levels list.
Definition gmLog.h:36
GmAllocStrategy
Allocation strategy for the stored data.
Definition gmValueInfo.h:88
@ GM_STRATEGY_SPARSE_HASH
Sparse data is stored in a hash table.
Definition gmValueInfo.h:90
@ GM_STRATEGY_AUTO
Framework defined strategy.
Definition gmValueInfo.h:89
@ GM_STRATEGY_SPARSE_LINKED
Sparse data is stored as a linked list.
Definition gmValueInfo.h:91
@ GM_STRATEGY_SPARSE_RLE
Sparse data is stored as run lenght encoded blocks.
Definition gmValueInfo.h:92
GmStorageType
The desired storage type for the data.
Definition gmValueInfo.h:55
@ GM_INT32_TYPE
Values are a signed 32 bits integer.
Definition gmValueInfo.h:58
@ GM_BYTE_TYPE
Values are a signed 8 bits integer.
Definition gmValueInfo.h:60
@ GM_DOUBLE_TYPE
Values are a double.
Definition gmValueInfo.h:56
@ GM_UINT32_TYPE
Values are a unsigned 32 bits integer.
Definition gmValueInfo.h:61
@ GM_FLOAT_TYPE
Values are a single precision float.
Definition gmValueInfo.h:57
@ GM_UBYTE_TYPE
Values are a unsigned 8 bits integer.
Definition gmValueInfo.h:63
@ GM_INT16_TYPE
Values are a signed 16 bits integer.
Definition gmValueInfo.h:59
@ GM_UINT16_TYPE
Values are a unsigned 16 bits integer.
Definition gmValueInfo.h:62
GmAllocMode
Type describing how the data space should be allocated.
Definition gmValueInfo.h:80
@ GM_ALLOC_AUTO
The data is NOT sparse but should be allocated only when the first non default value is written.
Definition gmValueInfo.h:83
@ GM_ALLOC_SPARSE
The data is sparse.
Definition gmValueInfo.h:82
@ GM_ALLOC_FULL
The data is NOT sparse and space should be fully preallocated.
Definition gmValueInfo.h:81
GmAffectedNodes
Affected node types for node based values (GM_NODE_COORDINATES, GM_NODE_ATTRIBUTE or GM_NODE_STATEVAR...
Definition gmValueInfo.h:97
@ GM_GHOST_NODE
Specifies that this value exists over ghost nodes only.
Definition gmValueInfo.h:99
@ GM_BOTH
Specifies that this value exists over mesh and ghost nodes.
Definition gmValueInfo.h:100
@ GM_GEOMETRY_NODE
Specifies that this value exists over common geometry mesh nodes only.
Definition gmValueInfo.h:98
GmDimType
Value dimension type.
Definition gmValueInfo.h:72
@ GM_SCALAR_VALUE
Means that the value is a scalar number.
Definition gmValueInfo.h:73
@ GM_MATRIX_VALUE
Means that the value is a 2D matrix of numbers.
Definition gmValueInfo.h:75
@ GM_VECTOR_VALUE
Means that the value is a 1D vector of numbers.
Definition gmValueInfo.h:74
GmValueSetKind
Type describing what kind of information is stored by a values set.
Definition gmValueInfo.h:37
@ GM_PSET_PROPERTY
This value set stores properties attached to a property set.
Definition gmValueInfo.h:44
@ GM_GAUSS_ATTRIBUTE
This value set stores attributes attached to Gauss points.
Definition gmValueInfo.h:43
@ GM_BC_NODE_PROPERTY
This value set stores properties attached to a node for a boundary condition.
Definition gmValueInfo.h:45
@ GM_BC_BOUNDARY_PROPERTY
This value set stores properties attached to a boundary (edge or face) for a boundary condition.
Definition gmValueInfo.h:46
@ GM_NODE_ATTRIBUTE
This value set stores attributes attached to nodes.
Definition gmValueInfo.h:39
@ GM_NODE_COORDINATES
This value set stores coordinates attached to nodes.
Definition gmValueInfo.h:38
@ GM_CELL_ATTRIBUTE
This value set stores attributes attached to cells.
Definition gmValueInfo.h:41
@ GM_DS_ATTRIBUTE
This value set stores attributes attached to discontinuity sets.
Definition gmValueInfo.h:47
@ GM_NODE_STATEVAR
This value set stores state variables attached to nodes.
Definition gmValueInfo.h:40
@ GM_USER
Other kinds of value set used by the Gui / extensions.
Definition gmValueInfo.h:48
@ GM_CELL_STATEVAR
This value set stores state variables attached to cells.
Definition gmValueInfo.h:42
A helper struct to store bc tag information.
Definition gmValueInfo.h:111
bool _ignoreDef
Should we ignore NODE values (component) equal to the default value?
Definition gmValueInfo.h:120
bool _ignoreZero
Should we ignore NODE zero values (component)?
Definition gmValueInfo.h:121
int * _tags
The set of tags. Vector size is ALWAYS equal to the associated value info object dimension....
Definition gmValueInfo.h:119