GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
gmPCR.h
Go to the documentation of this file.
1/************************************************************************
2**
3** Copyright (C) 2015 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_PCR_H_
25#define _GEMA_PCR_H_
26
27#include "gmPluginObject.h"
28#include "gmPluginCategory.h"
29#include "gmCell.h"
30
31class GmMesh;
32class GmCellGroupSet;
33class GmValueAccessor;
34class GmStateDump;
35
37#define GM_PCR_REMOTE_BIT 0x01
38
40#define GM_PCR_HALO_BIT 0x02
41
43#define GM_PCR_MASK 0x03
44
46#define GM_PCR_NUM_MASK_BITS 2
47
49#define GM_PCR_NUM_CLASSES (1 << GM_PCR_NUM_MASK_BITS)
50
51
54{
55public:
56 GmPCR(GmSimulationData* simulation, QString id, QString description, const GmLogCategory& logger);
57 virtual ~GmPCR();
58
59 // Comments on the base class
60 virtual const char* pluginCategory() const { return GM_PLUGIN_PCR; }
61
73 virtual bool hasCapability(QString capabilityName) const = 0;
74
76 virtual GmMesh* mesh() const = 0;
77
85 virtual bool setMesh(GmMesh* mesh) = 0;
86
87 virtual void printParameters(const GmLogCategory& logger);
88
90 virtual size_t printMemoryStatistics(const GmLogCategory& logger, GmLogLevel level) const = 0;
91
93 virtual size_t usedMemory() const = 0;
94
95 // --------------------------------------------------------------------------
96 // The public API used at the simulation execution by processes, etc
97 // --------------------------------------------------------------------------
98
99 // -- Partition --------------------------
100
102 virtual int numPartitions() const = 0;
103
107 virtual int partition() const = 0;
108
112 virtual int numGlobalNodes() const = 0;
113
117 virtual int numGlobalGhostNodes() const = 0;
118
122 virtual int numGlobalCells() const = 0;
123
126 MY_CELL = 0,
127 MY_HALO_CELL = GM_PCR_HALO_BIT,
128 REMOTE_HALO_CELL = GM_PCR_REMOTE_BIT | GM_PCR_HALO_BIT,
129 };
130
133 MY_NODE = 0,
134 REMOTE_NODE = GM_PCR_REMOTE_BIT,
135 MY_HALO_NODE = GM_PCR_HALO_BIT,
136 REMOTE_HALO_NODE = GM_PCR_REMOTE_BIT | GM_PCR_HALO_BIT,
137 };
138
140 virtual CellClass cellClass(int cellId) const = 0;
141
147 virtual int cellClassData(int cellId) const = 0;
148
150 virtual int numCellsInClass(CellClass cellClass) const = 0;
151
155 virtual NodeClass nodeClass(int nodeId) const = 0;
156
164 virtual int nodeClassData(int nodeId) const = 0;
165
170 virtual int numNodesInClass(NodeClass nodeClass, GmCellFillMode mode = GM_CELL_NODES) const = 0;
171
173 virtual int numRemoteRanks(int templateIndex) const = 0;
174
178 virtual const int* remoteRanks(int templateIndex) const = 0;
179
184 virtual bool skipRemote() const = 0;
185
198 virtual bool addPartitionInfoAsMeshAttributes(QString cellAttrPrefix, QString nodeAttrPrefix) = 0;
199
209 virtual bool addDebugPartitionInfoAsMeshAttributes(QString cellAttrPrefix, QString nodeAttrPrefix) = 0;
210
212 virtual void printPartitionRankTemplateData(const GmLogCategory& logger) const = 0;
213
215 virtual void printPartitionClassStatistics(const GmLogCategory& logger) const = 0;
216
217 // -- Coloring --------------------------
218
225
227 virtual ColorType coloringType() const = 0;
228
236
243
262
268 virtual const GmCellGroupSet* sequentialSet(const GmCellGroupSet* gs) = 0;
269
272
274 virtual const GmCellGroupSet* sequentialHaloSet(const GmCellGroupSet* gs) = 0;
275
283 virtual bool addColoringAsMeshAttribute(const GmCellGroupSet* gs, QString attrName) = 0;
284
290 virtual bool addColoringAsMeshAttribute(const QVector<const GmCellGroupSet*>& gsets, QString attrName) = 0;
291
293 virtual void printColoringStatistics(const GmLogCategory& logger) const = 0;
294
295 // -- Renumbering --------------------------
296
301 virtual bool nodesRenumbered() const = 0;
302
307 virtual bool cellsRenumbered() const = 0;
308
318 virtual int originalToLocalOrderNode(int originalNodeId) const = 0;
319
321 virtual int originalToLocalOrderGeomNode(int originalNodeId) const = 0;
322
324 virtual int originalToLocalOrderGhostNodeHighSet(int originalNodeId) const = 0;
325
327 virtual int originalToLocalOrderGhostNodeHighClear(int originalNodeId) const = 0;
328
333 virtual int originalToLocalOrderCell(int originalCellId) const = 0;
334
336 virtual int originalToLocalOrderNodeSR(int originalNodeId) const = 0;
337
339 virtual int originalToLocalOrderGeomNodeSR(int originalNodeId) const = 0;
340
342 virtual int originalToLocalOrderGhostNodeHighSetSR(int originalNodeId) const = 0;
343
345 virtual int originalToLocalOrderGhostNodeHighClearSR(int originalNodeId) const = 0;
346
348 virtual int originalToLocalOrderCellSR(int originalCellId) const = 0;
349
350
360 virtual int localOrderToOriginalNode(int nodeId) const = 0;
361
363 virtual int localOrderToOriginalGeomNode(int nodeId) const = 0;
364
366 virtual int localOrderToOriginalGhostNodeHighSet(int nodeId) const = 0;
367
369 virtual int localOrderToOriginalGhostNodeHighClear(int nodeId) const = 0;
370
375 virtual int localOrderToOriginalCell(int cellId) const = 0;
376
385 virtual int originalNodeTraversalOrder(int i) const = 0;
386
392 virtual int originalCellTraversalOrder(int i) const = 0;
393
394 // --------------------------------------------------------------------------
395 // The "private" API used by the mesh plugin when creating the mesh.
396 // NOT for general use. Should be used only at model loading for adjusting
397 // the mesh.
398 // --------------------------------------------------------------------------
399
409 virtual bool initPartitions(int numPartitions, int partition) = 0;
410
436 virtual bool initNodeMapping(GmValueAccessor* ac, bool ghost, bool* renumbered,
437 QMap<int, int>& partOrigToLocOrder) = 0;
438
460 virtual bool initCellMapping(bool* renumbered, QMap<int, int>& partOrigToLocOrder,
461 QVector<int>& partLocToOrigOrder) = 0;
462
467
471 virtual bool addNodes(int numNodes) = 0;
472
477 virtual bool addGhostNodes(int numGhostNodes) = 0;
478
483 virtual bool addCells(int numCells) = 0;
484
486 virtual void clear() = 0;
487
488 //---------------------------------------
489 // State dump control functions: Since the PCR object is always tied to
490 // the mesh, we are going to persist it together with the mesh. To do so,
491 // the PCR object follows the same interface defined by GmMesh to add
492 // data to its state.
493 //---------------------------------------
494
495 // See comments on the base GmMesh class
496 virtual bool addStateGeometryData (GmStateDump* state, int groupId) = 0;
497 virtual bool fillDumpControlMapData (QVariantMap* map, const GmLogCategory& logger) = 0;
498 virtual bool dumpControlMapDataLoaded(QVariantMap* map, const GmLogCategory& logger) = 0;
499};
500
501#endif // _GEMA_PCR_H_
Interface for helping managing mesh cell groups and returning the elements in their union.
Definition gmCellGroupSet.h:35
Class representing a category with multiple logging levels.
Definition gmLog.h:58
Base interface class for Mesh type plugins.
Definition gmMesh.h:48
Base interface class for Partition-Color-Renumber object plugins.
Definition gmPCR.h:54
virtual void printPartitionClassStatistics(const GmLogCategory &logger) const =0
Helper debug function to print class statistics. In "debug mode" prints the statistics for all partit...
NodeClass
Node classification enum.
Definition gmPCR.h:132
virtual size_t usedMemory() const =0
Returns the approximate memory used for storing the PCR data structures.
virtual int originalToLocalOrderNodeSR(int originalNodeId) const =0
SR version for originalToLocalOrderNode(). Returns -1 if skipRemote() is true and the node is a remot...
virtual const char * pluginCategory() const
Returns the plugin category.
Definition gmPCR.h:60
virtual int originalToLocalOrderCell(int originalCellId) const =0
Translates an original(model) cell id into the local, ordered, cell id used by the mesh....
ColorState
State of a coloring operation.
Definition gmPCR.h:230
@ NOT_COLORED
The cells have NOT been colored due to a coloring error.
Definition gmPCR.h:233
@ NOT_SET
No attempt has been made to color the cells yet.
Definition gmPCR.h:234
@ COLORED
All cells have been colored together.
Definition gmPCR.h:231
@ COLORED_WITH_HALO
Regular cells and halo cells have been colored separately.
Definition gmPCR.h:232
virtual int originalToLocalOrderCellSR(int originalCellId) const =0
SR version for originalToLocalOrderCell(). Returns -1 if skipRemote() is true and the cell is a remot...
virtual int partition() const =0
Returns the number of the selected partition for the current mesh. Will return 0 if the mesh was not ...
virtual int nodeClassData(int nodeId) const =0
virtual bool addPartitionInfoAsMeshAttributes(QString cellAttrPrefix, QString nodeAttrPrefix)=0
Adds to the mesh a set of new node and cell attributes with information on node and cell classes plus...
virtual const int * remoteRanks(int templateIndex) const =0
Returns a vector with size equal to numRemoteRanks(templateIndex) storing the ranks (partitions) shar...
virtual int originalToLocalOrderGhostNodeHighClearSR(int originalNodeId) const =0
SR version for originalToLocalOrderGhostNodeHighClear(). Returns -1 if skipRemote() is true and the n...
virtual int originalToLocalOrderNode(int originalNodeId) const =0
Translates an original (model) node id into the local, ordered, node id used by the mesh....
virtual int originalNodeTraversalOrder(int i) const =0
When traversing the whole set of mesh nodes, one common requirement is for the traversal to produce t...
virtual int numGlobalCells() const =0
When working with partitioned meshes, returns the number of cells in the global mesh,...
virtual int numGlobalGhostNodes() const =0
When working with partitioned meshes, returns the number of ghost nodes in the global mesh,...
virtual const QVector< GmCellGroupSet * > & coloredHaloSets(const GmCellGroupSet *gs)=0
Similar to coloredSets() but including only halo cells from the given group set (if any)
virtual bool addNodes(int numNodes)=0
Informs that the number of nodes has been increased. That does not mean that coordinates have been fi...
virtual QStringList cellMappingRequiredGroups()=0
Method called by the mesh to query if the pcr object needs any cell group information to exist before...
virtual bool addColoringAsMeshAttribute(const QVector< const GmCellGroupSet * > &gsets, QString attrName)=0
Similar to addColoringAsMeshAttribute(const GmCellGroupSet*, QString) but "appending" together severa...
virtual int localOrderToOriginalGeomNode(int nodeId) const =0
An specialization of localOrderToOriginalNode, accepting ONLY geometric nodes (between 0 and num node...
virtual bool setMesh(GmMesh *mesh)=0
Function called by the mesh to establish that this PCR object is tied to the given mesh....
virtual bool initCellMapping(bool *renumbered, QMap< int, int > &partOrigToLocOrder, QVector< int > &partLocToOrigOrder)=0
Method called by the mesh to initialize the cell renumbering mapping. It will be called once after ce...
virtual int originalToLocalOrderGhostNodeHighSetSR(int originalNodeId) const =0
SR version for originalToLocalOrderGhostNodeHighSet(). Returns -1 if skipRemote() is true and the nod...
virtual bool cellsRenumbered() const =0
Returns true if the cells where renumbered, false if not. Notice that translation functions work as a...
virtual ColorState coloringState(const GmCellGroupSet *gs)=0
Returns the coloring state for the given cell group. Will trigger the coloring algorithm if the given...
virtual bool addCells(int numCells)=0
Informs that the number of cells has been increased. That does not mean that cell nodes or properties...
virtual const QVector< GmCellGroupSet * > & coloredSets(const GmCellGroupSet *gs)=0
Returns the set of colored cell sub-groups for the given cell group. Within each sub-group,...
CellClass
Cell classification enum.
Definition gmPCR.h:125
virtual bool initPartitions(int numPartitions, int partition)=0
Breaks the mesh into the specified number of partitions, gathers information about cells,...
virtual void printPartitionRankTemplateData(const GmLogCategory &logger) const =0
Helper debug function to print the rank template data.
virtual int originalToLocalOrderGhostNodeHighSet(int originalNodeId) const =0
An specialization of originalToLocalOrderNode, accepting ONLY ghost nodes with the high bit SET (betw...
virtual int originalToLocalOrderGhostNodeHighClear(int originalNodeId) const =0
An specialization of originalToLocalOrderNode, accepting ONLY ghost nodes with the high bit CLEARED (...
virtual bool hasCapability(QString capabilityName) const =0
This function should return true or false to indicate whether the PCR object supports the requested c...
virtual const GmCellGroupSet * sequentialSet(const GmCellGroupSet *gs)=0
Returns the set of cells from the given cell group that could not be colored and should be treated se...
virtual bool skipRemote() const =0
Returns true if the mesh was partitioned, includes remote halo cells and the PCR object was configure...
virtual GmMesh * mesh() const =0
Returns the mesh that this PCR object is tied to.
virtual int cellClassData(int cellId) const =0
virtual void clear()=0
Informs that the mesh was cleared.
virtual int originalToLocalOrderGeomNode(int originalNodeId) const =0
An specialization of originalToLocalOrderNode, accepting ONLY geometric nodes (between 0 and num node...
virtual CellClass cellClass(int cellId) const =0
Returns the cell class for the given cell. Will return MY_CELL if the mesh was not partitioned.
virtual size_t printMemoryStatistics(const GmLogCategory &logger, GmLogLevel level) const =0
Prints memory usage for the PCR object to the given logger. Returns the used memory as reported by us...
virtual int localOrderToOriginalGhostNodeHighClear(int nodeId) const =0
An specialization of localOrderToOriginalNode, accepting ONLY ghost nodes with the high bit CLEARED (...
virtual bool nodesRenumbered() const =0
Returns true if the nodes where renumbered, false if not. Notice that translation functions work as a...
virtual void printColoringStatistics(const GmLogCategory &logger) const =0
Helper debug function to print coloring statistics for the existing colorings.
virtual int numRemoteRanks(int templateIndex) const =0
Returns the number of remote ranks sharing the local cell / node for the given template index.
virtual bool addDebugPartitionInfoAsMeshAttributes(QString cellAttrPrefix, QString nodeAttrPrefix)=0
Similar to addPartitionInfoAsMeshAttributes() but adding extra cell and node attributes named by the ...
virtual int originalCellTraversalOrder(int i) const =0
When traversing the whole set of mesh cells, one common requirement is for the traversal to produce t...
virtual int localOrderToOriginalNode(int nodeId) const =0
Translates a local, ordered, node id used by the mesh into the original (model) node id....
virtual const GmCellGroupSet * sequentialHaloSet(const GmCellGroupSet *gs)=0
Similar to sequentialSet() but including only halo cells from the given group set (if any)
virtual bool addGhostNodes(int numGhostNodes)=0
Informs that the number of ghost nodes has been increased. That does not mean that coordinates have b...
virtual ColorType coloringType() const =0
Returns the type of coloring for this PCR object.
virtual int localOrderToOriginalCell(int cellId) const =0
Translates a local, ordered, cell id used by the mesh into the original(model) cell id When working w...
virtual int originalToLocalOrderGeomNodeSR(int originalNodeId) const =0
SR version for originalToLocalOrderGeomNode(). Returns -1 if skipRemote() is true and the node is a r...
virtual NodeClass nodeClass(int nodeId) const =0
Returns the node class for the given node. Will return MY_NODE if the mesh was not partitioned....
ColorType
Type of coloring.
Definition gmPCR.h:220
@ FVM_COLORING
Within each color group, cells do not share edges for surface meshes or faces for volumetric meshes.
Definition gmPCR.h:223
@ FEM_COLORING
Within each color group, cells do not share nodes.
Definition gmPCR.h:222
@ NO_COLORING
No coloring configured.
Definition gmPCR.h:221
virtual int numPartitions() const =0
Returns the number of partitions for the mesh. Will return 1 if the mesh was not partitioned.
virtual bool addColoringAsMeshAttribute(const GmCellGroupSet *gs, QString attrName)=0
Adds to the mesh a new cell attribute, named attrName, with the 1-based coloring index for each cell....
virtual int numNodesInClass(NodeClass nodeClass, GmCellFillMode mode=GM_CELL_NODES) const =0
Returns the number of nodes in the mesh that are classified in the given nodeClass....
virtual int localOrderToOriginalGhostNodeHighSet(int nodeId) const =0
An specialization of localOrderToOriginalNode, accepting ONLY ghost nodes with the high bit SET (betw...
virtual int numGlobalNodes() const =0
When working with partitioned meshes, returns the number of nodes in the global mesh,...
virtual int numCellsInClass(CellClass cellClass) const =0
Returns the number of cells in the mesh that are classified in the given cellClass.
virtual bool initNodeMapping(GmValueAccessor *ac, bool ghost, bool *renumbered, QMap< int, int > &partOrigToLocOrder)=0
Method called by the mesh to initialize the node renumbering mapping. It will be called once,...
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
Interface class for accessing and setting values from an "indexable" collection of values.
Definition gmValueAccessor.h:60
Declaration of the GmCell class.
GmCellFillMode
Operation modes for the fillNodeMatrix() method.
Definition gmCell.h:39
@ GM_CELL_NODES
The coordinate matrix will be filled with cell geometry nodes only (the default, and includes extra d...
Definition gmCell.h:40
#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
GmLogLevel
Available log levels list.
Definition gmLog.h:36
#define GM_PCR_REMOTE_BIT
The bit used for classifying a cell / node into a remote cell / node.
Definition gmPCR.h:37
#define GM_PCR_HALO_BIT
The bit used for classifying a cell / node into a halo cell / node.
Definition gmPCR.h:40
Declaration of macros for standard plugin categories.
#define GM_PLUGIN_PCR
Plugin implements PCR (Partition-Color-Renumber) objects.
Definition gmPluginCategory.h:33
Declaration of the GmPluginObject base class.