24#ifndef _GEMA_PLUGIN_CELL_MESH_H_
25#define _GEMA_PLUGIN_CELL_MESH_H_
51template <
class Mesh,
template <
class>
class Vector>
57 :
GmpNodeMesh<Mesh, Vector>(simulation, id, description, logger),
_cd(this)
69 virtual bool hasCapability(
QString capabilityName)
const
71 return (capabilityName ==
"addCells" || capabilityName ==
"editGroups" || capabilityName ==
"topology" ||
76 virtual int numCells()
const {
return _cd._numCells; }
79 virtual int numActiveCells()
const {
return _cd._numActiveCells; }
82 virtual const GmCell* cell(
int cellIndex)
const
84 assert(cellIndex >= 0 && cellIndex < numCells());
85 return _cd.cell(cellIndex);
89 virtual GmCell* cell(
int cellIndex)
91 assert(cellIndex >= 0 && cellIndex < numCells());
92 return _cd.cell(cellIndex);
98 if(!
_cd._topology && create)
108 self->
_cd.buildTopologyStructure(
this, &self->
_nd, simulationData(), logger());
110 return _cd._topoQuery;
114 virtual void clearTopology() {
_cd.clearTopology(); }
117 virtual bool hasSolidElements()
const {
return _cd._hasSolidElements; }
120 virtual const int* numCellTypes()
const {
return _cd._cellsByType; }
123 virtual const int* numActiveCellTypes()
const {
return _cd._activeCellsByType; }
126 virtual int maxNumCellNodes()
const {
return _cd._maxNumNodes; }
129 virtual int maxNumCellGhostNodes()
const {
return _cd._maxNumGhostNodes; }
132 virtual int maxTotalNumCellNodes()
const {
return _cd._maxTotalNumNodes; }
135 virtual void ghostNodesUpdated(
int nghost,
int ntotal)
137 if(nghost >
_cd._maxNumGhostNodes)
138 _cd._maxNumGhostNodes = nghost;
139 if(ntotal >
_cd._maxTotalNumNodes)
140 _cd._maxTotalNumNodes = ntotal;
144 virtual void activeCellUpdated(
GmCellType type,
bool active)
146 int o = active ? 1 : -1;
147 _cd._numActiveCells += o;
148 _cd._activeCellsByType[type] += o;
152 virtual QStringList cellGroupIds()
const {
return _cd._cellGroupIds; }
155 virtual int numCellsInGroup(
int groupIndex)
const
157 return _cd._numCellsInGroup.
at(groupIndex);
161 virtual const GmCell* cellInGroup(
int groupIndex,
int cellIndex)
const
163 assert(cellIndex >= 0 && cellIndex < numCellsInGroup(groupIndex));
164 return cell(
_cd._cellGroupCells.at(groupIndex)[cellIndex]);
168 virtual GmCell* cellInGroup(
int groupIndex,
int cellIndex)
170 assert(cellIndex >= 0 && cellIndex < numCellsInGroup(groupIndex));
171 return cell(
_cd._cellGroupCells.at(groupIndex)[cellIndex]);
175 virtual int addCellGroup(
QString groupName) {
return _cd.addCellGroup(groupName); }
178 virtual bool addCellsToGroup(
int groupId,
const QVector<int>& cellIds) {
return _cd.addCellsToGroup(groupId, cellIds); }
181 virtual bool addCellsToGroup(
int groupId,
const QVector<
QPair<int, int>>& cellIds) {
return _cd.addCellsToGroup(groupId, cellIds); }
190 virtual int propertySetIndex(
QString id)
const
192 for(
int i = 0, size =
_cd._propertySets.size(); i<size; i++)
203 virtual int addCells(
int* numCellTypes)
207 clearCellStatistics();
213 return _cd.addCells(
this, numCellTypes,
true,
true,
_pcr, logger());
232 virtual void emitMeshChanged()
234 if(!
_cd.topologyMeshChanged())
235 gmWarnMsg(logger(),
QObject::tr(
"Error updating the topological structure. The structure was removed."));
245 clearCellStatistics();
252 virtual size_t cellMemory()
const {
return _cd.
cellMemory(); }
255 virtual size_t cellGroupsMemory()
const {
return _cd.cellGroupsMemory(); }
258 virtual size_t cellBoundariesMemory()
const {
return _cd.cellBoundariesMemory(); }
269 bool hSupport =
false;
271 if(pluginType() ==
QString(
"elem") || pluginType() ==
QString(
"elemd"))
281 gmErrorMsg(logger(),
QObject::tr(
"Error loading mesh hierarchical order. Invalid values for P and/or Q.\n"
286 if(!
_cd.setHierarchicalIndex(p, q))
288 gmErrorMsg(logger(),
QObject::tr(
"Error loading mesh hierarchical order.\n"
289 "A model can only have %1 different sets of hierarchical orders.")
295 *ghostSupport =
true;
302 assert(
_cd._cellSize > 0);
323 virtual int cellSize(
bool ghostSupport,
bool hSupport)
const = 0;
331 virtual bool addStateGeometryData(
GmStateDump* state,
int groupId)
335 return _cd._dumper->addStateGeometryData(simulationData(),
this, state, groupId);
339 virtual bool fillDumpControlMapData(QVariantMap* map,
const GmLogCategory& logger)
344 return _cd._dumper->fillDumpControlMapData(
this, map, logger);
348 virtual bool dumpControlMapDataLoaded(QVariantMap* map,
const GmLogCategory& logger)
352 _oldNumCells = (*map)[
"CellMeshBase_oldNumCells"].toInt();
353 return _cd._dumper->dumpControlMapDataLoaded(
this, map, logger);
362template <
template <
class>
class Vector>
371 virtual const char* pluginType()
const {
if constexpr(std::is_same<Vector<int>,
GmSingleVector<int>>::value)
return "cell";
else return "celld"; }
383 return ghostSupport ? GmpCellFactory<GmpGhostCell, GmCell, GmLuaCell, GmpCellMeshData<Vector>> :
384 GmpCellFactory<GmpCell, GmCell, GmLuaCell, GmpCellMeshData<Vector>>;
388 virtual int cellSize(
bool ghostSupport,
bool hSupport)
const
393 return ghostSupport ? GmpCellSize<GmpGhostCell, GmCell, GmLuaCell, GmpCellMeshData<Vector>>() :
394 GmpCellSize<GmpCell, GmCell, GmLuaCell, GmpCellMeshData<Vector>>();
402template <
template <
class>
class Vector>
411 virtual const char* pluginType()
const {
if constexpr(std::is_same<Vector<int>,
GmSingleVector<int>>::value)
return "elem";
else return "elemd"; }
428 assert(ghostSupport);
429 return GmpHElementFactory<GmpGhostCell, GmpCellMeshData<Vector>>;
433 return ghostSupport ? GmpCellFactory<GmpGhostCell, GmElement, GmLuaElement, GmpCellMeshData<Vector>> :
434 GmpCellFactory<GmpCell, GmElement, GmLuaElement, GmpCellMeshData<Vector>>;
439 virtual int cellSize(
bool ghostSupport,
bool hSupport)
const
443 assert(ghostSupport);
444 return GmpHElementSize<GmpGhostCell, GmpCellMeshData<Vector>>();
448 return ghostSupport ? GmpCellSize<GmpGhostCell, GmElement, GmLuaElement, GmpCellMeshData<Vector>>() :
449 GmpCellSize<GmpCell, GmElement, GmLuaElement, GmpCellMeshData<Vector>>();
454 virtual int controlMapStateItemType()
virtual GmValueInfo * propertyInfo(QString propertyId) const=0
static bool inMainThread()
Basic class for implementing a mesh with support for cells.
Definition gmpCellMesh.h:53
GmpCellMeshBase(GmSimulationData *simulation, QString id, QString description, const GmLogCategory &logger)
Constructor. Will be called by the plugin loading code.
Definition gmpCellMesh.h:56
virtual int cellSize(bool ghostSupport, bool hSupport) const =0
Virtual function that should be overridden by derived classes to specify the concrete "sizeof" of the...
virtual GmpCellAllocator cellAllocator(bool ghostSupport, bool hSupport) const =0
Virtual function that should be overridden by derived classes. The ghostSupport parameter defines if ...
virtual GmpCellMeshData< Vector > * initCellData(LuaTable &table, bool *ghostSupport, bool *ok)
Method called by gmpNodeMesh::loadPrivateData() to initialize the cell data object....
Definition gmpCellMesh.h:265
GmpCellMeshData< Vector > _cd
The complete cell data.
Definition gmpCellMesh.h:356
virtual ~GmpCellMeshBase()
Destructor.
Definition gmpCellMesh.h:63
int _oldNumCells
The old number of cells that the mesh had before calls to addCells()
Definition gmpCellMesh.h:357
static int hierarchicalPOrder(int index)
Returns the P order for hierarchical elements associated with the given index (returned by hierarchic...
Definition gmpCellMeshData.h:81
static int hierarchicalQOrder(int index)
Returns the Q order for hierarchical elements associated with the given index (returned by hierarchic...
Definition gmpCellMeshData.h:86
Auxiliar structure used to share data between GmpCellMesh and GmpMeshLoader. All fields are public si...
Definition gmpCellMeshData.h:121
size_t cellMemory() const
Returns the approximate memory used for storing mesh cells.
Definition gmpCellMeshData.cpp:822
A mesh that supports cell data, parameterized by the vector type (either GmSingleVector or GmDualVect...
Definition gmpCellMesh.h:364
virtual int cellSize(bool ghostSupport, bool hSupport) const
Returns the size of a cell object.
Definition gmpCellMesh.h:388
virtual GmpCellAllocator cellAllocator(bool ghostSupport, bool hSupport) const
Returns the function responsible for allocating and initializing a new cell.
Definition gmpCellMesh.h:378
GmpCellMesh(GmSimulationData *simulation, QString id, QString description, const GmLogCategory &logger)
Constructor. Will be called by the plugin loading code.
Definition gmpCellMesh.h:367
A mesh that supports Element data, parameterized by the vector type (either GmSingleVector or GmDualV...
Definition gmpCellMesh.h:404
virtual int cellSize(bool ghostSupport, bool hSupport) const
Returns the size of a cell object.
Definition gmpCellMesh.h:439
virtual GmpCellAllocator cellAllocator(bool ghostSupport, bool hSupport) const
Returns the function responsible for allocating and initializing a new element.
Definition gmpCellMesh.h:424
GmpElementMesh(GmSimulationData *simulation, QString id, QString description, const GmLogCategory &logger)
Constructor. Will be called by the plugin loading code.
Definition gmpCellMesh.h:407
Basic class for a plugin mesh. Implements the needed functions for a GmMesh interface,...
Definition gmpNodeMesh.h:71
GmPCR * _pcr
PCR object. Not stored inside _nd since that class does not have access to the model data for correct...
Definition gmpNodeMesh.h:248
GmpNodeMeshData< Vector > _nd
The complete node data.
Definition gmpNodeMesh.h:246
static void pushObject(lua_State *L, Base *obj)
QVariant getField(const char *name, LuaEnv::StackOption opt=LuaEnv::STACK_AUTO)
#define GM_MAX_ORTHOGONAL_POL_ORDER
GmCell *(* GmpCellAllocator)(void *addr, int meshId, GmCellType type, int hindex, int id, int offset)
Typedef for a function that can construct a single cell of the given type, placing it at the provided...
Definition gmpCellAllocator.h:36
Implementation of the GmpCellDataDump class.
@ GMP_GEMA_CMESH_DUMP_ITEM
Cell mesh dump type.
Definition gmpDataDump.h:35
@ GMP_GEMA_EMESH_DUMP_ITEM
Element mesh dump type.
Definition gmpDataDump.h:36
@ GMP_GEMA_HMESH_DUMP_ITEM
Element mesh with hierarchical elements dump type.
Definition gmpDataDump.h:37
#define GMP_GEMAMESH_MAX_HTYPES
The maximum number of distinct hierarchical type orders that can be used simmultaneously....
Definition gmpGemaMeshConfig.h:63
Declaration of the GmpNodeMesh class.
void append(const T &value)
const T & at(int i) const const
QString tr(const char *sourceText, const char *disambiguation, int n)
int toInt(bool *ok) const const
Declaration of the UibhmQuery familiy of classes.
Declaration of the UibhmTopology familiy of classes.