From 3da361f88e3e9ddd997d393ea1aa912f516298cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Fri, 29 Jun 2012 14:52:21 +0200 Subject: [PATCH 01/25] Document interface of hybsys_well_schur_comp_symm() --- opm/core/pressure/mimetic/hybsys.h | 33 ++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/opm/core/pressure/mimetic/hybsys.h b/opm/core/pressure/mimetic/hybsys.h index 2fd77a96..34b534e5 100644 --- a/opm/core/pressure/mimetic/hybsys.h +++ b/opm/core/pressure/mimetic/hybsys.h @@ -358,6 +358,39 @@ hybsys_schur_comp_gen(int nc, const int *pconn, const double *Binv, const double *C2, const double *P, struct hybsys *sys); +/** + * Compute elemental contributions to global, symmetric system of + * simultaneous linear equations from cell<->well connections. + * + * Specifically, for a well @c w intersecting a cell @c c, this function + * computes the elemental contributions + * \f[ + * (F_1)_{wc} = C_{wc}^\mathsf{T} B_{wc}^{-1} D_{wc} = \mathit{WI}_{wc} + * \f] + * and + * \f[ + * L_{wc} = C_{wc}^\mathsf{T} B_{wc}^{-1} C_{wc} = \mathit{WI}_{wc} + * \f] + * and incorporates the contributions into the global system quantities + * as appropriate. + * + * This function modifies sys->L and wsys->F1. + * + * @param[in] nc Total number of grid cells. + * @param[in] cwpos Indirection array that defines each cell's + * connecting wells. Values typically computed + * using function derive_cell_wells(). + * @param[in] WI Peaceman well connection indices. Array of + * size cwpos[nc]. Must incorporate + * effects of multiple phases (i.e., total mobility) + * if applicable. + * @param[in,out] sys Hybrid system management structure allocated + * using hybsys_allocate_symm() and initialised + * using hybsys_init() and/or filled using function + * hybsys_schur_comp_symm(). + * @param[in,out] wsys Hybrid well-system management structure obtained + * from function hybsys_well_allocate_symm(). + */ void hybsys_well_schur_comp_symm(int nc, const int *cwpos, double *WI, From 70e763c8bdd93d3a69f84a04a765f24447a4c9c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Fri, 29 Jun 2012 19:27:35 +0200 Subject: [PATCH 02/25] Document hybsys_cellcontrib_symm() public interface. --- opm/core/pressure/mimetic/hybsys.h | 33 ++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/opm/core/pressure/mimetic/hybsys.h b/opm/core/pressure/mimetic/hybsys.h index 34b534e5..44a7e7ce 100644 --- a/opm/core/pressure/mimetic/hybsys.h +++ b/opm/core/pressure/mimetic/hybsys.h @@ -397,6 +397,39 @@ hybsys_well_schur_comp_symm(int nc, const int *cwpos, struct hybsys *sys, struct hybsys_well *wsys); +/** + * Compute final (symmetric) Schur complement contributions to + * global system of simultaneous linear equations. + * + * This function forms the coefficient matrix + * \f[ + * S_c = D^\mathsf{T}B_c^{-1}D - F_c^\mathsf{T}L_c^{-1}F_c + * \f] + * and similar right-hand side \f$r_c\f$ elemental contributions. + * These values must be subsequently assembled into the global system + * using function hybsys_global_assemble_cell() after imposing any + * applicable boundary conditions. + * + * This function overwrites the fields @c S and @c r of the hybrid system + * structure. + * + * @param[in] c Cell for which to compute local contributions. + * @param[in] nconn Number of connections (faces) of cell @c c. + * @param[in] p1 Start address (into @c gpress) of the gravity + * contributions of cell @c c. + * @param[in] p2 Start address (into @c Binv) of the inverse + * inner product of cell @c c. + * @param[in] gpress Gravity contributions of all cells. Must + * include effects of multiple phases if applicable. + * @param[in] src Explicit source terms for all cells. + * @param[in] Binv Inverse inner products for all cells. Must + * include effects of multiple phases if applicable. + * @param[in,out] sys Hybrid system management structure allocated + * using hybsys_allocate_symm() and initialised + * using hybsys_init() and/or filled using function + * hybsys_schur_comp_symm() and + * hybsys_well_schur_comp_symm() if applicable. + */ void hybsys_cellcontrib_symm(int c, int nconn, int p1, int p2, const double *gpress, const double *src, From d7cfab5ee094508ce680f0ad16a3e52884b8c56e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Wed, 27 Jun 2012 22:01:09 +0200 Subject: [PATCH 03/25] Reference variables using ${...} syntax. --- m4/opm_dynlink_boost_test.m4 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/m4/opm_dynlink_boost_test.m4 b/m4/opm_dynlink_boost_test.m4 index 89c82908..0602d8fe 100644 --- a/m4/opm_dynlink_boost_test.m4 +++ b/m4/opm_dynlink_boost_test.m4 @@ -41,8 +41,8 @@ AC_DEFUN([OPM_DYNLINK_BOOST_TEST], AC_REQUIRE([AX_BOOST_BASE]) AC_REQUIRE([AX_BOOST_UNIT_TEST_FRAMEWORK]) -_opm_LIBS_SAVE="$LIBS" -_opm_CPPFLAGS_SAVE="$CPPFLAGS" +_opm_LIBS_SAVE="${LIBS}" +_opm_CPPFLAGS_SAVE="${CPPFLAGS}" LIBS="${BOOST_LDFLAGS} ${BOOST_UNIT_TEST_FRAMEWORK_LIB} ${LIBS}" CPPFLAGS="${BOOST_CPPFLAGS} ${CPPFLAGS}" @@ -66,12 +66,12 @@ AC_CACHE_CHECK([if the Boost.Test library can be linked dynamically],dnl AC_LANG_POP([C++]) -LIBS="$_opm_LIBS_SAVE" -CPPFLAGS="$_opm_CPPFLAGS_SAVE" +LIBS="${_opm_LIBS_SAVE}" +CPPFLAGS="${_opm_CPPFLAGS_SAVE}" -AS_IF([test x"$opm_cv_boost_link_static" = x"yes" -o \ - x"$opm_cv_boost_link_dynamic" = x"yes"], -[AS_IF([test x"$opm_cv_boost_link_dynamic" = x"yes"], +AS_IF([test x"${opm_cv_boost_link_static}" = x"yes" -o \ + x"${opm_cv_boost_link_dynamic}" = x"yes"], +[AS_IF([test x"${opm_cv_boost_link_dynamic}" = x"yes"], [AC_DEFINE([HAVE_DYNAMIC_BOOST_TEST], [1], [Define to `1' if Boost.Test should use BOOST_TEST_DYN_LINK])] [:])[]dnl From fed0117242c9a4776e09048dc4d0f3c07102a41b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Fri, 29 Jun 2012 23:13:18 +0200 Subject: [PATCH 04/25] Document public interface of hybsys_cellcontrib_unsymm(). --- opm/core/pressure/mimetic/hybsys.h | 33 ++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/opm/core/pressure/mimetic/hybsys.h b/opm/core/pressure/mimetic/hybsys.h index 44a7e7ce..3cb0bec5 100644 --- a/opm/core/pressure/mimetic/hybsys.h +++ b/opm/core/pressure/mimetic/hybsys.h @@ -435,6 +435,39 @@ hybsys_cellcontrib_symm(int c, int nconn, int p1, int p2, const double *gpress, const double *src, const double *Binv, struct hybsys *sys); + +/** + * Compute final (non-symmetric) Schur complement contributions to + * global system of simultaneous linear equations. + * + * This function forms the coefficient matrix + * \f[ + * S_c = D^\mathsf{T}B_c^{-1}D - (F_1)_c^\mathsf{T}L_c^{-1}(F_2)_c + * \f] + * and similar right-hand side \f$r_c\f$ elemental contributions. + * These values must be subsequently assembled into the global system + * using function hybsys_global_assemble_cell() after imposing any + * applicable boundary conditions. + * + * This function overwrites the fields @c S and @c r of the hybrid system + * structure. + * + * @param[in] c Cell for which to compute local contributions. + * @param[in] nconn Number of connections (faces) of cell @c c. + * @param[in] p1 Start address (into @c gpress) of the gravity + * contributions of cell @c c. + * @param[in] p2 Start address (into @c Binv) of the inverse + * inner product of cell @c c. + * @param[in] gpress Gravity contributions of all cells. Must + * include effects of multiple phases if applicable. + * @param[in] src Explicit source terms for all cells. + * @param[in] Binv Inverse inner products for all cells. Must + * include effects of multiple phases if applicable. + * @param[in,out] sys Hybrid system management structure allocated + * using hybsys_allocate_symm() and initialised + * using hybsys_init() and/or filled using functions + * hybsys_schur_comp_unsymm() or hybsys_schur_comp_gen(). + */ void hybsys_cellcontrib_unsymm(int c, int nconn, int p1, int p2, const double *gpress, const double *src, From fae98697a6fbbcbcb92eaefd26ad21b750a44871 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Fri, 29 Jun 2012 23:44:40 +0200 Subject: [PATCH 05/25] Document public interface hybsys_compute_press_flux(). Likely to be refined at a later stage. --- opm/core/pressure/mimetic/hybsys.h | 40 ++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/opm/core/pressure/mimetic/hybsys.h b/opm/core/pressure/mimetic/hybsys.h index 3cb0bec5..392da62b 100644 --- a/opm/core/pressure/mimetic/hybsys.h +++ b/opm/core/pressure/mimetic/hybsys.h @@ -479,6 +479,46 @@ hybsys_well_cellcontrib_symm(int c, int ngconn, int p1, const double *WI, const double *wdp, struct hybsys *sys, struct hybsys_well *wsys); + +/** + * Recover cell pressures and outward fluxes (with respect to cells--i.e., the + * ``half-face fluxes'') through back substitution after solving a symmetric + * (i.e., incompressible) Schur complement system of simultaneous linear + * equations. + * + * Specifically, given the solution \f$\pi\f$ to the global system of + * simultaneous linear equations, \f$A\pi=b\f$, that arises as a result of the + * Schur complement analysis, this function recovers the cell pressures \f$p\f$ + * and outward fluxes \f$v\f$ defined by + * \f[ + * \begin{aligned} + * Lp &= g - C_2^\mathsf{T}B^{-1}G + F_2\pi \\ + * Bv &= G + C_1p - D\pi + * \end{aligned}. + * \f] + * + * @param[in] nc Total number of grid cells. + * @param[in] pconn Cell-to-face start pointers. + * @param[in] conn Cell-to-face mapping. + * @param[in] gpress Gravity contributions of all cells. Must coincide with + * equally named parameter in calls to cell contribution + * functions such as hybsys_cellcontrib_symm(). + * @param[in] Binv Inverse inner products for all cells. Must coincide + * with equally named parameter in calls to contribution + * functions such as hybsys_cellcontrib_symm(). + * @param[in] sys Hybrid system management structure coinciding with + * equally named parameter in contribution functions such + * as hybsys_cellcontrib_symm() or + * hybsys_cellcontrib_unsymm(). + * @param[in] pi Solution (interface/contact pressure) obtained from + * solving the global system \f$A\pi = b\f$. + * @param[out] press Cell pressures, \f$p\f$. Array of size @c nc. + * @param[out] flux Outward interface fluxes, \f$v\f$. Array of size + * pconn[nc]. + * @param[in,out] work Scratch array for temporary results. Array of size at + * least \f$\max_c \{ \mathit{pconn}_{c + 1} + * - \mathit{pconn}_c \} \f$. + */ void hybsys_compute_press_flux(int nc, const int *pconn, const int *conn, const double *gpress, From c40ddf42d0bfaf8dde163d5bd1f38d675c47af10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Sat, 30 Jun 2012 00:21:43 +0200 Subject: [PATCH 06/25] Document public interface hybsys_compute_press_flux_well(). Refinements are likely. --- opm/core/pressure/mimetic/hybsys.h | 46 ++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/opm/core/pressure/mimetic/hybsys.h b/opm/core/pressure/mimetic/hybsys.h index 392da62b..c28a749b 100644 --- a/opm/core/pressure/mimetic/hybsys.h +++ b/opm/core/pressure/mimetic/hybsys.h @@ -526,6 +526,52 @@ hybsys_compute_press_flux(int nc, const int *pconn, const int *conn, const double *pi, double *press, double *flux, double *work); + +/** + * Recover well pressures (i.e., bottom-hole pressure values) and well + * connection (perforation) fluxes. + * + * Specifically, this function performs the same role (i.e., back-substitution) + * for wells as function hybsys_compute_press_flux() does for grid cells and + * grid contacts (interfaces). + * + * @param[in] nc Total number of grid cells. + * @param[in] pgconn Cell-to-face start pointers. + * @param[in] nf Total number of grid faces. + * @param[in] nw Total number of wells. + * @param[in] pwconn Cell-to-well start pointers. If nw > 0, + * then this parameter must coincide with the @c cwpos + * array used in call to hybsys_well_schur_comp_symm(). + * @param[in] wconn Cell-to-well mapping. + * @param[in] Binv Inverse inner products for all cells. Must coincide + * with equally named parameter in calls to contribution + * functions such as hybsys_well_cellcontrib_symm(). + * @param[in] WI Peaceman well connection indices. Array of + * size pwconn[nc]. Must coincide with + * equally named parameter of contribution function + * hybsys_well_cellcontrib_symm(). + * @param[in] wdp Well connection gravity pressure adjustments. + * @param[in] sys Hybrid system management structure coinciding with + * equally named parameter in contribution functions such + * as hybsys_cellcontrib_symm() and + * hybsys_well_cellcontrib_symm(). + * @param[in] wsys Hybrid well-system management structure. Must coincide + * with equally named paramter of contribution function + * hybsys_well_cellcontrib_symm(). + * @param[in] pi Solution (interface/contact pressure and well BHPs) + * obtained from solving the global system \f$A\pi = b\f$. + * @param[in] cpress Cell pressures, \f$p\f$, obtained from a previous call + * to function hybsys_compute_press_flux(). + * @param[in] cflux Outward fluxes, \f$v\f$, obtained from a previous call + * to function hybsys_compute_press_flux(). + * @param[out] wpress Well (i.e., bottom-hole) pressures. Array of size + * @c nw. + * @param[out] wflux Well connection (perforation) fluxes. Array of size + * pwconn[nw]. + * @param[in,out] work Scratch array for storing intermediate results. Array + * of size at least \f$\max_w \{ \mathit{pwconn}_{w + 1} + * - \mathit{pwconn}_w\}\f$. + */ void hybsys_compute_press_flux_well(int nc, const int *pgconn, int nf, int nw, const int *pwconn, const int *wconn, From be54b53cb52aed5c3ecd3dbc608da6b8794aaf65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Sun, 1 Jul 2012 00:20:06 +0200 Subject: [PATCH 07/25] Add stub documentation for hybsys_well_cellcontrib_symm(). Expansion and refinement needed. --- opm/core/pressure/mimetic/hybsys.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/opm/core/pressure/mimetic/hybsys.h b/opm/core/pressure/mimetic/hybsys.h index c28a749b..12ace45e 100644 --- a/opm/core/pressure/mimetic/hybsys.h +++ b/opm/core/pressure/mimetic/hybsys.h @@ -473,6 +473,32 @@ hybsys_cellcontrib_unsymm(int c, int nconn, int p1, int p2, const double *gpress, const double *src, const double *Binv, struct hybsys *sys); + +/** + * Form elemental direct contributions to global system of simultaneous linear + * equations from cell<->well interactions. + * + * Plays a role similar to function hybsys_cellcontrib_symm(), but for wells. + * + * @param[in] c Cell for which to compute cell<->well Schur complement + * @param[in] ngconn Number of inter-cell connections (faces) of cell @c c. + * @param[in] p1 Start index (into sys->F1) of cell @c c. + * @param[in] cwpos Indirection array that defines each cell's connecting + * wells. Must coincide with equally named parameter of + * function hybsys_well_schur_comp_symm(). + * @param[in] WI Peaceman well connection indices. Array of + * size pwconn[nc]. Must coincide with + * equally named parameter of contribution function + * hybsys_well_schur_comp_symm(). + * @param[in] wdp Well connection gravity pressure adjustments. + * One scalar for each well connection in an array of size + * pwconn[nc]. + * @param[in,out] sys Hybrid system management structure filled using + * functions hybsys_schur_comp_unsymm() or + * hybsys_schur_comp_gen(). + * @param[in,out] wsys Hybrid well-system management structure filled using + * function hybsys_well_schur_comp_symm(). + */ void hybsys_well_cellcontrib_symm(int c, int ngconn, int p1, const int *cwpos, From 8947ef569f11762533ab25de5f33b25a7fe26c72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Mon, 2 Jul 2012 12:55:28 +0200 Subject: [PATCH 08/25] Mark return values as \return rather than \ret. Needed for Doxygen compliance. --- opm/core/utility/StopWatch.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opm/core/utility/StopWatch.hpp b/opm/core/utility/StopWatch.hpp index ee996d40..ec631670 100644 --- a/opm/core/utility/StopWatch.hpp +++ b/opm/core/utility/StopWatch.hpp @@ -57,11 +57,11 @@ namespace Opm /// restarted by a call to start(). void stop(); - /// \ret the number of running seconds that have passed + /// \return the number of running seconds that have passed /// since last call to start(), secsSinceLast() or /// secsSinceStart() double secsSinceLast(); - /// \ret the number of running seconds that have passed + /// \return the number of running seconds that have passed /// since last call to start(). double secsSinceStart(); From cda6c937244befb39545d44a0cab59f683e9d1de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Mon, 2 Jul 2012 14:13:42 +0200 Subject: [PATCH 09/25] Initialise all members in constructor. --- opm/core/transport/ImplicitAssembly.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/opm/core/transport/ImplicitAssembly.hpp b/opm/core/transport/ImplicitAssembly.hpp index 88f7ac11..20958071 100644 --- a/opm/core/transport/ImplicitAssembly.hpp +++ b/opm/core/transport/ImplicitAssembly.hpp @@ -47,7 +47,9 @@ namespace Opm { public: ImplicitAssembly(Model& model) - : model_(model) + : model_(model), + nconn_(-1) , + asm_buffer_() {} template Date: Mon, 2 Jul 2012 14:58:59 +0200 Subject: [PATCH 10/25] Doxygenise class spu_2p::ModelParameterStorage Mostly stub comments. --- .../transport/SinglePointUpwindTwoPhase.hpp | 175 +++++++++++++++++- 1 file changed, 166 insertions(+), 9 deletions(-) diff --git a/opm/core/transport/SinglePointUpwindTwoPhase.hpp b/opm/core/transport/SinglePointUpwindTwoPhase.hpp index 11afecdc..83261d48 100644 --- a/opm/core/transport/SinglePointUpwindTwoPhase.hpp +++ b/opm/core/transport/SinglePointUpwindTwoPhase.hpp @@ -33,6 +33,12 @@ along with OPM. If not, see . */ +/** + * \file + * Numerical model and support classes needed to model transport of two + * incompressible fluid phases. Intended for the ImplicitTransport system. + */ + #ifndef OPM_SINGLEPOINTUPWINDTWOPHASE_HPP_HEADER #define OPM_SINGLEPOINTUPWINDTWOPHASE_HPP_HEADER @@ -45,8 +51,43 @@ namespace Opm { namespace spu_2p { + /** + * Internal class to manage the direct and derived quantities needed to + * formulate the fluid transport system. + * + * Note: This class elides off-diagonal elements of the phase mobility + * Jacobian, \f$(\partial_{s_\beta} \lambda_\alpha)_{\alpha\beta}\f$. + * These elements are assumed to be strictly equal to zero. In other + * words, the relative permeability of phase \f$\alpha\f$ is assumed to + * depend only on the saturation of phase \f$\alpha\f$. This convention + * allows storing only the two diagonals of the mobility Jacobian per + * grid cell. + * + * The static gravity term is the scalar value + * \f[ + * \Delta G_i = \mathsf{T}_f\, \vec{g}\cdot(\Bar{x}_f - \Bar{x}_c) + * \f] + * in which @c i is the half face index corresponding to the cell-face + * pair (f,c) and \f$\mathsf{T}_f\f$ is the absolute + * (bacground) two-point transmissibility of face @c f. + * + * The fluid transport problem is formulated in terms of saturation + * changes, \f$\Delta s\f$, per cell. These changes are the primary + * degrees of freedom in this model. + * + * Capillary pressures are defined by the fluid model, but usually + * correspond to \f$p_w - p_n\f$ (e.g., \f$p_\mathit{oil} - + * p_\mathit{water}\f$). + */ class ModelParameterStorage { public: + /** + * Constructor. + * + * @param[in] nc Total number of grid cells. + * @param[in] totconn Total number of connections, accumulated per + * cell (``half faces''). + */ ModelParameterStorage(int nc, int totconn) : drho_(0.0), mob_(0), dmob_(0), porevol_(0), dg_(0), ds_(0), pc_(0), dpc_(0), trans_(0), @@ -74,44 +115,160 @@ namespace Opm { trans_ = dpc_ + (1 * nc ); } + /** + * Modifiable density difference. + * @return Reference to modifiable internal representation of fluid + * phase density difference. + */ double& drho () { return drho_ ; } + /** + * Read-only density difference. + * @return Read-only value of current fluid phase difference value. + */ double drho () const { return drho_ ; } + /** + * Phase mobility in cell. + * @param[in] c Cell. + * @return Read-write reference to two consecutive phase mobilities + * in cell @c c. + */ double* mob (int c) { return mob_ + (2*c + 0); } + /** + * Phase mobility in cell. + * @param[in] c Cell. + * @return Read-only reference to two consecutive phase mobilities + * in cell @c c. + */ const double* mob (int c) const { return mob_ + (2*c + 0); } + /** + * Diagonal elements of phase mobility derivative (Jacobian). + * + * @param[in] c Cell. + * @return Read-write reference to diagonal elements of phase + * mobility Jacobian in cell @c c. + */ double* dmob (int c) { return dmob_ + (2*c + 0); } + /** + * Diagonal elements of phase mobility derivative (Jacobian). + * + * @param[in] c Cell. + * @return Read-only reference to two consecutive diagonal elements + * of phase mobility Jacobian in cell @c c. + */ const double* dmob (int c) const { return dmob_ + (2*c + 0); } + /** + * Retrieve pore volumes for all cells. + * @return Modifiable vector of pore volumes for all cells. + */ double* porevol() { return porevol_ ; } + /** + * Pore volume of single cell. + * @param[in] c Cell. + * @return Pore volume of cell @c c. + */ double porevol(int c) const { return porevol_[c] ; } + /** + * Static gravity term associated to single half face. + * + * @param[in] i Half face index corresponding to particular + * cell-face pair. + * @return Read-write reference to static gravity term of single + * half face. + */ double& dg(int i) { return dg_[i] ; } + /** + * Static gravity term associated to single half face. + * @param[in] i Half face index corresponding to particular + * cell-face pair. + * @return Read-only reference to static gravity term of single half + * face. + */ double dg(int i) const { return dg_[i] ; } + /** + * Saturation change in particular cell. + * + * @param[in] c + * @return Read-write reference to saturation change (scalar) in + * cell @c c. + */ double& ds(int c) { return ds_[c] ; } + /** + * Saturation change in particular cell. + * + * @param[in] c + * @return Read-only reference to saturation change (scalar) in cell + * @c c. + */ double ds(int c) const { return ds_[c] ; } + /** + * Capillary pressure in particular cell. + * + * @param[in] c Cell. + * @return Read-write reference to capillary pressure in cell @c c. + */ double& pc(int c) { return pc_[c] ; } + /** + * Capillary pressure in particular cell. + * + * @param[in] c Cell + * @return Read-only reference to capillary pressure in cell @c c. + */ double pc(int c) const { return pc_[c] ; } + /** + * Derivative of capillary pressure with respect to saturation. + * + * @param[in] c Cell + * @return Read-write reference to capillary pressure derivative + * with respect to primary saturation in cell @c c. + */ double& dpc(int c) { return dpc_[c] ; } + /** + * Derivative of capillary pressure with respect to saturation. + * + * @param[in] c Cell + * @return Read-only reference to capillary pressure derivative with + * respect to primary saturation in cell @c c. + */ double dpc(int c) const { return dpc_[c] ; } + /** + * Background (absolute) face transmissibility of particular face. + * + * @param[in] f Face + * @return Read-write reference to background face transmissibility + * of face @c f. + */ double& trans(int f) { return trans_[f] ; } + /** + * Background (absolute) face transmissibility of particular face. + * + * @param[in] f Face + * @return Read-only reference to bacground face transmissibility of + * face @c f. + */ double trans(int f) const { return trans_[f] ; } private: - double drho_ ; - double *mob_ ; - double *dmob_ ; - double *porevol_; - double *dg_ ; - double *ds_ ; - double *pc_ ; - double *dpc_ ; - double *trans_ ; + double drho_ ; /**< Fluid phase density difference */ + double *mob_ ; /**< Fluid phase mobility in all cells */ + double *dmob_ ; /**< Derivative of phase mobility in all cells */ + double *porevol_; /**< Pore volume in all cells */ + double *dg_ ; /**< Static gravity term on all half faces */ + double *ds_ ; /**< Saturation change in all cells */ + double *pc_ ; /**< Capillary pressure in all cells */ + double *dpc_ ; /**< Derivative of cap. pressure in all cells */ + double *trans_ ; /**< Absolute transmissibility on all faces */ + /** + * Data storage from which individual quantities are managed. + */ std::vector data_; }; } From f57ed8856dc490c190a154188a54ecff8c069498 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Mon, 2 Jul 2012 17:22:48 +0200 Subject: [PATCH 11/25] WelSpecsLine: Initialise all members in constructor --- opm/core/eclipse/SpecialEclipseFields.hpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/opm/core/eclipse/SpecialEclipseFields.hpp b/opm/core/eclipse/SpecialEclipseFields.hpp index 7e2fce9a..382fa658 100644 --- a/opm/core/eclipse/SpecialEclipseFields.hpp +++ b/opm/core/eclipse/SpecialEclipseFields.hpp @@ -780,9 +780,11 @@ struct WelspecsLine int fluids_in_place_reg_numb_; // Fluids in place region number WelspecsLine() : - datum_depth_BHP_(-1.0), drain_rad_(0.0), spec_inflow_("STD"), - shut_in_("SHUT"), crossflow_("YES"), pressure_table_number_(0), - density_calc_type_("SEG"), fluids_in_place_reg_numb_(0) + name_(), group_(), I_(-1), J_(-1), + datum_depth_BHP_(-1.0), pref_phase_(), drain_rad_(0.0), + spec_inflow_("STD"), shut_in_("SHUT"), crossflow_("YES"), + pressure_table_number_(0), density_calc_type_("SEG"), + fluids_in_place_reg_numb_(0) {} }; From f2f0b95a1de5e54a8f2038b692b6241dea686a66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Mon, 2 Jul 2012 17:29:59 +0200 Subject: [PATCH 12/25] WgrupconLine: Initialise all members in constructor. --- opm/core/eclipse/SpecialEclipseFields.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opm/core/eclipse/SpecialEclipseFields.hpp b/opm/core/eclipse/SpecialEclipseFields.hpp index 382fa658..4a3ea863 100644 --- a/opm/core/eclipse/SpecialEclipseFields.hpp +++ b/opm/core/eclipse/SpecialEclipseFields.hpp @@ -1362,8 +1362,8 @@ struct WgrupconLine bool available_for_group_control_; double guide_rate_; std::string phase_; - WgrupconLine() : - available_for_group_control_(true) + WgrupconLine() + : well_(), available_for_group_control_(true), guide_rate_(-1.0), phase_() { } }; From 2ef628233ec480b473ba7acf75b9893ae32e520a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Mon, 2 Jul 2012 17:32:37 +0200 Subject: [PATCH 13/25] WeltargLine: Initialise all members in constructor. --- opm/core/eclipse/SpecialEclipseFields.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/opm/core/eclipse/SpecialEclipseFields.hpp b/opm/core/eclipse/SpecialEclipseFields.hpp index 4a3ea863..6e81a5fa 100644 --- a/opm/core/eclipse/SpecialEclipseFields.hpp +++ b/opm/core/eclipse/SpecialEclipseFields.hpp @@ -1582,6 +1582,7 @@ struct WeltargLine double new_value_; // New value of this quantity WeltargLine() + : well_(), control_change_(), new_value_(-1.0) { } }; From 95df9e5e2f948bd9166b8d212df2932626eec5bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Mon, 2 Jul 2012 17:42:10 +0200 Subject: [PATCH 14/25] WpolymerLine: Initialise all members in constructor. --- opm/core/eclipse/SpecialEclipseFields.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/opm/core/eclipse/SpecialEclipseFields.hpp b/opm/core/eclipse/SpecialEclipseFields.hpp index 6e81a5fa..0b92af31 100644 --- a/opm/core/eclipse/SpecialEclipseFields.hpp +++ b/opm/core/eclipse/SpecialEclipseFields.hpp @@ -2131,7 +2131,8 @@ struct WpolymerLine WpolymerLine() { - well_ = polymer_group_ = salt_group_ = ""; + well_ = polymer_group_ = salt_group_ = ""; + polymer_concentration_ = salt_concentration_ = 0.0; } }; From 4ffd9198bfc1eb2f4e00035f389a463397ee75e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Mon, 2 Jul 2012 17:44:16 +0200 Subject: [PATCH 15/25] Initialise all members in default constructor. --- opm/core/fluid/SaturationPropsBasic.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/opm/core/fluid/SaturationPropsBasic.cpp b/opm/core/fluid/SaturationPropsBasic.cpp index 4f20bd1b..8249a31f 100644 --- a/opm/core/fluid/SaturationPropsBasic.cpp +++ b/opm/core/fluid/SaturationPropsBasic.cpp @@ -99,6 +99,7 @@ namespace Opm /// Default constructor. SaturationPropsBasic::SaturationPropsBasic() + : num_phases_(0), relperm_func_(Constant) { } From 4c36b397fd351097f99347e7462e2011eae79976 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Mon, 2 Jul 2012 18:30:56 +0200 Subject: [PATCH 16/25] EquilLine: Initialise all members in default constructor. --- opm/core/eclipse/SpecialEclipseFields.hpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/opm/core/eclipse/SpecialEclipseFields.hpp b/opm/core/eclipse/SpecialEclipseFields.hpp index 0b92af31..a8a1ba11 100644 --- a/opm/core/eclipse/SpecialEclipseFields.hpp +++ b/opm/core/eclipse/SpecialEclipseFields.hpp @@ -1742,6 +1742,13 @@ struct EquilLine // initial fluids in place calculation. EquilLine() { + datum_depth_ = datum_depth_pressure_ = 0.0; + water_oil_contact_depth_ = oil_water_cap_pressure_ = 0.0; + gas_oil_contact_depth_ = gas_oil_cap_pressure_ = 0.0; + + live_oil_table_index_ = 0; + wet_gas_table_index_ = 0; + N_ = 0; } }; From 02e715fe14ddb448f38598d7623794a0a3932347 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Mon, 2 Jul 2012 19:09:58 +0200 Subject: [PATCH 17/25] makefhfQPeriodic(): Use less branch'y implementation. --- .../transport/SinglePointUpwindTwoPhase.hpp | 62 +++++++++---------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/opm/core/transport/SinglePointUpwindTwoPhase.hpp b/opm/core/transport/SinglePointUpwindTwoPhase.hpp index 83261d48..87ea6c2f 100644 --- a/opm/core/transport/SinglePointUpwindTwoPhase.hpp +++ b/opm/core/transport/SinglePointUpwindTwoPhase.hpp @@ -306,42 +306,42 @@ namespace Opm { std::copy(porevol.begin(), porevol.end(), store_.porevol()); } - void makefhfQPeriodic( const std::vector& p_faces,const std::vector& hf_faces, - const std::vector& nb_faces) + + void + makefhfQPeriodic(const std::vector& p_faces , + const std::vector& hf_faces, + const std::vector& nb_faces) { + assert (! p_faces.empty()); + assert (p_faces.size() == hf_faces.size()); + assert (hf_faces.size() == nb_faces.size()); + std::vector nbhf(hf_faces.size()); - for(unsigned int i=0; i::size_type i = 0; i < p_faces.size(); ++i) { + const int nbf = nb_faces[i]; + + assert (2*std::vector::size_type(nbf) + 1 < f2hf_.size()); + assert ((f2hf_[2*nbf + 0] < 0) ^ (f2hf_[2*nbf + 1] < 0)); + + const int p = (f2hf_[2*nbf + 0] < 0) ? 1 : 0; // "Self" + nbhf[ i ] = f2hf_[2*nbf + p]; } - for(unsigned int i=0; i::size_type i = 0; i < p_faces.size(); ++i) { + const int f = p_faces [i]; + const int hf = hf_faces[i]; - if(f2hf_[2*f] == hf){ - assert(f2hf_[2*f+1]==-1); - }else{ - assert(f2hf_[2*f]==-1); - f2hf_[2*f]=nbhf[i]; - changed=true; - } - if(!changed){ - if(f2hf_[2*f+1]== hf){ - assert(f2hf_[2*f]==-1); - }else{ - assert(f2hf_[2*f+1]==-1); - f2hf_[2*f+1]=nbhf[i]; - changed=true; - } - } - assert(changed); + assert (0 <= f); + assert (0 <= hf); + assert (2*std::vector::size_type(f) + 1 < f2hf_.size()); + + assert ((f2hf_[2*f + 0] < 0 ) ^ (f2hf_[2*f + 1] < 0 )); + assert ((f2hf_[2*f + 0] == hf) ^ (f2hf_[2*f + 1] == hf)); + + const int p = (f2hf_[2*f + 0] == hf) ? 1 : 0; // "Other" + + f2hf_[2*f + p] = nbhf[ i ]; } } From 8e436e174aa292009001fe7f0ef2e230954f6597 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Mon, 2 Jul 2012 22:29:47 +0200 Subject: [PATCH 18/25] Include missing headers. --- opm/core/pressure/TPFAPressureSolver.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/opm/core/pressure/TPFAPressureSolver.hpp b/opm/core/pressure/TPFAPressureSolver.hpp index 45a37012..33f7e33a 100644 --- a/opm/core/pressure/TPFAPressureSolver.hpp +++ b/opm/core/pressure/TPFAPressureSolver.hpp @@ -27,8 +27,9 @@ #include #include // for updating gpress #include +#include #include - +#include /// @brief From 1235b8ecbcadc79cea37fb22665af9edfb803889 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Tue, 3 Jul 2012 01:29:34 +0200 Subject: [PATCH 19/25] Document public interface for transmissibility calculation. --- opm/core/pressure/tpfa/trans_tpfa.h | 77 ++++++++++++++++++++++++++--- 1 file changed, 71 insertions(+), 6 deletions(-) diff --git a/opm/core/pressure/tpfa/trans_tpfa.h b/opm/core/pressure/tpfa/trans_tpfa.h index ab3fba76..5da1490f 100644 --- a/opm/core/pressure/tpfa/trans_tpfa.h +++ b/opm/core/pressure/tpfa/trans_tpfa.h @@ -20,23 +20,88 @@ #ifndef OPM_TRANS_TPFA_HEADER_INCLUDED #define OPM_TRANS_TPFA_HEADER_INCLUDED +/** + * \file + * Routines to assist in the calculation of two-point transmissibilities. + */ + #include #ifdef __cplusplus extern "C" { #endif +/** + * Calculate static, one-sided transmissibilities for use in the two-point flux + * approximation method. + * + * The one-sided transmissibilities are defined by the formula + * \f[ + * t_i = \frac{\vec{n}_f \mathsf{K}_c \vec{c}_c}{\lVert \vec{c}_c \rVert^2} + * \f] + * in which @c i is the half-face index corresponding to the cell-face index + * pair (c,f) and \f$\vec{c}_{cf} = \Bar{x}_f - \Bar{x}_c\f$ is the + * centroid difference vector. + * + * @param[in] G Grid. + * @param[in] perm Permeability. One symmetric, positive definite tensor + * per grid cell. + * @param[out] htrans One-sided transmissibilities. Array of size at least + * G->cell_facepos[ G->number_of_cells ]. + */ void -tpfa_htrans_compute(struct UnstructuredGrid *G, const double *perm, double *htrans); +tpfa_htrans_compute(struct UnstructuredGrid *G , + const double *perm , + double *htrans); +/** + * Compute two-point transmissibilities from one-sided transmissibilities. + * + * The two-point transmissibilities are given by the simple, near-harmonic + * average (save a factor of two) + * \f[ + * \mathsf{T}_f = \big(\frac{1}{t_1} + \frac{1}{t_2}\big)^{-1} + * = \frac{t_1t_2}{t_1 + t_2} + * \f] + * in which \f$t_1\f$ and \f$t_2\f$ are the one-sided transmissibilities that + * connect the neighbouring cells of face @c f. + * + * @param[in] G Grid. + * @param[in] htrans One-sided transmissibilities as defined by function + * tpfa_htrans_compute(). + * @param[out] trans Interface, two-point transmissibilities. Array of size + * at least G->number_of_faces. + */ void -tpfa_trans_compute(struct UnstructuredGrid *G, const double *htrans, double *trans); +tpfa_trans_compute(struct UnstructuredGrid *G , + const double *htrans, + double *trans ); +/** + * Calculate effective two-point transmissibilities from one-sided, total + * mobility weighted, transmissibilities. + * + * Specifically, compute the following product + * \f[ + * \mathsf{T}_f = \big(\frac{1}{\lambda_1t_1} + \frac{1}{\lambda_2t_2}\big)^{-1} + * = \lambda_1\lambda_2 \frac{t_1t_2}{t_1 + t_2} + * \f] + * in which \f$t_1\f$ and \f$t_2\f$ are the one-sided, static transmissibility + * values connecting the cells of face @c f and \f$\lambda_1\f$ and + * \f$\lambda_2\f$ denote the total mobilities of the respective cells. + * + * @param[in] G Grid. + * @param[in] totmob Total mobilities. One positive scalar value for each cell. + * @param[in] htrans One-sided transmissibilities as defined by function + * tpfa_htrans_compute(). + * @param[out] trans Effective, two-point transmissibilities. Array of size at + * least G->number_of_faces. + */ void -tpfa_eff_trans_compute(struct UnstructuredGrid *G, - const double *totmob, - const double *htrans, - double *trans); +tpfa_eff_trans_compute(struct UnstructuredGrid *G , + const double *totmob, + const double *htrans, + double *trans ); #ifdef __cplusplus } From c2eaa970492941c9c21bc87928d9a3d9fc8af71c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Tue, 3 Jul 2012 01:30:18 +0200 Subject: [PATCH 20/25] Add partial Doxygen markup to public interfaces. More work needed. --- opm/core/pressure/tpfa/ifs_tpfa.h | 65 ++++++++++++++++++++++++------- 1 file changed, 52 insertions(+), 13 deletions(-) diff --git a/opm/core/pressure/tpfa/ifs_tpfa.h b/opm/core/pressure/tpfa/ifs_tpfa.h index f7ab4230..d7853bef 100644 --- a/opm/core/pressure/tpfa/ifs_tpfa.h +++ b/opm/core/pressure/tpfa/ifs_tpfa.h @@ -20,6 +20,16 @@ #ifndef OPM_IFS_TPFA_HEADER_INCLUDED #define OPM_IFS_TPFA_HEADER_INCLUDED +/** + * \file + * Interfaces and data structures to assemble a system of simultaneous linear + * equations discretising a flow problem that is either incompressible or + * features rock compressibility using the two-point flux approximation method. + * + * Includes support for reconstructing the Darcy flux field as well as well + * connection fluxes. + */ + #include #ifdef __cplusplus @@ -31,37 +41,66 @@ struct CSRMatrix; struct FlowBoundaryConditions; struct Wells; +/** + * Main data structure presenting a view of an assembled system of simultaneous + * linear equations which may be solved using external software. + */ struct ifs_tpfa_data { - struct CSRMatrix *A; - double *b; - double *x; + struct CSRMatrix *A; /**< Coefficient matrix */ + double *b; /**< Right-hand side */ + double *x; /**< Solution */ - struct ifs_tpfa_impl *pimpl; + struct ifs_tpfa_impl *pimpl; /**< Internal management structure */ }; +/** + * Solution variables. + */ struct ifs_tpfa_solution { - double *cell_press; - double *face_flux ; + double *cell_press; /**< Cell pressures */ + double *face_flux ; /**< Interface fluxes */ - double *well_press; /* BHP */ - double *well_flux ; /* Perforation (total) fluxes */ + double *well_press; /**< Bottom-hole pressures for each well */ + double *well_flux ; /**< Well connection total fluxes */ }; +/** + * Driving forces pertaining to a particular model setup. + */ struct ifs_tpfa_forces { - const double *src; - const struct FlowBoundaryConditions *bc ; + const double *src; /**< Explicit source terms */ + const struct FlowBoundaryConditions *bc ; /**< Boundary conditions */ - const struct Wells *W ; - const double *totmob; - const double *wdp ; + const struct Wells *W ; /**< Well topology */ + const double *totmob; /**< Total mobility in each cell */ + const double *wdp ; /**< Gravity adjustment at each perforation */ }; +/** + * Allocate TPFA management structure capable of assembling a system of + * simultaneous linear equations corresponding to a particular grid and well + * configuration. + * + * @param[in] G Grid. + * @param[in] W Well topology. + * @return Fully formed TPFA management structure if successful, @c NULL in case + * of allocation failure. + */ struct ifs_tpfa_data * ifs_tpfa_construct(struct UnstructuredGrid *G, struct Wells *W); +/** + * + * @param[in] G + * @param[in] F + * @param[in] trans + * @param[in] gpress + * @param[in,out] h + * @return + */ int ifs_tpfa_assemble(struct UnstructuredGrid *G , const struct ifs_tpfa_forces *F , From 9005e4353c6b86f15d7f239a1320efd3f2e7c4a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Tue, 3 Jul 2012 16:44:03 +0200 Subject: [PATCH 21/25] Build the library in a lib/ sub-directory of $(builddir) Suggested by: Andreas Lauser --- Makefile.am | 14 +++++++------- examples/Makefile.am | 2 +- tests/Makefile.am | 2 +- tutorials/Makefile.am | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Makefile.am b/Makefile.am index fcc79468..f734f826 100644 --- a/Makefile.am +++ b/Makefile.am @@ -6,7 +6,7 @@ SUBDIRS = . tests examples tutorials # ---------------------------------------------------------------------- # Declare products (i.e., the library) -lib_LTLIBRARIES = libopmcore.la +lib_LTLIBRARIES = lib/libopmcore.la # ---------------------------------------------------------------------- # Build-time flags needed to build libopmcore.la @@ -18,7 +18,7 @@ $(BOOST_CPPFLAGS) # Link-time flags needed both to successfully link the library and to # (transitively) convey inter-library dependency information. -libopmcore_la_LDFLAGS = \ +lib_libopmcore_la_LDFLAGS = \ $(BOOST_LDFLAGS) \ $(BOOST_FILESYSTEM_LIB) \ $(BOOST_SYSTEM_LIB) \ @@ -31,7 +31,7 @@ $(LAPACK_LIBS) $(BLAS_LIBS) $(LIBS) $(FLIBS) # # Please try to keep the list sorted. -libopmcore_la_SOURCES = \ +lib_libopmcore_la_SOURCES = \ opm/core/GridManager.cpp \ opm/core/eclipse/EclipseGridInspector.cpp \ opm/core/eclipse/EclipseGridParser.cpp \ @@ -256,7 +256,7 @@ opm/core/wells/WellsManager.hpp # Optional library constituents. if UMFPACK -libopmcore_la_SOURCES += \ +lib_libopmcore_la_SOURCES += \ opm/core/linalg/call_umfpack.c \ opm/core/linalg/LinearSolverUmfpack.cpp @@ -267,7 +267,7 @@ endif if DUNE_ISTL -libopmcore_la_SOURCES += \ +lib_libopmcore_la_SOURCES += \ opm/core/linalg/LinearSolverIstl.cpp nobase_include_HEADERS += \ @@ -276,7 +276,7 @@ endif if BUILD_AGMG -libopmcore_la_SOURCES += \ +lib_libopmcore_la_SOURCES += \ $(AGMG_SRCDIR)/dagmg.f90 \ $(AGMG_SRCDIR)/dagmg_mumps.f90 \ opm/core/linalg/LinearSolverAGMG.cpp @@ -284,6 +284,6 @@ opm/core/linalg/LinearSolverAGMG.cpp nobase_include_HEADERS += \ opm/core/linalg/LinearSolverAGMG.hpp -libopmcore_la_LDFLAGS += \ +lib_libopmcore_la_LDFLAGS += \ $(FCLIBS) endif diff --git a/examples/Makefile.am b/examples/Makefile.am index 7f165295..79112c30 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -5,7 +5,7 @@ $(BOOST_CPPFLAGS) # All targets link to the library LDADD = \ -$(top_builddir)/libopmcore.la \ +$(top_builddir)/lib/libopmcore.la \ $(BOOST_FILESYSTEM_LIB) \ $(BOOST_SYSTEM_LIB) diff --git a/tests/Makefile.am b/tests/Makefile.am index 03188860..3419da11 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -5,7 +5,7 @@ $(BOOST_CPPFLAGS) LDFLAGS = $(BOOST_LDFLAGS) -LDADD = $(top_builddir)/libopmcore.la +LDADD = $(top_builddir)/lib/libopmcore.la noinst_PROGRAMS = \ diff --git a/tutorials/Makefile.am b/tutorials/Makefile.am index 5d77386b..605c8e06 100644 --- a/tutorials/Makefile.am +++ b/tutorials/Makefile.am @@ -4,7 +4,7 @@ $(BOOST_CPPFLAGS) LDFLAGS = $(BOOST_LDFLAGS) -LDADD = $(top_builddir)/libopmcore.la +LDADD = $(top_builddir)/lib/libopmcore.la noinst_PROGRAMS = tutorial1 tutorial1_SOURCES = tutorial1.cpp From 6672a94fb28372b4c76d8e18032462ebc1ebefcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Tue, 3 Jul 2012 17:45:24 +0200 Subject: [PATCH 22/25] Distinguish distributable from non-distributable sources. We do not want to distribute the AGMG sources along with OPM-Core. These sources must be defined by the builder at configure time. This fixes "make distcheck". --- Makefile.am | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index f734f826..643e4248 100644 --- a/Makefile.am +++ b/Makefile.am @@ -31,6 +31,10 @@ $(LAPACK_LIBS) $(BLAS_LIBS) $(LIBS) $(FLIBS) # # Please try to keep the list sorted. +# List of sources that should be built but not distributed. See AGMG +# support below for additional details. +nodist_lib_libopmcore_la_SOURCES = + lib_libopmcore_la_SOURCES = \ opm/core/GridManager.cpp \ opm/core/eclipse/EclipseGridInspector.cpp \ @@ -276,9 +280,11 @@ endif if BUILD_AGMG -lib_libopmcore_la_SOURCES += \ +nodist_lib_libopmcore_la_SOURCES += \ $(AGMG_SRCDIR)/dagmg.f90 \ -$(AGMG_SRCDIR)/dagmg_mumps.f90 \ +$(AGMG_SRCDIR)/dagmg_mumps.f90 + +lib_libopmcore_la_SOURCES += \ opm/core/linalg/LinearSolverAGMG.cpp nobase_include_HEADERS += \ From 6f69de969a64cad76c51d69726ae2068b461f2fb Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Wed, 27 Jun 2012 11:10:25 +0200 Subject: [PATCH 23/25] opm-core: make it work nicely with clang --- opm/core/eclipse/EclipseGridParser.cpp | 18 +---- opm/core/eclipse/EclipseGridParser.hpp | 76 ++++++++++----------- opm/core/simulator/SimulatorTwophase.cpp | 12 ++-- opm/core/simulator/SimulatorTwophase.hpp | 2 +- opm/core/utility/Factory.hpp | 2 +- opm/core/utility/MonotCubicInterpolator.hpp | 16 ++--- 6 files changed, 56 insertions(+), 70 deletions(-) diff --git a/opm/core/eclipse/EclipseGridParser.cpp b/opm/core/eclipse/EclipseGridParser.cpp index fd5f5ef5..45017a46 100644 --- a/opm/core/eclipse/EclipseGridParser.cpp +++ b/opm/core/eclipse/EclipseGridParser.cpp @@ -191,21 +191,7 @@ namespace { return us; } - inline std::string readKeyword(std::istream& is) - { - std::string keyword_candidate; - while (!is.eof()) { - is >> keyword_candidate; - if(keyword_candidate.find("--") == 0) { - is >> ignoreLine; // This line is a comment - } else { - return upcase(keyword_candidate); - } - } - return "CONTINUE"; // Last line in included file is a comment - } - - inline bool readKeywordNew(std::istream& is, std::string& keyword) + inline bool readKeyword(std::istream& is, std::string& keyword) { char buf[9]; int i, j; @@ -377,7 +363,7 @@ void EclipseGridParser::readImpl(istream& is) std::string keyword; while (is.good()) { is >> ignoreWhitespace; - bool ok = readKeywordNew(is, keyword); + bool ok = readKeyword(is, keyword); if (ok) { //#ifdef VERBOSE cout << "Keyword found: " << keyword << endl; diff --git a/opm/core/eclipse/EclipseGridParser.hpp b/opm/core/eclipse/EclipseGridParser.hpp index 56e9ee4f..9f66e9ae 100644 --- a/opm/core/eclipse/EclipseGridParser.hpp +++ b/opm/core/eclipse/EclipseGridParser.hpp @@ -129,47 +129,47 @@ public: { return dynamic_cast(*getSpecialValue(#keyword)); } // Support for special fields. - SPECIAL_FIELD(SPECGRID); - SPECIAL_FIELD(FAULTS); - SPECIAL_FIELD(MULTFLT); - SPECIAL_FIELD(TITLE); - SPECIAL_FIELD(START); - SPECIAL_FIELD(DATES); - SPECIAL_FIELD(DENSITY); - SPECIAL_FIELD(PVDG); - SPECIAL_FIELD(PVDO); - SPECIAL_FIELD(PVTG); - SPECIAL_FIELD(PVTO); - SPECIAL_FIELD(PVTW); - SPECIAL_FIELD(SGOF); - SPECIAL_FIELD(SWOF); - SPECIAL_FIELD(ROCK); - SPECIAL_FIELD(ROCKTAB); - SPECIAL_FIELD(WELSPECS); - SPECIAL_FIELD(COMPDAT); - SPECIAL_FIELD(WCONINJE); - SPECIAL_FIELD(WCONPROD); - SPECIAL_FIELD(WELTARG); - SPECIAL_FIELD(WELOPEN); - SPECIAL_FIELD(EQUIL); - SPECIAL_FIELD(PVCDO); - SPECIAL_FIELD(TSTEP); - SPECIAL_FIELD(PLYVISC); - SPECIAL_FIELD(PLYROCK); - SPECIAL_FIELD(PLYADS); - SPECIAL_FIELD(PLYMAX); - SPECIAL_FIELD(TLMIXPAR); - SPECIAL_FIELD(WPOLYMER); - SPECIAL_FIELD(GRUPTREE); - SPECIAL_FIELD(GCONINJE); - SPECIAL_FIELD(GCONPROD); - SPECIAL_FIELD(WGRUPCON); + SPECIAL_FIELD(SPECGRID) + SPECIAL_FIELD(FAULTS) + SPECIAL_FIELD(MULTFLT) + SPECIAL_FIELD(TITLE) + SPECIAL_FIELD(START) + SPECIAL_FIELD(DATES) + SPECIAL_FIELD(DENSITY) + SPECIAL_FIELD(PVDG) + SPECIAL_FIELD(PVDO) + SPECIAL_FIELD(PVTG) + SPECIAL_FIELD(PVTO) + SPECIAL_FIELD(PVTW) + SPECIAL_FIELD(SGOF) + SPECIAL_FIELD(SWOF) + SPECIAL_FIELD(ROCK) + SPECIAL_FIELD(ROCKTAB) + SPECIAL_FIELD(WELSPECS) + SPECIAL_FIELD(COMPDAT) + SPECIAL_FIELD(WCONINJE) + SPECIAL_FIELD(WCONPROD) + SPECIAL_FIELD(WELTARG) + SPECIAL_FIELD(WELOPEN) + SPECIAL_FIELD(EQUIL) + SPECIAL_FIELD(PVCDO) + SPECIAL_FIELD(TSTEP) + SPECIAL_FIELD(PLYVISC) + SPECIAL_FIELD(PLYROCK) + SPECIAL_FIELD(PLYADS) + SPECIAL_FIELD(PLYMAX) + SPECIAL_FIELD(TLMIXPAR) + SPECIAL_FIELD(WPOLYMER) + SPECIAL_FIELD(GRUPTREE) + SPECIAL_FIELD(GCONINJE) + SPECIAL_FIELD(GCONPROD) + SPECIAL_FIELD(WGRUPCON) // The following fields only have a dummy implementation // that allows us to ignore them. - SPECIAL_FIELD(SWFN); - SPECIAL_FIELD(SOF2); - SPECIAL_FIELD(TUNING); + SPECIAL_FIELD(SWFN) + SPECIAL_FIELD(SOF2) + SPECIAL_FIELD(TUNING) #undef SPECIAL_FIELD diff --git a/opm/core/simulator/SimulatorTwophase.cpp b/opm/core/simulator/SimulatorTwophase.cpp index 9c1f9023..43913095 100644 --- a/opm/core/simulator/SimulatorTwophase.cpp +++ b/opm/core/simulator/SimulatorTwophase.cpp @@ -89,9 +89,9 @@ namespace Opm const RockCompressibility* rock_comp_; const Wells* wells_; const std::vector& src_; - const FlowBoundaryConditions* bcs_; - const LinearSolverInterface& linsolver_; - const double* gravity_; + //const FlowBoundaryConditions* bcs_; + //const LinearSolverInterface& linsolver_; + //const double* gravity_; // Solvers IncompTpfa psolver_; TransportModelTwophase tsolver_; @@ -207,9 +207,9 @@ namespace Opm rock_comp_(rock_comp), wells_(wells), src_(src), - bcs_(bcs), - linsolver_(linsolver), - gravity_(gravity), + //bcs_(bcs), + //linsolver_(linsolver), + //gravity_(gravity), psolver_(grid, props, rock_comp, linsolver, param.getDefault("nl_pressure_residual_tolerance", 0.0), param.getDefault("nl_pressure_change_tolerance", 1.0), diff --git a/opm/core/simulator/SimulatorTwophase.hpp b/opm/core/simulator/SimulatorTwophase.hpp index 5baa161e..818d40db 100644 --- a/opm/core/simulator/SimulatorTwophase.hpp +++ b/opm/core/simulator/SimulatorTwophase.hpp @@ -36,7 +36,7 @@ namespace Opm class SimulatorTimer; class TwophaseState; class WellState; - class SimulatorReport; + struct SimulatorReport; /// Class collecting all necessary components for a two-phase simulation. class SimulatorTwophase diff --git a/opm/core/utility/Factory.hpp b/opm/core/utility/Factory.hpp index eb73d208..124b5b44 100644 --- a/opm/core/utility/Factory.hpp +++ b/opm/core/utility/Factory.hpp @@ -86,7 +86,7 @@ namespace Opm template static void addCreator(const std::string& type) { - instance().doAddCreator(type); + instance().template doAddCreator(type); } private: diff --git a/opm/core/utility/MonotCubicInterpolator.hpp b/opm/core/utility/MonotCubicInterpolator.hpp index 7e1c6710..fb635ac7 100644 --- a/opm/core/utility/MonotCubicInterpolator.hpp +++ b/opm/core/utility/MonotCubicInterpolator.hpp @@ -73,7 +73,7 @@ class MonotCubicInterpolator { if (!read(datafilename)) { throw("Unable to constuct MonotCubicInterpolator from file.") ; } ; - } ; + } /** @@ -94,7 +94,7 @@ class MonotCubicInterpolator { if (!read(std::string(datafilename))) { throw("Unable to constuct MonotCubicInterpolator from file.") ; } ; - } ; + } /** @@ -110,7 +110,7 @@ class MonotCubicInterpolator { if (!read(std::string(datafilename),xColumn,fColumn)) { throw("Unable to constuct MonotCubicInterpolator from file.") ; } ; - } ; + } /** @param datafilename data file @@ -125,7 +125,7 @@ class MonotCubicInterpolator { if (!read(datafilename,xColumn,fColumn)) { throw("Unable to constuct MonotCubicInterpolator from file.") ; } ; - } ; + } /** @param x vector of x values @@ -144,7 +144,7 @@ class MonotCubicInterpolator { This object must be treated with care until populated. */ - MonotCubicInterpolator() {;} ; + MonotCubicInterpolator() { } @@ -163,7 +163,7 @@ class MonotCubicInterpolator { */ bool read(const std::string & datafilename) { return read(datafilename,1,2) ; - } ; + } /** @param datafilename data file @@ -188,7 +188,7 @@ class MonotCubicInterpolator { @return f(x) for a given x */ - double operator () (double x) const { return evaluate(x) ; } ; + double operator () (double x) const { return evaluate(x) ; } /** @param x x value @@ -485,7 +485,7 @@ class MonotCubicInterpolator { */ void shrinkFlatAreas() { shrinkFlatAreas(1e-14); - }; + } From 789bc5ca7188df60c5500a6917ec28cb36c4f270 Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Thu, 14 Jun 2012 18:13:56 +0200 Subject: [PATCH 24/25] opm-core: make it a usable in conjunction wit dunecontrol MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows projects which use the DUNE build system and want to use OPM-Core to specify a dependency in their dune.module file. (i.e. they don't have to worry about compiler and linker flags anymore.) opm-core can still be used without having DUNE installed, though. This means that for users which do not need/want a dependency on DUNE, nothing changes. v2: avoid naming conflict of the AX_BOOST_BASE macro with dune-common by renaming it to OPM_BOOST_BASE. v3: make the library detection work nicely v4: Use AX_BOOST_BASE M4 macro from opm-core instead from dune-common as base for OPM_BOOST_BASE to get rid of a few bugs, reworded commit message. Thanks to Bård Skaflestad for the review. --- configure.ac | 51 +-- dune.module | 7 + m4/{ax_boost_base.m4 => opm_boost_base.m4} | 4 +- m4/opm_core.m4 | 346 +++++++++++++++++++++ m4/opm_dynlink_boost_test.m4 | 2 +- 5 files changed, 357 insertions(+), 53 deletions(-) create mode 100644 dune.module rename m4/{ax_boost_base.m4 => opm_boost_base.m4} (98%) create mode 100644 m4/opm_core.m4 diff --git a/configure.ac b/configure.ac index ef5fc0d8..e979c9a3 100644 --- a/configure.ac +++ b/configure.ac @@ -28,59 +28,10 @@ m4_ifdef([LT_INIT], AC_PROG_FC[]dnl ])[]dnl -# Checks for libraries. - -# Bring in numerics support (standard library component) -AC_SEARCH_LIBS([sqrt], [m]) - -OPM_LAPACK - -AX_BOOST_BASE([1.37]) -AX_BOOST_SYSTEM -AX_BOOST_DATE_TIME -AX_BOOST_FILESYSTEM -AX_BOOST_UNIT_TEST_FRAMEWORK - -AX_DUNE_ISTL -OPM_AGMG +OPM_CORE_CHECKS OPM_DYNLINK_BOOST_TEST -# Checks for header files. -AC_CHECK_HEADERS([float.h limits.h stddef.h stdlib.h string.h]) - -AC_CHECK_HEADERS([suitesparse/umfpack.h], - [umfpack_header=yes], - [umfpack_header=no]) - -# Checks for typedefs, structures, and compiler characteristics. -AC_HEADER_STDBOOL -AC_TYPE_SIZE_T -AC_CHECK_TYPES([ptrdiff_t]) - -# Checks for library functions. -AC_CHECK_FUNCS([floor memset memmove strchr strtol sqrt pow]) -AC_FUNC_STRTOD - -# Search for UMFPACK direct sparse solver. -AC_SEARCH_LIBS([amd_free], [amd]) -AC_SEARCH_LIBS([camd_free], [camd]) -AC_SEARCH_LIBS([colamd_set_defaults], [colamd]) -AC_SEARCH_LIBS([ccolamd_set_defaults], [ccolamd]) -AC_SEARCH_LIBS([cholmod_l_start], [cholmod]) -AC_SEARCH_LIBS([umfpack_dl_solve], [umfpack],dnl - [umfpack_lib=yes], [umfpack_lib=no]) - -AM_CONDITIONAL([UMFPACK], - [test "x$umfpack_header" != "xno" -a "x$umfpack_lib" != "xno"]) - -m4_ifdef([AM_COND_IF], -[AM_COND_IF([UMFPACK], [], - [AC_MSG_NOTICE([Found no working installation of UMFPACK. - UMFPACK support is disabled.])]) -]) - - AC_CONFIG_FILES([ Makefile tests/Makefile diff --git a/dune.module b/dune.module new file mode 100644 index 00000000..7deeedde --- /dev/null +++ b/dune.module @@ -0,0 +1,7 @@ +#dune module information file# +############################## + +#Name of the module +Module: opm-core +Version: 0.1 +Maintainer: atgeirr@sintef.no diff --git a/m4/ax_boost_base.m4 b/m4/opm_boost_base.m4 similarity index 98% rename from m4/ax_boost_base.m4 rename to m4/opm_boost_base.m4 index 54a2a1be..cabbd339 100644 --- a/m4/ax_boost_base.m4 +++ b/m4/opm_boost_base.m4 @@ -4,7 +4,7 @@ # # SYNOPSIS # -# AX_BOOST_BASE([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +# OPM_BOOST_BASE([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # # DESCRIPTION # @@ -35,7 +35,7 @@ #serial 20 -AC_DEFUN([AX_BOOST_BASE], +AC_DEFUN([OPM_BOOST_BASE], [ AC_ARG_WITH([boost], [AS_HELP_STRING([--with-boost@<:@=ARG@:>@], diff --git a/m4/opm_core.m4 b/m4/opm_core.m4 new file mode 100644 index 00000000..c1a4bbc5 --- /dev/null +++ b/m4/opm_core.m4 @@ -0,0 +1,346 @@ +dnl -*- autoconf -*- +# Macros needed to find OPM-core and dependent libraries. They are called by +# the macros in ${top_src_dir}/dependencies.m4, which is generated by +# "dunecontrol autogen" +AC_DEFUN([OPM_CORE_CHECKS], +[ + +# Checks for libraries. + +# Bring in numerics support (standard library component) +AC_SEARCH_LIBS([sqrt], [m]) + +OPM_LAPACK + +OPM_BOOST_BASE([1.37]) +AX_BOOST_SYSTEM +AX_BOOST_DATE_TIME +AX_BOOST_FILESYSTEM +AX_BOOST_UNIT_TEST_FRAMEWORK + +AX_DUNE_ISTL +OPM_AGMG + +# Checks for header files. +AC_CHECK_HEADERS([float.h limits.h stddef.h stdlib.h string.h]) + +AC_CHECK_HEADERS([suitesparse/umfpack.h], + [umfpack_header=yes], + [umfpack_header=no]) + +# Checks for typedefs, structures, and compiler characteristics. +AC_HEADER_STDBOOL +AC_TYPE_SIZE_T +AC_CHECK_TYPES([ptrdiff_t]) + +# Checks for library functions. +AC_CHECK_FUNCS([floor memset memmove strchr strtol sqrt pow]) +AC_FUNC_STRTOD + +# Search for UMFPACK direct sparse solver. +AC_SEARCH_LIBS([amd_free], [amd]) +AC_SEARCH_LIBS([camd_free], [camd]) +AC_SEARCH_LIBS([colamd_set_defaults], [colamd]) +AC_SEARCH_LIBS([ccolamd_set_defaults], [ccolamd]) +AC_SEARCH_LIBS([cholmod_l_start], [cholmod]) +AC_SEARCH_LIBS([umfpack_dl_solve], [umfpack],dnl + [umfpack_lib=yes], [umfpack_lib=no]) + +AM_CONDITIONAL([UMFPACK], + [test "x$umfpack_header" != "xno" -a "x$umfpack_lib" != "xno"]) + +m4_ifdef([AM_COND_IF], +[AM_COND_IF([UMFPACK], [], + [AC_MSG_NOTICE([Found no working installation of UMFPACK. + UMFPACK support is disabled.])]) +]) + +]) + +# OPM_CORE_CHECK_MODULES(NAME, HEADER, SYMBOL) +# +# THIS MACRO IS JUST A COPY OF DUNE_CHECK_MODULES WITH THE REQUIREMENT THAT ALL +# HEADERS MUST RESIDE IN $MODULE_ROOT/dune REMOVED. REMOVE THIS MACRO AS SOON AS DUNE +# DOES NOT ENFORCE THIS ANYMORE. +# +# Generic check for dune modules. This macro should not be used directly, but +# in the modules m4/{module}.m4 in the {MODULE}_CHECK_MODULE macro. The +# {MODULE}_CHECK_MODULE macro knows the parameters to call this +# DUNE_CHECK_MODULES macro with, and it does not take any parameters itself, +# so it may be used with AC_REQUIRE. +# +# NAME Name of the module, lowercase with dashes (like "dune-common"). The +# value must be known when autoconf runs, so shell variables in the +# value are not permissible. +# +# HEADER Header to check for. The check will really be for , +# so the header must reside within a directory called "dune". +# +# SYMBOL Symbol to check for in the module's library. If this argument is +# empty or missing, it is assumed that the module does not provide a +# library. The value must be known when autoconf runs, so shell +# variables in the value are not permissible. This value is actually +# handed to AC_TRY_LINK unchanged as the FUNCTION-BODY argument, so it +# may contain more complex stuff than a simple symbol. +# +# The name of the library is assumed to be the same as the module name, +# with any occurance of "-" removed. The path of the library is +# obtained from pkgconfig for installed modules, or assumed to be the +# directory "lib" within the modules root for non-installed modules. +# +# In the following, {module} is {NAME} with any "-" replaced by "_" and +# {MODULE} is the uppercase version of {module}. +# +# configure options: +# --with-{NAME} +# +# configure/shell variables: +# {MODULE}_ROOT, {MODULE}_LIBDIR +# HAVE_{MODULE} (1 or 0) +# with_{module} ("yes" or "no") +# DUNE_CPPFLAGS, DUNE_LDFLAGS, DUNE_LIBS (adds the modules values here, +# substitution done by DUNE_CHECK_ALL) +# ALL_PKG_CPPFLAGS, ALL_PKG_LDFLAGS, ALL_PKG_LIBS (adds the modules values +# here, substitution done by DUNE_CHECK_ALL) +# {MODULE}_VERSION +# {MODULE}_VERSION_MAJOR +# {MODULE}_VERSION_MINOR +# {MODULE}_VERSION_REVISION +# +# configure substitutions/makefile variables: +# {MODULE}_CPPFLAGS, {MODULE}_LDFLAGS, {MODULE}_LIBS +# {MODULE}_ROOT +# {MODULE}_LIBDIR (only if modules provides a library) +# +# preprocessor defines: +# HAVE_{MODULE} (1 or undefined) +# {MODULE}_VERSION +# {MODULE}_VERSION_MAJOR +# {MODULE}_VERSION_MINOR +# {MODULE}_VERSION_REVISION +# +# automake conditionals: +# HAVE_{MODULE} +AC_DEFUN([OPM_CORE_CHECK_MODULES],[ + AC_REQUIRE([AC_PROG_CXX]) + AC_REQUIRE([AC_PROG_CXXCPP]) + AC_REQUIRE([PKG_PROG_PKG_CONFIG]) + AC_REQUIRE([DUNE_DISABLE_LIBCHECK]) + AC_REQUIRE([LT_OUTPUT]) + + # ____DUNE_CHECK_MODULES_____ ($1) + + m4_pushdef([_dune_name], [$1]) + m4_pushdef([_dune_module], [m4_translit(_dune_name, [-], [_])]) + m4_pushdef([_dune_header], [$2]) + m4_pushdef([_dune_ldpath], [lib]) + m4_pushdef([_dune_lib], [m4_translit(_dune_name, [-], [])]) + m4_pushdef([_dune_symbol], [$3]) + m4_pushdef([_DUNE_MODULE], [m4_toupper(_dune_module)]) + + # switch tests to c++ + AC_LANG_PUSH([C++]) + + # the usual option... + AC_ARG_WITH(_dune_name, + AS_HELP_STRING([--with-_dune_name=PATH],[_dune_module directory])) + + # backup of flags + ac_save_CPPFLAGS="$CPPFLAGS" + ac_save_LIBS="$LIBS" + ac_save_LDFLAGS="$LDFLAGS" + CPPFLAGS="" + LIBS="" + + ## + ## Where is the module $1? + ## + + AC_MSG_CHECKING([for $1 installation or source tree]) + + # is a directory set? + AS_IF([test -z "$with_[]_dune_module"],[ + # + # search module $1 via pkg-config + # + with_[]_dune_module="global installation" + AS_IF([test -z "$PKG_CONFIG"],[ + AC_MSG_RESULT([failed]) + AC_MSG_NOTICE([could not search for module _dune_name]) + AC_MSG_ERROR([pkg-config is required for using installed modules]) + ]) + AS_IF(AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]),[ + _dune_cm_CPPFLAGS="`$PKG_CONFIG --cflags _dune_name`" 2>/dev/null + _DUNE_MODULE[]_ROOT="`$PKG_CONFIG --variable=prefix _dune_name`" 2>/dev/null + _DUNE_MODULE[]_VERSION="`$PKG_CONFIG --modversion _dune_name`" 2>/dev/null + _dune_cm_LDFLAGS="" + ifelse(_dune_symbol,, + [_DUNE_MODULE[]_LIBDIR="" + _dune_cm_LIBS=""], + [_DUNE_MODULE[]_LIBDIR=`$PKG_CONFIG --variable=libdir _dune_name 2>/dev/null` + _dune_cm_LIBS="-L$_DUNE_MODULE[]_LIBDIR -l[]_dune_lib"]) + HAVE_[]_DUNE_MODULE=1 + AC_MSG_RESULT([global installation in $_DUNE_MODULE[]_ROOT]) + ],[ + HAVE_[]_DUNE_MODULE=0 + AC_MSG_RESULT([not found]) + ]) + ],[ + # + # path for module $1 is specified via command line + # + AS_IF([test -d "$with_[]_dune_module"],[ + # expand tilde / other stuff + _DUNE_MODULE[]_ROOT=`cd $with_[]_dune_module && pwd` + + # expand search path (otherwise empty CPPFLAGS) + AS_IF([test -d "$_DUNE_MODULE[]_ROOT/include/dune"],[ + # Dune was installed into directory given by with-dunecommon + _dune_cm_CPPFLAGS="-I$_DUNE_MODULE[]_ROOT/include" + _DUNE_MODULE[]_BUILDDIR=_DUNE_MODULE[]_ROOT + _DUNE_MODULE[]_VERSION="`PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$_DUNE_MODULE[]_ROOT/lib/pkgconfig $PKG_CONFIG --modversion _dune_name`" 2>/dev/null + ],[ + _DUNE_MODULE[]_SRCDIR=$_DUNE_MODULE[]_ROOT + # extract src and build path from Makefile, if found + AS_IF([test -f $_DUNE_MODULE[]_ROOT/Makefile],[ + _DUNE_MODULE[]_SRCDIR="`sed -ne '/^abs_top_srcdir = /{s/^abs_top_srcdir = //; p;}' $_DUNE_MODULE[]_ROOT/Makefile`" + ]) + _dune_cm_CPPFLAGS="-I$_DUNE_MODULE[]_SRCDIR" + _DUNE_MODULE[]_VERSION="`grep Version $_DUNE_MODULE[]_SRCDIR/dune.module | sed -e 's/^Version: *//'`" 2>/dev/null + ]) + _dune_cm_LDFLAGS="" + ifelse(_dune_symbol,, + [_DUNE_MODULE[]_LIBDIR="" + _dune_cm_LIBS=""], + [_DUNE_MODULE[]_LIBDIR="$_DUNE_MODULE[]_ROOT" + _dune_cm_LIBS="-L$_DUNE_MODULE[]_LIBDIR -l[]_dune_lib"]) + # set expanded module path + with_[]_dune_module="$_DUNE_MODULE[]_ROOT" + HAVE_[]_DUNE_MODULE=1 + AC_MSG_RESULT([found in $_DUNE_MODULE[]_ROOT]) + ],[ + HAVE_[]_DUNE_MODULE=0 + AC_MSG_RESULT([not found]) + AC_MSG_ERROR([_dune_name-directory $with_[]_dune_module does not exist]) + ]) + ]) + + CPPFLAGS="$ac_save_CPPFLAGS $DUNE_CPPFLAGS $_dune_cm_CPPFLAGS" + ## + ## check for an arbitrary header + ## + AS_IF([test "$HAVE_[]_DUNE_MODULE" != "1"],[ + AC_CHECK_HEADER([[]_dune_header], + [HAVE_[]_DUNE_MODULE=1], [HAVE_[]_DUNE_MODULE=0]) + ]) + + AS_IF([test "$HAVE_[]_DUNE_MODULE" != "1"],[ + AC_MSG_WARN([$_DUNE_MODULE[]_ROOT does not seem to contain a valid _dune_name (dune/[]_dune_header not found)]) + ]) + + ## + ## check for lib (if lib name was provided) + ## + ifelse(_dune_symbol,, + AC_MSG_NOTICE([_dune_name does not provide libs]), + + AS_IF([test "x$enable_dunelibcheck" = "xno"],[ + AC_MSG_WARN([library check for _dune_name is disabled. DANGEROUS!]) + ],[ + AS_IF([test "x$HAVE_[]_DUNE_MODULE" = "x1"],[ + + # save current LDFLAGS + ac_save_CXX="$CXX" + HAVE_[]_DUNE_MODULE=0 + + # define LTCXXLINK like it will be defined in the Makefile + CXX="./libtool --tag=CXX --mode=link $ac_save_CXX" + + # use module LDFLAGS + LDFLAGS="$ac_save_LDFLAGS $DUNE_LDFLAGS $_dune_cm_LDFLAGS" + LIBS="$_dune_cm_LIBS $DUNE_LIBS $LIBS" + + AC_MSG_CHECKING([for lib[]_dune_lib]) + + AC_TRY_LINK(dnl + [#]include<_dune_header>, + _dune_symbol, + [ + AC_MSG_RESULT([yes]) + HAVE_[]_DUNE_MODULE=1 + ],[ + AC_MSG_RESULT([no]) + HAVE_[]_DUNE_MODULE=0 + AS_IF([test -n "$_DUNE_MODULE[]_ROOT"],[ + AC_MSG_WARN([$with_[]_dune_module does not seem to contain a valid _dune_name (failed to link with lib[]_dune_lib[].la)]) + ]) + ] + ) + ]) + + # reset variables + CXX="$ac_save_CXX" + ]) + ) + + # did we succeed? + AS_IF([test "x$HAVE_[]_DUNE_MODULE" = "x1"],[ + # add the module's own flags and libs to the modules and the global + # variables + DUNE_ADD_MODULE_DEPS(m4_defn([_dune_name]), m4_defn([_dune_name]), + [$_dune_cm_CPPFLAGS], [$_dune_cm_LDFLAGS], [$_dune_cm_LIBS]) + + # set variables for our modules + AC_SUBST(_DUNE_MODULE[]_CPPFLAGS, "$_DUNE_MODULE[]_CPPFLAGS") + AC_SUBST(_DUNE_MODULE[]_LDFLAGS, "$_DUNE_MODULE[]_LDFLAGS") + AC_SUBST(_DUNE_MODULE[]_LIBS, "$_DUNE_MODULE[]_LIBS") + AC_SUBST(_DUNE_MODULE[]_ROOT, "$_DUNE_MODULE[]_ROOT") + ifelse(m4_defn([_dune_symbol]),, + [], + [AC_SUBST(_DUNE_MODULE[]_LIBDIR) + ]) + AC_DEFINE(HAVE_[]_DUNE_MODULE, 1, [Define to 1 if] _dune_name [was found]) + + DUNE_PARSE_MODULE_VERSION(_dune_name, $_DUNE_MODULE[]_VERSION) + + # set DUNE_* variables + # This should actually be unneccesary, but I'm keeping it in here for now + # for backward compatibility + DUNE_LDFLAGS="$DUNE_LDFLAGS $_DUNE_MODULE[]_LDFLAGS" + DUNE_LIBS="$_DUNE_MODULE[]_LIBS $DUNE_LIBS" + + with_[]_dune_module="yes" + ],[ + with_[]_dune_module="no" + ]) + + AM_CONDITIONAL(HAVE_[]_DUNE_MODULE, test x$HAVE_[]_DUNE_MODULE = x1) + + # reset previous flags + CPPFLAGS="$ac_save_CPPFLAGS" + LDFLAGS="$ac_save_LDFLAGS" + LIBS="$ac_save_LIBS" + + # add this module to DUNE_SUMMARY + DUNE_MODULE_ADD_SUMMARY_ENTRY(_dune_name) + + # remove local variables + m4_popdef([_dune_name]) + m4_popdef([_dune_module]) + m4_popdef([_dune_header]) + m4_popdef([_dune_ldpath]) + m4_popdef([_dune_lib]) + m4_popdef([_dune_symbol]) + m4_popdef([_DUNE_MODULE]) + + # restore previous language settings (leave C++) + AC_LANG_POP([C++]) +]) + +# Additional checks needed to find eWoms +# This macro should be invoked by every module which depends on dumux, but +# not by dumux itself +AC_DEFUN([OPM_CORE_CHECK_MODULE], +[ + OPM_CORE_CHECK_MODULES([opm-core],[opm/core/grid.h],[create_grid_empty()]) +]) diff --git a/m4/opm_dynlink_boost_test.m4 b/m4/opm_dynlink_boost_test.m4 index 0602d8fe..7c5982b1 100644 --- a/m4/opm_dynlink_boost_test.m4 +++ b/m4/opm_dynlink_boost_test.m4 @@ -38,7 +38,7 @@ dnl ------------------------------------------------------------------- # system uses dynamic linking of Boost.Test . AC_DEFUN([OPM_DYNLINK_BOOST_TEST], [ -AC_REQUIRE([AX_BOOST_BASE]) +AC_REQUIRE([OPM_BOOST_BASE]) AC_REQUIRE([AX_BOOST_UNIT_TEST_FRAMEWORK]) _opm_LIBS_SAVE="${LIBS}" From 6e0a566e5373fd4f14962f73f18317029894d0b7 Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Tue, 3 Jul 2012 15:42:01 +0200 Subject: [PATCH 25/25] factor out OPM_CORE_CHECK_MODULES into a separate file thanks to Roland Kaufmann for suggesting this. --- m4/opm_core.m4 | 282 +---------------------------------- m4/opm_core_check_modules.m4 | 281 ++++++++++++++++++++++++++++++++++ 2 files changed, 282 insertions(+), 281 deletions(-) create mode 100644 m4/opm_core_check_modules.m4 diff --git a/m4/opm_core.m4 b/m4/opm_core.m4 index c1a4bbc5..efb75c13 100644 --- a/m4/opm_core.m4 +++ b/m4/opm_core.m4 @@ -1,5 +1,5 @@ dnl -*- autoconf -*- -# Macros needed to find OPM-core and dependent libraries. They are called by + # Macros needed to find OPM-core and dependent libraries. They are called by # the macros in ${top_src_dir}/dependencies.m4, which is generated by # "dunecontrol autogen" AC_DEFUN([OPM_CORE_CHECKS], @@ -57,286 +57,6 @@ m4_ifdef([AM_COND_IF], ]) -# OPM_CORE_CHECK_MODULES(NAME, HEADER, SYMBOL) -# -# THIS MACRO IS JUST A COPY OF DUNE_CHECK_MODULES WITH THE REQUIREMENT THAT ALL -# HEADERS MUST RESIDE IN $MODULE_ROOT/dune REMOVED. REMOVE THIS MACRO AS SOON AS DUNE -# DOES NOT ENFORCE THIS ANYMORE. -# -# Generic check for dune modules. This macro should not be used directly, but -# in the modules m4/{module}.m4 in the {MODULE}_CHECK_MODULE macro. The -# {MODULE}_CHECK_MODULE macro knows the parameters to call this -# DUNE_CHECK_MODULES macro with, and it does not take any parameters itself, -# so it may be used with AC_REQUIRE. -# -# NAME Name of the module, lowercase with dashes (like "dune-common"). The -# value must be known when autoconf runs, so shell variables in the -# value are not permissible. -# -# HEADER Header to check for. The check will really be for , -# so the header must reside within a directory called "dune". -# -# SYMBOL Symbol to check for in the module's library. If this argument is -# empty or missing, it is assumed that the module does not provide a -# library. The value must be known when autoconf runs, so shell -# variables in the value are not permissible. This value is actually -# handed to AC_TRY_LINK unchanged as the FUNCTION-BODY argument, so it -# may contain more complex stuff than a simple symbol. -# -# The name of the library is assumed to be the same as the module name, -# with any occurance of "-" removed. The path of the library is -# obtained from pkgconfig for installed modules, or assumed to be the -# directory "lib" within the modules root for non-installed modules. -# -# In the following, {module} is {NAME} with any "-" replaced by "_" and -# {MODULE} is the uppercase version of {module}. -# -# configure options: -# --with-{NAME} -# -# configure/shell variables: -# {MODULE}_ROOT, {MODULE}_LIBDIR -# HAVE_{MODULE} (1 or 0) -# with_{module} ("yes" or "no") -# DUNE_CPPFLAGS, DUNE_LDFLAGS, DUNE_LIBS (adds the modules values here, -# substitution done by DUNE_CHECK_ALL) -# ALL_PKG_CPPFLAGS, ALL_PKG_LDFLAGS, ALL_PKG_LIBS (adds the modules values -# here, substitution done by DUNE_CHECK_ALL) -# {MODULE}_VERSION -# {MODULE}_VERSION_MAJOR -# {MODULE}_VERSION_MINOR -# {MODULE}_VERSION_REVISION -# -# configure substitutions/makefile variables: -# {MODULE}_CPPFLAGS, {MODULE}_LDFLAGS, {MODULE}_LIBS -# {MODULE}_ROOT -# {MODULE}_LIBDIR (only if modules provides a library) -# -# preprocessor defines: -# HAVE_{MODULE} (1 or undefined) -# {MODULE}_VERSION -# {MODULE}_VERSION_MAJOR -# {MODULE}_VERSION_MINOR -# {MODULE}_VERSION_REVISION -# -# automake conditionals: -# HAVE_{MODULE} -AC_DEFUN([OPM_CORE_CHECK_MODULES],[ - AC_REQUIRE([AC_PROG_CXX]) - AC_REQUIRE([AC_PROG_CXXCPP]) - AC_REQUIRE([PKG_PROG_PKG_CONFIG]) - AC_REQUIRE([DUNE_DISABLE_LIBCHECK]) - AC_REQUIRE([LT_OUTPUT]) - - # ____DUNE_CHECK_MODULES_____ ($1) - - m4_pushdef([_dune_name], [$1]) - m4_pushdef([_dune_module], [m4_translit(_dune_name, [-], [_])]) - m4_pushdef([_dune_header], [$2]) - m4_pushdef([_dune_ldpath], [lib]) - m4_pushdef([_dune_lib], [m4_translit(_dune_name, [-], [])]) - m4_pushdef([_dune_symbol], [$3]) - m4_pushdef([_DUNE_MODULE], [m4_toupper(_dune_module)]) - - # switch tests to c++ - AC_LANG_PUSH([C++]) - - # the usual option... - AC_ARG_WITH(_dune_name, - AS_HELP_STRING([--with-_dune_name=PATH],[_dune_module directory])) - - # backup of flags - ac_save_CPPFLAGS="$CPPFLAGS" - ac_save_LIBS="$LIBS" - ac_save_LDFLAGS="$LDFLAGS" - CPPFLAGS="" - LIBS="" - - ## - ## Where is the module $1? - ## - - AC_MSG_CHECKING([for $1 installation or source tree]) - - # is a directory set? - AS_IF([test -z "$with_[]_dune_module"],[ - # - # search module $1 via pkg-config - # - with_[]_dune_module="global installation" - AS_IF([test -z "$PKG_CONFIG"],[ - AC_MSG_RESULT([failed]) - AC_MSG_NOTICE([could not search for module _dune_name]) - AC_MSG_ERROR([pkg-config is required for using installed modules]) - ]) - AS_IF(AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]),[ - _dune_cm_CPPFLAGS="`$PKG_CONFIG --cflags _dune_name`" 2>/dev/null - _DUNE_MODULE[]_ROOT="`$PKG_CONFIG --variable=prefix _dune_name`" 2>/dev/null - _DUNE_MODULE[]_VERSION="`$PKG_CONFIG --modversion _dune_name`" 2>/dev/null - _dune_cm_LDFLAGS="" - ifelse(_dune_symbol,, - [_DUNE_MODULE[]_LIBDIR="" - _dune_cm_LIBS=""], - [_DUNE_MODULE[]_LIBDIR=`$PKG_CONFIG --variable=libdir _dune_name 2>/dev/null` - _dune_cm_LIBS="-L$_DUNE_MODULE[]_LIBDIR -l[]_dune_lib"]) - HAVE_[]_DUNE_MODULE=1 - AC_MSG_RESULT([global installation in $_DUNE_MODULE[]_ROOT]) - ],[ - HAVE_[]_DUNE_MODULE=0 - AC_MSG_RESULT([not found]) - ]) - ],[ - # - # path for module $1 is specified via command line - # - AS_IF([test -d "$with_[]_dune_module"],[ - # expand tilde / other stuff - _DUNE_MODULE[]_ROOT=`cd $with_[]_dune_module && pwd` - - # expand search path (otherwise empty CPPFLAGS) - AS_IF([test -d "$_DUNE_MODULE[]_ROOT/include/dune"],[ - # Dune was installed into directory given by with-dunecommon - _dune_cm_CPPFLAGS="-I$_DUNE_MODULE[]_ROOT/include" - _DUNE_MODULE[]_BUILDDIR=_DUNE_MODULE[]_ROOT - _DUNE_MODULE[]_VERSION="`PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$_DUNE_MODULE[]_ROOT/lib/pkgconfig $PKG_CONFIG --modversion _dune_name`" 2>/dev/null - ],[ - _DUNE_MODULE[]_SRCDIR=$_DUNE_MODULE[]_ROOT - # extract src and build path from Makefile, if found - AS_IF([test -f $_DUNE_MODULE[]_ROOT/Makefile],[ - _DUNE_MODULE[]_SRCDIR="`sed -ne '/^abs_top_srcdir = /{s/^abs_top_srcdir = //; p;}' $_DUNE_MODULE[]_ROOT/Makefile`" - ]) - _dune_cm_CPPFLAGS="-I$_DUNE_MODULE[]_SRCDIR" - _DUNE_MODULE[]_VERSION="`grep Version $_DUNE_MODULE[]_SRCDIR/dune.module | sed -e 's/^Version: *//'`" 2>/dev/null - ]) - _dune_cm_LDFLAGS="" - ifelse(_dune_symbol,, - [_DUNE_MODULE[]_LIBDIR="" - _dune_cm_LIBS=""], - [_DUNE_MODULE[]_LIBDIR="$_DUNE_MODULE[]_ROOT" - _dune_cm_LIBS="-L$_DUNE_MODULE[]_LIBDIR -l[]_dune_lib"]) - # set expanded module path - with_[]_dune_module="$_DUNE_MODULE[]_ROOT" - HAVE_[]_DUNE_MODULE=1 - AC_MSG_RESULT([found in $_DUNE_MODULE[]_ROOT]) - ],[ - HAVE_[]_DUNE_MODULE=0 - AC_MSG_RESULT([not found]) - AC_MSG_ERROR([_dune_name-directory $with_[]_dune_module does not exist]) - ]) - ]) - - CPPFLAGS="$ac_save_CPPFLAGS $DUNE_CPPFLAGS $_dune_cm_CPPFLAGS" - ## - ## check for an arbitrary header - ## - AS_IF([test "$HAVE_[]_DUNE_MODULE" != "1"],[ - AC_CHECK_HEADER([[]_dune_header], - [HAVE_[]_DUNE_MODULE=1], [HAVE_[]_DUNE_MODULE=0]) - ]) - - AS_IF([test "$HAVE_[]_DUNE_MODULE" != "1"],[ - AC_MSG_WARN([$_DUNE_MODULE[]_ROOT does not seem to contain a valid _dune_name (dune/[]_dune_header not found)]) - ]) - - ## - ## check for lib (if lib name was provided) - ## - ifelse(_dune_symbol,, - AC_MSG_NOTICE([_dune_name does not provide libs]), - - AS_IF([test "x$enable_dunelibcheck" = "xno"],[ - AC_MSG_WARN([library check for _dune_name is disabled. DANGEROUS!]) - ],[ - AS_IF([test "x$HAVE_[]_DUNE_MODULE" = "x1"],[ - - # save current LDFLAGS - ac_save_CXX="$CXX" - HAVE_[]_DUNE_MODULE=0 - - # define LTCXXLINK like it will be defined in the Makefile - CXX="./libtool --tag=CXX --mode=link $ac_save_CXX" - - # use module LDFLAGS - LDFLAGS="$ac_save_LDFLAGS $DUNE_LDFLAGS $_dune_cm_LDFLAGS" - LIBS="$_dune_cm_LIBS $DUNE_LIBS $LIBS" - - AC_MSG_CHECKING([for lib[]_dune_lib]) - - AC_TRY_LINK(dnl - [#]include<_dune_header>, - _dune_symbol, - [ - AC_MSG_RESULT([yes]) - HAVE_[]_DUNE_MODULE=1 - ],[ - AC_MSG_RESULT([no]) - HAVE_[]_DUNE_MODULE=0 - AS_IF([test -n "$_DUNE_MODULE[]_ROOT"],[ - AC_MSG_WARN([$with_[]_dune_module does not seem to contain a valid _dune_name (failed to link with lib[]_dune_lib[].la)]) - ]) - ] - ) - ]) - - # reset variables - CXX="$ac_save_CXX" - ]) - ) - - # did we succeed? - AS_IF([test "x$HAVE_[]_DUNE_MODULE" = "x1"],[ - # add the module's own flags and libs to the modules and the global - # variables - DUNE_ADD_MODULE_DEPS(m4_defn([_dune_name]), m4_defn([_dune_name]), - [$_dune_cm_CPPFLAGS], [$_dune_cm_LDFLAGS], [$_dune_cm_LIBS]) - - # set variables for our modules - AC_SUBST(_DUNE_MODULE[]_CPPFLAGS, "$_DUNE_MODULE[]_CPPFLAGS") - AC_SUBST(_DUNE_MODULE[]_LDFLAGS, "$_DUNE_MODULE[]_LDFLAGS") - AC_SUBST(_DUNE_MODULE[]_LIBS, "$_DUNE_MODULE[]_LIBS") - AC_SUBST(_DUNE_MODULE[]_ROOT, "$_DUNE_MODULE[]_ROOT") - ifelse(m4_defn([_dune_symbol]),, - [], - [AC_SUBST(_DUNE_MODULE[]_LIBDIR) - ]) - AC_DEFINE(HAVE_[]_DUNE_MODULE, 1, [Define to 1 if] _dune_name [was found]) - - DUNE_PARSE_MODULE_VERSION(_dune_name, $_DUNE_MODULE[]_VERSION) - - # set DUNE_* variables - # This should actually be unneccesary, but I'm keeping it in here for now - # for backward compatibility - DUNE_LDFLAGS="$DUNE_LDFLAGS $_DUNE_MODULE[]_LDFLAGS" - DUNE_LIBS="$_DUNE_MODULE[]_LIBS $DUNE_LIBS" - - with_[]_dune_module="yes" - ],[ - with_[]_dune_module="no" - ]) - - AM_CONDITIONAL(HAVE_[]_DUNE_MODULE, test x$HAVE_[]_DUNE_MODULE = x1) - - # reset previous flags - CPPFLAGS="$ac_save_CPPFLAGS" - LDFLAGS="$ac_save_LDFLAGS" - LIBS="$ac_save_LIBS" - - # add this module to DUNE_SUMMARY - DUNE_MODULE_ADD_SUMMARY_ENTRY(_dune_name) - - # remove local variables - m4_popdef([_dune_name]) - m4_popdef([_dune_module]) - m4_popdef([_dune_header]) - m4_popdef([_dune_ldpath]) - m4_popdef([_dune_lib]) - m4_popdef([_dune_symbol]) - m4_popdef([_DUNE_MODULE]) - - # restore previous language settings (leave C++) - AC_LANG_POP([C++]) -]) - # Additional checks needed to find eWoms # This macro should be invoked by every module which depends on dumux, but # not by dumux itself diff --git a/m4/opm_core_check_modules.m4 b/m4/opm_core_check_modules.m4 new file mode 100644 index 00000000..b445a886 --- /dev/null +++ b/m4/opm_core_check_modules.m4 @@ -0,0 +1,281 @@ +dnl -*- autoconf -*- + +# OPM_CORE_CHECK_MODULES(NAME, HEADER, SYMBOL) +# +# THIS MACRO IS JUST A COPY OF DUNE_CHECK_MODULES WITH THE REQUIREMENT +# THAT ALL HEADERS MUST RESIDE IN $MODULE_ROOT/dune REMOVED. REMOVE +# THIS MACRO AS SOON AS DUNE DOES NOT ENFORCE THIS ANYMORE. +# +# Generic check for dune modules. This macro should not be used directly, but +# in the modules m4/{module}.m4 in the {MODULE}_CHECK_MODULE macro. The +# {MODULE}_CHECK_MODULE macro knows the parameters to call this +# DUNE_CHECK_MODULES macro with, and it does not take any parameters itself, +# so it may be used with AC_REQUIRE. +# +# NAME Name of the module, lowercase with dashes (like "dune-common"). The +# value must be known when autoconf runs, so shell variables in the +# value are not permissible. +# +# HEADER Header to check for. The check will really be for , +# so the header must reside within a directory called "dune". +# +# SYMBOL Symbol to check for in the module's library. If this argument is +# empty or missing, it is assumed that the module does not provide a +# library. The value must be known when autoconf runs, so shell +# variables in the value are not permissible. This value is actually +# handed to AC_TRY_LINK unchanged as the FUNCTION-BODY argument, so it +# may contain more complex stuff than a simple symbol. +# +# The name of the library is assumed to be the same as the module name, +# with any occurance of "-" removed. The path of the library is +# obtained from pkgconfig for installed modules, or assumed to be the +# directory "lib" within the modules root for non-installed modules. +# +# In the following, {module} is {NAME} with any "-" replaced by "_" and +# {MODULE} is the uppercase version of {module}. +# +# configure options: +# --with-{NAME} +# +# configure/shell variables: +# {MODULE}_ROOT, {MODULE}_LIBDIR +# HAVE_{MODULE} (1 or 0) +# with_{module} ("yes" or "no") +# DUNE_CPPFLAGS, DUNE_LDFLAGS, DUNE_LIBS (adds the modules values here, +# substitution done by DUNE_CHECK_ALL) +# ALL_PKG_CPPFLAGS, ALL_PKG_LDFLAGS, ALL_PKG_LIBS (adds the modules values +# here, substitution done by DUNE_CHECK_ALL) +# {MODULE}_VERSION +# {MODULE}_VERSION_MAJOR +# {MODULE}_VERSION_MINOR +# {MODULE}_VERSION_REVISION +# +# configure substitutions/makefile variables: +# {MODULE}_CPPFLAGS, {MODULE}_LDFLAGS, {MODULE}_LIBS +# {MODULE}_ROOT +# {MODULE}_LIBDIR (only if modules provides a library) +# +# preprocessor defines: +# HAVE_{MODULE} (1 or undefined) +# {MODULE}_VERSION +# {MODULE}_VERSION_MAJOR +# {MODULE}_VERSION_MINOR +# {MODULE}_VERSION_REVISION +# +# automake conditionals: +# HAVE_{MODULE} +AC_DEFUN([OPM_CORE_CHECK_MODULES],[ + AC_REQUIRE([AC_PROG_CXX]) + AC_REQUIRE([AC_PROG_CXXCPP]) + AC_REQUIRE([PKG_PROG_PKG_CONFIG]) + AC_REQUIRE([DUNE_DISABLE_LIBCHECK]) + AC_REQUIRE([LT_OUTPUT]) + + # ____DUNE_CHECK_MODULES_____ ($1) + + m4_pushdef([_dune_name], [$1]) + m4_pushdef([_dune_module], [m4_translit(_dune_name, [-], [_])]) + m4_pushdef([_dune_header], [$2]) + m4_pushdef([_dune_ldpath], [lib]) + m4_pushdef([_dune_lib], [m4_translit(_dune_name, [-], [])]) + m4_pushdef([_dune_symbol], [$3]) + m4_pushdef([_DUNE_MODULE], [m4_toupper(_dune_module)]) + + # switch tests to c++ + AC_LANG_PUSH([C++]) + + # the usual option... + AC_ARG_WITH(_dune_name, + AS_HELP_STRING([--with-_dune_name=PATH],[_dune_module directory])) + + # backup of flags + ac_save_CPPFLAGS="$CPPFLAGS" + ac_save_LIBS="$LIBS" + ac_save_LDFLAGS="$LDFLAGS" + CPPFLAGS="" + LIBS="" + + ## + ## Where is the module $1? + ## + + AC_MSG_CHECKING([for $1 installation or source tree]) + + # is a directory set? + AS_IF([test -z "$with_[]_dune_module"],[ + # + # search module $1 via pkg-config + # + with_[]_dune_module="global installation" + AS_IF([test -z "$PKG_CONFIG"],[ + AC_MSG_RESULT([failed]) + AC_MSG_NOTICE([could not search for module _dune_name]) + AC_MSG_ERROR([pkg-config is required for using installed modules]) + ]) + AS_IF(AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]),[ + _dune_cm_CPPFLAGS="`$PKG_CONFIG --cflags _dune_name`" 2>/dev/null + _DUNE_MODULE[]_ROOT="`$PKG_CONFIG --variable=prefix _dune_name`" 2>/dev/null + _DUNE_MODULE[]_VERSION="`$PKG_CONFIG --modversion _dune_name`" 2>/dev/null + _dune_cm_LDFLAGS="" + ifelse(_dune_symbol,, + [_DUNE_MODULE[]_LIBDIR="" + _dune_cm_LIBS=""], + [_DUNE_MODULE[]_LIBDIR=`$PKG_CONFIG --variable=libdir _dune_name 2>/dev/null` + _dune_cm_LIBS="-L$_DUNE_MODULE[]_LIBDIR -l[]_dune_lib"]) + HAVE_[]_DUNE_MODULE=1 + AC_MSG_RESULT([global installation in $_DUNE_MODULE[]_ROOT]) + ],[ + HAVE_[]_DUNE_MODULE=0 + AC_MSG_RESULT([not found]) + ]) + ],[ + # + # path for module $1 is specified via command line + # + AS_IF([test -d "$with_[]_dune_module"],[ + # expand tilde / other stuff + _DUNE_MODULE[]_ROOT=`cd $with_[]_dune_module && pwd` + + # expand search path (otherwise empty CPPFLAGS) + AS_IF([test -d "$_DUNE_MODULE[]_ROOT/include/dune"],[ + # Dune was installed into directory given by with-dunecommon + _dune_cm_CPPFLAGS="-I$_DUNE_MODULE[]_ROOT/include" + _DUNE_MODULE[]_BUILDDIR=_DUNE_MODULE[]_ROOT + _DUNE_MODULE[]_VERSION="`PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$_DUNE_MODULE[]_ROOT/lib/pkgconfig $PKG_CONFIG --modversion _dune_name`" 2>/dev/null + ],[ + _DUNE_MODULE[]_SRCDIR=$_DUNE_MODULE[]_ROOT + # extract src and build path from Makefile, if found + AS_IF([test -f $_DUNE_MODULE[]_ROOT/Makefile],[ + _DUNE_MODULE[]_SRCDIR="`sed -ne '/^abs_top_srcdir = /{s/^abs_top_srcdir = //; p;}' $_DUNE_MODULE[]_ROOT/Makefile`" + ]) + _dune_cm_CPPFLAGS="-I$_DUNE_MODULE[]_SRCDIR" + _DUNE_MODULE[]_VERSION="`grep Version $_DUNE_MODULE[]_SRCDIR/dune.module | sed -e 's/^Version: *//'`" 2>/dev/null + ]) + _dune_cm_LDFLAGS="" + ifelse(_dune_symbol,, + [_DUNE_MODULE[]_LIBDIR="" + _dune_cm_LIBS=""], + [_DUNE_MODULE[]_LIBDIR="$_DUNE_MODULE[]_ROOT" + _dune_cm_LIBS="-L$_DUNE_MODULE[]_LIBDIR -l[]_dune_lib"]) + # set expanded module path + with_[]_dune_module="$_DUNE_MODULE[]_ROOT" + HAVE_[]_DUNE_MODULE=1 + AC_MSG_RESULT([found in $_DUNE_MODULE[]_ROOT]) + ],[ + HAVE_[]_DUNE_MODULE=0 + AC_MSG_RESULT([not found]) + AC_MSG_ERROR([_dune_name-directory $with_[]_dune_module does not exist]) + ]) + ]) + + CPPFLAGS="$ac_save_CPPFLAGS $DUNE_CPPFLAGS $_dune_cm_CPPFLAGS" + ## + ## check for an arbitrary header + ## + AS_IF([test "$HAVE_[]_DUNE_MODULE" != "1"],[ + AC_CHECK_HEADER([[]_dune_header], + [HAVE_[]_DUNE_MODULE=1], [HAVE_[]_DUNE_MODULE=0]) + ]) + + AS_IF([test "$HAVE_[]_DUNE_MODULE" != "1"],[ + AC_MSG_WARN([$_DUNE_MODULE[]_ROOT does not seem to contain a valid _dune_name (dune/[]_dune_header not found)]) + ]) + + ## + ## check for lib (if lib name was provided) + ## + ifelse(_dune_symbol,, + AC_MSG_NOTICE([_dune_name does not provide libs]), + + AS_IF([test "x$enable_dunelibcheck" = "xno"],[ + AC_MSG_WARN([library check for _dune_name is disabled. DANGEROUS!]) + ],[ + AS_IF([test "x$HAVE_[]_DUNE_MODULE" = "x1"],[ + + # save current LDFLAGS + ac_save_CXX="$CXX" + HAVE_[]_DUNE_MODULE=0 + + # define LTCXXLINK like it will be defined in the Makefile + CXX="./libtool --tag=CXX --mode=link $ac_save_CXX" + + # use module LDFLAGS + LDFLAGS="$ac_save_LDFLAGS $DUNE_LDFLAGS $_dune_cm_LDFLAGS" + LIBS="$_dune_cm_LIBS $DUNE_LIBS $LIBS" + + AC_MSG_CHECKING([for lib[]_dune_lib]) + + AC_TRY_LINK(dnl + [#]include<_dune_header>, + _dune_symbol, + [ + AC_MSG_RESULT([yes]) + HAVE_[]_DUNE_MODULE=1 + ],[ + AC_MSG_RESULT([no]) + HAVE_[]_DUNE_MODULE=0 + AS_IF([test -n "$_DUNE_MODULE[]_ROOT"],[ + AC_MSG_WARN([$with_[]_dune_module does not seem to contain a valid _dune_name (failed to link with lib[]_dune_lib[].la)]) + ]) + ] + ) + ]) + + # reset variables + CXX="$ac_save_CXX" + ]) + ) + + # did we succeed? + AS_IF([test "x$HAVE_[]_DUNE_MODULE" = "x1"],[ + # add the module's own flags and libs to the modules and the global + # variables + DUNE_ADD_MODULE_DEPS(m4_defn([_dune_name]), m4_defn([_dune_name]), + [$_dune_cm_CPPFLAGS], [$_dune_cm_LDFLAGS], [$_dune_cm_LIBS]) + + # set variables for our modules + AC_SUBST(_DUNE_MODULE[]_CPPFLAGS, "$_DUNE_MODULE[]_CPPFLAGS") + AC_SUBST(_DUNE_MODULE[]_LDFLAGS, "$_DUNE_MODULE[]_LDFLAGS") + AC_SUBST(_DUNE_MODULE[]_LIBS, "$_DUNE_MODULE[]_LIBS") + AC_SUBST(_DUNE_MODULE[]_ROOT, "$_DUNE_MODULE[]_ROOT") + ifelse(m4_defn([_dune_symbol]),, + [], + [AC_SUBST(_DUNE_MODULE[]_LIBDIR) + ]) + AC_DEFINE(HAVE_[]_DUNE_MODULE, 1, [Define to 1 if] _dune_name [was found]) + + DUNE_PARSE_MODULE_VERSION(_dune_name, $_DUNE_MODULE[]_VERSION) + + # set DUNE_* variables + # This should actually be unneccesary, but I'm keeping it in here for now + # for backward compatibility + DUNE_LDFLAGS="$DUNE_LDFLAGS $_DUNE_MODULE[]_LDFLAGS" + DUNE_LIBS="$_DUNE_MODULE[]_LIBS $DUNE_LIBS" + + with_[]_dune_module="yes" + ],[ + with_[]_dune_module="no" + ]) + + AM_CONDITIONAL(HAVE_[]_DUNE_MODULE, test x$HAVE_[]_DUNE_MODULE = x1) + + # reset previous flags + CPPFLAGS="$ac_save_CPPFLAGS" + LDFLAGS="$ac_save_LDFLAGS" + LIBS="$ac_save_LIBS" + + # add this module to DUNE_SUMMARY + DUNE_MODULE_ADD_SUMMARY_ENTRY(_dune_name) + + # remove local variables + m4_popdef([_dune_name]) + m4_popdef([_dune_module]) + m4_popdef([_dune_header]) + m4_popdef([_dune_ldpath]) + m4_popdef([_dune_lib]) + m4_popdef([_dune_symbol]) + m4_popdef([_DUNE_MODULE]) + + # restore previous language settings (leave C++) + AC_LANG_POP([C++]) +])