Merge branch 'master' into reorder_tof
This commit is contained in:
commit
43335dfce3
@ -12,7 +12,8 @@ lib_LTLIBRARIES = lib/libopmcore.la
|
||||
# Build-time flags needed to build libopmcore.la
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
$(OPM_BOOST_CPPFLAGS)
|
||||
$(OPM_BOOST_CPPFLAGS) \
|
||||
${SUPERLU_CPPFLAGS}
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Link-time flags needed both to successfully link the library and to
|
||||
@ -20,14 +21,15 @@ $(OPM_BOOST_CPPFLAGS)
|
||||
|
||||
lib_libopmcore_la_LDFLAGS = \
|
||||
-R $(OPM_BOOST_LIBDIR) \
|
||||
$(OPM_BOOST_LDFLAGS)
|
||||
$(OPM_BOOST_LDFLAGS) \
|
||||
${SUPERLU_LDFLAGS}
|
||||
|
||||
lib_libopmcore_la_LIBADD = \
|
||||
$(BOOST_FILESYSTEM_LIB) \
|
||||
$(BOOST_SYSTEM_LIB) \
|
||||
$(BOOST_DATE_TIME_LIB) \
|
||||
$(BOOST_UNIT_TEST_FRAMEWORK_LIB) \
|
||||
$(LAPACK_LIBS) $(BLAS_LIBS) $(LIBS)
|
||||
$(LAPACK_LIBS) ${SUPERLU_LIBS} $(BLAS_LIBS) $(LIBS)
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Library constituents. SOURCES followed by HEADERS.
|
||||
|
15
README
15
README
@ -88,10 +88,25 @@ If you want to contribute, fork OPM/opm-core on github.
|
||||
BUILDING
|
||||
--------
|
||||
|
||||
There are two ways to build the opm-core library:
|
||||
|
||||
1. As a stand-alone library.
|
||||
cd opm-core
|
||||
autoreconf -i
|
||||
./configure
|
||||
make
|
||||
If you want to install the library:
|
||||
make install
|
||||
or (if installing to /usr/local or similar)
|
||||
sudo make install
|
||||
|
||||
2. As a dune module.
|
||||
- Put the opm-core directory in the same directory
|
||||
as the other dune modules to be built (e.g. dune-commmon,
|
||||
dune-grid).
|
||||
- Run dunecontrol as normal. For more information on
|
||||
the dune build system, see
|
||||
http://www.dune-project.org/doc/installation-notes.html
|
||||
|
||||
|
||||
DOCUMENTATION
|
||||
|
@ -1,11 +1,27 @@
|
||||
# Build-time flags needed to form example programs
|
||||
AM_CPPFLAGS = \
|
||||
-I$(top_srcdir) \
|
||||
$(OPM_BOOST_CPPFLAGS)
|
||||
$(OPM_BOOST_CPPFLAGS) \
|
||||
${SUPERLU_CPPFLAGS}
|
||||
|
||||
# All targets link to the library
|
||||
LDADD = \
|
||||
$(top_builddir)/lib/libopmcore.la
|
||||
$(top_builddir)/lib/libopmcore.la \
|
||||
$(SUPERLU_LIBS) $(BLAS_LIBS) $(LIBS)
|
||||
|
||||
# Convenience definition for targets that use Boost.Filesystem directly.
|
||||
# While libopmcore depends on (and references) Boost.Filesystem (through
|
||||
# the $(BOOST_FILESYSTEM_LIB) macro) this indirect dependency is not
|
||||
# sufficient to satisfy the requirements of targets that use the indirect
|
||||
# libraries directly.
|
||||
#
|
||||
# Additional details at
|
||||
# https://fedoraproject.org/wiki/UnderstandingDSOLinkChange
|
||||
#
|
||||
LINK_BOOST_FILESYSTEM = \
|
||||
$(OPM_BOOST_LDFLAGS) \
|
||||
$(BOOST_FILESYSTEM_LIB) \
|
||||
$(BOOST_SYSTEM_LIB)
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Declare products (i.e., the example programs).
|
||||
@ -30,9 +46,16 @@ wells_example
|
||||
|
||||
compute_tof_SOURCES = compute_tof.cpp
|
||||
refine_wells_SOURCES = refine_wells.cpp
|
||||
|
||||
sim_2p_comp_reorder_SOURCES = sim_2p_comp_reorder.cpp
|
||||
sim_2p_comp_reorder_LDADD = $(LDADD) $(LINK_BOOST_FILESYSTEM)
|
||||
|
||||
sim_2p_incomp_reorder_SOURCES = sim_2p_incomp_reorder.cpp
|
||||
sim_2p_incomp_reorder_LDADD = $(LDADD) $(LINK_BOOST_FILESYSTEM)
|
||||
|
||||
sim_wateroil_SOURCES = sim_wateroil.cpp
|
||||
sim_wateroil_LDADD = $(LDADD) $(LINK_BOOST_FILESYSTEM)
|
||||
|
||||
wells_example_SOURCES = wells_example.cpp
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
@ -44,5 +67,6 @@ noinst_PROGRAMS += spu_2p
|
||||
spu_2p_SOURCES = spu_2p.cpp
|
||||
spu_2p_LDADD = \
|
||||
$(LDADD) \
|
||||
$(LINK_BOOST_FILESYSTEM) \
|
||||
$(LAPACK_LIBS) $(BLAS_LIBS) $(LIBS)
|
||||
endif
|
||||
|
@ -19,6 +19,7 @@ AX_BOOST_FILESYSTEM
|
||||
AX_BOOST_UNIT_TEST_FRAMEWORK
|
||||
|
||||
AX_DUNE_ISTL
|
||||
DUNE_PATH_SUPERLU
|
||||
OPM_AGMG
|
||||
|
||||
# Checks for header files.
|
||||
|
334
m4/opm_superlu.m4
Normal file
334
m4/opm_superlu.m4
Normal file
@ -0,0 +1,334 @@
|
||||
## -*- autoconf -*-
|
||||
# $Id: superlu.m4 5908 2010-02-23 16:46:05Z joe $
|
||||
# searches for SuperLU headers and libs
|
||||
|
||||
# _slu_lib_path(SUPERLU_ROOT, HEADER)
|
||||
#
|
||||
# Try to find the subpath unter SUPERLU_ROOT containing HEADER. Try
|
||||
# SUPERLU_ROOT/"include/superlu", SUPERLU_ROOT/"include", and
|
||||
# SUPERLU_ROOT/"SRC", in that order. Set the subpath for the library to
|
||||
# "lib". If HEADER was found in SUPERLU_ROOT/"SRC", check whether
|
||||
# SUPERLU_ROOT/"lib" is a directory, and set the subpath for the library to
|
||||
# the empty string "" if it isn't.
|
||||
#
|
||||
# Shell variables:
|
||||
# my_include_path
|
||||
# The subpath HEADER was found in: "include/superlu", "include", or
|
||||
# "SRC". Contents is only meaningful for my_slu_found=yes.
|
||||
# my_lib_path
|
||||
# The subpath for the library: "lib" or "". Contents is only meaningful
|
||||
# for my_slu_found=yes.
|
||||
# my_slu_found
|
||||
# Whether HEADER was found at all. Either "yes" or "no".
|
||||
AC_DEFUN([_slu_lib_path],
|
||||
[
|
||||
my_include_path=include/superlu
|
||||
my_lib_path=lib
|
||||
my_slu_found=yes
|
||||
if test ! -f "$1/$my_include_path/$2" ; then
|
||||
#Try to find headers under superlu
|
||||
my_include_path=include
|
||||
if test ! -f "$1/$my_include_path/$2" ; then
|
||||
my_include_path=SRC
|
||||
if test ! -f "$1/$my_include_path/$2"; then
|
||||
my_slu_found=no
|
||||
else
|
||||
if ! test -d "$1/$my_lib_path"; then
|
||||
my_lib_path=""
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
]
|
||||
)
|
||||
|
||||
# _slu_search_versions(SUPERLU_ROOT)
|
||||
#
|
||||
# Search for either "slu_ddefs.h" or "dsp_defs.h" using _slu_lib_path().
|
||||
#
|
||||
# Shell variables:
|
||||
# my_slu_header
|
||||
# The name of the header that was found: first of "slu_ddefs.h" or
|
||||
# "dsp_defs.h". Contents is only meaningful for my_slu_found=yes.
|
||||
# my_include_path
|
||||
# The subpath the header was found in: "include/superlu", "include", or
|
||||
# "SRC". Contents is only meaningful for my_slu_found=yes.
|
||||
# my_lib_path
|
||||
# The subpath for the library: "lib" or "". Contents is only meaningful
|
||||
# for my_slu_found=yes.
|
||||
# my_slu_found
|
||||
# Whether any of the headers. Either "yes" or "no".
|
||||
AC_DEFUN([_slu_search_versions],
|
||||
[
|
||||
my_slu_header=slu_ddefs.h
|
||||
_slu_lib_path($1, $my_slu_header)
|
||||
if test "$my_slu_found" != "yes"; then
|
||||
my_slu_header="dsp_defs.h"
|
||||
_slu_lib_path($1, $my_slu_header)
|
||||
fi
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
# _slu_search_default()
|
||||
#
|
||||
# Search for SuperLU in the default locations "/usr" and "/usr/local".
|
||||
#
|
||||
# Shell variables:
|
||||
# with_superlu
|
||||
# Root of the SuperLU installation: first of "/usr" and "/usr/local".
|
||||
# Contents is only meaningful for my_slu_found=yes.
|
||||
# For other output variables see documentation of _slu_search_versions().
|
||||
AC_DEFUN([_slu_search_default],
|
||||
[
|
||||
with_superlu=/usr
|
||||
_slu_search_versions($with_superlu)
|
||||
|
||||
if test "$my_slu_found" = "no"; then
|
||||
with_superlu=/usr/local
|
||||
_slu_search_versions($with_superlu)
|
||||
fi
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
# DUNE_PATH_SUPERLU()
|
||||
#
|
||||
# REQUIRES: AC_PROG_CC, AX_BLAS
|
||||
#
|
||||
# Shell variables:
|
||||
# with_superlu
|
||||
# "no", "yes (version 4.3 or newer)", "yes (version 4.2 or older, post 2005)" or "yes (pre 2005)"
|
||||
# direct_SUPERLU_CPPFLAGS
|
||||
# direct_SUPERLU_LIBS
|
||||
# CPPFLAGS and LIBS necessary to link against SuperLU. This variable
|
||||
# contains no indirect references and is suitable for use inside
|
||||
# configure. Guaranteed empty if SuperLU was not found.
|
||||
# SUPERLU_CPPFLAGS
|
||||
# SUPERLU_LIBS
|
||||
# CPPFLAGS and LIBS necessary to link against SuperLU. This variable may
|
||||
# contain indirect references and is suitable for use inside makefiles.
|
||||
# Guaranteed empty if SuperLU was not found.
|
||||
# HAVE_SUPERLU
|
||||
# "0" or "1" depending on whether SuperLU was found.
|
||||
#
|
||||
# Substitutions:
|
||||
# SUPERLU_LIBS
|
||||
# SUPERLU_CPPFLAGS
|
||||
# Substitutes the values of the corresponding shell variables.
|
||||
# ALL_PKG_LIBS
|
||||
# ALL_PKG_CPPFLAGS
|
||||
# Adds references to SuperLU's substitutions.
|
||||
#
|
||||
# Defines:
|
||||
# HAVE_SUPERLU
|
||||
# ENABLE_SUPERLU or undefined. Whether SuperLU was found. The correct
|
||||
# way to check this is "#if HAVE_SUPERLU": This way SuperLU features will
|
||||
# be disabled unless ${SUPERLU_CPPFLAGS} was given when compiling.
|
||||
# SUPERLU_POST_2005_VERSION
|
||||
# 1 or undefined. A post-2005 version of SuperLU uses the header
|
||||
# "slu_ddefs.h" while earlier versions use "dsp_defs.h".
|
||||
# SUPERLU_MIN_VERSION_4_3
|
||||
# 1 or undefined. SuperLU version 4.3 or newer uses the symbol
|
||||
# "SLU_DOUBLE" while earlier versions use "DOUBLE".
|
||||
# HAVE_MEM_USAGE_T_EXPANSIONS
|
||||
# 1 or undefined. Whether "mem_usage_t.expansions" was found in
|
||||
# "slu_ddefs.h" or "dsp_defs.h" as apropriate.
|
||||
#
|
||||
# Conditionals:
|
||||
# SUPERLU
|
||||
AC_DEFUN([DUNE_PATH_SUPERLU],[
|
||||
AC_REQUIRE([AC_PROG_CC])
|
||||
# we need this for FLIBS
|
||||
AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])
|
||||
AC_REQUIRE([AX_BLAS])
|
||||
|
||||
#
|
||||
# User hints ...
|
||||
#
|
||||
my_lib_path=""
|
||||
my_include_path=""
|
||||
AC_ARG_WITH([superlu],
|
||||
[AC_HELP_STRING([--with-superlu],[user defined path to SuperLU library])],
|
||||
[dnl
|
||||
if test x"$withval" != xno ; then
|
||||
# get absolute path
|
||||
with_superlu=`eval cd $withval 2>&1 && pwd`
|
||||
if test x"$withval" = xyes; then
|
||||
# Search in default locations
|
||||
_slu_search_default
|
||||
else
|
||||
# Search for the headers in the specified location
|
||||
_slu_search_versions(["$with_superlu"])
|
||||
fi
|
||||
fi
|
||||
], [dnl
|
||||
# Search in default locations
|
||||
_slu_search_default
|
||||
])
|
||||
|
||||
AC_ARG_WITH([superlu-lib],
|
||||
[AC_HELP_STRING([--with-superlu-lib],
|
||||
[The name of the static SuperLU library to link to. By default
|
||||
the static library with the name superlu.a is tried, but
|
||||
only if shared linking has failed first. Giving this
|
||||
options forces static linking for SuperLU.])],
|
||||
[
|
||||
if test x"$withval" = xno ; then
|
||||
with_superlu_lib=
|
||||
fi
|
||||
])
|
||||
|
||||
AC_ARG_WITH([superlu-blaslib],
|
||||
[AC_HELP_STRING([--with-superlu-blaslib],
|
||||
[The name of the static blas library to link to. By default
|
||||
we try to link to the systems blas library (see
|
||||
--with-blas). Giving this options forces static linking
|
||||
for SuperLU.])],
|
||||
[
|
||||
if test "$withval" = no ; then
|
||||
with_superlu_blaslib=
|
||||
fi
|
||||
])
|
||||
|
||||
# store old values
|
||||
ac_save_LDFLAGS="$LDFLAGS"
|
||||
ac_save_CPPFLAGS="$CPPFLAGS"
|
||||
ac_save_LIBS="$LIBS"
|
||||
|
||||
# do nothing if --without-superlu is used
|
||||
if test x"$with_superlu" != x"no" ; then
|
||||
# defaultpath
|
||||
SUPERLU_LIB_PATH="$with_superlu/$my_lib_path"
|
||||
SUPERLU_INCLUDE_PATH="$with_superlu/$my_include_path"
|
||||
|
||||
# set variables so that tests can use them
|
||||
direct_SUPERLU_CPPFLAGS="-I$SUPERLU_INCLUDE_PATH -DENABLE_SUPERLU"
|
||||
SUPERLU_CPPFLAGS="-I$SUPERLU_INCLUDE_PATH -DENABLE_SUPERLU"
|
||||
CPPFLAGS="$CPPFLAGS $direct_SUPERLU_CPPFLAGS"
|
||||
|
||||
# check for central header
|
||||
AC_CHECK_HEADER([$my_slu_header],
|
||||
[HAVE_SUPERLU="1"],
|
||||
[
|
||||
HAVE_SUPERLU="0"
|
||||
AC_MSG_WARN([$my_slu_header not found in $SUPERLU_INCLUDE_PATH with $CPPFLAGS])
|
||||
])
|
||||
|
||||
# if header is found check for the libs
|
||||
if test x$HAVE_SUPERLU = x1 ; then
|
||||
HAVE_SUPERLU=0
|
||||
|
||||
# if neither --with-superlu-lib nor --with-superlu-blaslib was
|
||||
# given, try to link dynamically or with properly names static libs
|
||||
if test x"$with_superlu_lib$with_superlu_blaslib" = x; then
|
||||
LDFLAGS="$ac_save_LDFLAGS -L$SUPERLU_LIB_PATH"
|
||||
LIBS="$ac_save_LIBS"
|
||||
AC_CHECK_LIB([superlu], [dgssvx],
|
||||
[
|
||||
direct_SUPERLU_LIBS="-L$SUPERLU_LIB_PATH -lsuperlu $BLAS_LIBS $FLIBS"
|
||||
SUPERLU_LIBS="-L$SUPERLU_LIB_PATH -lsuperlu \${BLAS_LIBS} \${FLIBS}"
|
||||
HAVE_SUPERLU="1"
|
||||
], [], [$BLAS_LIBS $FLIBS])
|
||||
fi
|
||||
|
||||
if test $HAVE_SUPERLU = 0 && test x"$with_superlu_lib" = x; then
|
||||
# set the default
|
||||
with_superlu_lib=superlu.a
|
||||
fi
|
||||
|
||||
if test $HAVE_SUPERLU = 0 &&
|
||||
test x"$with_superlu_blaslib" = x; then
|
||||
# try system blas
|
||||
LDFLAGS="$ac_save_LDFLAGS"
|
||||
LIBS="$SUPERLU_LIB_PATH/$with_superlu_lib $BLAS_LIBS $FLIBS $ac_save_LIBS"
|
||||
AC_CHECK_FUNC([dgssvx],
|
||||
[
|
||||
direct_SUPERLU_LIBS="$SUPERLU_LIB_PATH/$with_superlu_lib $BLAS_LIBS $FLIBS"
|
||||
SUPERLU_LIBS="$SUPERLU_LIB_PATH/$with_superlu_lib \${BLAS_LIBS} \${FLIBS}"
|
||||
HAVE_SUPERLU="1"
|
||||
])
|
||||
fi
|
||||
|
||||
# No default for with_superlu_blaslib
|
||||
|
||||
if test $HAVE_SUPERLU = 0 &&
|
||||
test x"$with_superlu_blaslib" != x; then
|
||||
# try internal blas
|
||||
LDFLAGS="$ac_save_LDFLAGS"
|
||||
LIBS="$SUPERLU_LIB_PATH/$with_superlu_lib $SUPERLU_LIB_PATH/$with_superlu_blaslib $FLIBS $ac_save_LIBS"
|
||||
AC_CHECK_FUNC([dgssvx],
|
||||
[
|
||||
direct_SUPERLU_LIBS="$SUPERLU_LIB_PATH/$with_superlu_lib $SUPERLU_LIB_PATH/$with_superlu_blaslib $FLIBS"
|
||||
SUPERLU_LIBS="$SUPERLU_LIB_PATH/$with_superlu_lib $SUPERLU_LIB_PATH/$with_superlu_blaslib \${FLIBS}"
|
||||
HAVE_SUPERLU="1"
|
||||
])
|
||||
fi
|
||||
|
||||
# test whether SuperLU version is at least 4.3
|
||||
if test $HAVE_SUPERLU = "1" ; then
|
||||
AC_CHECK_DECL([SLU_DOUBLE], [SUPERLU_MIN_VERSION_4_3="1"], [], [#include <$my_slu_header>])
|
||||
fi
|
||||
fi
|
||||
|
||||
else # $with_superlu = no
|
||||
HAVE_SUPERLU=0
|
||||
fi
|
||||
|
||||
# Inform the user whether SuperLU was sucessfully found
|
||||
AC_MSG_CHECKING([SuperLU])
|
||||
if test x$HAVE_SUPERLU = x1 ; then
|
||||
if test "$my_slu_header" = "slu_ddefs.h"; then
|
||||
if test x$SUPERLU_MIN_VERSION_4_3 = x1 ; then
|
||||
with_superlu="yes (version 4.3 or newer)"
|
||||
else
|
||||
with_superlu="yes (version 4.2 or older, post 2005)"
|
||||
fi
|
||||
else
|
||||
with_superlu="yes (pre 2005)"
|
||||
fi
|
||||
else
|
||||
with_superlu="no"
|
||||
fi
|
||||
AC_MSG_RESULT([$with_superlu])
|
||||
|
||||
# check for optional member
|
||||
if test $HAVE_SUPERLU = 1 ; then
|
||||
if test "$my_slu_header" = "slu_ddefs.h"; then
|
||||
AC_CHECK_MEMBERS([mem_usage_t.expansions],[],[],[#include "slu_ddefs.h"])
|
||||
else
|
||||
AC_CHECK_MEMBERS([mem_usage_t.expansions],[],[],[#include "dsp_defs.h"])
|
||||
fi
|
||||
fi
|
||||
|
||||
# substitute variables
|
||||
if test x$HAVE_SUPERLU = x0 ; then
|
||||
SUPERLU_LIBS=
|
||||
SUPERLU_CPPFLAGS=
|
||||
fi
|
||||
AC_SUBST([SUPERLU_LIBS])
|
||||
AC_SUBST([SUPERLU_CPPFLAGS])
|
||||
#DUNE_ADD_ALL_PKG([SUPERLU], [\${SUPERLU_CPPFLAGS}], [], [\${SUPERLU_LIBS}])
|
||||
|
||||
# tell automake
|
||||
AM_CONDITIONAL(SUPERLU, test x$HAVE_SUPERLU = x1)
|
||||
|
||||
# tell the preprocessor
|
||||
if test x$HAVE_SUPERLU = x1 ; then
|
||||
AC_DEFINE([HAVE_SUPERLU], [ENABLE_SUPERLU], [Define to ENABLE_SUPERLU if SUPERLU is found])
|
||||
if test "$my_slu_header" = "slu_ddefs.h"; then
|
||||
AC_DEFINE([SUPERLU_POST_2005_VERSION], 1, [define to 1 if there is a header slu_ddefs.h in SuperLU])
|
||||
if test x$SUPERLU_MIN_VERSION_4_3 = x1 ; then
|
||||
AC_DEFINE([SUPERLU_MIN_VERSION_4_3], 1, [define to 1 if there SLU_DOUBLE imported by header slu_ddefs.h from SuperLU])
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# summary
|
||||
#DUNE_ADD_SUMMARY_ENTRY([SuperLU],[$with_superlu])
|
||||
|
||||
# restore variables
|
||||
LDFLAGS="$ac_save_LDFLAGS"
|
||||
CPPFLAGS="$ac_save_CPPFLAGS"
|
||||
LIBS="$ac_save_LIBS"
|
||||
])
|
@ -468,6 +468,8 @@ add_well(enum WellType type ,
|
||||
|
||||
struct WellMgmt *m;
|
||||
|
||||
assert (W != NULL);
|
||||
|
||||
nw = W->number_of_wells;
|
||||
nperf_tot = W->well_connpos[nw];
|
||||
|
||||
@ -532,6 +534,7 @@ append_well_controls(enum WellControlType type,
|
||||
struct WellControlMgmt *m;
|
||||
|
||||
assert (W != NULL);
|
||||
assert ((0 <= well_index) && (well_index < W->number_of_wells));
|
||||
|
||||
ctrl = W->ctrls[well_index];
|
||||
np = W->number_of_phases;
|
||||
@ -567,8 +570,13 @@ void
|
||||
set_current_control(int well_index, int current_control, struct Wells *W)
|
||||
/* ---------------------------------------------------------------------- */
|
||||
{
|
||||
assert (W != NULL);
|
||||
assert ((0 <= well_index) && (well_index < W->number_of_wells));
|
||||
|
||||
assert (W->ctrls[well_index] != NULL);
|
||||
|
||||
assert (current_control < W->ctrls[well_index]->num);
|
||||
|
||||
W->ctrls[well_index]->current = current_control;
|
||||
}
|
||||
|
||||
@ -578,7 +586,85 @@ void
|
||||
clear_well_controls(int well_index, struct Wells *W)
|
||||
/* ---------------------------------------------------------------------- */
|
||||
{
|
||||
assert (W != NULL);
|
||||
assert ((0 <= well_index) && (well_index < W->number_of_wells));
|
||||
|
||||
if (W->ctrls[well_index] != NULL) {
|
||||
W->ctrls[well_index]->num = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
struct Wells *
|
||||
clone_wells(const struct Wells *W)
|
||||
/* ---------------------------------------------------------------------- */
|
||||
{
|
||||
int c, np, nperf, ok, pos, w;
|
||||
double target;
|
||||
const int *cells;
|
||||
const double *WI, *comp_frac, *distr;
|
||||
enum WellControlType type;
|
||||
const struct WellControls *ctrls;
|
||||
|
||||
struct Wells *ret;
|
||||
|
||||
if (W == NULL) {
|
||||
ret = NULL;
|
||||
}
|
||||
else {
|
||||
np = W->number_of_phases;
|
||||
ret = create_wells(W->number_of_phases, W->number_of_wells,
|
||||
W->well_connpos[ W->number_of_wells ]);
|
||||
|
||||
if (ret != NULL) {
|
||||
pos = W->well_connpos[ 0 ];
|
||||
ok = 1;
|
||||
|
||||
for (w = 0; ok && (w < W->number_of_wells); w++) {
|
||||
nperf = W->well_connpos[w + 1] - pos;
|
||||
cells = W->well_cells + pos;
|
||||
|
||||
WI = W->WI != NULL ? W->WI + pos : NULL;
|
||||
comp_frac = W->comp_frac != NULL ? W->comp_frac + w*np : NULL;
|
||||
|
||||
ok = add_well(W->type[ w ], W->depth_ref[ w ], nperf,
|
||||
comp_frac, cells, WI, W->name[ w ], ret);
|
||||
|
||||
/* Capacity should be sufficient from create_wells() */
|
||||
assert (ok);
|
||||
|
||||
ctrls = W->ctrls[ w ];
|
||||
|
||||
if (ok) {
|
||||
ok = well_controls_reserve(ctrls->num, np, ret->ctrls[ w ]);
|
||||
|
||||
for (c = 0; ok && (c < ctrls->num); c++) {
|
||||
type = ctrls->type [ c ];
|
||||
target = ctrls->target[ c ];
|
||||
distr = & ctrls->distr [ c * np ];
|
||||
|
||||
ok = append_well_controls(type, target, distr, w, ret);
|
||||
|
||||
/* Capacity *should* be sufficient from
|
||||
* well_controls_reserve() */
|
||||
assert (ok);
|
||||
}
|
||||
}
|
||||
|
||||
if (ok) {
|
||||
set_current_control(w, ctrls->current, ret);
|
||||
}
|
||||
|
||||
pos = W->well_connpos[w + 1];
|
||||
}
|
||||
|
||||
if (! ok) {
|
||||
destroy_wells(ret);
|
||||
ret = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -235,6 +235,19 @@ void
|
||||
destroy_wells(struct Wells *W);
|
||||
|
||||
|
||||
/**
|
||||
* Create a deep-copy (i.e., clone) of an existing Wells object, including its
|
||||
* controls.
|
||||
*
|
||||
* @param[in] W Existing Wells object.
|
||||
* @return Complete clone of the input object. Dispose of resources using
|
||||
* function destroy_wells() when no longer needed. Returns @c NULL in case of
|
||||
* allocation failure.
|
||||
*/
|
||||
struct Wells *
|
||||
clone_wells(const struct Wells *W);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -226,6 +226,14 @@ namespace Opm
|
||||
|
||||
|
||||
|
||||
/// Construct from existing wells object.
|
||||
WellsManager::WellsManager(struct Wells* W)
|
||||
: w_(clone_wells(W))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// Construct wells from deck.
|
||||
WellsManager::WellsManager(const Opm::EclipseGridParser& deck,
|
||||
const UnstructuredGrid& grid,
|
||||
|
@ -41,7 +41,14 @@ namespace Opm
|
||||
{
|
||||
public:
|
||||
/// Default constructor -- no wells.
|
||||
WellsManager();
|
||||
WellsManager();
|
||||
|
||||
/// Construct from existing wells object.
|
||||
/// WellsManager is not properly initialised in the sense that the logic to
|
||||
/// manage control switching does not exist.
|
||||
///
|
||||
/// @param[in] W Existing wells object.
|
||||
WellsManager(struct Wells* W);
|
||||
|
||||
/// Construct from input deck and grid.
|
||||
/// The permeability argument may be zero if the input contain
|
||||
|
@ -1,6 +1,6 @@
|
||||
AM_CPPFLAGS = \
|
||||
-I$(top_srcdir) \
|
||||
$(OPM_BOOST_CPPFLAGS)
|
||||
$(OPM_BOOST_CPPFLAGS) ${SUPERLU_CPPFLAGS}
|
||||
|
||||
AM_LDFLAGS = $(OPM_BOOST_LDFLAGS)
|
||||
|
||||
@ -23,6 +23,7 @@ test_read_grid \
|
||||
test_read_vag \
|
||||
test_readpolymer \
|
||||
test_sf2p \
|
||||
test_wells \
|
||||
test_writeVtkData \
|
||||
unit_test
|
||||
|
||||
@ -59,6 +60,9 @@ test_sf2p_SOURCES = test_sf2p.cpp
|
||||
|
||||
test_writeVtkData_SOURCES = test_writeVtkData.cpp
|
||||
|
||||
test_wells_SOURCES = test_wells.cpp
|
||||
test_wells_LDADD = $(LDADD) $(BOOST_UNIT_TEST_FRAMEWORK_LIB)
|
||||
|
||||
unit_test_SOURCES = unit_test.cpp
|
||||
|
||||
|
||||
|
205
tests/test_wells.cpp
Normal file
205
tests/test_wells.cpp
Normal file
@ -0,0 +1,205 @@
|
||||
/*
|
||||
Copyright 2012 SINTEF ICT, Applied Mathematics.
|
||||
|
||||
This file is part of the Open Porous Media project (OPM).
|
||||
|
||||
OPM is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OPM is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#if HAVE_DYNAMIC_BOOST_TEST
|
||||
#define BOOST_TEST_DYN_LINK
|
||||
#endif
|
||||
|
||||
#define NVERBOSE // Suppress own messages when throw()ing
|
||||
|
||||
#define BOOST_TEST_MODULE WellsModuleTest
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <opm/core/newwells.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Construction)
|
||||
{
|
||||
const int nphases = 2;
|
||||
const int nwells = 2;
|
||||
const int nperfs = 2;
|
||||
|
||||
boost::shared_ptr<Wells> W(create_wells(nphases, nwells, nperfs),
|
||||
destroy_wells);
|
||||
|
||||
if (W) {
|
||||
int cells[] = { 0, 9 };
|
||||
double WI = 1.0;
|
||||
const double ifrac[] = { 1.0, 0.0 };
|
||||
|
||||
const bool ok0 = add_well(INJECTOR, 0.0, 1, &ifrac[0], &cells[0],
|
||||
&WI, "INJECTOR", W.get());
|
||||
|
||||
const double pfrac[] = { 0.0, 0.0 };
|
||||
const bool ok1 = add_well(PRODUCER, 0.0, 1, &pfrac[0], &cells[1],
|
||||
&WI, "PRODUCER", W.get());
|
||||
|
||||
if (ok0 && ok1) {
|
||||
BOOST_CHECK_EQUAL(W->number_of_phases, nphases);
|
||||
BOOST_CHECK_EQUAL(W->number_of_wells , nwells );
|
||||
|
||||
BOOST_CHECK_EQUAL(W->well_connpos[0], 0);
|
||||
BOOST_CHECK_EQUAL(W->well_connpos[1], 1);
|
||||
BOOST_CHECK_EQUAL(W->well_connpos[W->number_of_wells], nperfs);
|
||||
|
||||
BOOST_CHECK_EQUAL(W->well_cells[W->well_connpos[0]], cells[0]);
|
||||
BOOST_CHECK_EQUAL(W->well_cells[W->well_connpos[1]], cells[1]);
|
||||
|
||||
BOOST_CHECK_EQUAL(W->WI[W->well_connpos[0]], WI);
|
||||
BOOST_CHECK_EQUAL(W->WI[W->well_connpos[1]], WI);
|
||||
|
||||
using std::string;
|
||||
BOOST_CHECK_EQUAL(string(W->name[0]), string("INJECTOR"));
|
||||
BOOST_CHECK_EQUAL(string(W->name[1]), string("PRODUCER"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Controls)
|
||||
{
|
||||
const int nphases = 2;
|
||||
const int nwells = 1;
|
||||
const int nperfs = 2;
|
||||
|
||||
boost::shared_ptr<Wells> W(create_wells(nphases, nwells, nperfs),
|
||||
destroy_wells);
|
||||
|
||||
if (W) {
|
||||
int cells[] = { 0 , 9 };
|
||||
double WI [] = { 1.0, 1.0 };
|
||||
const double ifrac[] = { 1.0, 0.0 };
|
||||
|
||||
const bool ok = add_well(INJECTOR, 0.0, nperfs, &ifrac[0], &cells[0],
|
||||
&WI[0], "INJECTOR", W.get());
|
||||
|
||||
if (ok) {
|
||||
const double distr[] = { 1.0, 0.0 };
|
||||
const bool ok1 = append_well_controls(BHP, 1, &distr[0],
|
||||
0, W.get());
|
||||
const bool ok2 = append_well_controls(SURFACE_RATE, 1,
|
||||
&distr[0], 0, W.get());
|
||||
|
||||
if (ok1 && ok2) {
|
||||
WellControls* ctrls = W->ctrls[0];
|
||||
|
||||
BOOST_CHECK_EQUAL(ctrls->num , 2);
|
||||
BOOST_CHECK_EQUAL(ctrls->current, -1);
|
||||
|
||||
set_current_control(0, 0, W.get());
|
||||
BOOST_CHECK_EQUAL(ctrls->current, 0);
|
||||
|
||||
set_current_control(0, 1, W.get());
|
||||
BOOST_CHECK_EQUAL(ctrls->current, 1);
|
||||
|
||||
BOOST_CHECK_EQUAL(ctrls->type[0], BHP);
|
||||
BOOST_CHECK_EQUAL(ctrls->type[1], SURFACE_RATE);
|
||||
|
||||
BOOST_CHECK_EQUAL(ctrls->target[0], 1.0);
|
||||
BOOST_CHECK_EQUAL(ctrls->target[1], 1.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Copy)
|
||||
{
|
||||
const int nphases = 2;
|
||||
const int nwells = 2;
|
||||
const int nperfs = 2;
|
||||
|
||||
boost::shared_ptr<Wells> W1(create_wells(nphases, nwells, nperfs),
|
||||
destroy_wells);
|
||||
boost::shared_ptr<Wells> W2;
|
||||
|
||||
if (W1) {
|
||||
int cells[] = { 0, 9 };
|
||||
const double WI = 1.0;
|
||||
const double ifrac[] = { 1.0, 0.0 };
|
||||
|
||||
const bool ok0 = add_well(INJECTOR, 0.0, 1, &ifrac[0], &cells[0],
|
||||
&WI, "INJECTOR", W1.get());
|
||||
|
||||
const double pfrac[] = { 0.0, 0.0 };
|
||||
const bool ok1 = add_well(PRODUCER, 0.0, 1, &pfrac[0], &cells[1],
|
||||
&WI, "PRODUCER", W1.get());
|
||||
|
||||
bool ok = ok0 && ok1;
|
||||
for (int w = 0; ok && (w < W1->number_of_wells); ++w) {
|
||||
const double distr[] = { 1.0, 0.0 };
|
||||
const bool okc1 = append_well_controls(BHP, 1, &distr[0],
|
||||
w, W1.get());
|
||||
const bool okc2 = append_well_controls(SURFACE_RATE, 1,
|
||||
&distr[0], w,
|
||||
W1.get());
|
||||
|
||||
ok = okc1 && okc2;
|
||||
}
|
||||
|
||||
if (ok) {
|
||||
W2.reset(clone_wells(W1.get()), destroy_wells);
|
||||
}
|
||||
}
|
||||
|
||||
if (W2) {
|
||||
BOOST_CHECK_EQUAL(W2->number_of_phases, W1->number_of_phases);
|
||||
BOOST_CHECK_EQUAL(W2->number_of_wells , W1->number_of_wells );
|
||||
BOOST_CHECK_EQUAL(W2->well_connpos[0] , W1->well_connpos[0] );
|
||||
|
||||
for (int w = 0; w < W1->number_of_wells; ++w) {
|
||||
using std::string;
|
||||
BOOST_CHECK_EQUAL(string(W2->name[w]), string(W1->name[w]));
|
||||
BOOST_CHECK_EQUAL( W2->type[w] , W1->type[w] );
|
||||
|
||||
BOOST_CHECK_EQUAL(W2->well_connpos[w + 1],
|
||||
W1->well_connpos[w + 1]);
|
||||
|
||||
for (int j = W1->well_connpos[w];
|
||||
j < W1->well_connpos[w + 1]; ++j) {
|
||||
BOOST_CHECK_EQUAL(W2->well_cells[j], W1->well_cells[j]);
|
||||
BOOST_CHECK_EQUAL(W2->WI [j], W1->WI [j]);
|
||||
}
|
||||
|
||||
BOOST_CHECK(W1->ctrls[w] != 0);
|
||||
BOOST_CHECK(W2->ctrls[w] != 0);
|
||||
|
||||
WellControls* c1 = W1->ctrls[w];
|
||||
WellControls* c2 = W2->ctrls[w];
|
||||
|
||||
BOOST_CHECK_EQUAL(c2->num , c1->num );
|
||||
BOOST_CHECK_EQUAL(c2->current, c1->current);
|
||||
|
||||
for (int c = 0; c < c1->num; ++c) {
|
||||
BOOST_CHECK_EQUAL(c2->type [c], c1->type [c]);
|
||||
BOOST_CHECK_EQUAL(c2->target[c], c1->target[c]);
|
||||
|
||||
for (int p = 0; p < W1->number_of_phases; ++p) {
|
||||
BOOST_CHECK_EQUAL(c2->distr[c*W1->number_of_phases + p],
|
||||
c1->distr[c*W1->number_of_phases + p]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +1,10 @@
|
||||
AM_CPPFLAGS = \
|
||||
-I$(top_srcdir) \
|
||||
$(OPM_BOOST_CPPFLAGS)
|
||||
$(OPM_BOOST_CPPFLAGS) \
|
||||
${SUPERLU_CPPFLAGS}
|
||||
|
||||
AM_LDFLAGS = $(OPM_BOOST_LDFLAGS)
|
||||
AM_LDFLAGS = $(OPM_BOOST_LDFLAGS) \
|
||||
${SUPERLU_LIBS} $(BLAS_LIBS) $(LIBS)
|
||||
|
||||
LDADD = $(top_builddir)/lib/libopmcore.la
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user