GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
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"
29
30#include <QString>
31#include <QMap>
32#include <QMutex>
33
34class GmUserFunction;
37class GmMesh;
38class GmCell;
39class GmValueInfo;
40class GmLogCategory;
41
46{
47public:
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
102private:
103 Q_DISABLE_COPY(GmValueSetEvalContext)
104
105
107 {
112
113 CacheAlignedData() : _dataIndex(-1), _ipIndex(-1), _cacheKey(NULL), _cacheEval(NULL) {}
114 };
115
116 const GmMesh* _mesh;
121
124};
125
126
127#endif
128
129
Base interface for mesh cells.
Definition gmCell.h:88
virtual int cellId() const =0
Returns a number identifying the cell. It should be possible to use this id as an index to GmCellMesh...
Class representing a category with multiple logging levels.
Definition gmLog.h:58
Base interface class for Mesh type plugins.
Definition gmMesh.h:48
Auxiliar class used to store the complete set of simulation data.
Definition gmSimulationData.h:55
A class that works together with GmThreadManager to provide thread local storage.
Definition gmThreadLocalStorage.h:132
static bool inMainThread()
Is the current thread the main thread? Equivalent to comparing the currentId() with 0.
Definition gmThreadManager.h:174
Class responsible for evaluating a UserFunction over a node / cell.
Definition gmUserFunction.h:160
Class used to store the definition of a user function and its parameters.
Definition gmUserFunction.h:82
Auxiliar class used to store the definition of a value. It can be used to store informations about st...
Definition gmValueInfo.h:132
Auxiliar class used to store the needed information to translate an user function id / user function ...
Definition gmValueSetEvalContext.h:46
bool ghostData() const
Returns a flag set to true if this context is tied to a ghost value set.
Definition gmValueSetEvalContext.h:67
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
int ipIndex() const
Returns the integration point index equivalent to the coordinate passed to function evaluation or -1 ...
Definition gmValueSetEvalContext.h:64
GmSimulationData * _simData
Simulation data.
Definition gmValueSetEvalContext.h:117
const GmMesh * _mesh
Bound mesh used to evaluate function params.
Definition gmValueSetEvalContext.h:116
GmSimulationData * simulationData() const
Returns the simulationData object.
Definition gmValueSetEvalContext.h:56
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 QMap< GmUserFunction *, GmUserFunctionEvaluator * > & evaluatorMap() const
Returns a reference to the evaluator map. Must be called from the main thread only,...
Definition gmValueSetEvalContext.h:96
QMutex _mapMutex
A mutex protecting access to _evalMap.
Definition gmValueSetEvalContext.h:120
GmTLS< CacheAlignedData, true > _data
Per thread data.
Definition gmValueSetEvalContext.h:119
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
void setCell(const GmCell *cell, int ip)
Sets the cell / integration point over which values will be calculated.
Definition gmValueSetEvalContext.h:78
bool _ghostData
Is this context tied to a ghost value set?
Definition gmValueSetEvalContext.h:118
const GmMesh * mesh() const
Returns the mesh bound to this EvalContext. Can be NULL for 'incomplete' evaluators.
Definition gmValueSetEvalContext.h:53
Declaration of the GmCell class.
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 the GmTLS class.
A structure to merge cache aligned data since they combined fit inside a cache lign.
Definition gmValueSetEvalContext.h:107
int _ipIndex
The integration point.
Definition gmValueSetEvalContext.h:109
GmUserFunctionEvaluator * _cacheEval
Last used evaluator.
Definition gmValueSetEvalContext.h:111
int _dataIndex
The node / cell index over which values will be calculated (needed by property sets / boundary condit...
Definition gmValueSetEvalContext.h:108
GmUserFunction * _cacheKey
Key describing the last used evaluator.
Definition gmValueSetEvalContext.h:110