24 #ifndef _GEMA_PLUGIN_MESH_BASE_H_ 25 #define _GEMA_PLUGIN_MESH_BASE_H_ 39 #define GEMA_MESH_PLUGIN_DUMP_CODE 0x00AB0000 66 template <
class Mesh,
class CoordAcc,
class CoordGhostAcc,
67 class Data,
class CellData,
template <
class>
class Vector>
73 : Mesh(simulation, id, description, logger),
_nd(this)
84 virtual const char* pluginName()
const {
return "GemaMesh"; }
87 virtual const char* pluginType()
const {
if constexpr(std::is_same<Vector<int>,
GmSingleVector<int>>::value)
return "nodes";
else return "nodesd"; }
90 virtual bool hasCapability(
QString capabilityName)
const 95 return (capabilityName ==
"addNodes" ||
96 capabilityName ==
"clear" ||
97 capabilityName ==
"stateDump" ||
98 (capabilityName ==
"ghostNodes" &&
_nd._ghostEnabled));
110 #ifdef TRACK_MESHLOAD_TIME 120 gmErrorMsg(logger(),
QObject::tr(
"Error loading mesh. Unsuported coordinate dimension."));
129 cd->setGhostEnabled(
_nd.ghostEnabled());
133 if(cd && (pluginType() ==
QString(
"elem") || pluginType() ==
QString(
"elemd")))
143 gmErrorMsg(logger(),
QObject::tr(
"Error loading mesh hierarchical order. Invalid values for P and/or Q.\n" 148 int pqIndex = CellData::hierarchicalOrderIndex(p, q);
151 gmErrorMsg(logger(),
QObject::tr(
"Error loading mesh hierarchical order.\n" 152 "A model can only have %1 different sets of hierarchical orders.")
153 .arg(CellData::maxHTypes));
156 cd->_hierarchicalIndex = pqIndex;
157 _nd.setGhostEnabled(
true);
158 cd->setGhostEnabled(
true);
170 virtual GmValueInfo* nodeCoordInfo()
const {
return _nd._coordInfo; }
175 bool compatibleUnits;
179 gmInfoMsg(logger,
QObject::tr(
"Could not create an accessor for mesh coordinates due to incompatible units.\n" 180 "Data unit = '%1'. Requested unit = '%2'.")
181 .arg(
_nd._coordInfo->unit().name(), desiredUnit.
name()));
185 if(
_nd._ghostEnabled)
195 return new CoordAcc(const_cast<Data&>(
_nd), logger, conv, desiredUnit.
name());
199 virtual int numNodes()
const { assert(
_nd.numNodes() >= 0);
return _nd.numNodes(); }
202 virtual int numGhostNodes()
const { assert(
_nd.numGhostNodes() >= 0);
return _nd.numGhostNodes(); }
208 virtual int addNodes(
int numNodes) {
return _nd.addNewNodes(
this, numNodes); }
211 virtual int addGhostNodes(
int numNodes) {
return _nd.addNewGhostNodes(
this, numNodes); }
214 virtual void clear() {
_nd.clear(
this); }
220 virtual size_t nodeMemory()
const {
return _nd.nodeMemory(); }
223 virtual size_t nodeSetsMemory()
const {
return _nd.nodeSetsMemory(); }
245 virtual bool addStateGeometryData(
GmStateDump* state,
int groupId)
247 return Mesh::addStateGeometryData(state, groupId) &&
_nd.addStateGeometryData(state, groupId);
251 virtual bool fillDumpControlMapData(QVariantMap* map,
const GmLogCategory& logger)
253 return Mesh::fillDumpControlMapData(map, logger) &&
_nd.fillDumpControlMapData(
this, map, logger);
257 virtual bool dumpControlMapDataLoaded(QVariantMap* map,
const GmLogCategory& logger)
259 return Mesh::dumpControlMapDataLoaded(map, logger) &&
_nd.dumpControlMapDataLoaded(
this, map, logger);
Data _nd
The complete node data.
Definition: gmpMeshBase.h:262
#define GM_MAX_ORTHOGONAL_POL_ORDER
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
GmCell *(* GmpMeshLoaderCellAllocator)(GmCellMesh *mesh, int meshId, GmCellType type, int hindex, int id, int offset)
Typedef for a function that can allocate a single cell of the given type and initialize it with the g...
Definition: gmpMeshLoaderAllocator.h:36
Element mesh dump type.
Definition: gmpMeshBase.h:46
GmpMeshBase(GmSimulationData *simulation, QString id, QString description, const GmLogCategory &logger)
Constructor. Will be called by the plugin loading code.
Definition: gmpMeshBase.h:72
QString tr(const char *sourceText, const char *disambiguation, int n)
Element mesh with hierarchical elements dump type.
Definition: gmpMeshBase.h:47
int toInt(bool *ok) const const
GmpGemaMeshStateDumpItemTypes
Dump item type numbers for the different types of the GemaMesh plugin objects.
Definition: gmpMeshBase.h:42
virtual bool loadPrivateData(LuaTable &table)
See behaviour comments on the base class. When inheriting from this class, the idea is that this func...
Definition: gmpMeshBase.h:108
bool hierarchicalElements() const
Returns true if the mesh uses hierarchical elements, false otherwise.
Definition: gmpCellMeshData.h:76
virtual CellData * cellData()
Virtual function that should be overriden for derived classes that need to load cells.
Definition: gmpMeshBase.h:217
static UnitConverter * converter(const Unit &srcUnit, const Unit &dstUnit, bool *compatible=NULL)
Auxiliary class used to load mesh data from a Lua file.
Definition: gmpMeshLoader.h:54
Declaration of the GmpMeshLoader class.
Auxiliar structure used to share data between GmpXxxMeshBase and GmpMeshLoader.
Definition: gmpMeshData.h:43
Cell mesh dump type.
Definition: gmpMeshBase.h:45
virtual ~GmpMeshBase()
Destructor.
Definition: gmpMeshBase.h:78
Auxiliar structure used to share data between GmpXxxCellMeshBase and GmpMeshLoader.
Definition: gmpCellMeshData.h:123
Basic class for a plugin mesh. Implements the needed functions for a GmMesh interface,...
Definition: gmpMeshBase.h:68
static void pushObject(lua_State *L, Base *obj)
bool toBool() const const
virtual GmpMeshLoader< Vector > * meshLoader()
Returns the mesh loader used to load mesh data. This function should be replaced for using a custom m...
Definition: gmpMeshBase.h:235
virtual bool loadMeshData(LuaTable &table, GmMesh *mesh, GmpMeshData< Vector > *nd, GmpCellMeshData< Vector > *cd, GmpMeshLoaderCellAllocator cellAllocator)
Loads the mesh data from the supplied Lua table.
Definition: gmpMeshLoader.cpp:165
QVariant getField(const char *name, LuaEnv::StackOption opt=LuaEnv::STACK_AUTO)
Node mesh dump type.
Definition: gmpMeshBase.h:44