GemaMesh
The GeMA Mesh Plugin
Loading...
Searching...
No Matches
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 "gmpCellAllocator.h"
32#include "gmHdf5ModelReader.h"
33
34#include <gmCell.h>
35#include <gmCellBoundary.h>
36#include <gmValueInfo.h>
37#include <gmElementMesh.h>
38
39
41class GmValueInfo;
42class GmLogCategory;
43class GmPCR;
44class LuaTable;
45class LuaFunction;
46class LuaEnv;
47
48template <template <class> class> class GmpNodeMeshData;
49template <template <class> class> class GmpCellMeshData;
50
56template <template <class> class Vector>
57class GMP_GEMAMESH_API_EXPORT GmpMeshLoader
58{
59public:
60 GmpMeshLoader(GmSimulationData* simulation, const GmLogCategory& logger);
61 virtual ~GmpMeshLoader();
62
63 virtual bool loadMeshData(LuaTable& table, GmMesh* mesh, GmpNodeMeshData<Vector>* nd,
64 GmpCellMeshData<Vector>* cd, GmPCR** meshPcr, bool* newPcr);
65
66protected:
67
75
76 bool loadMeshDataAux(LuaTable& table, GmMesh* mesh, LoadMode loadFrom,
77 QString srcFile, GmPCR** meshPcr, bool* newPcr);
78
79 bool loadMetaData (LuaTable& table, GmMesh* mesh);
80 bool loadCoordMetaData (LuaTable& table, GmMesh* mesh);
81 bool loadNodeValueInfoMetaData (LuaTable& table, GmMesh* mesh);
82 bool loadCellValueInfoMetaData (LuaTable& table, GmCellMesh* mesh);
83 bool loadGaussValueInfoMetaData (LuaTable& table, GmElementMesh* mesh);
84 bool loadPropertySetMetaData (LuaTable& table, GmCellMesh* mesh);
85 bool loadIntegrationRulesIntoMesh(LuaTable& table, GmElementMesh* mesh);
86 bool loadTopologyConfigOptions (LuaTable& table, GmCellMesh* mesh);
87 bool initPcrObject (LuaTable& table, GmMesh* mesh, bool partition);
88
89 bool traverseAttributeDefinitions(LuaTable& table, const char* tableName, GmValueSetKind setKind, std::function<bool(GmValueInfo*)> adder);
90 bool traverseStateVarDefinitions (LuaTable& table, GmValueSetKind setKind, std::function<bool(GmValueInfo*)> adder);
91
92 bool addNodeValueSetsToMesh (GmMesh* mesh);
93 bool addCellValueSetsToMesh (GmCellMesh* mesh);
94 bool addGaussValueSetsToMesh(GmElementMesh* mesh);
95
96 void loadNumNodesFromLua (LuaTable& table, int* nnodes, int* nghost);
97 bool loadNodeCoordinatesFromLua (LuaTable& table, GmMesh* mesh, int nnodes, int nghost);
98 bool loadNodeDataFromLua (LuaTable& table, GmMesh* mesh);
99 bool loadNodeSetsFromLua (LuaTable& table, GmMesh* mesh);
100 bool loadCellNodeIncidencesFromLua(LuaTable& table, GmCellMesh* mesh, int* numCellsByType);
101 bool loadCellDataFromLua (LuaTable& table, GmCellMesh* mesh);
102 bool loadCellGroupsFromLua (LuaTable& table, GmCellMesh* mesh, const QStringList& filter, bool skipFilter);
103 bool loadBoundaryDataFromLua (LuaTable& table, GmCellMesh* mesh, const char* tableName, GmCellBoundaryType cellType);
104
105 bool loadNumCellsByType (LuaTable& table, GmCellMesh* mesh, int* numCellsByType);
106 void adjustSingleCellType (LuaTable& table, GmCellMesh* mesh, int* numCellsByType);
107 void getCellAndNodeCountFromPCR (int* nnodes, int* nghost, int* cellsByType);
108 bool loadBoundaryDataFromCellList (LuaEnv* env, QVariant& cellListData, GmCellMesh* mesh, GmCellBoundaryType cellType, QString id);
109 bool loadBoundaryDataFromBorderFilter(LuaFunction& filter, int borderId, GmCellMesh* mesh, GmCellBoundaryType cellType, QString id);
110 bool loadCellGroupsFromCellDefinition(LuaTable& table, GmCellMesh* mesh, const QStringList& filter, bool skipFilter);
111 bool loadAdditionalCellGroupDataFromCellList(LuaEnv* env, QVariant& cellListData, GmCellMesh* mesh, QString id);
112 bool loadAdditionalCellGroupDataFromFilter (LuaFunction& filter, GmCellMesh* mesh, QString id);
113
114 bool loadFromDump(QString dumpFile, GmMesh* mesh);
115
116 GmHdf5ModelReader* initHdf5Reader(QString hdf5File, GmMesh* mesh, const GmHdf5ModelReader::MeshInfo** info);
117 bool loadNodeCoordinatesFromHdf5 (GmHdf5ModelReader* reader, const GmHdf5ModelReader::MeshInfo* info, GmMesh* mesh, int nnodes, int nghost);
118 bool loadNodeDataFromHdf5 (GmHdf5ModelReader* reader, const GmHdf5ModelReader::MeshInfo* info, GmMesh* mesh);
119 bool loadNodeSetsFromHdf5 (GmHdf5ModelReader* reader, const GmHdf5ModelReader::MeshInfo* info, GmMesh* mesh);
120 bool loadCellNodeIncidencesFromHdf5(GmHdf5ModelReader* reader, const GmHdf5ModelReader::MeshInfo* info, GmCellMesh* mesh, int* numCellsByType);
121 bool loadCellDataFromHdf5 (GmHdf5ModelReader* reader, const GmHdf5ModelReader::MeshInfo* info, GmCellMesh* mesh);
122 bool loadGaussDataFromHdf5 (GmHdf5ModelReader* reader, const GmHdf5ModelReader::MeshInfo* info, GmElementMesh* mesh, const QVector<int>& cellTypeList);
123 bool loadInactiveCellsFromHdf5 (GmHdf5ModelReader* reader, const GmHdf5ModelReader::MeshInfo* info, GmCellMesh* mesh);
124 bool loadCellGroupsFromHdf5 (GmHdf5ModelReader* reader, const GmHdf5ModelReader::MeshInfo* info, GmCellMesh* mesh, const QStringList& filter, bool skipFilter);
125 bool loadBoundaryDataFromHdf5 (GmHdf5ModelReader* reader, const GmHdf5ModelReader::MeshInfo* info, GmCellMesh* mesh);
126
127 bool reorderNodes(GmMesh* mesh);
128 bool reorderCells(GmMesh* mesh);
129
130 int parseIntegrationRuleInfo(QVariant v, int* irType, int* r1, int* r2, int* r3);
131 int parseSide(LuaTable& tab, GmCellBoundaryType cellType, int* cellIndex, int* sideIndex, QString id, GmCellMesh* mesh, int entryIndex);
132
134 struct DataIt
135 {
136 const QVariant& _v;
137 const char* _field;
138 int _size;
139 int _type;
140 int _next;
141 int _nextt;
142
143 DataIt(const QVariant& v, const char* f, int s, int t)
144 : _v(v), _field(f), _size(s), _type(t), _next(1), _nextt(1) { assert(s >= 0 && t >= 0 && t <= 3); }
145
146 void reset() { _next = 1; _nextt = 1; }
147 };
148
149 DataIt tableSize(LuaEnv* env, const QVariant& v, const char* field);
150 LuaTable ttable (LuaEnv* env, DataIt& it);
151 int itable (LuaEnv* env, DataIt& it);
152 void tableInc (LuaEnv* env, DataIt& it);
153
154 void cleanup(GmMesh* mesh);
155
161 bool _newPcr;
163
168};
169
170
171#endif
172
Auxiliar structure used to share data between GmpCellMesh and GmpMeshLoader. All fields are public si...
Definition gmpCellMeshData.h:121
Auxiliary class used to load mesh data from a Lua file.
Definition gmpMeshLoader.h:58
GmSimulationData * _simulation
Pointer to simulation data.
Definition gmpMeshLoader.h:156
QVector< GmValueInfo * > _gaussList
Stores Gauss attributes metadata while they where not yet claimed by a ValueSet.
Definition gmpMeshLoader.h:167
QVector< GmValueInfo * > _ghostList
Stores ghost attributes & state vars metadata while they where not yet claimed by a ValueSet.
Definition gmpMeshLoader.h:165
GmpCellMeshData< Vector > * _cd
The cell data to be filled.
Definition gmpMeshLoader.h:159
bool _newPcr
Was this PCR object created by us?
Definition gmpMeshLoader.h:161
GmPCR * _pcr
The PCR object created / referenced from the model by loadPcrObject();.
Definition gmpMeshLoader.h:160
QVector< GmValueInfo * > _nodeList
Stores node attributes & state vars metadata while they where not yet claimed by a ValueSet.
Definition gmpMeshLoader.h:164
GmpNodeMeshData< Vector > * _nd
The node data to be filled.
Definition gmpMeshLoader.h:158
const GmLogCategory & _logger
The logger object used to emmit messages.
Definition gmpMeshLoader.h:157
LoadMode
Enum defining from where the data should be loaded.
Definition gmpMeshLoader.h:70
@ LOAD_FROM_LUA
Data should be loaded from the Lua model file.
Definition gmpMeshLoader.h:71
@ LOAD_FROM_DUMP
Data should be loaded from the dump file.
Definition gmpMeshLoader.h:72
@ LOAD_FROM_HDF5
Data should be loaded from the hdf5 file.
Definition gmpMeshLoader.h:73
QVector< GmValueInfo * > _cellList
Stores cell attributes & state vars metadata while they where not yet claimed by a ValueSet.
Definition gmpMeshLoader.h:166
bool _buildTopo
Should we build the topology after mesh loading?
Definition gmpMeshLoader.h:162
Auxiliar interface used to share node data between the mesh implementation and GmpMeshLoader....
Definition gmpNodeMeshData.h:53
GmCellBoundaryType
GmValueSetKind
Declaration of the GmpCellAllocator type.
Declaration of useful configuration definitions for the plugin library.
Iterator structure returned by tableSize and consumed by ttable / itable.
Definition gmpMeshLoader.h:135
int _size
The data size.
Definition gmpMeshLoader.h:138
int _next
The next index when calling a function / indexing a table.
Definition gmpMeshLoader.h:140
int _nextt
The next table index when the data is provided by multiple tables.
Definition gmpMeshLoader.h:141
const char * _field
The field name used on error messages.
Definition gmpMeshLoader.h:137
int _type
_v type: 0 = invalid, 1 = function, 2 = table, 3 = multiple tables
Definition gmpMeshLoader.h:139
const QVariant & _v
The data source. Either a LuaTable or a LuaFunction object, held externally.
Definition gmpMeshLoader.h:136