Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 22421d8d88 | |||
| f15fcacc68 | |||
| 55aa93e6d6 | |||
| 465152e58b | |||
| 6e03a3ca17 | |||
| 55171d3b14 | |||
| 173b09c39d | |||
| fca85a787d | |||
| e27bdb592e | |||
| 9becc99e02 | |||
| 556fe9b8a6 | |||
| bc84ce205a | |||
| c45c1e9bb9 | |||
| 4085a1c30c | |||
| ce8b6dae77 | |||
| 29888601b8 | |||
| d82e7143ed |
@@ -520,6 +520,7 @@ test/H5Fed/tetmesh_write.c -text
|
||||
test/H5Fed/tetmesh_write1.c -text
|
||||
test/H5Fed/tetmesh_write2.c -text
|
||||
test/H5Fed/tetmesh_write_tags.c -text
|
||||
test/H5Fed/trimesh_2gnuplot.c -text
|
||||
test/H5Fed/trimesh_adjacencies.c -text
|
||||
test/H5Fed/trimesh_read.c -text
|
||||
test/H5Fed/trimesh_write.c -text
|
||||
@@ -565,6 +566,8 @@ tools/h5hutcc.in -text
|
||||
tools/h5pAttrib.cc -text
|
||||
tools/h5pToGNUplot.cc -text
|
||||
tools/homdynToH5p.cc -text
|
||||
tools/vtk2h5grid/Makefile.am -text
|
||||
tools/vtk2h5grid/vtk2h5grid.cc -text
|
||||
visit_plugins/databases/H5Part/.depend -text
|
||||
visit_plugins/databases/H5Part/Makefile -text
|
||||
visit_plugins/databases/H5Part/README.txt -text
|
||||
|
||||
@@ -77,4 +77,6 @@ test/h5u_test
|
||||
tools/.deps
|
||||
tools/Makefile
|
||||
tools/Makefile.in
|
||||
tools/h5PartDcToVtk
|
||||
tools/h5PartSurfaceToVtk
|
||||
tools/h5hutcc
|
||||
|
||||
@@ -0,0 +1,407 @@
|
||||
#### H5PART 1.99.10 ###########################################################
|
||||
|
||||
Bugfixes in the malloc wrappers
|
||||
|
||||
Converter from vtk to H5hut added.
|
||||
|
||||
Bugfixes in the autotools files.
|
||||
|
||||
#### H5PART 1.99.9 ############################################################
|
||||
|
||||
Bugfix in option parsing in tools/h5PartDcToVtk and tools/h5PartSurfaceToVtk
|
||||
|
||||
tools/h5PartDcToVtk and tools/h5PartSurfaceToVtk removed from list of tools
|
||||
to be compiled. These tools should be moved to another repository anyway.
|
||||
|
||||
#### H5PART 1.99.8 ############################################################
|
||||
|
||||
Bugfixes
|
||||
|
||||
#### H5PART 1.99.7 ############################################################
|
||||
|
||||
Linking problem on Linux fixed
|
||||
|
||||
#### H5PART 1.99.6 ############################################################
|
||||
|
||||
|
||||
#### H5PART 1.99.5 ############################################################
|
||||
#### H5PART 1.99.4 ############################################################
|
||||
#### H5PART 1.99.3 ############################################################
|
||||
#### H5PART 1.99.2 ############################################################
|
||||
#### H5PART 1.99.1 ############################################################
|
||||
#### H5PART 1.99 ############################################################
|
||||
|
||||
Renamed type:
|
||||
H5PartFile -> h5_file_t
|
||||
h5part_int64_t -> h5_int64_t
|
||||
|
||||
Renamed functions:
|
||||
|
||||
|
||||
#### H5PART 1.6.6 ############################################################
|
||||
|
||||
Fixed typo (Write instead of Read) in the h5bl_3d_read_scalar_field* Fortran
|
||||
interface.
|
||||
|
||||
Added missing type normalization for int32 type.
|
||||
|
||||
Rewrite of h5pAttrib tool.
|
||||
|
||||
#### H5PART 1.6.5 ############################################################
|
||||
|
||||
Fixed several build errors reported by Iuri Prilepov on Ubuntu 11.04.
|
||||
|
||||
#### H5PART 1.6.4 ############################################################
|
||||
|
||||
Fixed bug where H5PartSetViewIndices was not setting an empty view when the
|
||||
number of elements is 0.
|
||||
|
||||
Set a threshold on the HDF5 alignment parameter so that small metadata writes
|
||||
are not aligned, which causes large gaps in the file.
|
||||
|
||||
#### H5PART 1.6.3 ############################################################
|
||||
|
||||
New build system uses libtool and can build shared libraries.
|
||||
|
||||
Fixed a bug that incorrectly identifies the number of selected points in a view
|
||||
when using H5PartSetViewIndices.
|
||||
|
||||
Fixed bug in Fortran test reported by several people, as well as several
|
||||
incorrect views set in the C test that were causing segfaults.
|
||||
|
||||
Fixed name mismatches in the Fortran interface, and an off-by-one indexing
|
||||
problem.
|
||||
|
||||
#### H5PART 1.6.2 ############################################################
|
||||
|
||||
Removed H5PartSetViewEmpty
|
||||
--------------------------
|
||||
|
||||
An empty view can now be selected with:
|
||||
H5PartSetNumParticles(file, 0);
|
||||
|
||||
Bug Fixes to Attribute Calls in Fortran API
|
||||
-------------------------------------------
|
||||
|
||||
Fixed a problem where attribute values were reverting to zero.
|
||||
|
||||
#### H5PART 1.6.1 ############################################################
|
||||
|
||||
Chunking in the H5Part API
|
||||
--------------------------
|
||||
|
||||
There is now an H5Part equivalent H5PartSetChunkSize to the existing
|
||||
H5BlockDefine3DChunkDims call. Both of these calls enable the chunking
|
||||
mechanism in the underlying HDF5 layer. Chunking is used in combination
|
||||
with the aligned open calls to pad datasets to alignment multiples
|
||||
on disk.
|
||||
|
||||
All Steps Available on Write
|
||||
----------------------------
|
||||
|
||||
Previously, existing steps in a file were only accessible in read-only mode.
|
||||
Now, all steps are available in all modes, including write-truncate and
|
||||
write-append. Thus, it is now possible to overwrite existing data in write
|
||||
mode. To help alert the user to this possibility, a warning is issued every
|
||||
time an existing dataset is written to. Warnings can be printed by setting
|
||||
the verbosity to H5PART_VERB_WARN or higher.
|
||||
|
||||
New Throttling Routine
|
||||
----------------------
|
||||
|
||||
Previously, a throttle factor of N meant that for P processors, the total
|
||||
number of P writes were divided into N batches of P/N writes.
|
||||
|
||||
To better accommodate round-robin lustre striping, the new policy is to
|
||||
execute P/N batches of N writes. Thus, matching N to the number of stripes
|
||||
results in the desirable 1-1 matching of writers to stripes.
|
||||
|
||||
Other Fixes
|
||||
-----------
|
||||
|
||||
* The configure script should correctly detect PGI compilers now.
|
||||
* There was a small memory leak in the Fortran file open calls.
|
||||
* There was a compile error with HDF5 1.6.x due to a missing assignment.
|
||||
|
||||
#### H5PART 1.6 ##############################################################
|
||||
|
||||
Updated Documentation
|
||||
---------------------
|
||||
|
||||
The Fortran API has been added to the doxygen documentation. Most entries have
|
||||
a reference to their respective C API call.
|
||||
|
||||
Regression Test Suite
|
||||
---------------------
|
||||
|
||||
The test subdirectory has been reorganized to include a systematic series
|
||||
of regression tests of common use cases for the API. The goal is to have both
|
||||
complete coverage of the API (every call is exercised) and testing of some
|
||||
unlikely or unsuspected values and cases.
|
||||
|
||||
Currently, the C test covers the entire H5Part API and the Fortran test is
|
||||
still in development.
|
||||
|
||||
Benchmark Utilities
|
||||
-------------------
|
||||
|
||||
Two benchmarking utilities, H5PartBench and H5BlockBench, have been added to
|
||||
the tools collection. Both require the parallel library and have functionality
|
||||
and syntax similar to the IOR benchmark:
|
||||
|
||||
http://sourceforge.net/projects/ior-sio/
|
||||
|
||||
File Mode Flags
|
||||
---------------
|
||||
|
||||
Previously, the only flags used were H5PART_READ, H5PART_WRITE, and
|
||||
H5PART_APPEND, and these were mutually exclusive. Additional flags have been
|
||||
added to select the underlying virtual file driver (VFD) that HDF5 uses in
|
||||
parallel mode and to accommodate the lustre filesystem:
|
||||
|
||||
H5PART_VFD_MPIPOSIX (use the MPI-POSIX driver, which bypasses MPI-IO)
|
||||
H5PART_VFD_MPIIO_IND (use MPI-IO in independent mode)
|
||||
H5PART_FS_LUSTRE (activate H5P tunings for the lustre stripe size)
|
||||
|
||||
These flags can be specified using the typical bitwise OR method, e.g.
|
||||
|
||||
char flag = H5PART_WRITE | H5PART_VFD_MPIPOSIX | H5PART_FS_LUSTRE;
|
||||
|
||||
will select write mode with these two additional options.
|
||||
|
||||
The parallel library now defaults to using the MPI-IO collective mode driver
|
||||
(previously it used independent mode). The collective buffering algorithm in
|
||||
the Cray XT4/5 environment has been substantially improved in the last year,
|
||||
and defaulting to collective mode allows us to take advantage of these
|
||||
improvements automatically.
|
||||
|
||||
There are also new open calls H5PartOpenAlign and H5PartOpenParallelAlign that
|
||||
take an additional 'alignment' value. This value is passed to HDF5 and used to
|
||||
pad out objects so that they align to filesystem boundaries. For instance, it
|
||||
would make sense to use the stripe size as the alignment value when writing to
|
||||
a lustre filesystem.
|
||||
|
||||
Unified 'View' Model
|
||||
--------------------
|
||||
|
||||
Views are now supported in both read and write mode (previously only supported
|
||||
in read mode). It is possible to specify non-sensical views: you could for
|
||||
instance specify a read view that is larger than the dataset on disk. Or you
|
||||
could create a write view that is larger than the data in memory. In those
|
||||
cases, you will encounter an error when you try to perform a read or write
|
||||
operation on a dataset.
|
||||
|
||||
There are two new methods for selecting views. H5PartSetNumParticlesStrided
|
||||
selects a view with $n$ particles per processor, but such that the data in
|
||||
memory is expected to have a 'stride' factor. For instance, if you have
|
||||
particle data with fields $x$ and $y$ and a single array with entries
|
||||
$x1,y1,x2,y2...$, then the stride factor is 2. Striding works for both reads
|
||||
and writes and only affects the view of memory: individual fields are still
|
||||
stored as individual arrays on disk.
|
||||
|
||||
The second new method is H5PartSetViewIndices, which allows for point
|
||||
selections of datasets. You can pass a list of indices for the points you
|
||||
want to select. This is useful, for instance, when interfacing with FastBit
|
||||
to perform queries that select a small subset of non-contiguous particles.
|
||||
|
||||
Because views are now supported on write, it is possible to write a dataset
|
||||
using multiple 'passes' or to leave some values unwritten.
|
||||
|
||||
Also, all views are now *inclusive*, so that a view of (0,9) corresponds
|
||||
to the 10 items 0, 1, 2, ... 9.
|
||||
|
||||
Internal Handling of Dataspaces
|
||||
-------------------------------
|
||||
|
||||
H5PartSetNumParticles and H5PartSetNumParticlesStrided now share the same
|
||||
HDF5 dataspace state in the H5PartFile struct with the calls that modify
|
||||
the view (H5PartSetView etc.). Previously, the memory and disk dataspaces
|
||||
were regenerated from the view on every read access, which was unnecessary.
|
||||
|
||||
Autogeneration of API Calls
|
||||
---------------------------
|
||||
|
||||
Python scripts have been added to automatically generate read/write call
|
||||
variants for different data types.
|
||||
|
||||
Renamed Fortran Include
|
||||
-----------------------
|
||||
|
||||
The automake system no longer greps the *F90.inc files to generate an include
|
||||
called 'H5Part.inc'. Instead, the *F90.inc files have been renamed to *.f90,
|
||||
and awk is used to generate an 'H5PartF.h' file (the same naming convention
|
||||
as in MPI's 'mpif.h').
|
||||
|
||||
The change to *.f90 was necessary to facilitate integration of the Fortran
|
||||
API into doxygen. Note that the *.f90 files will not compile, nor can they
|
||||
be included directly. Simply use
|
||||
|
||||
include 'H5PartF.h'
|
||||
|
||||
in your Fortran code to include all the definitions for Fortran H5Part/H5Block
|
||||
calls.
|
||||
|
||||
64 Char Limit on Dataset Names
|
||||
------------------------------
|
||||
|
||||
Previously, a user could overrun internal buffers for dataset names. Now, a
|
||||
fixed limit of 64 chars is imposed. Dataset names that are longer than this are
|
||||
truncated and a warning is printed. We expect that most users are using
|
||||
short canonical names like x, px, id, etc.
|
||||
|
||||
Changes to Existing API
|
||||
-----------------------
|
||||
|
||||
The H5BlockGetFieldInfo and H5BlockGetFieldInfoByName calls now both include
|
||||
a parameter for the 'type' of the field.
|
||||
|
||||
|
||||
#### H5PART 1.4 ##############################################################
|
||||
|
||||
Error Handling
|
||||
--------------
|
||||
Now all functions, in which an error could occure, are returning a
|
||||
value. This value is either a 64bit integer or a pointer.
|
||||
|
||||
A negative 64bit integer as result indicates an error. Values >= 0
|
||||
indicates successfull execution. This is similiar to the convention
|
||||
used in UNIX system calls, but we do not return -1 but the error
|
||||
number (which is always negative).
|
||||
|
||||
For functions returning a pointer the NULL-pointer is used to indicate
|
||||
an error. You can call the function H5PartGetErrno() to get the error
|
||||
number. For the time being there is no strerror(3) or perror(3)
|
||||
equivalent.
|
||||
|
||||
|
||||
API Changes
|
||||
-----------
|
||||
There are several changes in the API of H5Part. The biggest change is
|
||||
a side-effect of the implementation of strict error handling. The
|
||||
impact to the existing C/C++ code is very small. But now you *can*
|
||||
and *should* implement some kind of error handling. The simplest
|
||||
error handling is to set an error handler which aborts the program as
|
||||
soon as an error occured.
|
||||
|
||||
The next "biggest" change is the use of H5Part types instead of "long
|
||||
long" and "double". The replacement of "long long" is "h5part_int64_t"
|
||||
and for "double" "h5part_float64_t". This change has now effect in
|
||||
Fortran.
|
||||
|
||||
In some functions the argument type changed from "int" to
|
||||
"h5part_int64_t". Since on most systems "int" is a 32bit integer,
|
||||
calls to these functions must be adapted to the new API. In C/C++ the
|
||||
compiler will complain about it. But in Fortran you will *not* get an
|
||||
error message.So, you must check your Fortran code carefully.
|
||||
|
||||
Changes in detail (not listed are functions where only the return
|
||||
type changed from any to "h5part_int64_t"):
|
||||
|
||||
New API Changes to old API
|
||||
|
||||
h5part_int64_t void
|
||||
H5PartSetNumParticles (
|
||||
H5PartFile *f,
|
||||
h5part_int64_t nparticles long long
|
||||
);
|
||||
|
||||
h5part_int64_t int
|
||||
H5PartWriteDataFloat64 (
|
||||
H5PartFile *f,
|
||||
char *name,
|
||||
h5part_float64_t *dta double
|
||||
);
|
||||
|
||||
h5part_int64_t int
|
||||
H5PartWriteDataInt64 (
|
||||
H5PartFile *f,
|
||||
char *name,
|
||||
h5part_int64_t *dta long long
|
||||
);
|
||||
|
||||
h5part_int64_t void
|
||||
H5PartSetStep (
|
||||
H5PartFile *f,
|
||||
h5part_int64_t step int
|
||||
);
|
||||
|
||||
h5part_int64_t void
|
||||
H5PartSetView (
|
||||
H5PartFile *f,
|
||||
h5part_int64_t start, long long
|
||||
h5part_int64_t end long long
|
||||
);
|
||||
|
||||
h5part_int64_t int
|
||||
H5PartGetView (
|
||||
H5PartFile *f,
|
||||
h5part_int64_t *start, long long
|
||||
h5part_int64_t *end long long
|
||||
);
|
||||
|
||||
h5part_int64_t int
|
||||
H5PartReadDataFloat64 (
|
||||
H5PartFile *f,
|
||||
char *name,
|
||||
h5part_float64_t *dta double
|
||||
);
|
||||
|
||||
h5part_int64_t int
|
||||
H5PartReadDataInt64 (
|
||||
H5PartFile *f,
|
||||
char *name,
|
||||
h5part_int64_t *dta long long
|
||||
);
|
||||
|
||||
h5part_int64_t void
|
||||
H5PartReadParticleStep (
|
||||
H5PartFile *f,
|
||||
h5part_int64_t step, int
|
||||
h5part_float64_t *x, double
|
||||
h5part_float64_t *y, double
|
||||
h5part_float64_t *z, double
|
||||
h5part_float64_t *px, double
|
||||
h5part_float64_t *py, double
|
||||
h5part_float64_t *pz, double
|
||||
h5part_int64_t *id long long
|
||||
);
|
||||
|
||||
New functions:
|
||||
|
||||
h5part_int64_t
|
||||
H5PartSetVerbosityLevel (
|
||||
unsigned int
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
H5PartSetErrorHandler (
|
||||
h5part_error_handler handler
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
H5PartGetErrno (
|
||||
void
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
H5PartDefaultErrorHandler (
|
||||
const char *funcname,
|
||||
const h5part_int64_t eno,
|
||||
const char *fmt,
|
||||
...
|
||||
);
|
||||
|
||||
h5part_int64_t
|
||||
H5PartAbortErrorHandler (
|
||||
const char *funcname,
|
||||
const h5part_int64_t eno,
|
||||
const char *fmt,
|
||||
...
|
||||
);
|
||||
|
||||
Removed functions:
|
||||
|
||||
int
|
||||
H5PartFileIsValid (
|
||||
H5PartFile *f
|
||||
);
|
||||
|
||||
+38
-14
@@ -49,6 +49,13 @@ AC_ARG_ENABLE(
|
||||
[Compile the MPI/IO interface [default=no]])],
|
||||
[USE_PARALLEL=$enableval])
|
||||
|
||||
AC_ARG_ENABLE(
|
||||
[vtkconverter],
|
||||
[AS_HELP_STRING([--enable-vtkconverter],
|
||||
[Compile the vtk to H5hut converter for grids [default=no]])],
|
||||
[ENABLE_VTKCONVERTER=$enableval])
|
||||
AM_CONDITIONAL([ENABLE_VTKCONVERTER], [test "$ENABLE_VTKCONVERTER" = "yes"])
|
||||
|
||||
AC_ARG_WITH(
|
||||
[hdf5],
|
||||
[AC_HELP_STRING([--with-hdf5],
|
||||
@@ -67,6 +74,12 @@ AC_ARG_WITH(
|
||||
[path to lustre user API [default=""]])],
|
||||
[LUSTREPATH=$withval], [LUSTREPATH=""])
|
||||
|
||||
AC_ARG_WITH(
|
||||
[vtk],
|
||||
[AS_HELP_STRING([--with-vtk],
|
||||
[path to VTK installation [default=""]])],
|
||||
[VTK_PREFIX=$withval], [VTK_PREFIX=""])
|
||||
|
||||
###############################################################################
|
||||
############### PATH SERACH FUNCTION - to be used later... ####################
|
||||
###############################################################################
|
||||
@@ -108,6 +121,16 @@ AC_CANONICAL_HOST
|
||||
|
||||
AC_PROG_MAKE_SET
|
||||
|
||||
AC_MSG_CHECKING([if debug is enabled])
|
||||
|
||||
if test "X$USE_DEBUG" = "Xyes"; then
|
||||
AC_MSG_RESULT([yes])
|
||||
CFLAGS="$CFLAGS -g"
|
||||
FFLAGS="$FFLAGS -g"
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
|
||||
# Determine a C/C++ compiler to use.
|
||||
# If CC is not already set in the environment, check for gcc and cc, then
|
||||
# for other C compilers.
|
||||
@@ -181,16 +204,6 @@ AC_DEFINE_UNQUOTED(MY_UNAME, "$uname", "")
|
||||
######################## CONFIGURE LINE OPTIONS ###############################
|
||||
###############################################################################
|
||||
|
||||
AC_MSG_CHECKING([if debug is enabled])
|
||||
|
||||
if test "X$USE_DEBUG" = "Xyes"; then
|
||||
AC_MSG_RESULT([yes])
|
||||
CFLAGS="$CFLAGS -g"
|
||||
FFLAGS="$FFLAGS -g"
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
|
||||
############################ fortran enabled ##################################
|
||||
AC_MSG_CHECKING([if C interface enabled])
|
||||
if test "X$USE_C" = "Xyes"; then
|
||||
@@ -199,7 +212,7 @@ if test "X$USE_C" = "Xyes"; then
|
||||
LIB_C="libH5hutC.la"
|
||||
BUILD_LIBS="$BUILD_LIBS libH5hutC"
|
||||
BUILD_TESTS="$BUILD_TESTS h5u_test h5b_test"
|
||||
BUILD_TOOLS="$BUILD_TOOLS h5hutcc h5PartDcToVtk h5PartSurfaceToVtk"
|
||||
BUILD_TOOLS="$BUILD_TOOLS h5hutcc"
|
||||
fi
|
||||
|
||||
############################ fortran enabled ##################################
|
||||
@@ -320,7 +333,7 @@ if test -z "$HDF5ROOT"; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
INCLUDES="$INCLUDES -I$HDF5ROOT/include"
|
||||
AM_CPPFLAGS="$AM_CPPFLAGS -I$HDF5ROOT/include"
|
||||
LDFLAGS="$LDFLAGS -L$HDF5ROOT/lib"
|
||||
LIBS="$LIBS -lhdf5"
|
||||
|
||||
@@ -357,13 +370,23 @@ if test -z "$LUSTREROOT"; then
|
||||
AC_MSG_WARN([Couldn't locate the lustre API... building without support for lustre striping!])
|
||||
else
|
||||
CFLAGS="$CFLAGS -DH5_USE_LUSTRE"
|
||||
INCLUDES="$INCLUDES -I$LUSTREROOT/usr/include"
|
||||
AM_CPPFLAGS=="$AM_CPPFLAGS -I$LUSTREROOT/usr/include"
|
||||
LDFLAGS="$LDFLAGS -L$LUSTREROOT/usr/lib"
|
||||
LIBS="$LIBS -llustreapi"
|
||||
fi
|
||||
|
||||
LIBS="$LIBS -lz -lm"
|
||||
|
||||
###############################################################################
|
||||
# TOOLS
|
||||
AC_MSG_CHECKING([if we have to compile the VTK to H5hut grid converter])
|
||||
if test "X$ENABLE_VTKCONVERTER" = "Xyes"; then
|
||||
AC_MSG_RESULT([yes])
|
||||
# :TODO: add test whether we can compile/link a prog with vtk
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
|
||||
###############################################################################
|
||||
############## EXPORTING VARIABLES & CREATING OUTPUT FILES ####################
|
||||
###############################################################################
|
||||
@@ -378,7 +401,7 @@ AC_SUBST(HDF5ROOT)
|
||||
AC_SUBST(LUSTREROOT)
|
||||
AC_SUBST(CFLAGS)
|
||||
AC_SUBST(FFLAGS)
|
||||
AC_SUBST(INCLUDES)
|
||||
AC_SUBST(AM_CPPFLAGS)
|
||||
AC_SUBST(LDFLAGS)
|
||||
AC_SUBST(LIBS)
|
||||
AC_SUBST(UNDERSCORE_H)
|
||||
@@ -400,6 +423,7 @@ AC_CONFIG_FILES([
|
||||
test/H5Fed/Makefile
|
||||
tools/Makefile
|
||||
tools/h5hutcc
|
||||
tools/vtk2h5grid/Makefile
|
||||
])
|
||||
|
||||
AC_OUTPUT
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ CC = @CC@
|
||||
CXX = @CXX@
|
||||
|
||||
LIBS = @LIBS@
|
||||
INCLUDES = -I../include @INCLUDES@
|
||||
AM_CPPFLAGS = -I../include @AM_CPPFLAGS@
|
||||
|
||||
OBJEXT = o
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
OBJEXT=o
|
||||
|
||||
INCLUDES = -I../include @INCLUDES@
|
||||
AM_CPPFLAGS = -I../include @AM_CPPFLAGS@
|
||||
|
||||
# What to build... Will be determined by configure script.
|
||||
lib_LTLIBRARIES = @LIB_C@
|
||||
|
||||
@@ -116,7 +116,9 @@ h5bl_3d_getview (
|
||||
k_start, k_end);
|
||||
H5_API_RETURN (h5b_3d_get_view (
|
||||
fh,
|
||||
i_start, i_end, j_start, j_end, k_start, k_end ));
|
||||
(h5_size_t*)i_start, (h5_size_t*)i_end,
|
||||
(h5_size_t*)j_start, (h5_size_t*)j_end,
|
||||
(h5_size_t*)k_start, (h5_size_t*)k_end ));
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
@@ -142,7 +144,9 @@ h5bl_3d_getreducedview (
|
||||
k_start, k_end);
|
||||
H5_API_RETURN(h5b_3d_get_reduced_view (
|
||||
fh,
|
||||
i_start, i_end, j_start, j_end, k_start, k_end ));
|
||||
(h5_size_t*)i_start, (h5_size_t*)i_end,
|
||||
(h5_size_t*)j_start, (h5_size_t*)j_end,
|
||||
(h5_size_t*)k_start, (h5_size_t*)k_end ));
|
||||
}
|
||||
|
||||
h5_int64_t
|
||||
|
||||
@@ -155,14 +155,14 @@ h5pt_setview (
|
||||
h5_err_t
|
||||
h5pt_setview_indices (
|
||||
const h5_int64_t *f,
|
||||
const h5_int64_t *indices,
|
||||
const h5_int64_t * const indices,
|
||||
const h5_int64_t *nelem
|
||||
) {
|
||||
|
||||
h5_file_t *fh = h5_filehandlefor2c(f);
|
||||
H5_API_ENTER (h5_err_t, "f=%p, indices=%p, nelem=%lld",
|
||||
fh, indices, (long long)*nelem);
|
||||
H5_API_RETURN(h5u_set_view_indices ( fh, indices, *nelem ));
|
||||
H5_API_RETURN(h5u_set_view_indices ( fh, (const h5_size_t*const)indices, *nelem ));
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
|
||||
+3
-22
@@ -51,25 +51,6 @@
|
||||
|
||||
#endif
|
||||
|
||||
static h5_int32_t
|
||||
_flagsfor2c (
|
||||
char * flags
|
||||
) {
|
||||
|
||||
h5_int32_t fbits = 0x00;
|
||||
|
||||
flags = strtok ( flags, "," );
|
||||
while ( flags != NULL ) {
|
||||
if ( strcmp ( flags, "vfd_mpiposix" ) == 0 )
|
||||
fbits |= H5_VFD_MPIPOSIX;
|
||||
else if ( strcmp ( flags, "vfd_independent" ) == 0 )
|
||||
fbits |= H5_VFD_INDEPENDENT;
|
||||
flags = strtok ( NULL, "," );
|
||||
}
|
||||
|
||||
return fbits;
|
||||
}
|
||||
|
||||
/* open/close interface */
|
||||
h5_err_t
|
||||
h5_openr (
|
||||
@@ -79,7 +60,7 @@ h5_openr (
|
||||
|
||||
H5_API_ENTER (h5_err_t, "name='%s', l_name=%d", name, l_name);
|
||||
char *name2 = h5_strdupfor2c ( name, l_name );
|
||||
h5_file_t* f = h5_open_file ( name2, H5_O_RDONLY, 0 );
|
||||
h5_file_t* f = h5_open_file ( name2, H5_O_RDONLY, 0, 0 );
|
||||
free ( name2 );
|
||||
H5_API_RETURN((h5_int64_t)(size_t)f);
|
||||
}
|
||||
@@ -92,7 +73,7 @@ h5_openw (
|
||||
|
||||
H5_API_ENTER (h5_err_t, "name='%s', l_name=%d", name, l_name);
|
||||
char *name2 = h5_strdupfor2c ( name, l_name );
|
||||
h5_file_t* f = h5_open_file ( name2, H5_O_WRONLY, 0 );
|
||||
h5_file_t* f = h5_open_file ( name2, H5_O_WRONLY, 0, 0 );
|
||||
free ( name2 );
|
||||
H5_API_RETURN((h5_int64_t)(size_t)f);
|
||||
}
|
||||
@@ -105,7 +86,7 @@ h5pt_opena (
|
||||
|
||||
H5_API_ENTER (h5_err_t, "name='%s', l_name=%d", name, l_name);
|
||||
char *name2 = h5_strdupfor2c ( name, l_name );
|
||||
h5_file_t* f = h5_open_file ( name2, H5_O_APPEND, 0 );
|
||||
h5_file_t* f = h5_open_file ( name2, H5_O_APPEND, 0, 0 );
|
||||
free ( name2 );
|
||||
H5_API_RETURN((h5_int64_t)(size_t)f);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
OBJEXT=o
|
||||
|
||||
INCLUDES = -I../include @INCLUDES@
|
||||
AM_CPPFLAGS = -I../include @AM_CPPFLAGS@
|
||||
|
||||
F90_FILES = H5.f90 \
|
||||
H5_attribs.f90 \
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
OBJEXT=o
|
||||
|
||||
INCLUDES = -I../include @INCLUDES@
|
||||
AM_CPPFLAGS = -I../include @AM_CPPFLAGS@
|
||||
|
||||
EXTRA_HEADERS = \
|
||||
../include/h5core/h5_attach.h \
|
||||
|
||||
@@ -274,7 +274,7 @@ h5_get_attachment (
|
||||
// write file
|
||||
if (f->myproc == 0) {
|
||||
int fd;
|
||||
if ((fd = open (fname, O_WRONLY|O_CREAT|O_TRUNC)) < 0) {
|
||||
if ((fd = open (fname, O_WRONLY|O_CREAT|O_TRUNC, 0600)) < 0) {
|
||||
H5_CORE_API_LEAVE (
|
||||
h5_error (
|
||||
H5_ERR_H5,
|
||||
|
||||
@@ -310,3 +310,22 @@ h5t_get_vertex_coords_by_id (
|
||||
H5_CORE_API_RETURN (H5_SUCCESS);
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
h5t_get_neighbor_indices (
|
||||
h5t_mesh_t* const m,
|
||||
h5_loc_id_t entity_id,
|
||||
h5_loc_idx_t* neighbor_indices
|
||||
) {
|
||||
H5_CORE_API_ENTER (h5_err_t,
|
||||
"m=%p, entity_id=%llu, neighbor_indices=%p",
|
||||
m,
|
||||
(long long unsigned)entity_id,
|
||||
neighbor_indices);
|
||||
h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (entity_id);
|
||||
h5_loc_idx_t* indices = h5tpriv_get_loc_elem_neighbor_indices (m, elem_idx);
|
||||
int num_facets = h5tpriv_ref_elem_get_num_facets (m);
|
||||
for (int i = 0; i < num_facets; i++) {
|
||||
neighbor_indices[i] = indices[i];
|
||||
}
|
||||
H5_CORE_API_RETURN (H5_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -245,6 +245,9 @@ h5t_end_store_elems (
|
||||
H5_CORE_API_ENTER (h5_err_t, "m=%p", m);
|
||||
|
||||
m->num_elems[m->leaf_level] = m->last_stored_eid+1;
|
||||
if (m->leaf_level == 0) {
|
||||
m->num_leaf_elems[0] = m->num_elems[0];
|
||||
}
|
||||
|
||||
/* assign global indices to new indices */
|
||||
TRY (assign_glb_elem_indices (m));
|
||||
|
||||
@@ -173,6 +173,19 @@ H5FedGetVertexIndicesOfEntity (
|
||||
H5_API_RETURN (h5t_get_vertex_indices_of_entity (m, entity_id, vertex_indices));
|
||||
}
|
||||
|
||||
static inline h5_err_t
|
||||
H5FedGetNeighborIndicesOfElement (
|
||||
h5t_mesh_t* const m,
|
||||
h5_loc_id_t entity_id,
|
||||
h5_loc_idx_t* neighbor_indices
|
||||
) {
|
||||
H5_API_ENTER (h5_err_t,
|
||||
"m=%p, entity_id=%lld, neighbor_indices=%p",
|
||||
m, (long long)entity_id, neighbor_indices);
|
||||
H5_API_RETURN (h5t_get_neighbor_indices (m, entity_id, neighbor_indices));
|
||||
}
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -19,11 +19,11 @@ h5_alloc (
|
||||
void* ptr,
|
||||
const size_t size
|
||||
) {
|
||||
MALLOC_WRAPPER_ENTER (void_p, "ptr=%p, size=%lu", ptr, size);
|
||||
MALLOC_WRAPPER_ENTER (void_p, "ptr=%p, size=%zu", ptr, size);
|
||||
ptr = realloc (ptr, size);
|
||||
if (ptr == NULL) {
|
||||
MALLOC_WRAPPER_LEAVE (
|
||||
(void_p)h5_error (H5_ERR_NOMEM, "Out of memory."));
|
||||
(void_p)(uintptr_t)h5_error (H5_ERR_NOMEM, "Out of memory."));
|
||||
}
|
||||
MALLOC_WRAPPER_RETURN (ptr);
|
||||
}
|
||||
@@ -37,7 +37,7 @@ h5_calloc (
|
||||
void* ptr = calloc (count, size);
|
||||
if (ptr == NULL) {
|
||||
MALLOC_WRAPPER_LEAVE (
|
||||
(void_p)h5_error (H5_ERR_NOMEM, "Out of memory."));
|
||||
(void_p)(uintptr_t)h5_error (H5_ERR_NOMEM, "Out of memory."));
|
||||
}
|
||||
MALLOC_WRAPPER_RETURN (ptr);
|
||||
}
|
||||
@@ -62,7 +62,7 @@ h5_strdup (
|
||||
char_p s2 = (char_p)h5_calloc (1, strlen (s1)+1 );
|
||||
if (s2 == NULL) {
|
||||
MALLOC_WRAPPER_LEAVE (
|
||||
(char_p)h5_error (H5_ERR_NOMEM, "Out of memory."));
|
||||
(char_p)(uintptr_t)h5_error (H5_ERR_NOMEM, "Out of memory."));
|
||||
}
|
||||
MALLOC_WRAPPER_RETURN (strcpy (s2, s1));
|
||||
}
|
||||
|
||||
@@ -78,6 +78,8 @@ h5t_get_vertex_coords_by_index (h5t_mesh_t* const, h5_loc_idx_t, h5_float64_t[3]
|
||||
h5_err_t
|
||||
h5t_get_vertex_coords_by_id (h5t_mesh_t* const, h5_loc_id_t, h5_float64_t[3]);
|
||||
|
||||
h5_err_t
|
||||
h5t_get_neighbor_indices (h5t_mesh_t* const, h5_loc_id_t, h5_loc_idx_t*);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -4,7 +4,7 @@ OBJEXT = o
|
||||
|
||||
AM_LDFLAGS = -L../../src/lib @LDFLAGS@
|
||||
LIBS = -lH5hutC -lH5hut @LIBS@
|
||||
INCLUDES = -I../../src/include @INCLUDES@
|
||||
AM_CPPFLAGS = -I../../src/include @AM_CPPFLAGS@
|
||||
|
||||
noinst_PROGRAMS = \
|
||||
tetmesh_write \
|
||||
@@ -16,6 +16,7 @@ noinst_PROGRAMS = \
|
||||
tetmesh_read_tags \
|
||||
trimesh_read \
|
||||
trimesh_write \
|
||||
trimesh_2gnuplot \
|
||||
trimesh_adjacencies \
|
||||
trimesh_write_dunetest
|
||||
|
||||
@@ -28,12 +29,13 @@ EXTRA_DIST = \
|
||||
tetmesh_read.c \
|
||||
tetmesh_read_tags.c \
|
||||
tetmesh_write.c \
|
||||
tetmesh_write1.c \
|
||||
tetmesh_write1.c \
|
||||
tetmesh_write2.c \
|
||||
tetmesh_write_tags.c \
|
||||
trimesh_adjacencies.c \
|
||||
trimesh_read.c \
|
||||
trimesh_write.c \
|
||||
trimesh_2gnuplot.c \
|
||||
trimesh_write_dunetest.c
|
||||
|
||||
# map_tet2globalid.c \
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "H5hut.h"
|
||||
#if defined (PARALLEL_IO)
|
||||
#include <mpi.h>
|
||||
#endif
|
||||
|
||||
#define H5FedGetNumLeafElementsTotal H5FedGetNumElementsTotal
|
||||
/*
|
||||
Traverse elements and output coordinates
|
||||
*/
|
||||
static h5_err_t
|
||||
traverse_elems (
|
||||
h5t_mesh_t* const m
|
||||
) {
|
||||
/* get number of elements we have to expect */
|
||||
h5_size_t num_elems_expect = H5FedGetNumLeafElementsTotal (m);
|
||||
|
||||
/* get iterator for co-dim 0 */
|
||||
h5t_iterator_t* iter = H5FedBeginTraverseEntities (m, 0);
|
||||
|
||||
/* iterate over all co-dim 0 entities, i.e. elements */
|
||||
h5_loc_id_t local_id;
|
||||
h5_size_t num_elems = 0;
|
||||
while ((local_id = H5FedTraverseEntities (iter)) >= 0) {
|
||||
h5_loc_id_t local_vids[4];
|
||||
H5FedGetVertexIndicesOfEntity (m, local_id, local_vids);
|
||||
|
||||
printf ("# cell %llx\n", (long long unsigned)local_id );
|
||||
h5_float64_t P[3];
|
||||
for (int i = 0; i < 3; i++) {
|
||||
H5FedGetVertexCoordsByIndex (m, local_vids[i], P);
|
||||
printf (" %8.6f %8.6f\n", P[0], P[1]);
|
||||
}
|
||||
H5FedGetVertexCoordsByIndex (m, local_vids[0], P);
|
||||
printf (" %8.6f %8.6f\n", P[0], P[1]);
|
||||
printf ("\n");
|
||||
num_elems++;
|
||||
}
|
||||
|
||||
/* done */
|
||||
H5FedEndTraverseEntities (iter);
|
||||
|
||||
/* report error if we got a different number then expected */
|
||||
if (num_elems != num_elems_expect) {
|
||||
fprintf (stderr, "!!! Got %lld elements, but expected %lld.\n",
|
||||
(long long)num_elems, (long long)num_elems_expect);
|
||||
exit(1);
|
||||
}
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
int
|
||||
main (
|
||||
int argc,
|
||||
char* argv[]
|
||||
) {
|
||||
|
||||
#if defined (PARALLEL_IO)
|
||||
MPI_Comm comm = MPI_COMM_WORLD;
|
||||
MPI_Init (&argc, &argv);
|
||||
#else
|
||||
MPI_Comm comm = 0;
|
||||
#endif
|
||||
if (argc < 2 || argc > 3) {
|
||||
fprintf (stderr, "Usage: %s FILE [LEVEL]\n", argv[0]);
|
||||
exit (42);
|
||||
}
|
||||
|
||||
/* abort program on error, so we don't have to handle them */
|
||||
H5SetErrorHandler (H5AbortErrorhandler);
|
||||
H5SetVerbosityLevel (0);
|
||||
|
||||
/* open file and get number of meshes */
|
||||
h5_file_t* f = H5OpenFile (argv[1], H5_O_RDONLY, comm);
|
||||
h5t_mesh_t* m;
|
||||
H5FedOpenTriangleMeshByIndex (f, 0, &m);
|
||||
int num_levels = H5FedGetNumLevels (m);
|
||||
int level = num_levels-1;
|
||||
if (argc >= 3) {
|
||||
level = atoi (argv[2]);
|
||||
}
|
||||
if (level >= num_levels || level < 0) {
|
||||
fprintf (stderr, "level %d out of range\n", level);
|
||||
goto done;
|
||||
}
|
||||
H5FedSetLevel (m, level);
|
||||
traverse_elems (m);
|
||||
|
||||
|
||||
done:
|
||||
H5FedCloseMesh (m);
|
||||
H5CloseFile (f);
|
||||
|
||||
#if defined (PARALLEL_IO)
|
||||
MPI_Finalize ();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
+1
-1
@@ -5,7 +5,7 @@ SUBDIRS = H5Fed
|
||||
|
||||
OBJEXT=o
|
||||
|
||||
INCLUDES = -I../src/include @INCLUDES@
|
||||
AM_CPPFLAGS = -I../src/include @AM_CPPFLAGS@
|
||||
|
||||
noinst_PROGRAMS = @BUILD_TESTS@
|
||||
|
||||
|
||||
+6
-2
@@ -1,11 +1,15 @@
|
||||
# tools level Makefile.am
|
||||
|
||||
OBJEXT=o
|
||||
SUBDIRS =
|
||||
|
||||
if ENABLE_VTKCONVERTER
|
||||
SUBDIRS += vtk2h5grid
|
||||
endif
|
||||
|
||||
AM_LDFLAGS = -L../src/lib @LDFLAGS@
|
||||
LIBS = -lH5hutC -lH5hut @LIBS@
|
||||
|
||||
INCLUDES = -I../src/include @INCLUDES@
|
||||
AM_CPPFLAGS = -I../src/include @AM_CPPFLAGS@
|
||||
|
||||
# What to build... make install will place these files in the $(prefix)/bin directory.
|
||||
bin_PROGRAMS = @BUILD_TOOLS@
|
||||
|
||||
@@ -167,7 +167,7 @@ int get_option(int argc, const char **argv, const char *opts, const struct long_
|
||||
}
|
||||
else
|
||||
{
|
||||
register char *cp; /* pointer into current token */
|
||||
register const char *cp; /* pointer into current token */
|
||||
|
||||
/* short command line option */
|
||||
opt_opt = argv[opt_ind][sp];
|
||||
@@ -312,7 +312,7 @@ int main(int argc, const char *argv[])
|
||||
|
||||
string ifn = string(input_name) + string(".h5");
|
||||
|
||||
h5file = H5OpenFile(ifn.c_str(), H5_O_WRONLY, NULL);
|
||||
h5file = H5OpenFile(ifn.c_str(), H5_O_WRONLY, 0);
|
||||
|
||||
if( h5file == NULL ) {
|
||||
fprintf(stdout, "unable to open file %s\n", input_name);
|
||||
|
||||
@@ -176,7 +176,7 @@ int get_option(int argc, const char **argv, const char *opts, const struct long_
|
||||
}
|
||||
else
|
||||
{
|
||||
register char *cp; /* pointer into current token */
|
||||
register const char *cp; /* pointer into current token */
|
||||
|
||||
/* short command line option */
|
||||
opt_opt = argv[opt_ind][sp];
|
||||
@@ -336,7 +336,7 @@ int main(int argc, const char *argv[])
|
||||
|
||||
string ifn = string(input_name) + string(".h5");
|
||||
|
||||
h5file = H5OpenFile(ifn.c_str(), H5_O_WRONLY, NULL);
|
||||
h5file = H5OpenFile(ifn.c_str(), H5_O_WRONLY, 0);
|
||||
|
||||
if( h5file == NULL ) {
|
||||
fprintf(stdout, "unable to open file %s\n", input_name);
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
AM_CPPFLAGS = -I${abs_top_builddir}/src/include -Wno-deprecated
|
||||
FFLAGS += -cpp $(AM_CPPFLAGS)
|
||||
LDFLAGS += -L${abs_top_builddir}/src/lib
|
||||
|
||||
LDADD =
|
||||
|
||||
LDADD += -lH5hut -lH5hutC -lvtkCommon -lvtkIO
|
||||
|
||||
|
||||
bin_PROGRAMS =
|
||||
|
||||
bin_PROGRAMS += vtk2h5grid
|
||||
vtk2h5grid_SOURCES = vtk2h5grid.cc
|
||||
|
||||
distclean-local:
|
||||
$(RM) *~
|
||||
@@ -0,0 +1,204 @@
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <getopt.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <map>
|
||||
|
||||
|
||||
#include <vtkSmartPointer.h>
|
||||
#include <vtkExtractEdges.h>
|
||||
#include "vtkUnstructuredGrid.h"
|
||||
#include "vtkUnstructuredGridReader.h"
|
||||
|
||||
#include "H5hut.h"
|
||||
|
||||
const char* version = "0.1.0";
|
||||
int convert_boundary = 1;
|
||||
int convert_volume = 0;
|
||||
const struct option longopts[] = {
|
||||
{"version", no_argument, 0, 'v'},
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{"boundary", no_argument, &convert_boundary, 1},
|
||||
{"volume", no_argument, &convert_volume, 1},
|
||||
{"no-boundary", no_argument, &convert_boundary, 0},
|
||||
{"no-volume", no_argument, &convert_volume, 0},
|
||||
{0,0,0,0},
|
||||
};
|
||||
|
||||
typedef std::map<int, size_t> IdMap;
|
||||
|
||||
static void
|
||||
usage (
|
||||
char* cmd
|
||||
) {
|
||||
std::cout << std::endl << "Usage: " << std::endl;
|
||||
std::cout << " " << cmd << " [OPTIONS] FILE..." << std::endl << std::endl;
|
||||
std::cout << "Options:" << std::endl;
|
||||
std::cout << " --(no-)boundary do (not) convert boundary triangles." << std::endl;
|
||||
std::cout << " default is yes" << std::endl;
|
||||
std::cout << " --(no-)volume do (not) convert volume mesh." << std::endl;
|
||||
std::cout << " default is no" << std::endl;
|
||||
std::cout << std::endl;
|
||||
exit (1);
|
||||
}
|
||||
|
||||
static void
|
||||
print_version (
|
||||
char* cmd
|
||||
) {
|
||||
std::cout << "Version: " << cmd << " " << version << std::endl;
|
||||
exit (1);
|
||||
}
|
||||
|
||||
static int
|
||||
init (
|
||||
int argc,
|
||||
char* argv[]
|
||||
) {
|
||||
int index;
|
||||
int iarg = 0;
|
||||
|
||||
//turn off getopt error message
|
||||
opterr = 1;
|
||||
|
||||
while(iarg != -1) {
|
||||
iarg = getopt_long(argc, argv, "vh?", longopts, &index);
|
||||
|
||||
switch (iarg) {
|
||||
case 'h':
|
||||
case '?':
|
||||
usage (argv[0]);
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
print_version (argv[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return argc - optind;
|
||||
}
|
||||
|
||||
void
|
||||
convert_vtk2h5grid (
|
||||
vtkUnstructuredGrid* vtk_grid,
|
||||
h5t_mesh_t* h5_grid,
|
||||
int cell_type
|
||||
) {
|
||||
IdMap idmap;
|
||||
vtkIdType num_vtk_cells = vtk_grid->GetNumberOfCells ();
|
||||
vtkIdType num_vtk_pts = vtk_grid->GetNumberOfPoints ();
|
||||
h5_loc_idx_t (*cells)[4] = new h5_loc_idx_t[num_vtk_cells][4];
|
||||
int h5_cell_idx = 0;
|
||||
int h5_vertex_idx = 0;
|
||||
H5FedBeginStoreVertices (h5_grid, num_vtk_pts);
|
||||
for (vtkIdType vtk_cell_id = 0; vtk_cell_id < num_vtk_cells; vtk_cell_id++) {
|
||||
if (vtk_grid->GetCellType (vtk_cell_id) != cell_type)
|
||||
continue;
|
||||
|
||||
vtkIdType num_pts;
|
||||
vtkIdType* pts;
|
||||
vtk_grid->GetCellPoints (vtk_cell_id, num_pts, pts);
|
||||
for (vtkIdType i = 0; i < num_pts; i++) {
|
||||
IdMap::iterator it = idmap.find (pts[i]);
|
||||
if (it == idmap.end ()) {
|
||||
// add point to H5hut mesh
|
||||
double pt[3];
|
||||
vtk_grid->GetPoint (pts[i], pt);
|
||||
H5FedStoreVertex (h5_grid, -1, pt);
|
||||
// map pt index in vtk file to pt index in H5hut file
|
||||
idmap.insert (IdMap::value_type (pts[i], h5_vertex_idx));
|
||||
cells[h5_cell_idx][i] = h5_vertex_idx++;
|
||||
} else {
|
||||
cells[h5_cell_idx][i] = it->second;
|
||||
}
|
||||
}
|
||||
h5_cell_idx++;
|
||||
}
|
||||
H5FedEndStoreVertices (h5_grid);
|
||||
int num_h5_vertices = h5_vertex_idx;
|
||||
int num_h5_cells = h5_cell_idx;
|
||||
cout << " number of points in mesh: " << num_h5_vertices << endl;
|
||||
cout << " number of cells in mesh: " << num_h5_cells << endl;
|
||||
// add cells to H5hut file
|
||||
H5FedBeginStoreElements (h5_grid, num_h5_cells);
|
||||
for (int i = 0; i < num_h5_cells; i++) {
|
||||
H5FedStoreElement (h5_grid, cells[i]);
|
||||
}
|
||||
H5FedEndStoreElements (h5_grid);
|
||||
delete cells;
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
H5Errorhandler (
|
||||
const char* fmt,
|
||||
va_list ap
|
||||
) {
|
||||
vfprintf (stderr, fmt, ap);
|
||||
exit (42);
|
||||
return -2;
|
||||
}
|
||||
|
||||
int
|
||||
main (
|
||||
int argc,
|
||||
char* argv[]
|
||||
) {
|
||||
|
||||
argc = init (argc, argv);
|
||||
if (argc == 0) {
|
||||
std::cout << "No file(s) to convert?!" << std::endl;
|
||||
usage (argv[0]);
|
||||
}
|
||||
argv += optind;
|
||||
H5SetErrorHandler (H5Errorhandler);
|
||||
for (int i = 0; i < argc; i++) {
|
||||
std::string vtk_filename = argv[i];
|
||||
std::string h5grid_filename = vtk_filename.substr (0, vtk_filename.find_last_of ('.')) + ".h5";
|
||||
struct stat st;
|
||||
if (stat (vtk_filename.c_str(), &st) < 0) {
|
||||
perror (vtk_filename.c_str());
|
||||
exit (1);
|
||||
}
|
||||
if (!(st.st_mode & S_IRUSR)) {
|
||||
std::cerr << vtk_filename << ": not readable" << std::endl;
|
||||
exit (1);
|
||||
}
|
||||
if (stat (h5grid_filename.c_str(), &st) == 0) {
|
||||
std::cerr << h5grid_filename << ": already exits" << std::endl;
|
||||
exit (1);
|
||||
}
|
||||
if (errno != ENOENT) {
|
||||
perror (h5grid_filename.c_str());
|
||||
exit (1);
|
||||
}
|
||||
std::cout << vtk_filename << ": converting ...." << std::endl;
|
||||
|
||||
// read vtk file
|
||||
vtkSmartPointer<vtkUnstructuredGridReader> reader =
|
||||
vtkSmartPointer<vtkUnstructuredGridReader>::New ();
|
||||
reader->SetFileName (vtk_filename.c_str ());
|
||||
reader->Update ();
|
||||
vtkUnstructuredGrid* vtk_grid = reader->GetOutput ();
|
||||
|
||||
// open new H5hut file
|
||||
h5_file_t* f = H5OpenFile (h5grid_filename.c_str(), H5_O_WRONLY, 0);
|
||||
|
||||
h5t_mesh_t* h5_grid;
|
||||
if (convert_boundary) {
|
||||
// add boundary mesh
|
||||
H5FedAddTriangleMesh (f, "0", &h5_grid);
|
||||
convert_vtk2h5grid (vtk_grid, h5_grid, VTK_TRIANGLE);
|
||||
H5FedCloseMesh (h5_grid);
|
||||
}
|
||||
if (convert_volume) {
|
||||
// add volume mesh
|
||||
H5FedAddTetrahedralMesh (f, "0", &h5_grid);
|
||||
convert_vtk2h5grid (vtk_grid, h5_grid, VTK_TETRA);
|
||||
H5FedCloseMesh (h5_grid);
|
||||
}
|
||||
H5CloseFile (f);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user