GemaMesh
The GeMA Mesh Plugin
gmpGemaCellMesh.h
Go to the documentation of this file.
1 /************************************************************************
2 **
3 ** Copyright (C) 2014 by Carlos Augusto Teixera Mendes
4 ** All rights reserved.
5 **
6 ** This file is part of the "GeMA" software. It's use should respect
7 ** the terms in the license agreement that can be found together
8 ** with this source code.
9 ** It is provided AS IS, with NO WARRANTY OF ANY KIND,
10 ** INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR
11 ** A PARTICULAR PURPOSE.
12 **
13 ************************************************************************/
14 
24 #ifndef _GEMA_PLUGIN_GEMA_CELL_MESH_H_
25 #define _GEMA_PLUGIN_GEMA_CELL_MESH_H_
26 
27 #include "gmpCellMeshBase.h"
28 #include "gmpGemaCell.h"
29 #include "gmpGemaCellMeshData.h"
30 
31 #include <gmLuaCell.h>
32 
33 #include <gmCellMesh.h>
34 
35 #include <gmElementMesh.h>
36 #include <gmElement.h>
37 
39 template <template <class> class Vector>
40 class GMP_GEMAMESH_API_EXPORT GmpGemaCellMeshBase: public GmpCellMeshBase<GmpMeshBaseDataInterface<GmCellMesh, GmpGemaMeshData<Vector>, GmpGemaCellMeshData<Vector>>,
41  GmpGemaMeshCoordAccessor<GmpGemaMeshData<Vector>, Vector>,
42  GmpGemaMeshGhostCoordAccessor<GmpMeshData<Vector>, Vector>,
43  GmpGemaMeshData<Vector>, GmpGemaCellMeshData<Vector>,
44  Vector>
45 {
46 public:
48  GmpGemaCellMeshBase(GmSimulationData* simulation, QString id, QString description, const GmLogCategory& logger)
52  GmpGemaMeshData<Vector>, GmpGemaCellMeshData<Vector>, Vector>(simulation, id, description, logger)
53  {
54  }
55 
56  // Comments on the base class
57  virtual const char* pluginType() const { if constexpr(std::is_same<Vector<int>, GmSingleVector<int>>::value) return "cell"; else return "celld"; }
58 
59  // Comments on the base class
60  virtual void pushProxy(lua_State* L, const GmLogCategory& logger) { LuaProxy::pushObject(L, new GmLuaCellMesh(this, logger)); }
61 
62  virtual GmpGemaMeshData<Vector>* theNodeData() { return &_nd; }
63  virtual GmpGemaCellMeshData<Vector>* theCellData() { return &_cd; }
64 
65 protected:
67  virtual GmpMeshLoaderCellAllocator cellAllocator(bool ghostSupport, bool hSupport) const
68  {
69  Q_UNUSED(hSupport);
70  assert(!hSupport); // A cell mesh does not support hierarchical elements!
71 
72  return ghostSupport ? GmpCellFactory<GmpGemaGhostCell, GmCell, GmLuaCell, GmpGemaCellMeshData<Vector>> :
73  GmpCellFactory<GmpGemaCell, GmCell, GmLuaCell, GmpGemaCellMeshData<Vector>>;
74  }
75 
76  // See comments on the base class and on the enum definition
77  virtual int controlMapStateItemType() { return GMP_GEMA_CMESH_DUMP_ITEM; }
78 };
79 
82 
85 
86 
88 template <template <class> class Vector>
89 class GMP_GEMAMESH_API_EXPORT GmpGemaElementMeshBase: public GmpCellMeshBase<GmpMeshBaseDataInterface<GmElementMesh, GmpGemaMeshData<Vector>, GmpGemaCellMeshData<Vector>>,
90  GmpGemaMeshCoordAccessor<GmpGemaMeshData<Vector>, Vector>,
91  GmpGemaMeshGhostCoordAccessor<GmpMeshData<Vector>, Vector>,
92  GmpGemaMeshData<Vector>, GmpGemaCellMeshData<Vector>,
93  Vector>
94 {
95 public:
97  GmpGemaElementMeshBase(GmSimulationData* simulation, QString id, QString description, const GmLogCategory& logger)
101  GmpGemaMeshData<Vector>, GmpGemaCellMeshData<Vector>, Vector>(simulation, id, description, logger)
102  {
103  }
104 
105  // Comments on the base class
106  virtual const char* pluginType() const { if constexpr(std::is_same<Vector<int>, GmSingleVector<int>>::value) return "elem"; else return "elemd"; }
107 
108  // Comments on the base class
109  virtual void pushProxy(lua_State* L, const GmLogCategory& logger) { LuaProxy::pushObject(L, new GmLuaElementMesh(this, logger)); }
110 
111  // Comments on the base class
112  virtual int hPOrder() const { return GmpCellMeshData<Vector>::hierarchicalPOrder(_cd._hierarchicalIndex); }
113 
114  // Comments on the base class
115  virtual int hQOrder() const { return GmpCellMeshData<Vector>::hierarchicalQOrder(_cd._hierarchicalIndex); }
116 
117  virtual GmpGemaMeshData<Vector>* theNodeData() { return &_nd; }
118  virtual GmpGemaCellMeshData<Vector>* theCellData() { return &_cd; }
119 
120 protected:
122  virtual GmpMeshLoaderCellAllocator cellAllocator(bool ghostSupport, bool hSupport) const
123  {
124  if(hSupport)
125  {
126  assert(ghostSupport); // There is no point in having hierarchical elements without ghost support
127  return GmpHElementFactory<GmpGemaGhostCell, GmpGemaCellMeshData<Vector>>;
128  }
129  else
130  {
131  return ghostSupport ? GmpCellFactory<GmpGemaGhostCell, GmElement, GmLuaElement, GmpGemaCellMeshData<Vector>> :
132  GmpCellFactory<GmpGemaCell, GmElement, GmLuaElement, GmpGemaCellMeshData<Vector>>;
133  }
134  }
135 
136  // See comments on the base class and on the enum definition
137  virtual int controlMapStateItemType()
138  {
139  return _cd.hierarchicalElements() ? GMP_GEMA_HMESH_DUMP_ITEM : GMP_GEMA_EMESH_DUMP_ITEM;
140  }
141 };
142 
145 
148 
149 
150 #endif
151 
Data _nd
The complete node data.
Definition: gmpMeshBase.h:262
Auxiliary class implementing an accessor for mesh ghost coordinate values.
Definition: gmpGemaMeshCoordAccessor.h:90
Declaration of the GmpCellMeshBase class.
GmpGemaCellMeshBase< GmSingleVector > GmpGemaCellMesh
Typedef for a mesh that supports cell data using a GmSingleVector for storing node / cell data.
Definition: gmpGemaCellMesh.h:81
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
static int hierarchicalQOrder(int index)
Returns the Q order for hierarchical elements associated with the given index (returned by hierarchic...
Definition: gmpCellMeshData.h:90
Element mesh dump type.
Definition: gmpMeshBase.h:46
virtual GmpMeshLoaderCellAllocator cellAllocator(bool ghostSupport, bool hSupport) const
Returns the function responsible for allocating and initializing a new element.
Definition: gmpGemaCellMesh.h:122
GmpGemaElementMeshBase(GmSimulationData *simulation, QString id, QString description, const GmLogCategory &logger)
Constructor. Will be called by the plugin loading code.
Definition: gmpGemaCellMesh.h:97
GmpGemaElementMeshBase< GmDualVector > GmpGemaElementMeshD
Typedef for a mesh that supports element data using a GmDualVector for storing node / cell data.
Definition: gmpGemaCellMesh.h:147
Declaration of the GmpGemaCellMeshData structure.
Element mesh with hierarchical elements dump type.
Definition: gmpMeshBase.h:47
Auxiliar structure used to share data between GmpGemaCellMesh and GmpMeshLoader.
Definition: gmpGemaCellMeshData.h:36
GmpGemaCellMeshBase(GmSimulationData *simulation, QString id, QString description, const GmLogCategory &logger)
Constructor. Will be called by the plugin loading code.
Definition: gmpGemaCellMesh.h:48
static int hierarchicalPOrder(int index)
Returns the P order for hierarchical elements associated with the given index (returned by hierarchic...
Definition: gmpCellMeshData.h:85
Auxiliar structure used to share data between GmpXxxMeshBase and GmpMeshLoader.
Definition: gmpMeshData.h:43
Basic class for implementing a mesh with support for cells.
Definition: gmpCellMeshBase.h:66
CellData _cd
The complete cell data.
Definition: gmpCellMeshBase.h:338
A mesh that supports cell data, parameterized by the vector type (either GmSingleVector or GmDualVect...
Definition: gmpGemaCellMesh.h:40
Cell mesh dump type.
Definition: gmpMeshBase.h:45
virtual GmpMeshLoaderCellAllocator cellAllocator(bool ghostSupport, bool hSupport) const
Returns the function responsible for allocating and initializing a new cell.
Definition: gmpGemaCellMesh.h:67
An auxiliary class that can be used as a base class for GmpMeshBase so that a GmCellMesh instance can...
Definition: gmpCellMeshBase.h:41
Auxiliary class implementing an accessor for mesh coordinate values.
Definition: gmpGemaMeshCoordAccessor.h:76
static void pushObject(lua_State *L, Base *obj)
A mesh that supports Element data, parameterized by the vector type (either GmSingleVector or GmDualV...
Definition: gmpGemaCellMesh.h:89
Declaration of the GmpGemaCell class.
Auxiliar structure used to share data between GmpGemaMesh and GmpMeshLoader.
Definition: gmpGemaMeshData.h:31
GmpGemaElementMeshBase< GmSingleVector > GmpGemaElementMesh
Typedef for a mesh that supports element data using a GmSingleVector for storing node / cell data.
Definition: gmpGemaCellMesh.h:144
GmpGemaCellMeshBase< GmDualVector > GmpGemaCellMeshD
Typedef for a mesh that supports cell data using a GmDualVector for storing node / cell data.
Definition: gmpGemaCellMesh.h:84