Commit cf14e818 authored by Patrik Leidenberger's avatar Patrik Leidenberger

Extension of the H5Fed API and adding a dump program to test the API.

parent cdf1ce5e
......@@ -5,6 +5,8 @@
/GNUmakefile.orig -text
H5Fed/applications/gmsh2h5fed.cc -text
H5Fed/applications/gmsh2h5fed.hh -text
H5Fed/applications/h5feddump.cc -text
H5Fed/applications/h5feddump.hh -text
H5Fed/applications/makefile.am -text
H5Fed/autogen.sh -text
H5Fed/configure.ac -text
......
......@@ -7,6 +7,7 @@
// modified - 2006 jun 26, creation, patrick leidenberger
// modified - 2006 aug 25, extend, patrick leidenberger
// modified - 2006 aug 26, pl, integrate automatic index mapping.
// modified - 2006 sep 22, pl, addaped to h5fed api changes.
//
// feature - Implements the a mesh preprocessor.
// feature - It will read gmsh's mesh files of version 2.0 and write the mesh
......@@ -159,12 +160,12 @@ int main(int argc, char **argv)
// The gmsh node index has gaps and is not consecutive.
// So we activate the automatic index mapping from the h5fed api.
h5fedFile.beginIndexMapping(&gmshNodesIndex);
h5fedFile.beginIndexMapping(gmshNodesIndex);
// Get a vector with all node coordinates from the gmsh file.
gmshNodes = gmshInFile.gmshNode();
// Write the nodes to the h5fed file.
h5fedFile.coord3d(&gmshNodes);
h5fedFile.wCoord3d(gmshNodes);
// Every node in h5fed file, so we can save memory.
gmshNodes.clear();
......@@ -174,8 +175,10 @@ int main(int argc, char **argv)
{
// rDebug("Elem: %d Nodes: %d; %d; %d; %d", varI, gmshTetrahedron[varI][0], gmshTetrahedron[varI][1], gmshTetrahedron[varI][2], gmshTetrahedron[varI][3]);
}
std::vector<unsigned int> gmshTetrahedronMatIndex;
gmshTetrahedronMatIndex.resize(0,gmshTetrahedron.size());
// Write the tetrahedrons to the h5fed file on the respective level.
h5fedFile.tetrahedron(0,&gmshTetrahedron);
h5fedFile.wTetrahedron(0,gmshTetrahedron, gmshTetrahedronMatIndex);
// Every terahedron in h5fed file, so we can save memory.
gmshTetrahedron.clear();
......
// rights - 2006-, copyright patrick leidenberger and benedikt oswald,
// all rights reserved
// project - h5feddump
// file name - h5feddump.cc
// file type - c++ implementaton file
// objective - main file h5fed dump program
// modified - 2006 sep 21, creation, patrick leidenberger.
// modified - 2006 sep 22, pl, add dump for coordinates.
//
// feature - Implements the a dump tool for h5fed files.
// feature - It will read hf5ed file and write the data to the standard
// feature - output.
// feature - There are different options on command line what to dump.
// required software - rlog library, boost library
#include <h5feddump.hh>
using namespace rlog;
int main(int argc, char **argv)
{
//=================//
// Initialize RLog //
//=================//
// Make a instance of the class for RLog.
StdioNode stdLog;
/** Subscchar* inFile_;ribe output channels.
* Compile with -DRLOG_DEBUG to get the debug output.
**/
#ifdef USE_RLOG_DEBUG_CHANNEL
stdLog.subscribeTo(GetGlobalChannel("debug"));
#endif //USE_RLOG_DEBUG_CHANNEL
#ifdef USE_RLOG_ERROR_CHANNEL
stdLog.subscribeTo(GetGlobalChannel("error"));
#endif //USE_RLOG_ERROR_CHANNEL
#ifdef USE_RLOG_INFO_CHANNEL
stdLog.subscribeTo(GetGlobalChannel("info"));
#endif //USE_RLOG_INFO_CHANNEL
#ifdef USE_RLOG_WARNING_CHANNEL
stdLog.subscribeTo(GetGlobalChannel("warning"));
#endif //USE_RLOG_WARNING_CHANNEL
// Define variables that hold the command line parameters.
string hdf5fedFile;
//==================================================//
// Parse the comand line options //
// with the program_options from the boost library. //
//==================================================//
try
{
// Define and instance of the program_options class and name it.
boost::program_options::options_description
desc("Allowed program options");
// Define the command line options parsing rules.
desc.add_options()
("help", "produce this help")
("input-file", boost::program_options::value<string>(),
"hdf5fed file to dump");
// Parse the command line.
boost::program_options::variables_map varMap;
boost::program_options::store
(boost::program_options::parse_command_line(argc, argv, desc),
varMap);
boost::program_options::notify(varMap);
// Action in relation to the command line options.
if (varMap.count("help"))
{
cout << desc << "\n";
return ERRORCODE;
}
else if (varMap.count("input-file"))
{
hdf5fedFile = varMap["input-file"].as<string>();
rInfo("Input filename: %s",
hdf5fedFile.c_str());
}
else
{
rError("You have insert wrong options.");
rError("For details use: --help.");
return ERRORCODE;
}
}
catch(exception& error)
{
rError("Error: %d",error.what());
return ERRORCODE;
}
//==========================//
// Start with the main work //
//==========================//
// Put all H5Fed funktions in here.
#ifdef HAVE_HDF5
// Create H5Fed class instance.
H5Fed::H5Fed h5fedFile;
// Open H5Fed file for reading. Filename comes from
// command line parameters.
h5fedFile.open(hdf5fedFile,FILE_READ);
// Vector for the tetrahedorn nodes and the material tag.
std::vector< std::vector<unsigned int> > elem;
std::vector<unsigned int> materialIndex;
// Read the tetrahedrons of the h5fed file an print them.
h5fedFile.rTetrahedron((unsigned int)0, elem, materialIndex);
for(int varI = 0; varI<elem.size(); varI++)
{
rDebug("Tet number: %d; nodes: %d %d; %d %d; material index: %d",
varI,
elem[varI][0],
elem[varI][1],
elem[varI][2],
elem[varI][3],
materialIndex[varI]);
}
// Read the 3d coordinates of the h5fed file an print them.
std::vector<std::vector< double> > coord;
h5fedFile.rCoord3d(coord);
for(int varI = 0; varI<coord.size(); varI++)
{
rDebug("Coor Number %d; Coord3d: %f; %f; %f",
varI,
coord[varI][0],
coord[varI][1],
coord[varI][2]);
}
// Close H5Fed file.
h5fedFile.close();
#endif // HAVE_HDF5
return(0);
}
// rights - 2006-, copyright by
// benedikt oswald and patrick leidenberger,
// all rights reserved
// project - h5feddump
// file name - h5feddump.hh
// file type - c++ header file
// objective - header file for the h5feddump
// modified - 2006 sep 21, creation, Patrick Leidenberger
// modified - 2006 sep 22, pl, add dump for coordinates.
#ifndef H5FEDDUMP_H_
#define H5FEDDUMP_H_
/* include standard header files */
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <iostream>
#include <iterator>
#include <math.h>
/* Include the files for rlog. */
#include <rlog/rlog.h>
#include <rlog/rloglocation.h>
#include <rlog/Error.h>
#include <rlog/RLogChannel.h>
#include <rlog/StdioNode.h>
// Include this if you want to log the time.
#include <rlog/RLogTime.h>
// Include the boost program program_options to parse the comand line
// options.
#include <boost/program_options.hpp>
/* include standard proprietary header files */
#include <nonsciconst.h>
#include <physicomath.h>
// Include the Hdf5FiniteElementData API.
#ifdef HAVE_HDF5
// Include the Hdf5FiniteElementData API.
#include <h5fed.hh>
// Include h5fed specific constants.
#include <h5fedconst.hh>
#else
#warning No hdf5 lib found!!
#endif
using namespace physicomath;
using namespace nonsciconst;
using namespace H5Fed;
//using namespace gmshtohdf5fed;
#endif /*PHIDIAS3D_H_*/
......@@ -4,11 +4,12 @@
## modified - 2006 aug 21, patrick leidenberger, creation
## modified - 2006 aug 23, pl, adaped to changed directory structure.
## modified - 2006 aug 25, pl, adaped to changed directory structure.
## modified - 2006 sep 21, pl, add the h5feddump application.
#
## objective - automake input file for the gmsh directory
## project - gmsh2h5fed
noinst_PROGRAMS = gmsh2h5fed
noinst_PROGRAMS = gmsh2h5fed h5feddump
gmsh2h5fed_SOURCES = gmsh2h5fed.cc
gmsh2h5fed_DEPENDENCIES = ../libsrc/stdincl/nonsciconst.h \
......@@ -23,4 +24,14 @@ gmsh2h5fed_DEPENDENCIES = ../libsrc/stdincl/nonsciconst.h \
gmsh2h5fed_LDADD = @GMSH2H5FED_LIBS@
h5feddump_SOURCES = h5feddump.cc
h5feddump_DEPENDENCIES = ../libsrc/stdincl/nonsciconst.h \
../libsrc/stdincl/physicomath.h \
../libsrc/h5fed/h5fed.hh \
../libsrc/h5fed/h5fed.cc
h5feddump_LDADD = @H5FEDDUMP_LIBS@
#AM_CPPFLAGS = @AM_CPPFLAGS@
......@@ -3,6 +3,7 @@
## author - benedikt oswald and patrick leidenberger
## modified - 2006 aug 21, pl, creation.
## modified - 2006 aug 24, pl, add h5fed path.
## modified - 2006 sep 21, pl, add h5feddump libs.
##
## to do : The rlog lib needs a -DRLOG_COMPONENT="some name", I don't know
## how tho do this so that the quotation marks are in the output
......@@ -33,6 +34,7 @@ CXXFLAGS=""
# provide include directories
AC_SUBST([AM_CPPFLAGS], '-I$(top_srcdir)/libsrc/stdincl -I$(top_srcdir)/libsrc/gmsh -I$(top_srcdir)/libsrc/h5fed')
AC_SUBST([GMSH2H5FED_LIBS],'$(top_srcdir)/libsrc/gmsh/libgmsh.la $(top_srcdir)/libsrc/h5fed/libh5fed.la')
AC_SUBST([H5FEDDUMP_LIBS],'$(top_srcdir)/libsrc/h5fed/libh5fed.la')
# Make available external libraries
AC_ARG_WITH(boost,
......
This diff is collapsed.
......@@ -2,6 +2,10 @@
#define H5FEDCONST_HH_
#include<string>
// Include HDF5 headers.
#include <hdf5.h>
using namespace std;
//! Hdf5 specific file access:
......@@ -46,5 +50,10 @@ const unsigned short int H5FED_PYRAMID_N_NODE = 5;
const unsigned short int H5FED_TRIANGLE_N_NODE = 3;
const unsigned short int H5FED_QUADRANGLE_N_NODE = 4;
// In which format should a single element of a mesh entity and the
// index to the material list be stored.
const hid_t H5FED_MESH_ELEM_DATATYPE = H5T_STD_U32LE;
const hid_t H5FED_COORD_DATATYPE = H5T_IEEE_F64LE;
#endif /*H5FEDCONST_HH_*/
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment