GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
gmDefaultPCR.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_DEFAULT_PCR_H_
25#define _GEMA_DEFAULT_PCR_H_
26
27#include "gmPCR.h"
28#include "gmCellMesh.h"
29
32{
33public:
34 GmDefaultPCR(GmSimulationData* simulation, QString id, QString description, const GmLogCategory& logger)
35 : GmPCR(simulation, id, description, logger), _mesh(NULL) {}
36
37 // Comments on the base class
38 virtual const char* pluginCategory() const { return GM_PLUGIN_PCR; }
39
40 // Comments on the base class
41 virtual const char* pluginName() const { return "DummyGemaPCR"; }
42
43 // Comments on the base class
44 virtual const char* pluginType() const { return "pcr"; }
45
46 virtual bool loadPrivateData(LuaTable& table) { Q_UNUSED(table); return false; }
47
48 // Comments on the base class
49 virtual bool hasCapability(QString capabilityName) const { Q_UNUSED(capabilityName); return false; }
50
52 virtual GmMesh* mesh() const { return _mesh; }
53
55 virtual bool setMesh(GmMesh* mesh) { assert(mesh && !_mesh); _mesh = mesh; return true; }
56
57 // Comments on the base class
58 virtual size_t printMemoryStatistics(const GmLogCategory& logger, GmLogLevel level) const { Q_UNUSED(logger); Q_UNUSED(level); return 0; };
59
60 // Comments on the base class
61 virtual size_t usedMemory() const { return 0; }
62
63 virtual ColorType coloringType() const { return NO_COLORING; }
64
65 virtual int numPartitions() const { return 1; }
66 virtual int partition() const { return 0; }
67 virtual int numGlobalNodes() const { assert(_mesh); return _mesh->numNodes(); }
68 virtual int numGlobalGhostNodes() const { assert(_mesh); return _mesh->numGhostNodes(); }
69 virtual int numGlobalCells() const { assert(_mesh); GmCellMesh* cmesh = dynamic_cast<GmCellMesh*>(_mesh); return cmesh ? cmesh->numCells() : 0; }
70
71 virtual CellClass cellClass (int cellId) const { Q_UNUSED(cellId); return MY_CELL; }
72 virtual int cellClassData (int cellId) const { Q_UNUSED(cellId); return 0; }
73 virtual int numCellsInClass(CellClass cellClass) const { Q_UNUSED(cellClass); return 0; }
74 virtual NodeClass nodeClass (int nodeId) const { Q_UNUSED(nodeId); return MY_NODE; }
75 virtual int nodeClassData (int nodeId) const { Q_UNUSED(nodeId); return 0; }
76 virtual int numNodesInClass(NodeClass nodeClass, GmCellFillMode mode = GM_CELL_NODES) const { Q_UNUSED(nodeClass); Q_UNUSED(mode); return 0; }
77 virtual int numRemoteRanks (int templateIndex) const { Q_UNUSED(templateIndex); return 0; }
78 virtual const int* remoteRanks (int templateIndex) const { Q_UNUSED(templateIndex); return NULL; }
79 virtual bool skipRemote () const { return false;}
80 virtual bool addPartitionInfoAsMeshAttributes (QString cellAttrPrefix, QString nodeAttrPrefix) { Q_UNUSED(cellAttrPrefix); Q_UNUSED(nodeAttrPrefix); return false; }
81 virtual bool addDebugPartitionInfoAsMeshAttributes(QString cellAttrPrefix, QString nodeAttrPrefix) { Q_UNUSED(cellAttrPrefix); Q_UNUSED(nodeAttrPrefix); return false; }
82 virtual void printPartitionRankTemplateData (const GmLogCategory& logger) const { Q_UNUSED(logger); }
83 virtual void printPartitionClassStatistics (const GmLogCategory& logger) const { Q_UNUSED(logger); }
84
85
86 virtual ColorState coloringState (const GmCellGroupSet* gs) { Q_UNUSED(gs); return NOT_COLORED; }
87 virtual const QVector<GmCellGroupSet*>& coloredSets (const GmCellGroupSet* gs) { Q_UNUSED(gs); static QVector<GmCellGroupSet*> dummyEmptyVec; return dummyEmptyVec; }
88 virtual const GmCellGroupSet* sequentialSet (const GmCellGroupSet* gs) { return gs; }
89 virtual const QVector<GmCellGroupSet*>& coloredHaloSets (const GmCellGroupSet* gs) { Q_UNUSED(gs); static QVector<GmCellGroupSet*> dummyEmptyVec; return dummyEmptyVec; }
90 virtual const GmCellGroupSet* sequentialHaloSet(const GmCellGroupSet* gs) { Q_UNUSED(gs); return NULL; }
91
92 virtual bool addColoringAsMeshAttribute(const GmCellGroupSet* gs, QString attrName) { Q_UNUSED(gs); Q_UNUSED(attrName); return false; }
93 virtual bool addColoringAsMeshAttribute(const QVector<const GmCellGroupSet*>& gsets, QString attrName) { Q_UNUSED(gsets); Q_UNUSED(attrName); return false; }
94 virtual void printColoringStatistics (const GmLogCategory& logger) const { Q_UNUSED(logger); }
95
96 virtual bool nodesRenumbered() const { return false; }
97 virtual bool cellsRenumbered() const { return false; }
98
99 virtual int originalToLocalOrderNode (int originalNodeId) const { return originalNodeId; }
100 virtual int originalToLocalOrderGeomNode (int originalNodeId) const { return originalNodeId; }
101 virtual int originalToLocalOrderGhostNodeHighSet (int originalNodeId) const { return originalNodeId; }
102 virtual int originalToLocalOrderGhostNodeHighClear(int originalNodeId) const { return originalNodeId; }
103 virtual int originalToLocalOrderCell (int originalCellId) const { return originalCellId; }
104
105 virtual int originalToLocalOrderNodeSR (int originalNodeId) const { return originalNodeId; }
106 virtual int originalToLocalOrderGeomNodeSR (int originalNodeId) const { return originalNodeId; }
107 virtual int originalToLocalOrderGhostNodeHighSetSR (int originalNodeId) const { return originalNodeId; }
108 virtual int originalToLocalOrderGhostNodeHighClearSR(int originalNodeId) const { return originalNodeId; }
109 virtual int originalToLocalOrderCellSR (int originalCellId) const { return originalCellId; }
110
111 virtual int localOrderToOriginalNode (int nodeId) const { return nodeId; }
112 virtual int localOrderToOriginalGeomNode (int nodeId) const { return nodeId; }
113 virtual int localOrderToOriginalGhostNodeHighSet (int nodeId) const { return nodeId; }
114 virtual int localOrderToOriginalGhostNodeHighClear(int nodeId) const { return nodeId; }
115 virtual int localOrderToOriginalCell (int cellId) const { return cellId;}
116
117 virtual int originalNodeTraversalOrder(int i) const { return i; }
118 virtual int originalCellTraversalOrder(int i) const { return i; }
119
120 virtual bool initPartitions(int numPartitions, int partition)
121 {
122 Q_UNUSED(numPartitions); Q_UNUSED(partition);
123 return false;
124 }
125
126 virtual bool initNodeMapping(GmValueAccessor* ac, bool ghost, bool* renumbered,
127 QMap<int, int>& partOrigToLocOrder)
128 {
129 Q_UNUSED(ac); Q_UNUSED(ghost); Q_UNUSED(partOrigToLocOrder);
130 *renumbered = false;
131 return true;
132 }
133
134 virtual bool initCellMapping(bool* renumbered, QMap<int, int>& partOrigToLocOrder,
135 QVector<int>& partLocToOrigOrder)
136 {
137 Q_UNUSED(partOrigToLocOrder); Q_UNUSED(partLocToOrigOrder);
138 *renumbered = false; return true;
139 }
140
142
143 virtual bool addNodes (int numNodes) { Q_UNUSED(numNodes); return true; }
144 virtual bool addGhostNodes(int numGhostNodes) { Q_UNUSED(numGhostNodes); return true; }
145 virtual bool addCells (int numCells) { Q_UNUSED(numCells); return true; }
146
147 virtual void clear() {}
148
149 virtual bool addStateGeometryData (GmStateDump* state, int groupId) { Q_UNUSED(state); Q_UNUSED(groupId); return true; }
150 virtual bool fillDumpControlMapData (QVariantMap* map, const GmLogCategory& logger) { Q_UNUSED(map); Q_UNUSED(logger); return true; }
151 virtual bool dumpControlMapDataLoaded(QVariantMap* map, const GmLogCategory& logger) { Q_UNUSED(map); Q_UNUSED(logger); return true; }
152
153private:
155};
156
157
158#endif // _GEMA_DEFAULT_PCR_H_
Interface for helping managing mesh cell groups and returning the elements in their union.
Definition gmCellGroupSet.h:35
Base interface class for CellMesh type plugins.
Definition gmCellMesh.h:40
virtual int numCells() const =0
Returns the number of cells in the mesh.
An "empty" PCR object that will neither partition, color or renumber the mesh.
Definition gmDefaultPCR.h:32
virtual bool addPartitionInfoAsMeshAttributes(QString cellAttrPrefix, QString nodeAttrPrefix)
Adds to the mesh a set of new node and cell attributes with information on node and cell classes plus...
Definition gmDefaultPCR.h:80
virtual int numGlobalGhostNodes() const
When working with partitioned meshes, returns the number of ghost nodes in the global mesh,...
Definition gmDefaultPCR.h:68
virtual int originalToLocalOrderCell(int originalCellId) const
Translates an original(model) cell id into the local, ordered, cell id used by the mesh....
Definition gmDefaultPCR.h:103
virtual bool addCells(int numCells)
Informs that the number of cells has been increased. That does not mean that cell nodes or properties...
Definition gmDefaultPCR.h:145
virtual bool addNodes(int numNodes)
Informs that the number of nodes has been increased. That does not mean that coordinates have been fi...
Definition gmDefaultPCR.h:143
virtual const int * remoteRanks(int templateIndex) const
Returns a vector with size equal to numRemoteRanks(templateIndex) storing the ranks (partitions) shar...
Definition gmDefaultPCR.h:78
virtual int originalCellTraversalOrder(int i) const
When traversing the whole set of mesh cells, one common requirement is for the traversal to produce t...
Definition gmDefaultPCR.h:118
virtual bool hasCapability(QString capabilityName) const
This function should return true or false to indicate whether the PCR object supports the requested c...
Definition gmDefaultPCR.h:49
virtual int numGlobalCells() const
When working with partitioned meshes, returns the number of cells in the global mesh,...
Definition gmDefaultPCR.h:69
virtual const GmCellGroupSet * sequentialSet(const GmCellGroupSet *gs)
Returns the set of cells from the given cell group that could not be colored and should be treated se...
Definition gmDefaultPCR.h:88
virtual void printPartitionRankTemplateData(const GmLogCategory &logger) const
Helper debug function to print the rank template data.
Definition gmDefaultPCR.h:82
virtual bool nodesRenumbered() const
Returns true if the nodes where renumbered, false if not. Notice that translation functions work as a...
Definition gmDefaultPCR.h:96
virtual int originalToLocalOrderGhostNodeHighClearSR(int originalNodeId) const
SR version for originalToLocalOrderGhostNodeHighClear(). Returns -1 if skipRemote() is true and the n...
Definition gmDefaultPCR.h:108
virtual int originalNodeTraversalOrder(int i) const
When traversing the whole set of mesh nodes, one common requirement is for the traversal to produce t...
Definition gmDefaultPCR.h:117
virtual NodeClass nodeClass(int nodeId) const
Returns the node class for the given node. Will return MY_NODE if the mesh was not partitioned....
Definition gmDefaultPCR.h:74
virtual const char * pluginCategory() const
Returns the plugin category.
Definition gmDefaultPCR.h:38
virtual int numGlobalNodes() const
When working with partitioned meshes, returns the number of nodes in the global mesh,...
Definition gmDefaultPCR.h:67
virtual int numCellsInClass(CellClass cellClass) const
Returns the number of cells in the mesh that are classified in the given cellClass.
Definition gmDefaultPCR.h:73
virtual const char * pluginName() const
Returns a string identifying the plugin which implements this object. Should return the SAME string a...
Definition gmDefaultPCR.h:41
virtual ColorState coloringState(const GmCellGroupSet *gs)
Returns the coloring state for the given cell group. Will trigger the coloring algorithm if the given...
Definition gmDefaultPCR.h:86
virtual int originalToLocalOrderGhostNodeHighClear(int originalNodeId) const
An specialization of originalToLocalOrderNode, accepting ONLY ghost nodes with the high bit CLEARED (...
Definition gmDefaultPCR.h:102
virtual int originalToLocalOrderGhostNodeHighSetSR(int originalNodeId) const
SR version for originalToLocalOrderGhostNodeHighSet(). Returns -1 if skipRemote() is true and the nod...
Definition gmDefaultPCR.h:107
virtual int cellClassData(int cellId) const
Definition gmDefaultPCR.h:72
virtual bool addGhostNodes(int numGhostNodes)
Informs that the number of ghost nodes has been increased. That does not mean that coordinates have b...
Definition gmDefaultPCR.h:144
virtual size_t printMemoryStatistics(const GmLogCategory &logger, GmLogLevel level) const
Prints memory usage for the PCR object to the given logger. Returns the used memory as reported by us...
Definition gmDefaultPCR.h:58
virtual void clear()
Informs that the mesh was cleared.
Definition gmDefaultPCR.h:147
virtual const GmCellGroupSet * sequentialHaloSet(const GmCellGroupSet *gs)
Similar to sequentialSet() but including only halo cells from the given group set (if any)
Definition gmDefaultPCR.h:90
virtual const QVector< GmCellGroupSet * > & coloredSets(const GmCellGroupSet *gs)
Returns the set of colored cell sub-groups for the given cell group. Within each sub-group,...
Definition gmDefaultPCR.h:87
virtual const QVector< GmCellGroupSet * > & coloredHaloSets(const GmCellGroupSet *gs)
Similar to coloredSets() but including only halo cells from the given group set (if any)
Definition gmDefaultPCR.h:89
virtual int originalToLocalOrderNodeSR(int originalNodeId) const
SR version for originalToLocalOrderNode(). Returns -1 if skipRemote() is true and the node is a remot...
Definition gmDefaultPCR.h:105
virtual bool skipRemote() const
Returns true if the mesh was partitioned, includes remote halo cells and the PCR object was configure...
Definition gmDefaultPCR.h:79
virtual int numPartitions() const
Returns the number of partitions for the mesh. Will return 1 if the mesh was not partitioned.
Definition gmDefaultPCR.h:65
virtual bool initNodeMapping(GmValueAccessor *ac, bool ghost, bool *renumbered, QMap< int, int > &partOrigToLocOrder)
Method called by the mesh to initialize the node renumbering mapping. It will be called once,...
Definition gmDefaultPCR.h:126
virtual bool cellsRenumbered() const
Returns true if the cells where renumbered, false if not. Notice that translation functions work as a...
Definition gmDefaultPCR.h:97
virtual const char * pluginType() const
Returns the string identifying the plugin object type. Should return the SAME string as the one read ...
Definition gmDefaultPCR.h:44
virtual int numRemoteRanks(int templateIndex) const
Returns the number of remote ranks sharing the local cell / node for the given template index.
Definition gmDefaultPCR.h:77
virtual int originalToLocalOrderCellSR(int originalCellId) const
SR version for originalToLocalOrderCell(). Returns -1 if skipRemote() is true and the cell is a remot...
Definition gmDefaultPCR.h:109
virtual bool addColoringAsMeshAttribute(const GmCellGroupSet *gs, QString attrName)
Adds to the mesh a new cell attribute, named attrName, with the 1-based coloring index for each cell....
Definition gmDefaultPCR.h:92
virtual int originalToLocalOrderGeomNodeSR(int originalNodeId) const
SR version for originalToLocalOrderGeomNode(). Returns -1 if skipRemote() is true and the node is a r...
Definition gmDefaultPCR.h:106
virtual bool initPartitions(int numPartitions, int partition)
Breaks the mesh into the specified number of partitions, gathers information about cells,...
Definition gmDefaultPCR.h:120
virtual bool loadPrivateData(LuaTable &table)
Function called by the model loader to give the object acess to it's private parameters....
Definition gmDefaultPCR.h:46
virtual GmMesh * mesh() const
Returns the mesh that this PCR object is tied to.
Definition gmDefaultPCR.h:52
virtual int originalToLocalOrderNode(int originalNodeId) const
Translates an original (model) node id into the local, ordered, node id used by the mesh....
Definition gmDefaultPCR.h:99
virtual int localOrderToOriginalCell(int cellId) const
Translates a local, ordered, cell id used by the mesh into the original(model) cell id When working w...
Definition gmDefaultPCR.h:115
virtual CellClass cellClass(int cellId) const
Returns the cell class for the given cell. Will return MY_CELL if the mesh was not partitioned.
Definition gmDefaultPCR.h:71
virtual bool setMesh(GmMesh *mesh)
Associates this PCR object with a mesh.
Definition gmDefaultPCR.h:55
virtual int nodeClassData(int nodeId) const
Definition gmDefaultPCR.h:75
virtual int localOrderToOriginalGhostNodeHighClear(int nodeId) const
An specialization of localOrderToOriginalNode, accepting ONLY ghost nodes with the high bit CLEARED (...
Definition gmDefaultPCR.h:114
virtual int localOrderToOriginalGhostNodeHighSet(int nodeId) const
An specialization of localOrderToOriginalNode, accepting ONLY ghost nodes with the high bit SET (betw...
Definition gmDefaultPCR.h:113
virtual int partition() const
Returns the number of the selected partition for the current mesh. Will return 0 if the mesh was not ...
Definition gmDefaultPCR.h:66
virtual void printColoringStatistics(const GmLogCategory &logger) const
Helper debug function to print coloring statistics for the existing colorings.
Definition gmDefaultPCR.h:94
virtual bool initCellMapping(bool *renumbered, QMap< int, int > &partOrigToLocOrder, QVector< int > &partLocToOrigOrder)
Method called by the mesh to initialize the cell renumbering mapping. It will be called once after ce...
Definition gmDefaultPCR.h:134
virtual bool addDebugPartitionInfoAsMeshAttributes(QString cellAttrPrefix, QString nodeAttrPrefix)
Similar to addPartitionInfoAsMeshAttributes() but adding extra cell and node attributes named by the ...
Definition gmDefaultPCR.h:81
virtual int localOrderToOriginalGeomNode(int nodeId) const
An specialization of localOrderToOriginalNode, accepting ONLY geometric nodes (between 0 and num node...
Definition gmDefaultPCR.h:112
virtual QStringList cellMappingRequiredGroups()
Method called by the mesh to query if the pcr object needs any cell group information to exist before...
Definition gmDefaultPCR.h:141
virtual int numNodesInClass(NodeClass nodeClass, GmCellFillMode mode=GM_CELL_NODES) const
Returns the number of nodes in the mesh that are classified in the given nodeClass....
Definition gmDefaultPCR.h:76
GmMesh * _mesh
The associated mesh. Must be set by a call to setMesh()
Definition gmDefaultPCR.h:154
virtual size_t usedMemory() const
Returns the approximate memory used for storing the PCR data structures.
Definition gmDefaultPCR.h:61
virtual int localOrderToOriginalNode(int nodeId) const
Translates a local, ordered, node id used by the mesh into the original (model) node id....
Definition gmDefaultPCR.h:111
virtual void printPartitionClassStatistics(const GmLogCategory &logger) const
Helper debug function to print class statistics. In "debug mode" prints the statistics for all partit...
Definition gmDefaultPCR.h:83
virtual bool addColoringAsMeshAttribute(const QVector< const GmCellGroupSet * > &gsets, QString attrName)
Similar to addColoringAsMeshAttribute(const GmCellGroupSet*, QString) but "appending" together severa...
Definition gmDefaultPCR.h:93
virtual int originalToLocalOrderGhostNodeHighSet(int originalNodeId) const
An specialization of originalToLocalOrderNode, accepting ONLY ghost nodes with the high bit SET (betw...
Definition gmDefaultPCR.h:101
virtual int originalToLocalOrderGeomNode(int originalNodeId) const
An specialization of originalToLocalOrderNode, accepting ONLY geometric nodes (between 0 and num node...
Definition gmDefaultPCR.h:100
virtual ColorType coloringType() const
Returns the type of coloring for this PCR object.
Definition gmDefaultPCR.h:63
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
NodeClass
Node classification enum.
Definition gmPCR.h:132
@ MY_NODE
A node belonging to the current partition that is not a halo node
Definition gmPCR.h:133
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
CellClass
Cell classification enum.
Definition gmPCR.h:125
@ MY_CELL
A cell belonging to the current partition that is not a halo cell.
Definition gmPCR.h:126
virtual GmMesh * mesh() const =0
Returns the mesh that this PCR object is tied to.
ColorType
Type of coloring.
Definition gmPCR.h:220
@ NO_COLORING
No coloring configured.
Definition gmPCR.h:221
GmPCR(GmSimulationData *simulation, QString id, QString description, const GmLogCategory &logger)
Constructor.
Definition gmPCR.cpp:41
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
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
Declaration of the GmCellMesh interface class.
#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
Implementation of the GmPCR class.
#define GM_PLUGIN_PCR
Plugin implements PCR (Partition-Color-Renumber) objects.
Definition gmPluginCategory.h:33