24 #ifndef _GEMA_PLUGIN_CELL_MESH_BASE_H_ 25 #define _GEMA_PLUGIN_CELL_MESH_BASE_H_ 40 template <
class BaseMesh,
class NodeData,
class CellData>
44 static_assert(std::is_same<BaseMesh, GmCellMesh>::value || std::is_same<BaseMesh, GmElementMesh>::value,
45 "Unexpected base class");
48 : BaseMesh(simulation,
id, description, logger) {}
50 virtual NodeData* theNodeData() {
return NULL; }
51 virtual CellData* theCellData() {
return NULL; }
65 template <
class Mesh,
class CoordAcc,
class CoordGhostAcc,
class Data,
class CellData,
template <
class>
class Vector>
71 :
GmpMeshBase<Mesh, CoordAcc, CoordGhostAcc, Data, CellData, Vector>(simulation, id, description, logger),
80 clearCellAttributeSets();
84 virtual bool hasCapability(
QString capabilityName)
const 86 return (capabilityName ==
"addCells" || capabilityName ==
"editGroups" || capabilityName ==
"topology" ||
91 virtual int numCells()
const {
return _cd._numCells; }
94 virtual int numActiveCells()
const {
return _cd._numActiveCells; }
97 virtual const GmCell* cell(
int cellIndex)
const 99 assert(cellIndex >= 0 && cellIndex < numCells());
100 return _cd._cells[cellIndex];
104 virtual GmCell* cell(
int cellIndex)
106 assert(cellIndex >= 0 && cellIndex < numCells());
107 return _cd._cells[cellIndex];
113 if(!
_cd._topology && create)
121 MyType*
self = const_cast<MyType*>(
this);
122 if(!self->_cd.buildTopologyStructure(
self))
123 gmErrorMsg(logger(),
QObject::tr(
"Error creating the topological structure for mesh %1.").
arg(
id()));
125 assert((
_cd._topology &&
_cd._topoQuery) || (!
_cd._topology && !
_cd._topoQuery));
126 return _cd._topoQuery;
130 virtual void clearTopology()
132 assert((
_cd._topology &&
_cd._topoQuery) || (!
_cd._topology && !
_cd._topoQuery));
135 delete _cd._topology;
_cd._topology = NULL;
136 delete _cd._topoQuery;
_cd._topoQuery = NULL;
141 virtual const int* numCellTypes()
const {
return _cd._cellsByType; }
144 virtual const int* numActiveCellTypes()
const {
return _cd._activeCellsByType; }
147 virtual int maxNumCellNodes()
const {
return _cd._maxNumNodes; }
150 virtual int maxNumCellGhostNodes()
const {
return _cd._maxNumGhostNodes; }
153 virtual int maxTotalNumCellNodes()
const {
return _cd._maxTotalNumNodes; }
156 virtual void ghostNodesUpdated(
int nghost,
int ntotal)
158 if(nghost >
_cd._maxNumGhostNodes)
159 _cd._maxNumGhostNodes = nghost;
160 if(ntotal >
_cd._maxTotalNumNodes)
161 _cd._maxTotalNumNodes = ntotal;
165 virtual void activeCellUpdated(
GmCellType type,
bool active)
167 int o = active ? 1 : -1;
168 _cd._numActiveCells += o;
169 _cd._activeCellsByType[type] += o;
173 virtual QStringList cellGroupIds()
const {
return _cd._cellGroupIds; }
176 virtual int numCellsInGroup(
int groupIndex)
const 178 return _cd._numCellsInGroup.at(groupIndex);
182 virtual const GmCell* cellInGroup(
int groupIndex,
int cellIndex)
const 184 assert(cellIndex >= 0 && cellIndex < numCellsInGroup(groupIndex));
185 return cell(
_cd._cellGroupCells.at(groupIndex)[cellIndex]);
189 virtual GmCell* cellInGroup(
int groupIndex,
int cellIndex)
191 assert(cellIndex >= 0 && cellIndex < numCellsInGroup(groupIndex));
192 return cell(
_cd._cellGroupCells.at(groupIndex)[cellIndex]);
196 virtual int addCellGroup(
QString groupName) {
return _cd.addCellGroup(groupName); }
199 virtual bool addCellsToGroup(
int groupId,
const QVector<int>& cellIds) {
return _cd.addCellsToGroup(groupId, cellIds); }
202 virtual bool addCellsToGroup(
int groupId,
const QVector<
QPair<int, int>>& cellIds) {
return _cd.addCellsToGroup(groupId, cellIds); }
211 virtual int propertySetIndex(
QString id)
const 213 for(
int i = 0, size =
_cd._propertySets.size(); i<size; i++)
224 virtual int addCells(
int* numCellTypes)
226 if(
_cd._singleCellType)
236 gmErrorMsg(logger(),
QObject::tr(
"Error trying to add multiple cell types to a single cell type mesh."));
242 if(type >= 0 &&
_cd._cellsByType[type] !=
_cd._numCells)
244 gmErrorMsg(logger(),
QObject::tr(
"Cell type mismatch while adding cells to a single cell type mesh."));
251 clearCellStatistics();
252 return _cd.addCells(
this, numCellTypes,
cellAllocator(this->
_nd.ghostEnabled(),
_cd.hierarchicalElements()));
271 virtual void emitMeshChanged()
275 if(!
_cd._topology->addNewCells())
278 gmWarnMsg(logger(),
QObject::tr(
"Error updating the topological structure. The structure was removed."));
290 clearCellStatistics();
297 virtual size_t cellMemory()
const {
return _cd.cellMemory(); }
300 virtual size_t cellGroupsMemory()
const {
return _cd.cellGroupsMemory(); }
303 virtual size_t cellBoundariesMemory()
const {
return _cd.cellBoundariesMemory(); }
311 virtual bool addStateGeometryData(
GmStateDump* state,
int groupId)
315 return _cd.addStateGeometryData(simulationData(),
this,
321 virtual bool fillDumpControlMapData(QVariantMap* map,
const GmLogCategory& logger)
326 return _cd.fillDumpControlMapData(
this, map, logger);
330 virtual bool dumpControlMapDataLoaded(QVariantMap* map,
const GmLogCategory& logger)
334 _oldNumCells = (*map)[
"CellMeshBase_oldNumCells"].toInt();
335 return _cd.dumpControlMapDataLoaded(
this, map, logger);
Data _nd
The complete node data.
Definition: gmpMeshBase.h:262
virtual GmpMeshLoaderCellAllocator cellAllocator(bool ghostSupport, bool hSupport) const
Virtual function that should be overriden for derived classes that need to load cells....
Definition: gmpMeshBase.h:232
Declaration of the UibhmTopology familiy of classes.
GmpCellMeshBase(GmSimulationData *simulation, QString id, QString description, const GmLogCategory &logger)
Constructor. Will be called by the plugin loading code.
Definition: gmpCellMeshBase.h:70
QString tr(const char *sourceText, const char *disambiguation, int n)
virtual ~GmpCellMeshBase()
Destructor.
Definition: gmpCellMeshBase.h:78
Declaration of the UibhmQuery familiy of classes.
virtual GmValueInfo * propertyInfo(QString propertyId) const=0
void append(const T &value)
virtual CellData * cellData()
Virtual function that should be overriden for derived classes that need to load cells.
Definition: gmpCellMeshBase.h:294
Declaration of the GmpGemaMesh class.
Basic class for implementing a mesh with support for cells.
Definition: gmpCellMeshBase.h:66
CellData _cd
The complete cell data.
Definition: gmpCellMeshBase.h:338
Basic class for a plugin mesh. Implements the needed functions for a GmMesh interface,...
Definition: gmpMeshBase.h:68
An auxiliary class that can be used as a base class for GmpMeshBase so that a GmCellMesh instance can...
Definition: gmpCellMeshBase.h:41
int _oldNumCells
The old number of cells that the mesh had before calls to addCells()
Definition: gmpCellMeshBase.h:339
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const