GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
gmHdf5ModelReader.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_HDF5_MODEL_READER_H_
25#define _GEMA_HDF5_MODEL_READER_H_
26
27#include "gmLog.h"
28#include "gmHdf5Model.h"
29#include "gmBoundaryCondition.h"
30#include "gmCellBoundary.h"
31#include "gmDiscontinuitySet.h"
32#include "gmNanBoxedValue.h"
33
34#include <QStringList>
35
36class GmValueAccessor;
37class GmCellAccessor;
38class GmGaussAccessor;
41class GmPCR;
42
43namespace H5 {
44 class H5File;
45 class DataType;
46}
47
53{
54public:
55
56 GmHdf5ModelReader(QString fileName, const GmLogCategory& logger);
58
60 struct DicInfo
61 {
63 int _n;
64 };
65
67 struct AttrInfo
68 {
70 int _state;
71 int _n;
72 int _d;
74 };
75
85
87 struct DiscInfo
88 {
90 int _n1;
91 int _n2;
92 };
93
101
103 struct MeshInfo
104 {
105 int _d;
113
120
124
125 QVector<BcInfo> _bcList; // Information on each associated boundary condition
126 QVector<DsInfo> _dsList; // Information on each associated discontinuity set
127
128 MeshInfo()
129 : _d(0), _nGeometryNodes(0), _nGhostNodes(0), _nCells(0), _nPSets(0),
130 _nCellNodes(0), _nGhostCells(0), _nInactiveCells(0) {}
131 };
132
133 bool open();
134
136 QString fileName() const { return _fileName; }
137
138 QStringList meshList() const;
139 const MeshInfo* setCurrentMesh(QString mesh, bool meshInfo, bool bcInfo, bool dsInfo, const GmPCR* pcr);
140
142 const MeshInfo* currentMeshInfo() const { return _info; }
143
144 bool loadGeometryCoordinates (GmValueAccessor* coordAc, GmValueAccessor* ghostAc) const;
145 bool loadGeometryCellTopology(const QStringList& propertySetOrder, const QVector<int>& propertySetSizes,
146 int* type, int* propertySets, int* nodes, int* cellsPerType) const;
147 bool loadAndSetMeshGhostCells (GmCellMesh* mesh) const;
148 bool loadAndSetMeshInactiveCells(GmCellMesh* mesh) const;
149 bool loadCellGroupData (int groupIndex, int* data, int* realNumCells) const;
150 bool loadNodeSetData (int groupIndex, int* data, int* realNumNodes) const;
151 bool loadBoundaryData (int groupIndex, const GmCellMesh* mesh, int* data, int* realNumCells, GmCellBoundaryType type) const;
152
153 bool loadNodeData (int attrIndex, GmValueAccessor* ac) const;
154 bool loadCellData (int attrIndex, GmCellAccessor* ac) const;
155 bool loadGaussData(int attrIndex, GmGaussAccessor* ac, const QVector<int>& cellTypeList) const;
156
157 bool loadBcApplicationPoints(int bcIndex, const GmMesh* mesh, int* data, QVector<int>& skipList) const;
158 bool loadBcData (int bcIndex, int attrIndex, GmValueAccessor* ac, const QVector<int>& skipList) const;
159
160 bool loadDsCoordinateData(int dsIndex, int dIndex, double* data) const;
161 bool loadDsBorderData (int dsIndex, int dIndex, const GmCellMesh* mesh, int* data, int* realNumCells) const;
162 bool loadDsTriangleData (int dsIndex, int dIndex, int* data) const;
163
164private:
165 bool loadSharedDictionariesInfo();
166 bool loadMeshInfo();
167 bool loadBcInfo();
168 bool loadDsInfo();
169 bool loadAttributeInfo(GroupType group, QString subGroupName, QVector<AttrInfo>& data, QString excludedTable = "");
170
175 QString groupName(GroupType group, QString subGroupName) const { return GmHdf5Model::groupName(_currentMesh, group, subGroupName); }
176
177 int checkTableLayout(QString tablePath, int ncol, const H5::DataType& type, bool required,
178 int* nlines = NULL, int* ncolumns = NULL) const;
179
180 bool loadDictionary(DictionaryType type, QStringList& data, bool required) const;
181 bool loadDictionary(DictionaryType type, QVector<DicInfo>& data, bool required) const;
182
183 bool loadDictionaryData(int groupIndex, GroupType group, QVector<DicInfo>& dictionary, int* data) const;
184
185 bool loadAccessorData(const AttrInfo& attrInfo, GroupType group, QString subGroupName, GmValueAccessor* ac,
186 const GmMeshGaussIndex* gindex = NULL, const QVector<int>& bcSkipOrCellTypeList = QVector<int>()) const;
187
189 bool isFunctionValue(double v) const { return GmNanBoxedIndex(v, false).isIndex(); }
190
192 unsigned nanToDindex(double v) const { assert(isFunctionValue(v)); return GmNanBoxedIndex(v, false).toIndex(); }
193
196
197 H5::H5File* _fileh;
200
201 const GmPCR* _pcr;
202 const GmPCR* _defPcr;
203};
204
205
206#endif
207
The GmBoundaryConditionAccessor class is a proxy object to a value accesor implementing a more conven...
Definition gmBoundaryConditionAccessor.h:74
BcType
Boundary condition type defining where a BC is applied (node, edge or face)
Definition gmBoundaryCondition.h:62
The GmCellAccessor class is a proxy object to a value accesor implementing a more convenient interfac...
Definition gmCellAccessor.h:67
Base interface class for CellMesh type plugins.
Definition gmCellMesh.h:40
DiscontinuityType
Discontinuity type (defining how the disc. geometry is defined)
Definition gmDiscontinuitySet.h:63
The GmGaussAccessor class is a proxy object to a value accessor implementing a more convenient interf...
Definition gmGaussAccessor.h:39
A helper class with enums and methods common to GmHdf5ModelWriter & GmHdf5ModelReader.
Definition gmHdf5Model.h:36
QString groupName(QString meshName, GroupType group, QString subGroupName) const
Returns the group name for the given mesh / group type. If type is GM_HDF5MODEL_BC_GROUP or GM_HDF5MO...
Definition gmHdf5Model.cpp:61
GroupType
Definition gmHdf5Model.h:58
A helper class used to parse and retrieve data from am hdf5 model file. Used by the mesh plugin to re...
Definition gmHdf5ModelReader.h:53
const GmPCR * _defPcr
Set to an identity GmDefaultPCR object when the user didn't gave us his own PCR object.
Definition gmHdf5ModelReader.h:202
const MeshInfo * currentMeshInfo() const
Returns the current mesh information structure. Equal to the pointer returned on the last call to set...
Definition gmHdf5ModelReader.h:142
const GmPCR * _pcr
The PCR object used to translate indices for the current mesh. Will point to either the user given pc...
Definition gmHdf5ModelReader.h:201
bool isFunctionValue(double v) const
Returns true if v stores a nan encoded function value index.
Definition gmHdf5ModelReader.h:189
QString _currentMesh
The current mesh set by setCurrentMesh()
Definition gmHdf5ModelReader.h:198
H5::H5File * _fileh
The hdf5 file handle.
Definition gmHdf5ModelReader.h:197
QString _fileName
The saved file name.
Definition gmHdf5ModelReader.h:194
const GmLogCategory & _logger
The logger used to emmit error messages.
Definition gmHdf5ModelReader.h:195
unsigned nanToDindex(double v) const
Returns the encoded index into the given nan encoded value.
Definition gmHdf5ModelReader.h:192
QString groupName(GroupType group, QString subGroupName) const
Returns the group name for the given group type. If type is GM_HDF5MODEL_BC_GROUP or GM_HDF5MODEL_DS_...
Definition gmHdf5ModelReader.h:175
QString fileName() const
Returns the file name.
Definition gmHdf5ModelReader.h:136
MeshInfo * _info
The current mesh info data.
Definition gmHdf5ModelReader.h:199
Class representing a category with multiple logging levels.
Definition gmLog.h:58
A Gauss index interface always indexing ALL the elements of a mesh, with support for mesh growing.
Definition gmGaussIndex.h:275
Base interface class for Mesh type plugins.
Definition gmMesh.h:48
A helper class to store an usigned index as the boxed nan value.
Definition gmNanBoxedValue.h:78
bool isIndex() const
Is this a User function pointer value?
Definition gmNanBoxedValue.h:107
unsigned toIndex() const
Returns the stored value as an index.
Definition gmNanBoxedValue.h:110
Base interface class for Partition-Color-Renumber object plugins.
Definition gmPCR.h:54
Interface class for accessing and setting values from an "indexable" collection of values.
Definition gmValueAccessor.h:60
Declaration of the GmBoundaryCondition class.
Declaration of the GmCellBoundary class.
GmCellBoundaryType
Cell boundary type.
Definition gmCellBoundary.h:31
#define GMC_API_EXPORT
Macro for controlling if the class is being exported (GEMA_CORE_LIB defined) or imported (GEMA_CORE_L...
Definition gmCoreConfig.h:35
Implementation of the GmDiscontinuitySet class.
Declaration of the GmHdf5Model class.
Declaration of support functions and macros for information logging.
Declaration of the GmNanBoxedValue class.
Aux structure with information for a data attribute.
Definition gmHdf5ModelReader.h:68
int _d
The dimension of each value.
Definition gmHdf5ModelReader.h:72
int _n
The number of attribute values.
Definition gmHdf5ModelReader.h:71
QString _name
The attribute name.
Definition gmHdf5ModelReader.h:69
bool _functions
Does the data has encoded NAN "function" references?
Definition gmHdf5ModelReader.h:73
int _state
The attribute state (0 for current, 1 for first old and so on)
Definition gmHdf5ModelReader.h:70
Aux structure with information abou a boundary condition.
Definition gmHdf5ModelReader.h:78
QString _name
The boundary condition name.
Definition gmHdf5ModelReader.h:79
int _d
The number of columns in the application points table (really depends only on _type,...
Definition gmHdf5ModelReader.h:82
GmBoundaryCondition::BcType _type
The boundary condition type.
Definition gmHdf5ModelReader.h:80
int _n
The number of boundary condition lines (application point lines)
Definition gmHdf5ModelReader.h:81
QVector< AttrInfo > _attrData
Information on each associated attribute.
Definition gmHdf5ModelReader.h:83
Aux structure with information for dictionary tables with associated data sets.
Definition gmHdf5ModelReader.h:61
QString _name
The dictionary entry name.
Definition gmHdf5ModelReader.h:62
int _n
The number of "objects" (cell ids, node ids or border definitions) tied to this entry.
Definition gmHdf5ModelReader.h:63
Aux structure with information about a discontinuity.
Definition gmHdf5ModelReader.h:88
int _n1
The number of coordinate values for polyline or surface type. The number of borders for edge or face ...
Definition gmHdf5ModelReader.h:90
QString _name
The discontinuity name.
Definition gmHdf5ModelReader.h:89
int _n2
The coord dimension for polyline type. The number of triangles for surface type. 0 for edge or face l...
Definition gmHdf5ModelReader.h:91
Aux structure with information about a discontinuity set.
Definition gmHdf5ModelReader.h:96
GmDiscontinuitySet::DiscontinuityType _type
The discontinuity set type.
Definition gmHdf5ModelReader.h:98
QVector< DiscInfo > _discData
Information on each associated discontinuity.
Definition gmHdf5ModelReader.h:99
QString _name
The discontinuity set name.
Definition gmHdf5ModelReader.h:97
General mesh information (only the "metadata" is loaded - table contents are not loaded,...
Definition gmHdf5ModelReader.h:104
int _nGhostCells
The number of cells that have ghost nodes.
Definition gmHdf5ModelReader.h:111
QVector< AttrInfo > _gaussInitialData
Information regarding gauss initial values.
Definition gmHdf5ModelReader.h:123
QVector< DicInfo > _cellGroupsDictionary
The set of stored cell groups together with the number of cells in each group.
Definition gmHdf5ModelReader.h:116
int _nGeometryNodes
The number of geometry nodes.
Definition gmHdf5ModelReader.h:106
QVector< DicInfo > _boundaryFacesDictionary
The set of stored boundary faces together with the number of faces in each group.
Definition gmHdf5ModelReader.h:119
int _nCells
The number of cells in the mesh.
Definition gmHdf5ModelReader.h:108
int _nCellNodes
The sum of the number of each cell's nodes.
Definition gmHdf5ModelReader.h:110
QVector< DicInfo > _boundaryEdgesDictionary
The set of stored boundary edges together with the number of edges in each group.
Definition gmHdf5ModelReader.h:118
int _d
The mesh dimension.
Definition gmHdf5ModelReader.h:105
QVector< AttrInfo > _nodeInitialData
Information regarding node initial values.
Definition gmHdf5ModelReader.h:121
int _nPSets
The number of property sets tied to this mesh (equal to _propertySetsDictionary.size())
Definition gmHdf5ModelReader.h:109
QStringList _propertySetsDictionary
The set of stored mesh property sets.
Definition gmHdf5ModelReader.h:115
QVector< AttrInfo > _cellInitialData
Information regarding cell initial values.
Definition gmHdf5ModelReader.h:122
int _nGhostNodes
The number of ghost nodes.
Definition gmHdf5ModelReader.h:107
int _nInactiveCells
The number of inactive cells.
Definition gmHdf5ModelReader.h:112
QVector< DicInfo > _nodeSetsDictionary
The set of stored node groups together with the number of nodes in each group.
Definition gmHdf5ModelReader.h:117
QStringList _functionsDictionary
The set of stored functions.
Definition gmHdf5ModelReader.h:114