Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config.h.ac
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#undef HAVE_ASPRINTF
#undef HAVE_CLOCK_GETTIME
#undef HAVE_GETRUSAGE
#undef HAVE_GSL
#undef HAVE_PETSC
#undef HAVE_SLEPC
#undef HAVE_SUNDIALS
Expand Down
151 changes: 101 additions & 50 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,15 @@ AM_CONDITIONAL([INCLUDE_SLEPC], [test "x${have_slepc}" = "xyes"])


######################
# see if we have --enable-download-gsl
# check for GSL (optional)
AC_ARG_WITH([gsl],
[AS_HELP_STRING([--with-gsl],
[use GSL for advanced math features @<:@default=check@:>@])],
[],
[with_gsl=check]
)

have_gsl="no"
gslver=2.8
gsldist=gsl-${gslver}
gslmirror=http://ftpmirror.gnu.org/gsl/${gsldist}.tar.gz
Expand All @@ -323,59 +331,92 @@ AC_ARG_ENABLE([download-gsl],
[download_gsl=yes],
[download_gsl=no])

# if gsl directory does not exist, see if we have to uncompress and/or download
AS_IF([test ! -e ${gsldist}],[
AS_IF([test ! -e ${gsldist}.tar.gz],[
AS_IF([test "x$download_gsl" = "xyes"],[
AS_IF([test "x$(which wget)" != "x"],[
AC_MSG_NOTICE([downloading ${gslmirror}])
wget -c ${gslmirror}
AS_IF([test "x${with_gsl}" != "xno"], [
# if gsl directory does not exist, see if we have to uncompress and/or download
AS_IF([test ! -e ${gsldist}],[
AS_IF([test ! -e ${gsldist}.tar.gz],[
AS_IF([test "x$download_gsl" = "xyes"],[
AS_IF([test "x$(which wget)" != "x"],[
AC_MSG_NOTICE([downloading ${gslmirror}])
wget -c ${gslmirror}
],[
AS_IF([test "x${with_gsl}" != "xcheck"], [
AC_MSG_ERROR([file ${gsldist}.tar.gz not found and wget not installed])
])
])
AS_IF([test ! -e ${gsldist}.tar.gz],[
AS_IF([test "x${with_gsl}" != "xcheck"], [
AC_MSG_ERROR([file ${gsldist}.tar.gz could not be downloaded])
])
])
])
])

AS_IF([test -e ${gsldist}.tar.gz],[
AC_MSG_NOTICE([uncompressing ${gsldist}.tar.gz])
tar xzf ${gsldist}.tar.gz
])
])

# if gsl directory exists, see if we have to compile it
AS_IF([test -e ${gsldist}],[
AS_IF([test -e ${gsldist}/.libs/libgsl.a],[
AC_MSG_NOTICE([using already-compiled GSL library ${gsldist}/.libs/libgsl.a])
],[
AC_MSG_ERROR([file ${gsldist}.tar.gz not found and wget not installed])
AC_MSG_NOTICE([configuring ${gsldist}])
cd ${gsldist}
./configure --prefix=${prefix} --host=${host}
AC_MSG_NOTICE([compiling ${gsldist}])
make
cd ..
])
AS_IF([test ! -e ${gsldist}.tar.gz],[
AC_MSG_ERROR([file ${gsldist}.tar.gz could not be downloaded, copy it manually and re-try.])

AC_SUBST([DOWNLOADED_GSL_LIBS], ["../${gsldist}/.libs/libgsl.a ../${gsldist}/cblas/.libs/libgslcblas.a"])
AC_SUBST([DOWNLOADED_GSL_INCLUDES], ["-I ../${gsldist} -I ../../${gsldist}"])
gsl_version="${gslver} (downloaded and statically linked)"
have_gsl="yes"
],[
# traditional test for GSL
# check for GSL & CBLAS
AC_CHECK_HEADER([gsl/gsl_vector.h], [], [
AS_IF([test "x${with_gsl}" != "xcheck"], [
AC_MSG_FAILURE([--with-gsl was given but GSL headers libgsl-dev not found])
])
])

# TODO: the original idea is that
# if we found PETSc, we use whatever BLAS it has, otherwise we use GSL's CBLAS
# but this does not work in Fedora since even though the library flexiblas
# that is used by PETSc does contain cblas_dgemm, it is not found by the linker
#AS_IF([test "x${have_petsc}" != "xyes"],
AC_CHECK_LIB([gslcblas],[cblas_dgemm], [], [
AS_IF([test "x${with_gsl}" != "xcheck"], [
AC_MSG_FAILURE([--with-gsl was given but GSL CBLAS libgsl-dev not found])
])
])
#)
AC_CHECK_LIB([gsl],[gsl_blas_dgemm], [], [
AS_IF([test "x${with_gsl}" != "xcheck"], [
AC_MSG_FAILURE([--with-gsl was given but GSL library libgsl-dev not found])
])
])

# check if we have everything
AS_IF([test "x${ac_cv_lib_gsl_gsl_blas_dgemm}" = "xyes" -a \
"x${ac_cv_header_gsl_gsl_vector_h}" = "xyes"],
[
gsl_version="from system"
have_gsl="yes"
]
)
])
])

AS_IF([test -e ${gsldist}.tar.gz],[
AC_MSG_NOTICE([uncompressing ${gsldist}.tar.gz])
tar xzf ${gsldist}.tar.gz
])
])

# if gsl directory exists, see if we have to compile it
AS_IF([test -e ${gsldist}],[
AS_IF([test -e ${gsldist}/.libs/libgsl.a],[
AC_MSG_NOTICE([using already-compiled GSL library ${gsldist}/.libs/libgsl.a])
],[
AC_MSG_NOTICE([configuring ${gsldist}])
cd ${gsldist}
./configure --prefix=${prefix} --host=${host}
AC_MSG_NOTICE([compiling ${gsldist}])
make
cd ..
])

AC_SUBST([DOWNLOADED_GSL_LIBS], ["../${gsldist}/.libs/libgsl.a ../${gsldist}/cblas/.libs/libgslcblas.a"])
AC_SUBST([DOWNLOADED_GSL_INCLUDES], ["-I ../${gsldist} -I ../../${gsldist}"])
gsl_version="${gslver} (downloaded and statically linked)"
],[
# traditional test for GSL
# check for GSL & CBLAS (required)
AC_CHECK_HEADER([gsl/gsl_vector.h], [], AC_MSG_ERROR([GNU Scientific library headers libgsl-dev not found.
Either install them with your package manager or configure with --enable-download-gsl]))

# TODO: the original idea is that
# if we found PETSc, we use whatever BLAS it has, otherwise we use GSL's CBLAS
# but this does not work in Fedora since even though the library flexiblas
# that is used by PETSc does contain cblas_dgemm, it is not found by the linker
#AS_IF([test "x${have_petsc}" != "xyes"],
AC_CHECK_LIB([gslcblas],[cblas_dgemm], [], AC_MSG_ERROR([GNU Scientific library CBLAS libgsl-dev not found]))
#)
AC_CHECK_LIB([gsl],[gsl_blas_dgemm], [], AC_MSG_ERROR([GNU Scientific library libgsl-dev not found]))
gsl_version="from system"
# Define HAVE_GSL if we found it
AS_IF([test "x${have_gsl}" = "xyes"],
[
AC_DEFINE([HAVE_GSL], [1], [GSL is available])
]
)
])


Expand Down Expand Up @@ -424,22 +465,32 @@ AS_IF([test "x${enable_fee2ccx}" = "xyes"] , [


AS_BOX([Summary of dependencies])
AS_ECHO( [" GNU Scientific Library ${gsl_version}"])
AS_ECHO_N( [" GNU Scientific Library ${have_gsl}"])
AS_IF([test "x${have_gsl}" = "xyes"],
AS_ECHO([" ${gsl_version}"]),
AS_ECHO
)

# AS_ECHO( [" Readline ${have_readline}"])

AS_ECHO( [" SUNDIALS ${have_sundials}"])

AS_ECHO_N([" PETSc ${have_petsc}"])
AS_IF([test "x${have_petsc}" = "xyes"],
AS_ECHO([" ${PETSC_DIR} ${PETSC_ARCH}"]),
AS_ECHO
)

AS_ECHO_N([" SLEPc ${have_slepc}"])
AS_IF([test "x${have_slepc}" = "xyes"],
AS_ECHO([" ${SLEPC_DIR}"]),
AS_ECHO
)

AS_ECHO( [" Compile fee2ccx ${enable_fee2ccx}"])
AS_ECHO( [" Compiler ${compiler_show}"])
AS_ECHO( [" Compiler flags ${CFLAGS}"])
AS_ECHO( [" Compiler version ${compiler_version}"])
# AS_ECHO( [" Linker flags ${LDFLAGS}"])

AC_OUTPUT
57 changes: 25 additions & 32 deletions src/feenox.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,38 +41,17 @@
#endif

// for inlining as much as possible GSL
#ifdef HAVE_GSL
#define HAVE_INLINE
#define GSL_RANGE_CHECK_OFF
#endif

#ifndef sunrealtype
#define sunrealtype realtype
#endif

// we need all the includes here so they all follow the inline directive above
#include <gsl/gsl_blas.h>
#include <gsl/gsl_errno.h>
#include <gsl/gsl_deriv.h>
#include <gsl/gsl_heapsort.h>
#include <gsl/gsl_integration.h>
#include <gsl/gsl_interp.h>
#include <gsl/gsl_linalg.h>
#include <gsl/gsl_math.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_min.h>
#include <gsl/gsl_multifit_nlinear.h>
#include <gsl/gsl_multimin.h>
#include <gsl/gsl_multiroots.h>
#include <gsl/gsl_qrng.h>
#include <gsl/gsl_randist.h>
#include <gsl/gsl_rng.h>
#include <gsl/gsl_roots.h>
#include <gsl/gsl_spline.h>
#include <gsl/gsl_sf.h>
#include <gsl/gsl_statistics.h>
#include <gsl/gsl_sort_double.h>
#include <gsl/gsl_sort_vector_double.h>
#include <gsl/gsl_vector.h>
#include <gsl/gsl_version.h>
// Include linear algebra layer (GSL or compatibility implementation)
#include "math/linalg.h"

#ifdef HAVE_SUNDIALS
#include <ida/ida.h>
Expand Down Expand Up @@ -162,7 +141,11 @@ extern "C++" {
// reasonable defaults
#define DEFAULT_DT 1.0/16.0
#define DEFAULT_DAE_RTOL 1e-6
#ifdef HAVE_GSL
#define DEFAULT_RANDOM_METHOD gsl_rng_mt19937
#else
#define DEFAULT_RANDOM_METHOD NULL
#endif

#define DEFAULT_PRINT_FORMAT "%g"
#define DEFAULT_PRINT_SEPARATOR "\t"
Expand All @@ -187,7 +170,11 @@ extern "C++" {
#define DEFAULT_FIT_GTOL 1e-8
#define DEFAULT_FIT_FTOL 0.0

#ifdef HAVE_GSL
#define DEFAULT_SOLVE_METHOD gsl_multiroot_fsolver_dnewton
#else
#define DEFAULT_SOLVE_METHOD NULL
#endif
#define DEFAULT_SOLVE_EPSREL 0 // zero means do not look for deltas in derivatives
#define DEFAULT_SOLVE_EPSABS 1e-6
#define DEFAULT_SOLVE_MAX_ITER 128
Expand Down Expand Up @@ -231,7 +218,9 @@ extern "C++" {
#define ELEMENT_TYPE_PRISM15 18
#define NUMBER_ELEMENT_TYPE 19

#ifndef M_SQRT5
#define M_SQRT5 2.23606797749978969640917366873127623544061835961152572427089
#endif

#define FEENOX_SOLUTION_NOT_GRADIENT 0
#define FEENOX_SOLUTION_GRADIENT 1
Expand Down Expand Up @@ -1430,8 +1419,8 @@ struct mesh_write_t {

int (*write_header)(mesh_t *mesh, FILE *file);
int (*write_mesh)(mesh_t *mesh, FILE *file, int no_physical_names);
int (*write_data)(mesh_write_t *this, mesh_write_dist_t *dist);
int (*write_footer)(mesh_write_t *this);
int (*write_data)(mesh_write_t *mesh, mesh_write_dist_t *dist);
int (*write_footer)(mesh_write_t *mesh);

// these two are to know if we have to change the type in VTK
int point_init;
Expand Down Expand Up @@ -1538,7 +1527,11 @@ struct solve_t {
int max_iter;
int verbose;

#ifdef HAVE_GSL
const gsl_multiroot_fsolver_type *type;
#else
const void *type;
#endif

solve_t *next;
};
Expand Down Expand Up @@ -2130,7 +2123,7 @@ extern int feenox_read_arguments(char *string, int n_arguments, char ***arg, siz


// file.c
char *feenox_evaluate_string(const char *restrict format, int n_args, expr_t *arg);
char *feenox_evaluate_string(const char *restrict fmt, int n_args, expr_t *arg);
extern int feenox_instruction_file(void *arg);
FILE *feenox_fopen(const char *filepath, const char *mode);
extern int feenox_instruction_file_open(void *arg);
Expand Down Expand Up @@ -2303,7 +2296,7 @@ extern double feenox_gsl_function(double x, void *params);
// mesh.c
extern int feenox_instruction_mesh_read(void *arg);
extern int feenox_mesh_create_nodes_argument(mesh_t *);
extern int feenox_mesh_create_index2tag(mesh_t *this);
extern int feenox_mesh_create_index2tag(mesh_t *mesh);
extern int feenox_mesh_free(mesh_t *);

extern int feenox_mesh_read_vtk(mesh_t *);
Expand Down Expand Up @@ -2427,13 +2420,13 @@ extern int feenox_mesh_write_header_vtk(mesh_t *mesh, FILE *file);
extern int feenox_mesh_write_vtk_cells(mesh_t *mesh, FILE * file, int with_size);
extern int feenox_mesh_write_vtk_types(mesh_t *mesh, FILE * file);
extern int feenox_mesh_write_mesh_vtk(mesh_t *mesh, FILE *file, int dummy);
extern int feenox_mesh_write_data_vtk(mesh_write_t *this, mesh_write_dist_t *dist);
extern int feenox_mesh_write_data_vtk(mesh_write_t *mesh, mesh_write_dist_t *dist);

// vtu.c
extern int feenox_mesh_write_header_vtu(mesh_t *mesh, FILE *file);
extern int feenox_mesh_write_mesh_vtu(mesh_t *, FILE *file, int dummy);
extern int feenox_mesh_write_data_vtu(mesh_write_t *this, mesh_write_dist_t *dist);
extern int feenox_mesh_write_footer_vtu(mesh_write_t *this);
extern int feenox_mesh_write_data_vtu(mesh_write_t *mesh, mesh_write_dist_t *dist);
extern int feenox_mesh_write_footer_vtu(mesh_write_t *mesh);

// neighbors.c
extern element_t *feenox_mesh_find_element_volumetric_neighbor(element_t *e) __attribute__((noinline));
Expand Down
Loading
Loading