Skip to content

Commit f629eff

Browse files
committed
Upgrade SimpleX to the newer libqhull_r
1 parent 96706e0 commit f629eff

File tree

6 files changed

+30
-19
lines changed

6 files changed

+30
-19
lines changed

src/amuse_simplex/src/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ CXXCFLAGS := $(CXXCFLAGS_NO_C) -c
3030
export CXXCFLAGS
3131

3232
MACRODEFS = -DH5_USE_16_API
33-
MYLIBS = -lqhull $(GSL_LIBS) $(HDF5_LIBS)
33+
MYLIBS = -lqhull_r $(GSL_LIBS) $(HDF5_LIBS)
3434
MYINCLUDE = -I$(KEYVALUE_PATH) $(HDF5_PLUGIN_FLAGS) $(HDF5_FLAGS) \
3535
-I$(PLUGINS)/octree -I$(PLUGINS)/hilbert -I$(SRC) \
3636
-I$(PLUGINS)/unit_sphere_tess/include $(GSL_FLAGS)

src/amuse_simplex/src/src/SimpleX.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ SimpleX::SimpleX(const string& output_path, const string& data_path){
7676
// Random number generator
7777
ran = gsl_rng_alloc (gsl_rng_taus);
7878

79+
// Qhull library
80+
qh = &Qhull;
81+
7982
// Method for RT
8083
ballisticTransport = 0;
8184
dirConsTransport = 0;
@@ -1183,7 +1186,7 @@ void SimpleX::compute_triangulation(){
11831186
//assume for now the triangulation will be correct, check will follow
11841187
correct = 1;
11851188
//call to qhull to do triangulation
1186-
int qh_error = qh_new_qhull(dimension, in_box.size(), pt_array, ismalloc, flags, NULL, errfile);
1189+
int qh_error = qh_new_qhull(qh, dimension, in_box.size(), pt_array, ismalloc, flags, NULL, errfile);
11871190
if (!qh_error) {
11881191
//loop over all facets
11891192
FORALLfacets {
@@ -1192,11 +1195,11 @@ void SimpleX::compute_triangulation(){
11921195
//store the simplex in simplices vector
11931196
unsigned int r=0;
11941197
Simpl tempSimpl;
1195-
tempSimpl.set_volume( qh_facetarea(facet) );
1198+
tempSimpl.set_volume( qh_facetarea(qh, facet) );
11961199

11971200
FOREACHvertex_ (facet->vertices) {
11981201
//store the indices of each simplex
1199-
ids[r++]=idList[qh_pointid(vertex->point)];
1202+
ids[r++]=idList[qh_pointid(qh, vertex->point)];
12001203
}//for each facet
12011204

12021205
tempSimpl.set_id1( in_box[ ids[0] ] );
@@ -1447,10 +1450,10 @@ void SimpleX::compute_triangulation(){
14471450
}
14481451

14491452
//free long memory
1450-
qh_freeqhull(!qh_ALL);
1453+
qh_freeqhull(qh, !qh_ALL);
14511454

14521455
//free short memory and memory allocator
1453-
qh_memfreeshort (&curlong, &totlong);
1456+
qh_memfreeshort (qh, &curlong, &totlong);
14541457
if (curlong || totlong) {
14551458
fprintf(errfile, "QHull: did not free %d bytes of long memory (%d pieces)", totlong, curlong);
14561459
}

src/amuse_simplex/src/src/SimpleX.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,8 @@ extern "C"
5454
#endif
5555
#include <stdio.h>
5656
#include <stdlib.h>
57-
#include <libqhull/libqhull.h>
58-
#include <libqhull/mem.h>
59-
#include <libqhull/qset.h>
60-
#include <libqhull/geom.h>
61-
#include <libqhull/merge.h>
62-
#include <libqhull/poly.h>
63-
#include <libqhull/io.h>
64-
#include <libqhull/stat.h>
57+
#include <libqhull_r/libqhull_r.h>
58+
#include <libqhull_r/geom_r.h>
6559
#if defined(__cplusplus)
6660
}
6761
#endif
@@ -542,6 +536,8 @@ class SimpleX{
542536
unsigned int*** maps; //!< Array to hold the mappings between direction bins
543537
unsigned int number_of_directions; //!< Number of discretizations of the unit sphere for DCT
544538
unsigned int number_of_orientations;//!< Number of random rotations of the DCT discretization
539+
qhT Qhull; //!< QHull main object
540+
qhT *qh; //!< Points to Qhull, needed for Qhull macros to work
545541
};
546542

547543
#endif

src/amuse_simplex/support/configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5995,7 +5995,7 @@ return conftest::qh_freeqhull ();
59955995
return 0;
59965996
}
59975997
_ACEOF
5998-
for ac_lib in '' qhull
5998+
for ac_lib in '' qhull_r
59995999
do
60006000
if test -z "$ac_lib"; then
60016001
ac_res="none required"

support/configure

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14745,7 +14745,7 @@ return qh_freeqhull ();
1474514745
return 0;
1474614746
}
1474714747
_ACEOF
14748-
for ac_lib in '' qhull
14748+
for ac_lib in '' qhull_r
1474914749
do
1475014750
if test -z "$ac_lib"; then
1475114751
ac_res="none required"
@@ -15216,6 +15216,9 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
1521615216
1521715217
amuse_lib_healpix_cxx_save_libs="$LIBS"
1521815218
15219+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for HEALPix" >&5
15220+
printf %s "checking for HEALPix... " >&6; }
15221+
1521915222
ac_ext=cpp
1522015223
ac_cpp='$CXXCPP $CPPFLAGS'
1522115224
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -15229,7 +15232,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
1522915232
/* end confdefs.h. */
1523015233
1523115234
15232-
#include <healpix_base.h>
15235+
#include <healpix_cxx/healpix_base.h>
1523315236
1523415237
#ifdef F77_DUMMY_MAIN
1523515238
@@ -15243,7 +15246,7 @@ int
1524315246
main (void)
1524415247
{
1524515248
15246-
Healpix_Base hb();
15249+
Healpix_Base hb;
1524715250
1524815251
;
1524915252
return 0;
@@ -15257,6 +15260,9 @@ then :
1525715260
HEALPIX_CXX_CFLAGS=""
1525815261
HEALPIX_CXX_LIBS="$LIBS"
1525915262
15263+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
15264+
printf "%s\n" "yes" >&6; }
15265+
1526015266
else $as_nop
1526115267
1526215268
# Not found, try pkg-config instead
@@ -15321,12 +15327,16 @@ fi
1532115327
1532215328
1532315329
FOUND_HEALPIX_CXX="no"
15330+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
15331+
printf "%s\n" "no" >&6; }
1532415332
1532515333
elif test $pkg_failed = untried; then
1532615334
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
1532715335
printf "%s\n" "no" >&6; }
1532815336
1532915337
FOUND_HEALPIX_CXX="no"
15338+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
15339+
printf "%s\n" "no" >&6; }
1533015340
1533115341
else
1533215342
HEALPIX_CXX_CFLAGS=$pkg_cv_HEALPIX_CXX_CFLAGS
@@ -15335,6 +15345,8 @@ else
1533515345
printf "%s\n" "yes" >&6; }
1533615346
1533715347
FOUND_HEALPIX_CXX="yes"
15348+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
15349+
printf "%s\n" "yes" >&6; }
1533815350
1533915351
fi
1534015352

support/shared/m4/amuse_lib_qhull.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ AC_DEFUN([AMUSE_LIB_QHULL], [
1414
amuse_lib_qhull_save_libs="$LIBS"
1515
1616
LIBS=""
17-
AC_SEARCH_LIBS([qh_freeqhull], [qhull], [
17+
AC_SEARCH_LIBS([qh_freeqhull], [qhull_r], [
1818
FOUND_QHULL="yes"
1919
], [])
2020
QHULL_LIBS="$LIBS"

0 commit comments

Comments
 (0)