GemaCoreLib
The GeMA Core library
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
GmValueInfo Class Reference

Auxiliar class used to store the definition of a value. It can be used to store informations about state variables, attributes and properties. More...

#include <gmValueInfo.h>

Collaboration diagram for GmValueInfo:
Collaboration graph
[legend]

Public Member Functions

 GmValueInfo (QString id, QString description, Unit unit, GmValueSetKind kind, GmDimType dimType=GM_SCALAR_VALUE, int nlin=1, int ncol=1)
 Constructor.
 
 GmValueInfo (const GmValueInfo &)
 Copy constructor.
 
virtual ~GmValueInfo ()
 Destructor.
 
QString id () const
 Returns the value id.
 
QString description () const
 Returns the value description.
 
Unit unit () const
 Returns the unit in which the value is expressed.
 
GmValueSetKind kind () const
 Returns the kind of information associated to this definition.
 
QString kindStr () const
 Returns a string representation of the data kind.
 
bool isNodeBased () const
 Returns true if the set kind is a node based set (node coordinates, attributes or state vars)
 
GmStorageType storageType () const
 The desired storage type for data values. Might not be how the data is really stored. (default = double).
 
QString storageTypeStr () const
 Returns a string representation of the desired storage type.
 
GmDimType dimType () const
 Returns the dimension type associated to this definition (scalar, vector or matrix)
 
QString dimTypeStr () const
 Returns a string representation of the dimension type: scalar, vector(n), matrix(m,n) where m and n are the relevant sizes.
 
int size () const
 Returns the number of values (doubles) associated to this definition.
 
int nlin () const
 Returns the number of lines in a vector type or in a matrix type or 1 for scalars.
 
int ncol () const
 Returns the number of columns in a matrix type or 1 for scalars or arrays.
 
bool isScalar () const
 Checks the dimType to see if the value is a scalar value. This cannot be infered by size() == 1 since we can have a 1x1 matrix!
 
const double * defValue () const
 Returns the default value used for initializing/sparse values. If the default is a function, returns a vector filled with 0.0.
 
double defScalarValue () const
 Returns the default value for scalar data types.
 
bool defIsFunction () const
 Is the default value a function?
 
QString defFunction () const
 Returns the name of the function used as default.
 
bool canStoreFunctions () const
 Returns true if values associated to this definition can be expressed as functions. Default = false.
 
GmAllocMode allocMode () const
 Returns how the values associated with this definition should be allocated. Default = auto.
 
QString allocModeStr () const
 Returns a string representation of the alloc mode.
 
GmAllocStrategy allocStrategy () const
 Returns the allocation strategy for the stored data. Default = auto.
 
QString allocStrategyStr () const
 Returns a string representation of the alloc strategy.
 
GmAffectedNodes affectedNodes () const
 For node based values, returns whether values are stored for nodes, ghost nodes or both (default = node only)
 
QString affectedNodesStr () const
 Returns a string representation of the affected nodes type.
 
int history () const
 Returns -1 if the value does not have history support, 0 for unlimited history levels and n > 0 for a rolling history with 'n' levels.
 
int ruleSet () const
 Returns the integration rule set that this value is bound to. Used only by values with kind == GM_GAUSS_ATTRIBUTE.
 
const GmBcTagInfotagInfo () const
 Returns the boundary condition tag information that this value is associated with or NULL if the object doesn't have a tag. Used only by values with kind == GM_BC_NODE_PROPERTY or GM_BC_BOUNDARY_PROPERTY.
 
char format () const
 Returns the format type ('f', 'g', 'e', 'G' or 'E') used when printing values of this type.
 
int fieldWidth () const
 Returns the field width used when printing values of this type.
 
int precision () const
 Returns the number of decimal places used when printing values of this type.
 
QString formatStr () const
 Returns the map associating constant names to scalar values. Used for creating enumerated values. Usually empty. More...
 
const QMap< QString, double > & constantMap () const
 
void setUnit (Unit unit)
 Updates the value definition unit. USe with care. Changes the way how values are interpreted, and NOT the values itself.
 
void setStorageType (GmStorageType storageType)
 Updates the requested storage type of values bound to this definition. More...
 
void setDimType (GmDimType type, int nlin=1, int ncol=1)
 Updates the dimension type for values bound to this definition. More...
 
void setDefValue (const double *val)
 Updates the default value bound to this definition. The supplied parameter must be a vector with size equal to the result of GmValueInfo::size() More...
 
void setDefFunction (QString functionId)
 Updates the default value bound to this definition with a function name.
 
void setCanStoreFunctions (bool mode)
 Updates weather the values associated to this definition can or cannot be functions. More...
 
void setAllocMode (GmAllocMode mode)
 Updates the mode used for allocating space for the data values. More...
 
void setAllocStrategy (GmAllocStrategy strategy)
 Updates the allocation strategy used for allocating space for the data values. More...
 
void setAffectedNodes (GmAffectedNodes affNodes)
 Updates the affected nodes information. For node based values only. More...
 
void setHistory (int mode)
 Defines if this value should store only one value (default) or several versions of the value, forming a value history. More...
 
void setRuleSet (int ruleSet)
 Defines the integration rule set that this value is bound to. Used only by values with kind == GM_GAUSS_ATTRIBUTE. More...
 
void setTagInfo (GmBcTagInfo *info)
 Defines the boundary condition tag info that this value is associated with. Takes ownership of the info structure, that should have been allocated on the heap. Used only by values with kind == GM_BC_NODE_PROPERTY or GM_BC_BOUNDARY_PROPERTY.
 
void setFormat (int fieldWidth, char format, int precision)
 Updates the format used to print values of this type.
 
void setConstantMap (const QMap< QString, double > &map)
 Defines the map used to translate constant names into scalar values. More...
 
void print (const GmLogCategory &logger, GmLogLevel level) const
 Print information to the specified loggers and log level.
 

Static Public Member Functions

static QString dataKindToStr (GmValueSetKind kind)
 Returns a string representation of the data kind.
 
static QString storageTypeToStr (GmStorageType type)
 Returns a string representation of the desired storage type.
 
static QString dimTypeToStr (GmDimType type, int nlin=-1, int ncol=-1)
 Returns a string representation of the dimension type: scalar, vector(nlin), matrix(nlin,ncol). The sizes are ommited if the relevant parameters nlin and/or ncol are -1.
 
static QString allocModeToStr (GmAllocMode mode)
 Returns a string representation for the allocation mode.
 
static QString allocStrategyToStr (GmAllocStrategy strategy)
 Returns a string representation for the allocation strategy.
 
static QString affectedNodesToStr (GmAffectedNodes affNodes)
 Returns a string representation for the storage type.
 
static GmValueInfoloadFromTable (LuaTable &tab, GmValueSetKind kind)
 Factory function that creates a GmValueInfo object filled with data defined by the lua table tab and specified kind. More...
 
static QList< GmValueInfo * > loadFromTableList (LuaTable &tab, GmValueSetKind kind)
 Returns a list of GmValueInfo objects read from a lua table. Each table entry should be another table defining a value info, as expected by loadFromTable()
 

Private Member Functions

GmValueInfooperator= (const GmValueInfo &)
 

Private Attributes

QString _id
 Value id.
 
QString _description
 Value description.
 
Unit _unit
 Unit in which the values are given.
 
GmValueSetKind _setKind
 What kind of information is stored.
 
GmStorageType _storageType
 The desired type used to store values. Might not be equal to the type really used by a value set.
 
GmDimType _dimType
 The dimension type of the values.
 
GmAllocMode _allocMode
 How should values of this type be allocated?
 
GmAllocStrategy _allocStrategy
 Allocation strategy for the stored data.
 
GmAffectedNodes _affectedNodes
 Is this value stored for ghost nodes? Valid only if kind == GM_NODE_COORDINATES, GM_NODE_ATTRIBUTE or GM_NODE_STATEVAR.
 
double * _defValue
 Default value used for initializing/sparse values. Valid only if _defFunction is empty (0.0 in that case).
 
QString _defFunction
 A default function name if the default is a function.
 
int _nlin
 The number of lines in a vector type or in a matrix type (1 for scalars)
 
int _ncol
 The number of columns in a matrix type (1 for scalars or arrays)
 
bool _canStoreFunction
 Can values of this type be represented by functions?
 
int _history
 Does this value requires/ accepts history? -1 = no, 0 = multiple, n > 0 = 'n' rolling states.
 
int _ruleSet
 The integration rule set that this value is bound to. Used only by values with kind == GM_GAUSS_ATTRIBUTE.
 
GmBcTagInfo_tagInfo
 The tag information associated with this value. Can be NULL. Valid only if kind == GM_BC_NODE_PROPERTY or GM_BC_BOUNDARY_PROPERTY.
 
int _fieldWidth
 Field width used when printing values of this type.
 
char _format
 Format type ('f', 'g', 'e', 'G' or 'E') used when printing values of this type.
 
int _precision
 Number of decimal places used when printing values of this type.
 
QMap< QString, double > _constantMap
 A map associating constant names to values. Used for creating enumerated scalar values.
 

Detailed Description

Auxiliar class used to store the definition of a value. It can be used to store informations about state variables, attributes and properties.

Member Function Documentation

◆ formatStr()

QString GmValueInfo::formatStr ( ) const

Returns the map associating constant names to scalar values. Used for creating enumerated values. Usually empty.

Returns a string representation of the numeric format in C printf style.

◆ loadFromTable()

GmValueInfo * GmValueInfo::loadFromTable ( LuaTable tab,
GmValueSetKind  kind 
)
static

Factory function that creates a GmValueInfo object filled with data defined by the lua table tab and specified kind.

The value is initialized with the data found in the table. No validation is made. This function expects that a validation step has been done elsewhere.

◆ setAffectedNodes()

void GmValueInfo::setAffectedNodes ( GmAffectedNodes  affNodes)
inline

Updates the affected nodes information. For node based values only.

Please notice that setting this property after values are stored based on previous definitions will probably change nothing. This function should be called after object creation but BEFORE any values attached to this definition are stored in a mesh.

◆ setAllocMode()

void GmValueInfo::setAllocMode ( GmAllocMode  mode)
inline

Updates the mode used for allocating space for the data values.

Please notice that setting this property after values are stored based on previous definitions will probably change nothing. This function should be called after object creation but BEFORE any values attached to this definition are stored in a mesh.

◆ setAllocStrategy()

void GmValueInfo::setAllocStrategy ( GmAllocStrategy  strategy)
inline

Updates the allocation strategy used for allocating space for the data values.

Please notice that setting this property after values are stored based on previous definitions will probably change nothing. This function should be called after object creation but BEFORE any values attached to this definition are stored in a mesh.

◆ setCanStoreFunctions()

void GmValueInfo::setCanStoreFunctions ( bool  mode)
inline

Updates weather the values associated to this definition can or cannot be functions.

Please notice that setting this property after values are stored based on previous definitions will probably change nothing. This function should be called after object creation but BEFORE any values attached to this definition are stored in a mesh.

◆ setConstantMap()

void GmValueInfo::setConstantMap ( const QMap< QString, double > &  map)
inline

Defines the map used to translate constant names into scalar values.

Currently available for scalar values only

◆ setDefValue()

void GmValueInfo::setDefValue ( const double *  val)

Updates the default value bound to this definition. The supplied parameter must be a vector with size equal to the result of GmValueInfo::size()

If this function is not called, a vector filled with 0.0 is used as default.

Please notice that setting this property after values are stored based on previous definitions will probably change nothing. This function should be called after object creation but BEFORE any values attached to this definition are stored in a mesh. If a call to setDataType() is made, this call should happend AFTER that.

◆ setDimType()

void GmValueInfo::setDimType ( GmDimType  type,
int  nlin = 1,
int  ncol = 1 
)

Updates the dimension type for values bound to this definition.

Please notice that setting this property after values are stored based on previous definitions will probably change nothing. This function should be called after object creation but BEFORE any values attached to this definition are stored in a mesh.

IMPORTANT: This function adjusts the default value vector so it should be called PRIORLY to setting default values

Note that scalar types should be called with nlin == 1 and ncol == 1, and vector types with ncol == 1. Default values already obey this rule.

◆ setHistory()

void GmValueInfo::setHistory ( int  mode)
inline

Defines if this value should store only one value (default) or several versions of the value, forming a value history.

The mode parameter controls the history type. A value of -1 means no history. A 0 means that the value can have an unlimited number of history values and a value 'n', n > 0 means that the history keeps n states that are 'rolled' over time.

If this function is not called, no history is enabled.

Please notice that NOT every value container supports history and that this function should probably be called after object creation but BEFORE any values attached to this definition are stored in a mesh.

◆ setRuleSet()

void GmValueInfo::setRuleSet ( int  ruleSet)
inline

Defines the integration rule set that this value is bound to. Used only by values with kind == GM_GAUSS_ATTRIBUTE.

Please notice that setting this property after values are stored on Gauss attributes based on previous definitions will probably change nothing. This function should be called after object creation but BEFORE any values attached to this definition are stored in a mesh.

◆ setStorageType()

void GmValueInfo::setStorageType ( GmStorageType  storageType)
inline

Updates the requested storage type of values bound to this definition.

Please notice that setting this property after values are stored based on previous definitions will probably change nothing. This function should be called after object creation but BEFORE any values attached to this definition are stored in a mesh.


The documentation for this class was generated from the following files: