GemaCoreLib
The GeMA Core library
gmValueSetEvalContext.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_SET_EVAL_CONTEXT_H_
24 #define _GEMA_VALUE_SET_EVAL_CONTEXT_H_
25 
26 #include "gmCoreConfig.h"
27 #include "gmCell.h"
28 #include "gmThreadLocalStorage.h"
29 
30 #include <QString>
31 #include <QMap>
32 #include <QMutex>
33 
34 class GmUserFunction;
36 class GmSimulationData;
37 class GmMesh;
38 class GmCell;
39 class GmValueInfo;
40 class GmLogCategory;
41 
46 {
47 public:
48  GmValueSetEvalContext(GmSimulationData* simData, const GmMesh* mesh);
49 
51 
53  const GmMesh* mesh() const { return _mesh; }
54 
56  GmSimulationData* simulationData() const { return _simData; }
57 
59  int dataIndex() const { return _data.localData()._dataIndex; }
60 
64  int ipIndex() const { return _data.localData()._ipIndex; }
65 
67  bool ghostData() const { return _ghostData; }
68 
78  void setCell(const GmCell* cell, int ip) { CacheAlignedData& d = _data.localData(); d._dataIndex = cell->cellId(); d._ipIndex = ip; }
79 
81  void setDataIndex(int dataIndex) { assert(dataIndex >= 0); _data.localData()._dataIndex = dataIndex; }
82 
84  void setGhostData(bool mode) { _ghostData = mode; }
85 
86  GmUserFunction* userFunction(QString id);
87  GmUserFunctionEvaluator* userFunctionEvaluator(QString id, const GmValueInfo* info,
88  const GmLogCategory& logger, QString& err);
89  GmUserFunctionEvaluator* userFunctionEvaluator(GmUserFunction* ufunc, const GmValueInfo* info,
90  const GmLogCategory& logger, QString& err);
91 
97  {
99  return _evalMap;
100  }
101 
102 private:
103  Q_DISABLE_COPY(GmValueSetEvalContext)
104 
105 
107  {
109  int _ipIndex;
112 
113  CacheAlignedData() : _dataIndex(-1), _ipIndex(-1), _cacheKey(NULL), _cacheEval(NULL) {}
114  };
115 
116  const GmMesh* _mesh;
118  bool _ghostData;
121 
124 };
125 
126 
127 #endif
128 
129 
Auxiliar class used to store the definition of a value. It can be used to store informations about st...
Definition: gmValueInfo.h:126
GmUserFunctionEvaluator * _cacheEval
Last used evaluator.
Definition: gmValueSetEvalContext.h:111
A structure to merge cache aligned data since they combined fit inside a cache lign.
Definition: gmValueSetEvalContext.h:106
bool _ghostData
Is this context tied to a ghost value set?
Definition: gmValueSetEvalContext.h:118
Declaration of the GmTLS class.
Class responsible for evaluating a UserFunction over a node / cell.
Definition: gmUserFunction.h:148
GmSimulationData * simulationData() const
Returns the simulationData object.
Definition: gmValueSetEvalContext.h:56
int _ipIndex
The integration point.
Definition: gmValueSetEvalContext.h:109
Declaration of usefull configuration definitions for the Core library.
void setCell(const GmCell *cell, int ip)
Sets the cell / integration point over which values will be calculated.
Definition: gmValueSetEvalContext.h:78
Base interface for mesh cells.
Definition: gmCell.h:81
void setDataIndex(int dataIndex)
Saves the node / cell over which values will be calculated. Ghost indices should be linear indices.
Definition: gmValueSetEvalContext.h:81
const GmMesh * mesh() const
Returns the mesh bound to this EvalContext. Can be NULL for 'incomplete' evaluators.
Definition: gmValueSetEvalContext.h:53
GmTLS< CacheAlignedData, true > _data
Per thread data.
Definition: gmValueSetEvalContext.h:119
A class that works together with GmThreadManager to provide thread local storage.
Definition: gmThreadLocalStorage.h:131
virtual int cellId() const =0
Returns a number identifying the cell. It should be possible to use this id as an index to GmCellMesh...
const GmMesh * _mesh
Bound mesh used to evaluate function params.
Definition: gmValueSetEvalContext.h:116
Auxiliar class used to store the complete set of simulation data.
Definition: gmSimulationData.h:51
const QMap< GmUserFunction *, GmUserFunctionEvaluator * > & evaluatorMap() const
Returns a reference to the evaluator map. Must be called from the main thread only,...
Definition: gmValueSetEvalContext.h:96
bool ghostData() const
Returns a flag set to true if this context is tied to a ghost value set.
Definition: gmValueSetEvalContext.h:67
QMutex _mapMutex
A mutex protecting access to _evalMap.
Definition: gmValueSetEvalContext.h:120
void setGhostData(bool mode)
Changes the flag that states if this context is tied to a ghost value set or not.
Definition: gmValueSetEvalContext.h:84
#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
int ipIndex() const
Returns the integration point index equivalent to the coordinate passed to function evaluation or -1 ...
Definition: gmValueSetEvalContext.h:64
Auxiliar class used to store the needed information to translate an user function id / user function ...
Definition: gmValueSetEvalContext.h:45
Class representing a category with multiple logging levels.
Definition: gmLog.h:58
GmUserFunction * _cacheKey
Key describing the last used evaluator.
Definition: gmValueSetEvalContext.h:110
static bool inMainThread()
Is the current thread the main thread? Equivalent to comparing the currentId() with 0.
Definition: gmThreadManager.h:169
int _dataIndex
The node / cell index over which values will be calculated (needed by property sets / boundary condit...
Definition: gmValueSetEvalContext.h:108
GmSimulationData * _simData
Simulation data.
Definition: gmValueSetEvalContext.h:117
Declaration of the GmCell class.
int dataIndex() const
Returns the node/cell index over which the calculation will be made (-1 if not set by the accessor)
Definition: gmValueSetEvalContext.h:59
Base interface class for Mesh type plugins.
Definition: gmMesh.h:44
Class used to store the definition of a user function and its parameters.
Definition: gmUserFunction.h:78