24#ifndef _GEMA_PLUGIN_GEMA_PCR_H_
25#define _GEMA_PLUGIN_GEMA_PCR_H_
63template <
template <
class>
class Vector>
69 :
GmpGemaCRBase(simulation, id, description, logger), _numPartitions(1), _partition(0),
70 _numGlobalNodes(0), _numGlobalGhostNodes(0), _numGlobalCells(0), _partitionMethod(NULL),
71 _haloSides(false), _remoteHalo(false), _debugMode(false), _templateDumpData(NULL),
72 _templateDumpDataSize(0)
78 virtual const char* pluginType()
const {
if constexpr(std::is_same<Vector<int>,
GmSingleVector<int>>::value)
return "pcr";
else return "pcrd"; }
81 virtual bool hasCapability(
QString capabilityName)
const
94 virtual int numPartitions()
const {
return _numPartitions; }
95 virtual int partition()
const {
return _partition; }
96 virtual int numGlobalNodes()
const { assert(_mesh);
return _numPartitions > 1 ? _numGlobalNodes : _mesh->numNodes(); }
97 virtual int numGlobalGhostNodes()
const { assert(_mesh);
return _numPartitions > 1 ? _numGlobalGhostNodes : _mesh->numGhostNodes(); }
98 virtual int numGlobalCells()
const { assert(_mesh &&
dynamic_cast<GmCellMesh*
>(_mesh));
return _numPartitions > 1 ? _numGlobalCells : ((
GmCellMesh*)_mesh)->numCells(); }
101 virtual int cellClassData (
int cellId)
const;
104 virtual int nodeClassData (
int nodeId)
const;
108 virtual int numRemoteRanks(
int templateIndex)
const {
return _debugMode ? 0 : _classData._rankTemplates[templateIndex].first; }
109 virtual const int* remoteRanks (
int templateIndex)
const {
return _debugMode ? NULL : _classData._rankTemplates[templateIndex].second; }
111 virtual bool addPartitionInfoAsMeshAttributes (
QString cellAttrPrefix,
QString nodeAttrPrefix);
112 virtual bool addDebugPartitionInfoAsMeshAttributes(
QString cellAttrPrefix,
QString nodeAttrPrefix);
113 virtual void printPartitionRankTemplateData (
const GmLogCategory& logger)
const;
114 virtual void printPartitionClassStatistics (
const GmLogCategory& logger)
const;
119 virtual bool initPartitions(
int numPartitions,
int partition);
120 virtual bool initNodeMapping(
GmValueAccessor* ac,
bool ghost,
bool* renumbered,
122 virtual bool initCellMapping(
bool* renumbered,
QMap<int, int>& partOrigToLocOrder,
125 virtual bool addNodes (
int numNodes);
126 virtual bool addGhostNodes (
int numGhostNodes);
127 virtual bool addCells (
int numCells);
129 virtual void clear();
131 virtual bool addStateGeometryData (
GmStateDump* state,
int groupId);
132 virtual bool fillDumpControlMapData (QVariantMap* map,
const GmLogCategory& logger);
133 virtual bool dumpControlMapDataLoaded(QVariantMap* map,
const GmLogCategory& logger);
137 virtual size_t partitionMemory()
const;
152 size_t usedMemory()
const;
181 : _templateList(templateList) {}
188 int nodeData(
int nodeId)
const;
197 template <
template<
class>
class V,
class T,
class F>
bool adjustVector(V<T>& vector, F op)
const;
199 bool addAndInitClassDataVector(
ShortVector& v,
int numAddedEntries,
int val)
const;
202 void releaseDumpMemory();
An implementation of the CR (color and renumbering) object interface. The partition interface does no...
Definition gmpGemaCR.h:210
virtual void printParameters(const GmLogCategory &logger)
Print plugin parameters.
Definition gmpGemaCR.cpp:211
virtual bool loadPrivateData(LuaTable &table)
Parses configuration options given by the user to create this PCR object. IMPORTANT: This method is c...
Definition gmpGemaCR.cpp:104
Vector< int > IntVector
A Vector<int>
Definition gmpGemaCR.h:366
Helper class used to create rank templates.
Definition gmpGemaPCR.h:177
QVector< QPair< int, int * > > & _templateList
The template list.
Definition gmpGemaPCR.h:184
QMap< quint32, QVector< int > > _listIndex
Map indexed by a hash of the rank list, storing the indices in _templateList sharing that hash.
Definition gmpGemaPCR.h:185
An implementation of the PCR (partition, color and renumbering) object interface. The template parame...
Definition gmpGemaPCR.h:65
int _numGlobalGhostNodes
The number of ghost nodes on the mesh, before partitioning.
Definition gmpGemaPCR.h:207
int * _templateDumpData
A vector storing a temporary serialized version of _classData._rankTemplates, needed for dumping code...
Definition gmpGemaPCR.h:223
bool _debugMode
When the debug mode is turned on, the partition algorithm will be executed and cells will be classifi...
Definition gmpGemaPCR.h:213
GmpPartitionMethod * _partitionMethod
The configured partitioning object. Can be NULL if the user explicitly requested for no partitioning.
Definition gmpGemaPCR.h:210
GmpGemaPCRBase(GmSimulationData *simulation, QString id, QString description, const GmLogCategory &logger)
Default plugin object constructor.
Definition gmpGemaPCR.h:68
bool _remoteHalo
When set to true, includes the remote halo (remote cells adjacent to the partition halo cells) in the...
Definition gmpGemaPCR.h:212
ClassData _classData
The data set for the current partition. Filled only if _debugMode is false and _numPartitions > 1.
Definition gmpGemaPCR.h:216
bool _haloSides
If set to true, a cell belongs to the halo if one of its sides is shared with a remote cell....
Definition gmpGemaPCR.h:211
int _templateDumpDataSize
The size of the vector _templateDumpData.
Definition gmpGemaPCR.h:226
int _numGlobalCells
The number of cells on the mesh, before partitioning.
Definition gmpGemaPCR.h:208
Vector< short int > ShortVector
A Vector<short>. 14 bits (16k) should be more than enough to store ranks and template indices.
Definition gmpGemaPCR.h:144
int _partition
The number of my partition (rank)
Definition gmpGemaPCR.h:205
int _numGlobalNodes
The number of geometric nodes on the mesh, before partitioning.
Definition gmpGemaPCR.h:206
QVector< ClassData * > _rankClassData
A vector with class data for each partition. Filled only if _debugMode is true.
Definition gmpGemaPCR.h:215
int _numPartitions
The number of mesh partitions. Will always equal 1 in debug mode.
Definition gmpGemaPCR.h:204
typename GmpGemaCRBase< Vector, true >::IntVector IntVector
The same Vector<int> from the base class.
Definition gmpGemaPCR.h:141
The abstract interface for a partition method implementation.
Definition gmpGemaPCR.h:31
virtual bool checkOptions(const GmLogCategory &logger)=0
Virtual method responsible for validating the parameters supplied on the class constructor....
virtual bool partition(GmCellMesh *mesh, int numPartitions, QVector< int > &cellPartition, const GmLogCategory &logger) const =0
The cell partition function. It gets as input parameters the cell mesh with a valid cell incidence in...
virtual void printParameters(const GmLogCategory &logger) const =0
Virtual method responsible for printing the partition method description.
const QVariantMap & _options
The user provided options.
Definition gmpGemaPCR.h:54
#define GM_PCR_NUM_CLASSES
Declaration of the GmpGemaCR class & friends.
GmpGemaPCRBase< GmDualVector > GmpGemaPCRD
Typedef for the PCR implementation with dual vector.
Definition gmpGemaPCR.h:234
GmpGemaPCRBase< GmSingleVector > GmpGemaPCR
Typedef for the PCR implementation with single vector.
Definition gmpGemaPCR.h:231
Class data for cells and nodes.
Definition gmpGemaPCR.h:148
ShortVector _cellClass
Vector storing cell classes + associated data for the cells stored in _cells.
Definition gmpGemaPCR.h:161
ShortVector _nodeClass
Vector storing geometric node classes + associated data for the geometric nodes stored in _nodes.
Definition gmpGemaPCR.h:159
IntVector _cells
The ordered set of cells included in the partition. Unless in debug mode, will be cleared after renum...
Definition gmpGemaPCR.h:157
IntVector _nodes
The ordered set of geometric nodes included in the partition. Unless in debug mode,...
Definition gmpGemaPCR.h:155
QVector< QPair< int, int * > > _rankTemplates
A vector storing the templates defining which remote partitions share a halo node / cell owned by the...
Definition gmpGemaPCR.h:172
ShortVector _ghostClass
Vector storing ghost node classes + associated data for the ghost nodes stored in _ghosts.
Definition gmpGemaPCR.h:160
IntVector _ghosts
The ordered set of (0-based) ghost nodes included in the partition. Unless in debug mode,...
Definition gmpGemaPCR.h:156