From bc371d4df1e1a7302bfbf97e067aa8b6d73d2980 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Fri, 13 Apr 2012 15:35:19 +0200 Subject: [PATCH 1/4] Initial version of automatic checking for dune-istl in build system. --- Makefile.am | 13 +++++++++++-- configure.ac | 2 ++ m4/ax_dune_common.m4 | 37 +++++++++++++++++++++++++++++++++++++ m4/ax_dune_istl.m4 | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 m4/ax_dune_common.m4 create mode 100644 m4/ax_dune_istl.m4 diff --git a/Makefile.am b/Makefile.am index beb12e01..6330ab07 100644 --- a/Makefile.am +++ b/Makefile.am @@ -87,6 +87,7 @@ opm/core/pressure/FlowBCManager.cpp \ opm/core/pressure/well.c \ opm/core/pressure/fsh_common_impl.c \ opm/core/pressure/fsh.c \ +opm/core/pressure/IncompTpfa.cpp \ opm/core/pressure/tpfa/ifs_tpfa.c \ opm/core/pressure/tpfa/compr_source.c \ opm/core/pressure/tpfa/cfs_tpfa.c \ @@ -245,10 +246,18 @@ opm/core/transport/reorder/tarjan.h if UMFPACK libopmcore_la_SOURCES += \ opm/core/linalg/call_umfpack.c \ -opm/core/linalg/LinearSolverUmfpack.cpp \ -opm/core/pressure/IncompTpfa.cpp +opm/core/linalg/LinearSolverUmfpack.cpp nobase_include_HEADERS += \ opm/core/linalg/call_umfpack.h \ opm/core/linalg/LinearSolverUmfpack.hpp endif + + +if DUNE_ISTL +libopmcore_la_SOURCES += \ +opm/core/linalg/LinearSolverIstl.cpp + +nobase_include_HEADERS += \ +opm/core/linalg/LinearSolverIstl.hpp +endif diff --git a/configure.ac b/configure.ac index 965f607f..afc56de5 100644 --- a/configure.ac +++ b/configure.ac @@ -40,6 +40,8 @@ AX_BOOST_DATE_TIME AX_BOOST_FILESYSTEM AX_BOOST_UNIT_TEST_FRAMEWORK +AX_DUNE_ISTL + # Checks for header files. AC_CHECK_HEADERS([float.h limits.h stddef.h stdlib.h string.h]) diff --git a/m4/ax_dune_common.m4 b/m4/ax_dune_common.m4 new file mode 100644 index 00000000..611ddfbc --- /dev/null +++ b/m4/ax_dune_common.m4 @@ -0,0 +1,37 @@ +AC_DEFUN([AX_DUNE_COMMON], +[ + AC_MSG_CHECKING(for installed dune-common headers) + + AC_LANG_PUSH([C++])[]dnl + + AC_LINK_IFELSE(dnl + [AC_LANG_PROGRAM( + [[#include + #include + ]],dnl + [[Dune::FieldVector v; + Dune::FieldMatrix m; + m[0][0] = 1.0; + v[0] = 1.0; + Dune::FieldVector w = m*v; + ]])[]dnl + ],dnl + [ax_cv_dune_common_available=yes],dnl + [ax_cv_dune_common_available=no]dnl + ) + + AC_LANG_POP([C++])[]dnl + +AS_IF([test "x$ax_cv_dune_common_available" = "xyes"],dnl + [AC_DEFINE([HAVE_DUNE_COMMON], [1],dnl + [Define to 1 if `dune-common' is available])[]dnl + AC_MSG_RESULT(yes) + LIBS="-ldunecommon $LIBS" + ],dnl + [AC_MSG_RESULT(no) + ])[]dnl + + AM_CONDITIONAL([DUNE_COMMON], + [test "x$ax_cv_dune_common_available" = "xyes"]) + +]) diff --git a/m4/ax_dune_istl.m4 b/m4/ax_dune_istl.m4 new file mode 100644 index 00000000..32c9f149 --- /dev/null +++ b/m4/ax_dune_istl.m4 @@ -0,0 +1,38 @@ +AC_DEFUN([AX_DUNE_ISTL], +[ + AX_DUNE_COMMON + + AC_MSG_CHECKING(for installed dune-istl headers) + + AC_LANG_PUSH([C++])[]dnl + + AC_LINK_IFELSE(dnl + [AC_LANG_PROGRAM( + [[#include + #include + #include + ]],dnl + [[typedef Dune::BCRSMatrix > Matrix; + Matrix matrix( 3, 3, Matrix::random ); + for (int i = 0; i < 3; ++i) matrix.setrowsize(i, 2); + matrix.endrowsizes(); + ]])[]dnl + ],dnl + [ax_cv_dune_istl_available=yes],dnl + [ax_cv_dune_istl_available=no]dnl + ) + + AC_LANG_POP([C++])[]dnl + +AS_IF([test "x$ax_cv_dune_istl_available" = "xyes" -a "x$ax_cv_dune_common_available"],dnl + [AC_DEFINE([HAVE_DUNE_ISTL], [1],dnl + [Define to 1 if `dune-istl' is available])[]dnl + AC_MSG_RESULT(yes) + ],dnl + [AC_MSG_RESULT(no) + ])[]dnl + + AM_CONDITIONAL([DUNE_ISTL], + [test "x$ax_cv_dune_istl_available" = "xyes" -a "x$ax_cv_dune_common_available"]) + +]) From 477cc66a84df182d41d728ca4651928cb66f48c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Fri, 13 Apr 2012 15:37:11 +0200 Subject: [PATCH 2/4] Work around mismatch between our HAVE_BOOST and what dune-istl expects. In our config.h, HAVE_BOOST is defined (empty). In dune-istl it is expected to be defined to 0 or 1. --- opm/core/linalg/LinearSolverIstl.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/opm/core/linalg/LinearSolverIstl.cpp b/opm/core/linalg/LinearSolverIstl.cpp index 969d83c7..33f06b19 100644 --- a/opm/core/linalg/LinearSolverIstl.cpp +++ b/opm/core/linalg/LinearSolverIstl.cpp @@ -24,9 +24,13 @@ #include +// Work around the fact that istl headers expect +// HAVE_BOOST to be 1, and not just defined. +#undef HAVE_BOOST +#define HAVE_BOOST 1 // TODO: clean up includes. -#define DUNE_DEPRECATED +#include #include #include #include From df5043b2648e6484f032a3c42e159aacc5a8bb43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Fri, 13 Apr 2012 15:45:48 +0200 Subject: [PATCH 3/4] Use AC_REQUIRE for call to AX_DUNE_COMMON. --- m4/ax_dune_istl.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/m4/ax_dune_istl.m4 b/m4/ax_dune_istl.m4 index 32c9f149..c6226bbc 100644 --- a/m4/ax_dune_istl.m4 +++ b/m4/ax_dune_istl.m4 @@ -1,6 +1,6 @@ AC_DEFUN([AX_DUNE_ISTL], [ - AX_DUNE_COMMON + AC_REQUIRE([AX_DUNE_COMMON]) AC_MSG_CHECKING(for installed dune-istl headers) From 32ecba7717a06820c1a4ee3af14e50c58fb3ab22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Fri, 13 Apr 2012 15:46:15 +0200 Subject: [PATCH 4/4] Use C comments in C code. --- opm/core/utility/newwells.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opm/core/utility/newwells.c b/opm/core/utility/newwells.c index aed506b9..bac7cc25 100644 --- a/opm/core/utility/newwells.c +++ b/opm/core/utility/newwells.c @@ -408,7 +408,7 @@ well_controls_append(enum control_type type , ctrl->num += 1; - // TODO: Review this: + /* TODO: Review this: */ ctrl->current = 0; }