GemaCoreLib
The GeMA Core library
gmMesh.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 
24 #ifndef _GEMA_MESH_H_
25 #define _GEMA_MESH_H_
26 
27 #include "gmPluginObject.h"
28 #include "gmPluginCategory.h"
29 #include "gmStateDumpItem.h"
30 #include "gmPrintUtils.h"
31 
32 #include "gmValueSet.h"
33 
34 class GmStateVar;
35 class GmNodeSet;
37 class Unit;
38 struct lua_State;
39 
41 #define GM_GHOSTNODE_MASK (~(~0u >> 1))
42 
45 {
46 Q_OBJECT
47 
48 public:
49  GmMesh(GmSimulationData* simulation, QString id, QString description, const GmLogCategory& logger);
50  virtual ~GmMesh();
51 
52  // Comments on the base class
53  virtual const char* pluginCategory() const { return GM_PLUGIN_MESH; }
54 
69  virtual bool hasCapability(QString capabilityName) const = 0;
70 
79  virtual void pushProxy(lua_State* L, const GmLogCategory& logger) = 0;
80 
82  virtual GmValueInfo* nodeCoordInfo() const = 0;
83 
91  virtual GmValueAccessor* nodeCoordAccessor(Unit desiredUnit, const GmLogCategory& logger) const = 0;
92 
94  virtual int numNodes() const = 0;
95 
97  virtual int numGhostNodes() const { return 0; }
98 
100  int totalNumNodes() const { return numNodes() + numGhostNodes(); }
101 
109  static bool isGhostNode(int nodeIndex) { return nodeIndex & GM_GHOSTNODE_MASK; }
110 
112  static int setGhostFlag(int nodeIndex) { return nodeIndex | GM_GHOSTNODE_MASK; }
113 
115  static int clearGhostFlag(int nodeIndex) { return nodeIndex & (~GM_GHOSTNODE_MASK); }
116 
120  int toLinearGhostIndex(int nodeIndex) const { return isGhostNode(nodeIndex) ? clearGhostFlag(nodeIndex) + numNodes() : nodeIndex; }
121 
126  int toLocalGhostIndex(int nodeIndex) const { return nodeIndex - numNodes(); }
127 
131  virtual const QMap<QString, GmNodeSet*>& nodeSets() const = 0;
132 
133  virtual QStringList nodeAttributeIds() const;
134  virtual QStringList nodeStateVarIds() const;
135 
136  virtual GmValueInfo* nodeValueInfo(QString id, int filter = -1) const;
137  virtual GmValueAccessor* nodeValueAccessor(QString id, Unit desiredUnit, const GmLogCategory& logger) const;
138  virtual GmValueAccessor* nodeValueAccessor(QString id, int snum, bool locked, Unit desiredUnit, const GmLogCategory& logger) const;
139 
140  virtual GmValueAccessor* stateVarAccessorFromDof(int dof, Unit desiredUnit, GmStateVar** stateVar) const;
141 
142  virtual bool addNodeValueSet(GmValueInfo* info, int nNodes = -1, int nGhostNodes = -1);
143  virtual void removeNodeValueSet(QString id);
144  virtual void clearNodeValueSets();
145  virtual void clearNodeValueSetsData();
146 
147  virtual bool saveState (GmValueSet::SaveStateMode mode, const GmLogCategory& logger);
148  virtual bool saveNodeValueState (QString id, GmValueSet::SaveStateMode mode, const GmLogCategory& logger);
149  virtual int numNodeValueStates (QString id) const;
150  virtual QString nodeValueStateTag (QString id, int snum) const;
151  virtual double nodeValueStateTime (QString id, int snum) const;
152  virtual void setNodeValueStateTag (QString id, int snum, QString tag);
153  virtual void setNodeValueStateTime(QString id, int snum, double time);
154 
155 
176  virtual int addNodes(int numNodes) { Q_UNUSED(numNodes); return -1; }
177 
189  virtual int addGhostNodes(int numNodes) { Q_UNUSED(numNodes); return -1; }
190 
198  virtual void clear() {}
199 
201  QMap<QString, GmPhysicsUserFunctions*>& userFunctionsObjMap() const { return _cUserFuncObjMap; }
202 
203  virtual void printParameters(const GmLogCategory& logger);
204  virtual void printValues (const GmLogCategory& logger, int options = GM_PRINT_DEFAULT);
205 
207  virtual size_t nodeMemory() const = 0;
208 
210  virtual size_t nodeSetsMemory() const = 0;
211 
230  const QList<GmValueSet*>& nodeValueSets() const { return _nodeValuesData; }
231 
248  const QList<GmValueSet*>& ghostNodeValueSets() const { return _ghostNodeValuesData; }
249 
254  virtual void emitMeshChanged() { emit meshChanged(); }
255 
256 signals:
258  void meshChanged();
259 
260 protected:
261  void printValueInfo(const GmLogCategory& logger, QString title, const QStringList& idList);
262 
263  virtual bool addStateItemsToGroup(GmStateDump* state, int groupId);
264 
269  virtual int controlMapStateItemType() { return GM_MESH_DUMP_ITEM; }
270 
278  virtual bool addStateGeometryData(GmStateDump* state, int groupId) { Q_UNUSED(state); Q_UNUSED(groupId); return true; }
279 
280  virtual bool addStateAccessorData(GmStateDump* state, int groupId);
281 
282  virtual bool fillDumpControlMapData (QVariantMap* map, const GmLogCategory& logger);
283  virtual bool dumpControlMapDataLoaded(QVariantMap* map, const GmLogCategory& logger);
284 
286 
287 private:
288  Q_DISABLE_COPY(GmMesh)
289 
290  QMap<QString, int> _nodeValuesMap;
291  QList<GmValueSet*> _nodeValuesData;
292  QList<GmValueSet*> _ghostNodeValuesData;
293 
306  mutable QMap<QString, GmPhysicsUserFunctions*> _cUserFuncObjMap;
307 
308  QVariantMap _stateDumpControlMap;
309 };
310 
311 #endif
312 
const QList< GmValueSet * > & nodeValueSets() const
Returns a list with the mesh node value sets. This is a very specialized function....
Definition: gmMesh.h:230
Auxiliar class used to store the definition of a value. It can be used to store informations about st...
Definition: gmValueInfo.h:126
int _stateDumpControlMapItem
The dump item index for the control map. Used to make sure that there are no mesh data accessors prio...
Definition: gmMesh.h:285
virtual bool addStateGeometryData(GmStateDump *state, int groupId)
Virtual function that needs to be implemented by concrete implementation classes supporting the state...
Definition: gmMesh.h:278
Declaration of the GmPluginObject base class.
Basic class used to store sets of values, bound to a common definition, on behalf of another object (...
Definition: gmValueSet.h:53
const QList< GmValueSet * > & ghostNodeValueSets() const
Returns a list with the mesh ghost node value sets. This is a very specialized function....
Definition: gmMesh.h:248
The GmStateDump class presents a higher level of abstraction over GmMemoryDump, storing accessor data...
Definition: gmStateDump.h:52
int totalNumNodes() const
Returns the total number of nodes in the mesh, including normal nodes & ghost nodes.
Definition: gmMesh.h:100
#define GM_GHOSTNODE_MASK
Mask with 1 on The MSB to tell if an index is a ghost node index or not.
Definition: gmMesh.h:41
Utilitary functions for printing data.
This class stores a set of nodes belonging to a mesh. The nodes can belong to the mesh boundary but t...
Definition: gmNodeSet.h:32
virtual int addGhostNodes(int numNodes)
Similar to addNodes, this function adds ghost nodes to the mesh, WHITHOUT initializing their coordina...
Definition: gmMesh.h:189
Declaration of the GmStateDumpBaseDataItem and basic derived classes.
virtual bool addStateItemsToGroup(GmStateDump *state, int groupId)=0
Initialization method, called once, allowing the object to add its state items to the given group of ...
static int setGhostFlag(int nodeIndex)
Returns the given index with the ghost node bit set.
Definition: gmMesh.h:112
virtual void emitMeshChanged()
Emmits the signal meshChanged to signal other objects that the mesh has changed. Should be called by ...
Definition: gmMesh.h:254
Interface class for accessing and setting values from an "indexable" collection of values.
Definition: gmValueAccessor.h:59
Auxiliar class used to store the complete set of simulation data.
Definition: gmSimulationData.h:51
virtual int controlMapStateItemType()
Virtual function that needs to be implemented by concrete implementation classes supporting the state...
Definition: gmMesh.h:269
Base interface class for Physics type plugins to export user functions that can be used to provide at...
Definition: gmPhysics.h:158
int toLocalGhostIndex(int nodeIndex) const
Given a global ghost index (a value >= numNodes() and < totalNumNodes()), returns a zero based versio...
Definition: gmMesh.h:126
static bool isGhostNode(int nodeIndex)
Returns true if the given index is a ghost node index, false if not.
Definition: gmMesh.h:109
#define GM_PLUGIN_MESH
Plugin implements mesh objects.
Definition: gmPluginCategory.h:27
Auxiliar class used to store the definition of a state variable.
Definition: gmStateVar.h:40
virtual void printParameters(const GmLogCategory &logger)=0
Asks the object to print all of its parameters using the provided logger.
Definition: gmPluginObject.cpp:62
static int clearGhostFlag(int nodeIndex)
Returns the given index with the ghost node bit cleared.
Definition: gmMesh.h:115
virtual int addNodes(int numNodes)
Adds numNodes to the mesh, WHITHOUT initializing their coordinates or attributes.
Definition: gmMesh.h:176
virtual void clear()
Clears mesh nodes (and cells + other mesh related information depending on the concrete mesh type) if...
Definition: gmMesh.h:198
Declaration of macros for standard plugin categories.
Base interface class for all object plugins.
Definition: gmPluginObject.h:36
#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
Class representing a category with multiple logging levels.
Definition: gmLog.h:58
SaveStateMode
Initialization mode for calls to saveState()
Definition: gmValueSet.h:59
virtual int numGhostNodes() const
Returns the number of ghost nodes in the mesh.
Definition: gmMesh.h:97
virtual const char * pluginCategory() const
Returns the plugin category.
Definition: gmMesh.h:53
Declaration of the GmValueSet class.
A basic interface used for creating dump items for objects that can be dumped by a composition of mul...
Definition: gmStateDumpItem.h:52
Base interface class for Mesh type plugins.
Definition: gmMesh.h:44
Dump item for mesh objects.
Definition: gmStateDumpItem.h:108
QMap< QString, GmPhysicsUserFunctions * > & userFunctionsObjMap() const
Returns the mesh map storing physics user function objects.
Definition: gmMesh.h:201
int toLinearGhostIndex(int nodeIndex) const
If nodeIndex is a value with its high bit set, returns the index (high bit cleared)
Definition: gmMesh.h:120
A tag to request that the options should be filled with the default.
Definition: gmPrintUtils.h:68