24 #ifndef _GEMA_PLUGIN_CELL_BASE_H_ 25 #define _GEMA_PLUGIN_CELL_BASE_H_ 37 #include <QVarLengthArray> 50 #define GM_CELLBASE_ACTIVE_MASK (~(~0u >> 1)) 55 #define GM_CELLBASE_MESH_MASK ((~(~0u >> GMP_GEMAMESH_CELL_MESH_BITS)) >> 1) 58 #define GM_CELLBASE_CELL_MASK (~(GM_CELLBASE_ACTIVE_MASK | GM_CELLBASE_MESH_MASK)) 116 template <
class Base,
class Proxy,
class CellMeshData, GmCellType T,
int N,
int VN>
class GmpCellBase :
public Base
122 assert(N == geometry().numNodes());
123 assert(VN == geometry().numVertices());
127 virtual int numNodes()
const {
return N; }
136 virtual int propertyIndex(
int propertySet)
const 138 assert(propertySet >= 0 && propertySet < mesh()->propertySets().size());
139 return meshData()->cellPropertiesPtr(cellId())[propertySet];
143 virtual bool setProperties(
const int* propList,
int nprop)
146 assert(nprop == mesh()->propertySets().size());
148 memcpy(
meshData()->cellPropertiesPtr(cellId()), propList, nprop*
sizeof(
int));
180 #pragma pack(push, 4) 184 template <
class Base,
class Proxy,
class CellMeshData, GmCellType T,
int N,
int VN>
class GmpCellBaseWithId 185 :
public GmpCellBase<Base, Proxy, CellMeshData, T, N, VN>
201 virtual void setActive(
bool active)
203 if(active == this->active())
211 virtual void replaceCellId(
int id,
bool keepActiveFlag)
223 :
GmpCellBase<Base, Proxy, CellMeshData, T, N, VN>()
238 template <
template<
class,
class,
class, GmCellType,
int,
int>
class CellBase,
239 class Base,
class Proxy,
class CellMeshData,
GmCellType T,
int N,
int VN>
245 : CellBase<Base, Proxy, CellMeshData, T, N, VN>(mesh, meshId, id, offset)
254 virtual int addGhostNode(
int globalIndex)
257 if(index < 0 || index >= mesh()->numGhostNodes())
267 virtual void removeGhostNode(
int localIndex)
269 assert(localIndex >= N && localIndex < N + (
int)
_ghostList.
size());
274 virtual int nodeIndex(
int localIndex)
const 276 assert(localIndex >= 0 && localIndex < N + (
int)
_ghostList.
size());
277 return localIndex < N ? CellBase<Base, Proxy, CellMeshData, T, N, VN>::nodeIndex(localIndex) :
_ghostList[localIndex-N];
281 virtual void nodes(
int* nodeList,
bool ghost)
const 283 CellBase<Base, Proxy, CellMeshData, T, N, VN>::nodes(nodeList,
false);
289 virtual void replaceGhostNodes(
int* ghostNodes,
int numNodes)
340 template <
template<
class,
class,
class, GmCellType,
int,
int>
class T,
class Base,
class Proxy,
class CellMeshData>
345 assert(hindex == -1);
348 #error Create Cell macro already defined 351 #define CREATE_CELL(type, nn, nv) new T<Base, Proxy, CellMeshData, type, nn, nv>(mesh, meshId, id, offset) 404 template <
template<
class,
class,
class, GmCellType,
int,
int>
class T,
class CellMeshData>
410 #if GmpCellMeshDataMaxHTypes != 3 411 #error Unexpected value for GmpCellMeshDataMaxHTypes 415 #error Create Cell macro already defined 418 #define CREATE_CELL(i, type, nn, nv) new T<GmpHElementBase<i>, GmLuaHElement, CellMeshData, type, nn, nv>(mesh, meshId, id, offset) 423 if (hindex == 0)
return CREATE_CELL(0,
GM_HQUADP, 4, 4);
424 else if(hindex == 1)
return CREATE_CELL(1,
GM_HQUADP, 4, 4);
425 else if(hindex == 2)
return CREATE_CELL(2,
GM_HQUADP, 4, 4);
429 if (hindex == 0)
return CREATE_CELL(0,
GM_DGQUAD, 4, 4);
430 else if(hindex == 1)
return CREATE_CELL(1,
GM_DGQUAD, 4, 4);
431 else if(hindex == 2)
return CREATE_CELL(2,
GM_DGQUAD, 4, 4);
435 if (hindex == 0)
return CREATE_CELL(0,
GM_HHEXP, 8, 8);
436 else if(hindex == 1)
return CREATE_CELL(1,
GM_HHEXP, 8, 8);
437 else if(hindex == 2)
return CREATE_CELL(2,
GM_HHEXP, 8, 8);
441 if (hindex == 0)
return CREATE_CELL(0,
GM_DGHEX, 8, 8);
442 else if(hindex == 1)
return CREATE_CELL(1,
GM_DGHEX, 8, 8);
443 else if(hindex == 2)
return CREATE_CELL(2,
GM_DGHEX, 8, 8);
An auxiliar class that can be used as the base class for GmpCellBase for Hierarchical elements....
Definition: gmpCellBase.h:323
GmpCellBaseWithId(int cellId, int meshId)
Constructs a cell given its id and associated mesh id.
Definition: gmpCellBase.h:222
GmpGhostCellBase(GmCellMesh *mesh, int meshId, int id, int offset)
Constructs a cell given its id and associated mesh id.
Definition: gmpCellBase.h:244
static int hierarchicalQOrder(int index)
Returns the Q order for hierarchical elements associated with the given index (returned by hierarchic...
Definition: gmpCellMeshData.h:90
static int GmpCellSetActiveFlag(int cellId, bool active)
Returns the encoded cell id to represent an active/inactive cell dep3ending on the second parameter.
Definition: gmpCellBase.h:77
GmpCellBase()
Constructs a cell.
Definition: gmpCellBase.h:120
static int GmpCellMakeActive(int cellId)
Returns the encoded cell id with the flag set to represent an active cell.
Definition: gmpCellBase.h:71
GmCell * GmpHElementFactory(GmCellMesh *mesh, int meshId, GmCellType type, int hindex, int id, int offset)
An alternative version to GmpCellFactory() for creating hierarchical elements.
Definition: gmpCellBase.h:405
static int setGhostFlag(int nodeIndex)
static GmpCellMeshDataBase * meshData(int meshId)
Returns the mesh data pointer associated with the given mesh id.
Definition: gmpCellMeshData.h:98
virtual void activeCellUpdated(GmCellType type, bool active)=0
GmPODVector< int, uint32_t, GmPODVectorFastGrow< uint32_t > > _ghostList
List storing cell ghost nodes. Uses a GmPODVector with size control based on a 32 bits value giving a...
Definition: gmpCellBase.h:314
CellMeshData * meshData() const
Returns the mesh data object associated with this cell's mesh.
Definition: gmpCellBase.h:154
#define GMP_GEMAMESH_MAX_NUM_CELLS
The maximum number of allowed cells.
Definition: gmpGemaMeshConfig.h:52
static int clearGhostFlag(int nodeIndex)
#define GMP_GEMAMESH_CELL_ID_BITS
The number of bits effectivelly used to encode the cell id inside a 32 bits integer,...
Definition: gmpGemaMeshConfig.h:46
int _cellId
The cell index inside the mesh. MSB is used to control if the cell is active or not.
Definition: gmpCellBase.h:228
static bool GmpCellIsActive(int cellId)
Returns true if the given index is an active cell index, false if not. Inactive cells have their most...
Definition: gmpCellBase.h:68
Declaration of the GmpCellMeshData structure.
Auxiliar structure used to share data between GmpGemaCellMesh and GmpMeshLoader.
Definition: gmpGemaCellMeshData.h:36
#define GM_CELLBASE_ACTIVE_MASK
Mask with 1 on the MSB to tell if the cell is active (MSB = 0) or not (MSB = 1)
Definition: gmpCellBase.h:50
#define GmpCellMeshDataMaxHTypes
The maximum number of distinct hierarchical type orders that can be used simmultaneously....
Definition: gmpCellMeshData.h:57
Template class used to add ghost node support to template class CellBase.
Definition: gmpCellBase.h:240
static int hierarchicalPOrder(int index)
Returns the P order for hierarchical elements associated with the given index (returned by hierarchic...
Definition: gmpCellMeshData.h:85
bool resize(ControlSize newSize, GmPODGrowT grow=Grow)
static int GmpCellUpdateMeshIndex(int id, int oldId)
Returns the value of id with the mesh bits updated with the mesh from oldId.
Definition: gmpCellBase.h:87
#define GM_CELLBASE_CELL_MASK
Mask with 1 on bits representing the cell id part (least significant bits up to the mesh mask).
Definition: gmpCellBase.h:58
static int GmpCellMakeInactive(int cellId)
Returns the encoded cell id with the flag set to represent an inactive cell.
Definition: gmpCellBase.h:74
Class for storing cell data, implementing the virtual functions needed to store per cell type data,...
Definition: gmpCellBase.h:116
#define GM_CELLBASE_MESH_MASK
Mask with 1 on bits 29, 30 and 31. Used to extract the mesh index from the top id bits (taking into a...
Definition: gmpCellBase.h:55
void remove(ControlSize index, ControlSize numValues)
static void pushObject(lua_State *L, Base *obj)
static int GmpCellIndex(int cellId)
Returns the cell index encoded in a cell id.
Definition: gmpCellBase.h:84
static int GmpCellMeshIndex(int cellId)
Returns the mesh index encoded in a cell id.
Definition: gmpCellBase.h:81
#define GMP_GEMAMESH_MAX_NUM_MESHES
The maximum number of allowed meshes.
Definition: gmpGemaMeshConfig.h:49
Adds cell id and active information to a GmpCellBase class.
Definition: gmpCellBase.h:184
static int GmpCellEncodeId(int cellIndex, int meshIndex, bool active)
Encodes the given cell index, mesh index and active flag into a cell id.
Definition: gmpCellBase.h:90
GmCell * GmpCellFactory(GmCellMesh *mesh, int meshId, GmCellType type, int hindex, int id, int offset)
A factory function for allocating cell objects.
Definition: gmpCellBase.h:341