42 std::cout <<
"Opening HDF5 file " <<
h5FileName << std::endl;
47 file.openFile(h5FileName_, H5F_ACC_RDWR);
48 }
catch (FileIException error) {
49 #if H5_VERS_MAJOR >= 1 && H5_VERS_MINOR >= 8 && H5_VERS_RELEASE >= 20 50 error.printErrorStack();
51 #elif H5_VERS_MAJOR >= 1 && H5_VERS_MINOR >= 10 && H5_VERS_RELEASE >= 2 52 error.printErrorStack();
53 #elif H5_VERS_MAJOR >= 1 && H5_VERS_MINOR >= 11 && H5_VERS_RELEASE >= 0 54 error.printErrorStack();
64 std::cout <<
"Closing HDF5 file " <<
h5FileName << std::endl;
69 }
catch (FileIException error) {
70 #if H5_VERS_MAJOR >= 1 && H5_VERS_MINOR >= 8 && H5_VERS_RELEASE >= 20 71 error.printErrorStack();
72 #elif H5_VERS_MAJOR >= 1 && H5_VERS_MINOR >= 10 && H5_VERS_RELEASE >= 2 73 error.printErrorStack();
74 #elif H5_VERS_MAJOR >= 1 && H5_VERS_MINOR >= 11 && H5_VERS_RELEASE >= 0 75 error.printErrorStack();
88 DataSet dset =
file.openDataSet(dsetName);
93 catch (FileIException error) {
94 #if H5_VERS_MAJOR >= 1 && H5_VERS_MINOR >= 8 && H5_VERS_RELEASE >= 20 95 error.printErrorStack();
96 #elif H5_VERS_MAJOR >= 1 && H5_VERS_MINOR >= 10 && H5_VERS_RELEASE >= 2 97 error.printErrorStack();
98 #elif H5_VERS_MAJOR >= 1 && H5_VERS_MINOR >= 11 && H5_VERS_RELEASE >= 0 99 error.printErrorStack();
112 DataType dtype = dset.getDataType();
114 dset.read(buffer, dtype);
119 catch (DataSetIException error) {
120 #if H5_VERS_MAJOR >= 1 && H5_VERS_MINOR >= 8 && H5_VERS_RELEASE >= 20 121 error.printErrorStack();
122 #elif H5_VERS_MAJOR >= 1 && H5_VERS_MINOR >= 10 && H5_VERS_RELEASE >= 2 123 error.printErrorStack();
124 #elif H5_VERS_MAJOR >= 1 && H5_VERS_MINOR >= 11 && H5_VERS_RELEASE >= 0 125 error.printErrorStack();
138 group = Group(
file.openGroup(groupName));
139 }
catch (FileIException error) {
140 #if H5_VERS_MAJOR >= 1 && H5_VERS_MINOR >= 8 && H5_VERS_RELEASE >= 20 141 error.printErrorStack();
142 #elif H5_VERS_MAJOR >= 1 && H5_VERS_MINOR >= 10 && H5_VERS_RELEASE >= 2 143 error.printErrorStack();
144 #elif H5_VERS_MAJOR >= 1 && H5_VERS_MINOR >= 11 && H5_VERS_RELEASE >= 0 145 error.printErrorStack();
169 std::vector<double> _yCrd) {
175 std::vector<double> _yCrd,
176 std::vector<double> _zCrd) {
191 std::vector<std::map<
int, std::vector<int>>> _elementConnectivity) {
198 #if VTK_MAJOR_VERSION > 8 || (VTK_MAJOR_VERSION == 8 && VTK_MINOR_VERSION >= 1) 202 VTK_LAGRANGE_QUADRILATERAL);
225 std::cerr <<
"Element type not supported: " <<
vtkElementTypes[elementId]
230 std::vector<int> subConnectivity(
233 return subConnectivity;
236 <<
" not found in connectivity table" << std::endl;
242 std::cout <<
"Exporting hdf5Reader object to VTK format..." << std::endl;
251 points->SetDataTypeToDouble();
266 std::cout <<
" setting VTK point data..." << std::endl;
267 dataSet_tmp->SetPoints(
points);
269 std::cout <<
" allocating memory for elements..." << std::endl;
272 std::cout <<
" adding VTK elements..." << std::endl;
276 vtkElmIds->SetNumberOfIds(elmIds.size());
277 for (
int j = 0; j < elmIds.size(); ++j) {
278 vtkElmIds->SetId(j, elmIds[j] - 0);
281 #if VTK_MAJOR_VERSION > 8 || (VTK_MAJOR_VERSION == 8 && VTK_MINOR_VERSION >= 1) 282 case VTK_LAGRANGE_QUADRILATERAL:
283 dataSet_tmp->InsertNextCell(VTK_LAGRANGE_QUADRILATERAL, vtkElmIds);
287 dataSet_tmp->InsertNextCell(VTK_QUAD, vtkElmIds);
290 dataSet_tmp->InsertNextCell(VTK_TRIANGLE, vtkElmIds);
299 dataSet_tmp->BuildLinks();
314 std::cout <<
"Exporting hdf5Reader object to meshBase format..." << std::endl;
324 std::vector<std::string> dataNames,
325 std::vector<std::vector<double>>
data,
327 if (pointOrCell == 0) {
328 std::cout <<
"Setting hdf5Reader object point fields..." << std::endl;
329 }
else if (pointOrCell == 1) {
330 std::cout <<
"Setting hdf5Reader object cell fields..." << std::endl;
334 auto dataNameItr = dataNames.begin();
335 auto dataItr =
data.begin();
336 while (dataNameItr != dataNames.end() || dataItr !=
data.end()) {
337 std::cout <<
" " << *dataNameItr << std::endl;
339 if (pointOrCell == 0) {
341 }
else if (pointOrCell == 1) {
345 if (dataNameItr != dataNames.end()) {
348 if (dataItr !=
data.end()) {
355 std::cout <<
"Writing hdf5Reader object to VTK file" << std::endl;
void setNumberOfVertices(int numVertices)
Set number of vertices in meshBase.
data_type data
Edge/face with sorted point ids (a, b, c, ...) is located at some index i in data[b], with data[b][i].first == [a, c] (for edges, third point id treated as -1).
H5File file
HDF5 file object.
vtkSmartPointer< vtkDataSet > getVTKMesh()
Get VTK mesh object.
void setElementTypesList(std::vector< int > vtkElementTypesList)
Set list of each unique type of VTK element in mesh.
virtual void setPointDataArray(const std::string &name, const std::vector< std::vector< double >> &data)
register data to dataSet's point data
void writeVTK()
Write mesh to VTK file.
std::vector< int > vtkElementTypesList
vector storing list of each unique VTK element type
void setElementTypes(std::vector< int > vtkElementTypes)
Set VTK element types for each element.
A brief description of meshBase.
void exportToVTKMesh()
Export to VTK format.
geoMeshBase * New(MeshType meshType)
Create a new mesh object.
virtual void setCellDataArray(const std::string &name, const std::vector< std::vector< double >> &data)
register data to dataSet's cell data
std::vector< std::map< int, std::vector< int > > > elementConnectivity
element connectivity table
std::vector< double > yCrd
int closeFile()
Close HDF5 file.
meshBase * getMeshBase()
Get meshBase object.
static meshBase * Create(const std::string &fname)
Construct vtkMesh from filename.
int readGroup(std::string groupName, Group &group)
Read existing HDF5 Group.
std::vector< double > xCrd
std::string getFileName()
Get HDF5 filename.
void setConnectivities(std::vector< std::map< int, std::vector< int >>> elementConnectivity)
Set meshBase element connectivity table.
vtkSmartPointer< vtkDataSet > vtkMesh
VTK DataSet object.
int numVertices
number of vertices in mesh
virtual void write() const
write the mesh to file named after the private var 'filename'.
int readTopDataSet(std::string dsetName, std::string &buffer)
Read string data from top level HDF5 DataSet.
void setFields(meshBase *myMeshBase, std::vector< std::string > dataNames, std::vector< std::vector< double >> data, int pointOrCell)
Set meshBase field data.
std::vector< vtkIdType > points
points given by id in .inp file
int numDimensions
number of spatial dimensions
void exportToMeshBase()
Export HDF5 mesh to meshBase object.
meshBase * myMeshBase
meshBase object
std::vector< double > zCrd
vector of coordinates
std::string h5FileName
HDF5 filename.
std::vector< int > getElementConnectivity(int elementId)
Get element connectivity for global element ID.
void setNumberOfDimensions(int numDimensions)
Set number of spatial dimensions in meshBase.
int numElements
number of elements in mesh
std::string outputFname
VTK output filename.
void setCoordinates(std::vector< double > xCrd)
Set meshBase 1d coordinate data.
std::vector< int > vtkElementTypes
vector of VTK element type for each element
void setNumberOfElements(int numElements)
Set number of elements in meshBase.
int openFile()
Open HDF5 file.
int readDataSet(DataSet dset, std::string &buffer)
Read string data from generic HDF5 DataSet.