GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
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#include "gmPCR.h"
32
33#include "gmValueSetGroup.h"
34
35class GmStateVar;
36class GmNodeSet;
37class GmPCR;
39
40class Unit;
41struct lua_State;
42
44#define GM_GHOSTNODE_MASK (~(~0u >> 1))
45
48{
49Q_OBJECT
50
51public:
52 GmMesh(GmSimulationData* simulation, QString id, QString description, const GmLogCategory& logger);
53 virtual ~GmMesh();
54
55 // Comments on the base class
56 virtual const char* pluginCategory() const { return GM_PLUGIN_MESH; }
57
72 virtual bool hasCapability(QString capabilityName) const = 0;
73
82 virtual bool useDualVectors() const = 0;
83
92 virtual void pushProxy(lua_State* L, const GmLogCategory& logger) = 0;
93
95 virtual GmValueInfo* nodeCoordInfo() const = 0;
96
104 virtual GmValueAccessor* nodeCoordAccessor(Unit desiredUnit, const GmLogCategory& logger) const = 0;
105
107 virtual int numNodes() const = 0;
108
110 virtual int numGhostNodes() const { return 0; }
111
113 int totalNumNodes() const { return numNodes() + numGhostNodes(); }
114
116 virtual int numGlobalNodes() const { return pcrObject()->numGlobalNodes(); }
117
119 virtual int numGlobalGhostNodes() const { return pcrObject()->numGlobalGhostNodes(); }
120
122 int totalNumGlobalNodes() const { return numGlobalNodes() + numGlobalGhostNodes(); }
123
124
136 static bool isGhostNode(int nodeIndex) { return nodeIndex & GM_GHOSTNODE_MASK; }
137
139 static int setGhostFlag(int nodeIndex) { return nodeIndex | GM_GHOSTNODE_MASK; }
140
142 static int clearGhostFlag(int nodeIndex) { return nodeIndex & (~GM_GHOSTNODE_MASK); }
143
147 int toLinearGhostIndex(int nodeIndex) const { return isGhostNode(nodeIndex) ? clearGhostFlag(nodeIndex) + numNodes() : nodeIndex; }
148
153 int toLocalGhostIndex(int nodeIndex) const { return nodeIndex - numNodes(); }
154
158 virtual const QMap<QString, GmNodeSet*>& nodeSets() const = 0;
159
160 QStringList nodeValueIds(int filter = -1) const;
161
162 virtual GmValueInfo* nodeValueInfo(QString id, int filter = -1) const;
163 virtual GmValueAccessor* nodeValueAccessor(QString id, Unit desiredUnit, const GmLogCategory& logger) const;
164 virtual GmValueAccessor* nodeValueAccessor(QString id, int snum, bool locked, Unit desiredUnit, const GmLogCategory& logger) const;
165
166 virtual GmValueAccessor* nodeStateVarAccessorFromDof(int dof, Unit desiredUnit, GmStateVar** stateVar) const;
167
168 virtual bool addNodeValueSet(GmValueInfo* info);
169 virtual void removeNodeValueSet(QString id);
170 virtual bool initNodeValueSets();
171 virtual void beginAddingNodeAttributeSets();
172 virtual bool endAddingNodeAttributeSets();
173 virtual void clearNodeValueSets();
174 virtual void clearNodeValueSetsData();
175
176 virtual bool saveState (GmValueSet::SaveStateMode mode, const GmLogCategory& logger);
177 virtual bool saveNodeValueState (QString id, GmValueSet::SaveStateMode mode, const GmLogCategory& logger);
178 virtual int numNodeValueStates (QString id) const;
179 virtual QString nodeValueStateTag (QString id, int snum) const;
180 virtual double nodeValueStateTime (QString id, int snum) const;
181 virtual void setNodeValueStateTag (QString id, int snum, QString tag);
182 virtual void setNodeValueStateTime(QString id, int snum, double time);
183
184
206 virtual int addNodes(int numNodes) { Q_UNUSED(numNodes); return -1; }
207
220 virtual int addGhostNodes(int numNodes) { Q_UNUSED(numNodes); return numNodes == 0 ? -2 : -1; }
221
229 virtual void clear() {}
230
233
234 virtual void printParameters(const GmLogCategory& logger);
235 virtual void printValues (const GmLogCategory& logger, int options = GM_PRINT_DEFAULT);
236
238 virtual size_t nodeMemory() const = 0;
239
241 virtual size_t nodeSetsMemory() const = 0;
242
249 virtual GmPCR* pcrObject() const = 0;
250
268 GmValueSetGroup* nodeValueSetGroup() const { return _nodeValuesGroup; }
269
271 GmValueSet* nodeValueSet(QString id) const { return _nodeValuesGroup->valueSet(id); }
272
273
290 GmValueSetGroup* ghostNodeValueSetGroup() const { return _ghostNodeValuesGroup; }
291
293 GmValueSet* ghostNodeValueSet(QString id) const { return _ghostNodeValuesGroup->valueSet(id); }
294
299 virtual void emitMeshChanged() { emit meshChanged(); }
300
301signals:
304
305protected:
306
311 {
312 GmValueSet* vs = nodeValueSet(id);
313 if(!vs)
314 vs = ghostNodeValueSet(id);
315 return vs;
316 }
317
318 void printValueInfo(const GmLogCategory& logger, QString title, const QStringList& idList);
319
320 virtual bool addStateItemsToGroup(GmStateDump* state, int groupId);
321
327
335 virtual bool addStateGeometryData(GmStateDump* state, int groupId) { Q_UNUSED(state); Q_UNUSED(groupId); return true; }
336
337 virtual bool addStateAccessorData(GmStateDump* state, int groupId);
338
339 virtual bool fillDumpControlMapData (QVariantMap* map, const GmLogCategory& logger);
340 virtual bool dumpControlMapDataLoaded(QVariantMap* map, const GmLogCategory& logger);
341
343
344private:
346
347 GmValueSetGroup* _nodeValuesGroup;
348 GmValueSetGroup* _ghostNodeValuesGroup;
349
362 mutable QMap<QString, GmPhysicsUserFunctions*> _cUserFuncObjMap;
363
364 QVariantMap _stateDumpControlMap;
365};
366
367#endif
368
A basic interface used for creating dump items for objects that can be dumped by a composition of mul...
Definition gmStateDumpItem.h:53
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 ...
Class representing a category with multiple logging levels.
Definition gmLog.h:58
Base interface class for Mesh type plugins.
Definition gmMesh.h:48
virtual int numNodes() const =0
Returns the number of nodes in the mesh.
GmValueSetGroup * ghostNodeValueSetGroup() const
Returns the ValueSetGroup object used to store the set of mesh ghost node value sets....
Definition gmMesh.h:290
static bool isGhostNode(int nodeIndex)
Returns true if the given index is a ghost node index, false if not.
Definition gmMesh.h:136
virtual GmPCR * pcrObject() const =0
Returns the PCR(Partition - Color - Renumber) object associated with this mesh. Should NEVER return N...
QMap< QString, GmPhysicsUserFunctions * > & userFunctionsObjMap() const
Returns the mesh map storing physics user function objects.
Definition gmMesh.h:232
static int clearGhostFlag(int nodeIndex)
Returns the given index with the ghost node bit cleared.
Definition gmMesh.h:142
static int setGhostFlag(int nodeIndex)
Returns the given index with the ghost node bit set.
Definition gmMesh.h:139
virtual void emitMeshChanged()
Emmits the signal meshChanged to signal other objects that the mesh has changed. Should be called by ...
Definition gmMesh.h:299
virtual GmValueInfo * nodeCoordInfo() const =0
Returns metadata with information about node coordinates.
virtual size_t nodeMemory() const =0
Returns the approximate memory used for storing mesh nodes (does not include memory for s....
virtual void pushProxy(lua_State *L, const GmLogCategory &logger)=0
Pushes a proxy object for the current mesh onto the Lua stack.
virtual int numGhostNodes() const
Returns the number of ghost nodes in the mesh.
Definition gmMesh.h:110
int totalNumNodes() const
Returns the total number of nodes in the mesh, including normal nodes & ghost nodes.
Definition gmMesh.h:113
virtual int controlMapStateItemType()
Virtual function that needs to be implemented by concrete implementation classes supporting the state...
Definition gmMesh.h:326
virtual bool useDualVectors() const =0
Returns true if the mesh data is stored in a "dual" vector, instead of a single one.
virtual int addNodes(int numNodes)
Adds numNodes to the mesh, WHITHOUT initializing their coordinates or attributes.
Definition gmMesh.h:206
virtual int addGhostNodes(int numNodes)
Similar to addNodes, this function adds ghost nodes to the mesh, WHITHOUT initializing their coordina...
Definition gmMesh.h:220
GmValueSet * ghostNodeValueSet(QString id) const
Returns the ghost node value set associated with the given cell attribute. Might be NULL....
Definition gmMesh.h:293
virtual bool hasCapability(QString capabilityName) const =0
This function should return true or false to indicate whether the mesh implementation supports the re...
virtual size_t nodeSetsMemory() const =0
Returns the approximate memory used for storing node sets.
void meshChanged()
Signal emmited by emitMeshChanged(). See comments on that function.
virtual bool addStateGeometryData(GmStateDump *state, int groupId)
Virtual function that needs to be implemented by concrete implementation classes supporting the state...
Definition gmMesh.h:335
int totalNumGlobalNodes() const
Returns the total number of nodes in the mesh, including normal nodes & ghost nodes.
Definition gmMesh.h:122
GmValueSet * nodeValueSet(QString id) const
Returns the node value set associated with the given cell attribute. Might be NULL....
Definition gmMesh.h:271
int toLinearGhostIndex(int nodeIndex) const
If nodeIndex is a value with its high bit set, returns the index (high bit cleared)
Definition gmMesh.h:147
virtual int numGlobalGhostNodes() const
When working with partitioned meshes, returns the number of ghost nodes in the global mesh,...
Definition gmMesh.h:119
virtual void clear()
Clears mesh nodes (and cells + other mesh related information depending on the concrete mesh type) if...
Definition gmMesh.h:229
virtual GmValueAccessor * nodeCoordAccessor(Unit desiredUnit, const GmLogCategory &logger) const =0
Returns an accessor object used to access node coordinates.
virtual const char * pluginCategory() const
Returns the plugin category.
Definition gmMesh.h:56
GmValueSet * anyVsFromId(QString id) const
Helper function that, given an id, returns the node value set for that id if it exists....
Definition gmMesh.h:310
virtual int numGlobalNodes() const
When working with partitioned meshes, returns the number of nodes in the global mesh,...
Definition gmMesh.h:116
GmValueSetGroup * nodeValueSetGroup() const
Returns the ValueSetGroup object used to store the set of mesh node value sets. This is a very specia...
Definition gmMesh.h:268
int toLocalGhostIndex(int nodeIndex) const
Given a global ghost index (a value >= numNodes() and < totalNumNodes()), returns a zero based versio...
Definition gmMesh.h:153
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:342
virtual const QMap< QString, GmNodeSet * > & nodeSets() const =0
Returns a map of node sets registered within the mesh. Each entry in the returned map contains a grou...
This class stores a set of nodes belonging to a mesh. The nodes can belong to the mesh boundary but t...
Definition gmNodeSet.h:34
Base interface class for Partition-Color-Renumber object plugins.
Definition gmPCR.h:54
Base interface class for Physics type plugins to export user functions that can be used to provide at...
Definition gmPhysics.h:177
Base interface class for all object plugins.
Definition gmPluginObject.h:37
virtual void printParameters(const GmLogCategory &logger)=0
Asks the object to print all of its parameters using the provided logger.
Definition gmPluginObject.cpp:62
Auxiliar class used to store the complete set of simulation data.
Definition gmSimulationData.h:55
The GmStateDump class presents a higher level of abstraction over GmMemoryDump, storing accessor data...
Definition gmStateDump.h:54
Auxiliar class used to store the definition of a state variable.
Definition gmStateVar.h:41
Interface class for accessing and setting values from an "indexable" collection of values.
Definition gmValueAccessor.h:60
Auxiliar class used to store the definition of a value. It can be used to store informations about st...
Definition gmValueInfo.h:132
This class manages a group of ValueSets that have all the same size and must grow (or shrink) togethe...
Definition gmValueSetGroup.h:38
Basic class used to store sets of values, bound to a common definition, on behalf of another object (...
Definition gmValueSet.h:54
SaveStateMode
Initialization mode for calls to saveState()
Definition gmValueSet.h:60
#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
#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:44
Implementation of the GmPCR class.
Declaration of macros for standard plugin categories.
#define GM_PLUGIN_MESH
Plugin implements mesh objects.
Definition gmPluginCategory.h:27
Declaration of the GmPluginObject base class.
Utilitary functions for printing data.
@ GM_PRINT_DEFAULT
A tag to request that the options should be filled with the default.
Definition gmPrintUtils.h:72
Declaration of the GmStateDumpBaseDataItem and basic derived classes.
@ GM_MESH_DUMP_ITEM
Dump item for mesh objects.
Definition gmStateDumpItem.h:108
Declaration of the GmValueSetGroup class.
Q_DISABLE_COPY(Class)