23 #ifndef _GEMA_VALUE_ACCESSOR_H_ 24 #define _GEMA_VALUE_ACCESSOR_H_ 68 virtual int size()
const = 0;
76 bool isScalar()
const {
return info()->isScalar(); }
81 virtual bool isDefValue(
int index)
const = 0;
87 virtual const double*
defValue()
const {
return convertToAccessorUnit(info()->
defValue()); }
94 virtual Unit unit()
const = 0;
97 virtual bool hasUnitConversion()
const = 0;
126 virtual int adjustLinearIndex(
int index,
int firstGhostIndex) { Q_UNUSED(firstGhostIndex);
return (index < size()) ? index : -1; }
155 virtual const double* valueAt(
int index,
const GmVector* coord)
const = 0;
158 const double*
value(
int index)
const {
return valueAt(index, NULL); }
161 virtual double scalarValueAt(
int index,
const GmVector* coord)
const = 0;
164 double scalarValue(
int index)
const {
return scalarValueAt(index, NULL); }
171 mat.
setMemory(valueAt(index, coord), info()->nlin(), info()->ncol());
182 vec.
setMemory(valueAt(index, coord), info()->size());
200 virtual bool setValue(
int index,
const double* value) = 0;
203 virtual bool setScalarValue(
int index,
double value) = 0;
213 assert(dim >= 0 && dim < n);
215 memcpy(data.
data(), value(index), n *
sizeof(double));
217 return setValue(index, data.
data());
221 virtual bool setValueAsDef(
int index) = 0;
226 assert(info()->dimType() ==
GM_MATRIX_VALUE && info()->nlin() == (
int)mat.n_rows && info()->ncol() == (
int)mat.n_cols);
227 return setValue(index, mat.memptr());
233 assert(info()->dimType() !=
GM_MATRIX_VALUE && info()->nlin() == (
int)vec.n_rows);
234 return setValue(index, vec.memptr());
240 return setScalarValue(index, scalarValue(index) + value);
251 const double* v = value(index);
252 for(
int i = 0; i<n; i++)
253 data[i] = v[i] + val[i];
254 return setValue(index, data.
data());
263 virtual bool setFunctionValue(
int index,
GmUserFunction* functionDef) = 0;
288 virtual QString valueStr(
int index,
bool evalFunctions,
bool printDefAsNil,
289 int fieldWidth = 0,
char format =
'g',
int precision = -1,
290 const GmVector* coord = NULL)
const = 0;
297 virtual bool setFunctionFromName(
int index,
QString userFunctionId,
QString& err) = 0;
316 virtual bool setValueFromVariant(
int index,
const QVariant& v,
bool acceptMissingDimension,
QString& err) = 0;
321 virtual bool isFunction(
int index)
const = 0;
326 virtual QString functionId(
int index)
const = 0;
344 virtual double convertToAccessorUnit(
double val)
const = 0;
350 virtual const double* convertToAccessorUnit(
const double* p)
const = 0;
353 virtual void convertFromAccessorUnit(
double val,
double* dst)
const = 0;
356 virtual void convertFromAccessorUnit(
const double* val,
double* dst)
const = 0;
380 virtual QString valueStr(
int index,
bool evalFunctions,
bool printDefAsNil,
381 int fieldWidth = 0,
char format =
'g',
int precision = -1,
382 const GmVector* coord = NULL)
const;
390 static bool fillMatrixFromLuaTable(
double* m,
int nlin,
int ncol,
LuaTable& t,
const GmValueInfo* info,
const double* defVal,
QString& err);
397 const double* evalDefValue(
int index,
const GmVector* coord)
const;
404 double* convData()
const { assert(_convData);
return _convData->localBuffer(); }
419 bool _ownsEvalContext;
Auxiliar class used to store the definition of a value. It can be used to store informations about st...
Definition: gmValueInfo.h:126
virtual bool hasUnitConversion() const
Returns true if this accessor perfroms unit conversions, false if not.
Definition: gmValueAccessor.h:378
virtual GmValueInfo * info() const
Returns the information object describing the values returned by this accessor.
Definition: gmValueAccessor.h:372
void vectorValue(int index, GmCRVector &vec) const
Similar to vectorValueAt(), passing NULL as coordinates.
Definition: gmValueAccessor.h:186
bool isScalar() const
Returns true if the accessor returns scalar values (can be false even if valueSize() == 1 – think abo...
Definition: gmValueAccessor.h:76
bool addToValue(int index, const double *val)
Convenience function logically equivalent to calling setValue(index, value(index) + val) operating ov...
Definition: gmValueAccessor.h:247
void matrixValue(int index, GmCRMatrix &mat) const
Similar to matrixValueAt(), passing NULL as coordinates.
Definition: gmValueAccessor.h:175
int valueSize() const
Returns the size of the array returned by value(), i.e. 1 for scalar values and nlin * ncol for vecto...
Definition: gmValueAccessor.h:102
virtual const double * defValue() const
Returns the default value for the data converted to the accessor unit. The returned array contents is...
Definition: gmValueAccessor.h:87
double scalarValue(int index) const
Similar to scalarValueAt(), passing NULL as coordinates.
Definition: gmValueAccessor.h:164
virtual Unit unit() const
Returns the unit in which data returned/received by the accessor is expressed.
Definition: gmValueAccessor.h:375
Class responsible for evaluating a UserFunction over a node / cell.
Definition: gmUserFunction.h:148
virtual void setEvalContext(GmValueSetEvalContext *context, bool ownsContext)=0
Sets the EvalContext object that will be used to translate function names / objects into function eva...
Declaration of usefull configuration definitions for the Core library.
Declaration of the GmValueInfo class.
const double * value(int index) const
Similar to valueAt(), passing NULL as coordinates.
Definition: gmValueAccessor.h:158
Declaration of the GmTLBuffer class.
virtual GmValueSetEvalContext * evalContext() const
Returns the internal evaluation context. Needed by GmCellAccessorProxy, GmBcAccessorProxy & state dum...
Definition: gmValueAccessor.h:388
Declaration of the GmMatrix class.
void setMemory(const double *data, int nlin)
Exchanges the memory area used by the vector. Same caveats explained in the class documentation apply...
Definition: gmVector.h:100
Interface class for accessing and setting values from an "indexable" collection of values.
Definition: gmValueAccessor.h:59
virtual int adjustLinearIndex(int index, const GmMesh *m)
Translates a linear index (from 0 to mesh->totalNumNodes()-1) into a valid index for this accessor or...
Definition: gmValueAccessor.h:121
virtual void convertFromAccessorUnit(double val, double *dst) const =0
Copies the values given by val into the area pointed to by dst, converting units if needed.
virtual bool setScalarValueAtDim(int index, int dim, double val)
Similar to setValue() but changing only the value at the given dimension. Can be used over scalar,...
Definition: gmValueAccessor.h:210
void vectorValueAt(int index, const GmVector *coord, GmCRVector &vec) const
Similar to valueAt(), but returning the result as a CONST vector. Bear in mind that the resulting vec...
Definition: gmValueAccessor.h:180
QString _unit
The unit in which data will be returned. Needed for the case when _conv = NULL and _info->unit() is e...
Definition: gmValueAccessor.h:413
virtual bool setFunctionFromName(int index, QString userFunctionId, QString &err)=0
Sets a function value from the function name.
virtual ~GmValueAccessor()
Virtual destructor.
Definition: gmValueAccessor.h:63
GmValueInfo * _info
The metadata describing the values returned by this accessor.
Definition: gmValueAccessor.h:406
Declaration of the GmVector class.
virtual double convertToAccessorUnit(double val) const =0
An utility function that given a value, converts it to the accessor unit. If no conversion is needed,...
#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
An auxiliary vector WRAPPER that binds the vector to a CONST memory area with data already initialize...
Definition: gmVector.h:69
UnitConverter * _conv
Unit converter.
Definition: gmValueAccessor.h:411
Auxiliar class used to store the needed information to translate an user function id / user function ...
Definition: gmValueSetEvalContext.h:45
virtual QString valueStr(int index, bool evalFunctions, bool printDefAsNil, int fieldWidth=0, char format='g', int precision=-1, const GmVector *coord=NULL) const =0
Auxiliary function to return the value of an accessor converted to a string. Works for scalars,...
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
UnitConverter * _rconv
Unit converter in the reverse direction: from desired unit to data unit.
Definition: gmValueAccessor.h:412
A proxy class that receives as parameters two accessors for the same data, one for the common node da...
Definition: gmGhostNodeAccessor.h:75
The GmDiscontinuityAccessor class is a proxy object to a value accesor implementing a more convenient...
Definition: gmDiscontinuityAccessor.h:47
bool setVectorValue(int index, const GmVector &vec)
Similar to setValue() but receiving the data as a vector.
Definition: gmValueAccessor.h:231
void matrixValueAt(int index, const GmVector *coord, GmCRMatrix &mat) const
Similar to valueAt(), but returning the result as a CONST matrix. Bear in mind that the resulting mat...
Definition: gmValueAccessor.h:169
virtual bool setValueFromVariant(int index, const QVariant &v, bool acceptMissingDimension, QString &err)=0
Sets a value with data read from a QVariant.
arma::vec GmVector
The basic type for a GeMA vector object. Currently based on an Armadillo vector.
Definition: gmVector.h:34
bool addScalarToValue(int index, double value)
Convenience function equivalent to calling setScalarValue(index, scalarValue(index) + value)
Definition: gmValueAccessor.h:238
bool setMatrixValue(int index, const GmMatrix &mat)
Similar to setValue() but receiving the data as a matrix.
Definition: gmValueAccessor.h:224
Base interface class for Mesh type plugins.
Definition: gmMesh.h:44
An auxiliary matrix WRAPPER that binds the matrix to a CONST memory area with data already inicialize...
Definition: gmMatrix.h:100
An implementation of basic attributes and functions that should be common for most value accessor imp...
Definition: gmValueAccessor.h:364
arma::mat GmMatrix
The basic type for a GeMA matrix object. Currently based on an Armadillo matrix.
Definition: gmMatrix.h:38
Class used to store the definition of a user function and its parameters.
Definition: gmUserFunction.h:78
void setMemory(const double *data, int nlin, int ncol)
Exchanges the memory area used by the matrix. Same caveats explained in the class documentation apply...
Definition: gmMatrix.h:131
Helper class with common code for several classes that wrap a value accessor, provinding a slitly dif...
Definition: gmAccessorProxy.h:38
GmTLBuffer< double, true > * _convData
Per thread local buffer used to store converted data. Null if _conv == NULL.
Definition: gmValueAccessor.h:409
const GmLogCategory & _logger
The logger object used to report errors while accessing or setting data.
Definition: gmValueAccessor.h:407
virtual int adjustLinearIndex(int index, int firstGhostIndex)
Simmilar to adjustLinearIndex(int, const GmMesh*), this function overload gets as second parameter th...
Definition: gmValueAccessor.h:126