GemaMesh
The GeMA Mesh Plugin
gmpMeshLoader.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_MESH_LOADER_H_
25 #define _GEMA_PLUGIN_MESH_LOADER_H_
26 
27 #include <QList>
28 #include <QString>
29 
30 #include "gmpGemaMeshConfig.h"
31 #include "gmpMeshLoaderAllocator.h"
32 
33 #include <gmCell.h>
34 #include <gmCellBoundary.h>
35 #include <gmValueInfo.h>
36 #include <gmElementMesh.h>
37 
38 
39 class GmSimulationData;
40 class GmValueInfo;
41 class GmLogCategory;
42 class LuaTable;
43 class LuaEnv;
44 
45 template <template <class> class> struct GmpMeshData;
46 template <template <class> class> struct GmpCellMeshData;
47 
53 template <template <class> class Vector>
54 class GMP_GEMAMESH_API_EXPORT GmpMeshLoader
55 {
56 public:
57  GmpMeshLoader(GmSimulationData* simulation, const GmLogCategory& logger);
58  virtual ~GmpMeshLoader();
59 
60  virtual bool loadMeshData(LuaTable& table, GmMesh* mesh, GmpMeshData<Vector>* nd, GmpCellMeshData<Vector>* cd,
61  GmpMeshLoaderCellAllocator cellAllocator);
62 
63 protected:
64  bool loadMeshDataAux(LuaTable& table, GmMesh* mesh, GmpMeshLoaderCellAllocator cellAllocator);
65 
66  bool loadCoordData (LuaTable& table);
67  bool loadStateVarDefData (LuaTable& table, GmMesh* mesh);
68  bool loadAttributeDefData (LuaTable& table, const char* tabName, GmValueSetKind setKind, GmMesh* mesh);
69  bool loadNodeData (LuaEnv* env, const QVariant& table, GmMesh* mesh);
70  bool loadGhostData (LuaEnv* env, const QVariant& table, GmMesh* mesh);
71  bool loadNodeSets (LuaTable& table, GmMesh* mesh);
72  bool loadPropertySetData (LuaTable& table, GmMesh* mesh);
73  bool loadGaussAttributesData(LuaTable& table, GmElementMesh* mesh);
74  bool loadNumCellsByType (LuaTable& table, GmMesh* mesh);
75  bool loadCellData (LuaTable& table, GmCellMesh* mesh, GmpMeshLoaderCellAllocator cellAllocator);
76  bool loadBoundaryData (LuaTable& table, GmCellMesh* mesh, const char* tableName, GmCellBoundaryType cellType);
77  bool loadIntegrationRuleData(LuaTable& table, GmElementMesh* mesh);
78 
79  bool loadFromDump(QString dumpFile, GmMesh* mesh);
80 
81  int parseIntegrationRuleInfo(QVariant v, int* irType, int* r1, int* r2, int* r3);
82 
84  struct DataIt
85  {
86  const QVariant& _v;
87  const char* _field;
88  int _size;
89  int _type;
90  int _next;
91  int _nextt;
92 
93  DataIt(const QVariant& v, const char* f, int s, int t)
94  : _v(v), _field(f), _size(s), _type(t), _next(1), _nextt(1) { assert(s >= 0 && t >= 0 && t <= 3); }
95  };
96 
97  DataIt tableSize(LuaEnv* env, const QVariant& v, const char* field);
98  LuaTable ttable (LuaEnv* env, DataIt& it);
99  int itable (LuaEnv* env, DataIt& it);
100 
101  void cleanup(GmMesh* mesh);
102 
105 
109 
112 };
113 
114 
115 #endif
116 
const QVariant & _v
The data source. Either a LuaTable or a LuaFunction object, held externally.
Definition: gmpMeshLoader.h:86
const char * _field
The field name used on error messages.
Definition: gmpMeshLoader.h:87
GmpMeshData< Vector > * _nd
The node data to be filled.
Definition: gmpMeshLoader.h:110
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
QList< GmValueInfo * > _gaussList
Stores Gauss attributes metadata while they where not yet claimed by a ValueSet.
Definition: gmpMeshLoader.h:108
QList< GmValueInfo * > _ghostList
Stores ghost attributes && state vars metadata while they where not yet claimed by a ValueSet.
Definition: gmpMeshLoader.h:107
const GmLogCategory & _logger
The logger object used to emmit messages.
Definition: gmpMeshLoader.h:104
GmValueSetKind
Iterator structure returned by tableSize and consumed by ttable / itable.
Definition: gmpMeshLoader.h:84
GmpCellMeshData< Vector > * _cd
The cell data to be filled.
Definition: gmpMeshLoader.h:111
QList< GmValueInfo * > _infoList
Stores attributes && state vars metadata while they where not yet claimed by a ValueSet.
Definition: gmpMeshLoader.h:106
GmSimulationData * _simulation
Pointer to simulation data.
Definition: gmpMeshLoader.h:103
Auxiliary class used to load mesh data from a Lua file.
Definition: gmpMeshLoader.h:54
int _size
The data size.
Definition: gmpMeshLoader.h:88
int _nextt
The next table index when the data is provided by multiple tables.
Definition: gmpMeshLoader.h:91
Auxiliar structure used to share data between GmpXxxMeshBase and GmpMeshLoader.
Definition: gmpMeshData.h:43
Declaration of usefull configuration definitions for the plugin library.
Auxiliar structure used to share data between GmpXxxCellMeshBase and GmpMeshLoader.
Definition: gmpCellMeshData.h:123
int _next
The next index when calling a function / indexing a table.
Definition: gmpMeshLoader.h:90
Declaration of the GmpMeshLoaderCellAllocator type.
int _type
_v type: 0 = invalid, 1 = function, 2 = table, 3 = multiple tables
Definition: gmpMeshLoader.h:89
GmCellBoundaryType