mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Merge remote-tracking branch 'atgeirr/spe9-fixes'
This commit is contained in:
@@ -232,14 +232,6 @@ if (UMFPACK_LIBRARY)
|
||||
set (UMFPACK_EXTRA_LIBS "-NOTFOUND")
|
||||
endif (CHOLMOD_LIBRARIES)
|
||||
endif (HAVE_UMFPACK_WITHOUT_CHOLMOD)
|
||||
# test if umfpack is underlinked (CentOS 5.9), i.e. doesn't specify
|
||||
# that it depends on amd. in that case, force amd to be linked
|
||||
if (UMFPACK_EXTRA_LIBS AND (CMAKE_CXX_PLATFORM_ID STREQUAL "Linux") AND CMAKE_COMPILER_IS_GNUCC)
|
||||
try_compile_umfpack (HAVE_UMFPACK_NOT_UNDERLINKED "-Wl,--as-needed" ${UMFPACK_EXTRA_LIBS})
|
||||
if (NOT HAVE_UMFPACK_NOT_UNDERLINKED)
|
||||
list (APPEND UMFPACK_LINKER_FLAGS "-Wl,--no-as-needed")
|
||||
endif (NOT HAVE_UMFPACK_NOT_UNDERLINKED)
|
||||
endif (UMFPACK_EXTRA_LIBS AND (CMAKE_CXX_PLATFORM_ID STREQUAL "Linux") AND CMAKE_COMPILER_IS_GNUCC)
|
||||
list (APPEND UMFPACK_LIBRARIES ${UMFPACK_EXTRA_LIBS})
|
||||
list (REVERSE UMFPACK_LIBRARIES)
|
||||
list (REMOVE_DUPLICATES UMFPACK_LIBRARIES)
|
||||
|
||||
112
cmake/Modules/FindUG.cmake
Normal file
112
cmake/Modules/FindUG.cmake
Normal file
@@ -0,0 +1,112 @@
|
||||
#
|
||||
# This module first tests for UG and then sets the necessary flags
|
||||
# and config.h defines. If UG is found UG_FOUND will be true.
|
||||
#
|
||||
|
||||
# this function is required in order not to pollute the global
|
||||
# namespace with the macros defined in ug-config*.cmake
|
||||
function(opmFindUg)
|
||||
if(NOT UG_ROOT)
|
||||
# check whether UG is in /usr/local
|
||||
if(EXISTS "/usr/local/include/ug")
|
||||
set(UG_ROOT "/usr/local")
|
||||
|
||||
# check whether UG is in /usr
|
||||
elseif(EXISTS "/usr/include/ug")
|
||||
set(UG_ROOT "/usr")
|
||||
|
||||
# oops
|
||||
else()
|
||||
message(STATUS "Could not find UG. It seems to be not installed.")
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(UG_ROOT AND NOT UG_DIR)
|
||||
# define the directory where the config file resides
|
||||
if(EXISTS "${UG_ROOT}/lib/cmake/ug/ug-config.cmake")
|
||||
set(UG_DIR ${UG_ROOT}/lib/cmake/ug)
|
||||
elseif(EXISTS "${UG_ROOT}/lib64/cmake/ug/ug-config.cmake")
|
||||
set(UG_DIR ${UG_ROOT}/lib64/cmake/ug)
|
||||
else()
|
||||
message(WARNING "Could not find file ug-config.cmake relative to given UG_ROOT")
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# include the config mode files kindly provided by UG...
|
||||
include(${UG_DIR}/ug-config-version.cmake)
|
||||
include(${UG_DIR}/ug-config.cmake)
|
||||
|
||||
set(UG_FOUND "1")
|
||||
if(NOT UG_FOR_DUNE STREQUAL "yes")
|
||||
set(UG_FOUND "0")
|
||||
message(WARNING "UG was not configured for DUNE. Did pass --enable-dune to its configure?")
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(HAVE_UG ${UG_FOUND})
|
||||
|
||||
# parse version
|
||||
string(REGEX REPLACE "([0-9]*)\\.[0-9]*\\..*" "\\1" UG_VERSION_MAJOR "${PACKAGE_VERSION}")
|
||||
string(REGEX REPLACE "[0-9]*\\.([0-9]*)\\..*" "\\1" UG_VERSION_MINOR "${PACKAGE_VERSION}")
|
||||
string(REGEX REPLACE "[0-9]*\\.[0-9]*\\.([0-9]*).*" "\\1" UG_VERSION_REVISION "${PACKAGE_VERSION}")
|
||||
|
||||
string(REGEX REPLACE ".*-patch([0-9]*)" "\\1" TMP "${PACKAGE_VERSION}")
|
||||
if(TMP STREQUAL "${PACKAGE_VERSION}")
|
||||
set(UG_VERSION_PATCHLEVEL "")
|
||||
else()
|
||||
set(UG_VERSION_PATCHLEVEL "${TMP}")
|
||||
endif()
|
||||
|
||||
# Adjust compiler/linker arguments
|
||||
set(UG_LIBRARY_DIR "${libdir}")
|
||||
|
||||
foreach (UG_RAW_LIB "-lugS2" "-lugS3" "-ldevS")
|
||||
string(REGEX REPLACE "-l(.*)" "\\1" UG_LIB "${UG_RAW_LIB}")
|
||||
set(UG_LIB_FILE "${UG_LIBRARY_DIR}/lib${UG_LIB}.a")
|
||||
if (EXISTS "${UG_LIB_FILE}")
|
||||
set(UG_LIBS "${UG_LIBS}" ${UG_LIB_FILE})
|
||||
else()
|
||||
set(UG_LIBS "${UG_LIBS}" ${UG_LIB})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
set(UG_LIBRARIES "${UG_LIBS}")
|
||||
|
||||
# export all variables which need to be seen globally
|
||||
set(UG_FOUND "${UG_FOUND}" PARENT_SCOPE)
|
||||
set(HAVE_UG "${HAVE_UG}" PARENT_SCOPE)
|
||||
set(UG_INCLUDE_DIRS "${UG_INCLUDES}" PARENT_SCOPE)
|
||||
set(UG_LIBRARIES "${UG_LIBRARIES}" PARENT_SCOPE)
|
||||
set(UG_VERSION_MAJOR "${UG_VERSION_MAJOR}" PARENT_SCOPE)
|
||||
set(UG_VERSION_MINOR "${UG_VERSION_MINOR}" PARENT_SCOPE)
|
||||
set(UG_VERSION_REVISION "${UG_VERSION_REVISION}" PARENT_SCOPE)
|
||||
set(UG_VERSION_PATCHLEVEL "${UG_VERSION_PATCHLEVEL}" PARENT_SCOPE)
|
||||
|
||||
set(UG_DEFINITIONS "${UG_COMPILE_FLAGS}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
if (NOT HAVE_UG)
|
||||
opmFindUg()
|
||||
|
||||
set(HAVE_UG "${HAVE_UG}" CACHE BOOL "UG library is available")
|
||||
set(UG_INCLUDE_DIRS "${UG_INCLUDE_DIRS}" CACHE STRING "Directory containing the headers of the UG library")
|
||||
set(UG_LIBRARIES "${UG_LIBRARIES}" CACHE STRING "The libraries which need to be linked to be able to use the UG library")
|
||||
set(UG_DEFINITIONS "${UG_DEFINITIONS}" CACHE STRING "The compiler flags for the UG library")
|
||||
set(UG_VERSION_MAJOR "${UG_VERSION_MAJOR}" CACHE INT "Major version of the UG release")
|
||||
set(UG_VERSION_MINOR "${UG_VERSION_MINOR}" CACHE INT "Minor version of the UG release")
|
||||
set(UG_VERSION_REVISION "${UG_VERSION_REVISION}" CACHE INT "Revision of the UG release")
|
||||
set(UG_VERSION_PATCHLEVEL "${UG_VERSION_PATCHLEVEL}" CACHE INT "Patchlevel of the UG release")
|
||||
|
||||
mark_as_advanced(HAVE_UG)
|
||||
mark_as_advanced(UG_INCLUDE_DIRS)
|
||||
mark_as_advanced(UG_LIBRARIES)
|
||||
mark_as_advanced(UG_DEFINITIONS)
|
||||
mark_as_advanced(UG_VERSION_MAJOR)
|
||||
mark_as_advanced(UG_VERSION_MINOR)
|
||||
mark_as_advanced(UG_VERSION_REVISION)
|
||||
mark_as_advanced(UG_VERSION_PATCHLEVEL)
|
||||
else()
|
||||
set(UG_FOUND "0")
|
||||
endif()
|
||||
@@ -23,7 +23,8 @@ find_opm_package (
|
||||
dune-common REQUIRED;
|
||||
dune-geometry REQUIRED;
|
||||
MPI;
|
||||
ALUGrid
|
||||
ALUGrid;
|
||||
UG
|
||||
"
|
||||
# header to search for
|
||||
"dune/grid/onedgrid.hh"
|
||||
|
||||
@@ -23,9 +23,11 @@ function (prepend var_name value)
|
||||
endif (NOT ("${_var_pre}" STREQUAL "${value}"))
|
||||
endfunction (prepend var_name value)
|
||||
|
||||
option (ONLY_NEEDED_LIBRARIES "Instruct the linker to not use libraries which are unused" OFF)
|
||||
|
||||
# only ELF shared objects can be underlinked, and only GNU will accept
|
||||
# these parameters; otherwise just leave it to the defaults
|
||||
if ((CMAKE_CXX_PLATFORM_ID STREQUAL "Linux") AND CMAKE_COMPILER_IS_GNUCC)
|
||||
if ((CMAKE_CXX_PLATFORM_ID STREQUAL "Linux") AND CMAKE_COMPILER_IS_GNUCC AND ONLY_NEEDED_LIBRARIES)
|
||||
# these are the modules whose probes will turn up incompatible
|
||||
# flags on some systems
|
||||
set (_maybe_underlinked
|
||||
@@ -45,4 +47,4 @@ if ((CMAKE_CXX_PLATFORM_ID STREQUAL "Linux") AND CMAKE_COMPILER_IS_GNUCC)
|
||||
prepend (CMAKE_MODULE_LINKER_FLAGS "-Wl,--as-needed")
|
||||
prepend (CMAKE_SHARED_LINKER_FLAGS "-Wl,--as-needed")
|
||||
endif (NOT _underlinked)
|
||||
endif ((CMAKE_CXX_PLATFORM_ID STREQUAL "Linux") AND CMAKE_COMPILER_IS_GNUCC)
|
||||
endif ((CMAKE_CXX_PLATFORM_ID STREQUAL "Linux") AND CMAKE_COMPILER_IS_GNUCC AND ONLY_NEEDED_LIBRARIES)
|
||||
|
||||
@@ -12,3 +12,20 @@ if (CXX_COMPAT_GCC)
|
||||
add_options (ALL_LANGUAGES ALL_BUILDS "${_warn_flag}")
|
||||
endif (_warn_flag)
|
||||
endif ()
|
||||
|
||||
option(SILENCE_EXTERNAL_WARNINGS "Disable some warnings from external packages (requires GCC 4.6 or newer)" OFF)
|
||||
if(SILENCE_EXTERNAL_WARNINGS AND CXX_COMPAT_GCC)
|
||||
file(WRITE ${CMAKE_BINARY_DIR}/disable_warning_pragmas.h "
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored \"-Wdeprecated-declarations\"
|
||||
#pragma GCC diagnostic ignored \"-Wdeprecated-register\"
|
||||
#pragma GCC diagnostic ignored \"-Wignored-qualifiers\"
|
||||
#pragma GCC diagnostic ignored \"-Wmismatched-tags\"
|
||||
#pragma GCC diagnostic ignored \"-Wshadow\"
|
||||
#pragma GCC diagnostic ignored \"-Wsign-compare\"
|
||||
#pragma GCC diagnostic ignored \"-Wunused-parameter\"")
|
||||
file(WRITE ${CMAKE_BINARY_DIR}/reenable_warning_pragmas.h "#pragma GCC diagnostic pop")
|
||||
else()
|
||||
file(WRITE ${CMAKE_BINARY_DIR}/disable_warning_pragmas.h "")
|
||||
file(WRITE ${CMAKE_BINARY_DIR}/reenable_warning_pragmas.h "")
|
||||
endif()
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
set (opm-core_CONFIG_VAR
|
||||
HAVE_ERT
|
||||
HAVE_SUITESPARSE_UMFPACK_H
|
||||
HAVE_DUNE_ISTL
|
||||
HAVE_MPI
|
||||
)
|
||||
|
||||
# dependencies
|
||||
@@ -27,6 +29,8 @@ set (opm-core_DEPS
|
||||
"TinyXML"
|
||||
# Ensembles-based Reservoir Tools (ERT)
|
||||
"ERT"
|
||||
# Look for MPI support
|
||||
"MPI"
|
||||
# DUNE dependency
|
||||
"dune-common"
|
||||
"dune-istl"
|
||||
|
||||
2
cmake/Scripts/configure
vendored
2
cmake/Scripts/configure
vendored
@@ -36,6 +36,7 @@ Optional Features:
|
||||
--config-cache Reuse build configuration cache from a previous run
|
||||
|
||||
Optional Packages:
|
||||
--with-ug=PATH use the UG libraries from a specified location
|
||||
--with-alugrid=PATH use the ALUGrid library from a specified location
|
||||
--with-metis=PATH use the METIS graph partitioning library from a specified location
|
||||
--with-boost=PATH use Boost library from a specified location
|
||||
@@ -256,6 +257,7 @@ for OPT in "$@"; do
|
||||
superlu |\
|
||||
SuiteSparse |\
|
||||
TinyXML |\
|
||||
ug |\
|
||||
opm |\
|
||||
opm-* |\
|
||||
dune |\
|
||||
|
||||
@@ -25,11 +25,17 @@
|
||||
|
||||
#include <dune/common/version.hh>
|
||||
|
||||
#include "disable_warning_pragmas.h"
|
||||
|
||||
#if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 3)
|
||||
#include <dune/common/parallel/mpihelper.hh>
|
||||
#else
|
||||
#include <dune/common/mpihelper.hh>
|
||||
#endif
|
||||
#include <dune/grid/CpGrid.hpp>
|
||||
#include <dune/grid/common/GridAdapter.hpp>
|
||||
|
||||
#include "reenable_warning_pragmas.h"
|
||||
|
||||
#include <opm/core/pressure/FlowBCManager.hpp>
|
||||
|
||||
@@ -38,9 +44,6 @@
|
||||
|
||||
#include <opm/core/grid/GridManager.hpp>
|
||||
|
||||
#include <dune/grid/CpGrid.hpp>
|
||||
#include <dune/grid/common/GridAdapter.hpp>
|
||||
|
||||
#include <opm/core/wells.h>
|
||||
#include <opm/core/wells/WellsManager.hpp>
|
||||
#include <opm/core/utility/ErrorMacros.hpp>
|
||||
@@ -99,7 +102,10 @@ int
|
||||
main(int argc, char** argv)
|
||||
try
|
||||
{
|
||||
Dune::MPIHelper& helper= Dune::MPIHelper::instance(argc, argv);
|
||||
// Must ensure an instance of the helper is created to initialise MPI,
|
||||
// but we don't use the helper here.
|
||||
// Dune::MPIHelper& helper = Dune::MPIHelper::instance(argc, argv);
|
||||
Dune::MPIHelper::instance(argc, argv);
|
||||
using namespace Opm;
|
||||
|
||||
std::cout << "\n================ Test program for fully implicit three-phase black-oil flow ===============\n\n";
|
||||
|
||||
@@ -20,8 +20,13 @@
|
||||
#ifndef OPM_AUTODIFFBLOCK_HEADER_INCLUDED
|
||||
#define OPM_AUTODIFFBLOCK_HEADER_INCLUDED
|
||||
|
||||
#include "disable_warning_pragmas.h"
|
||||
|
||||
#include <Eigen/Eigen>
|
||||
#include <Eigen/Sparse>
|
||||
|
||||
#include "reenable_warning_pragmas.h"
|
||||
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
|
||||
@@ -34,7 +34,9 @@
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
#ifdef HAVE_DUNE_CORNERPOINT
|
||||
#include "disable_warning_pragmas.h"
|
||||
#include <dune/grid/CpGrid.hpp>
|
||||
#include "reenable_warning_pragmas.h"
|
||||
#endif
|
||||
|
||||
namespace Opm
|
||||
|
||||
@@ -165,14 +165,15 @@ namespace Opm {
|
||||
|
||||
void
|
||||
addWellControlEq(const SolutionState& state,
|
||||
const WellStateFullyImplicitBlackoil& xw);
|
||||
const WellStateFullyImplicitBlackoil& xw,
|
||||
const V& aliveWells);
|
||||
|
||||
void
|
||||
addWellEq(const SolutionState& state,
|
||||
WellStateFullyImplicitBlackoil& xw);
|
||||
V& aliveWells);
|
||||
|
||||
void updateWellControls(const ADB& bhp,
|
||||
const ADB& well_phase_flow_rate,
|
||||
void updateWellControls(ADB& bhp,
|
||||
ADB& well_phase_flow_rate,
|
||||
WellStateFullyImplicitBlackoil& xw) const;
|
||||
|
||||
void
|
||||
|
||||
@@ -49,6 +49,19 @@
|
||||
<< collapseJacs(foo) << std::endl; \
|
||||
} while (0)
|
||||
|
||||
#define DUMPVAL(foo) \
|
||||
do { \
|
||||
std::cout << "==========================================\n" \
|
||||
<< #foo ":\n" \
|
||||
<< foo.value() << std::endl; \
|
||||
} while (0)
|
||||
|
||||
#define DISKVAL(foo) \
|
||||
do { \
|
||||
std::ofstream os(#foo); \
|
||||
os.precision(16); \
|
||||
os << foo.value() << std::endl; \
|
||||
} while (0)
|
||||
|
||||
|
||||
namespace Opm {
|
||||
@@ -638,7 +651,7 @@ namespace {
|
||||
{
|
||||
using namespace Opm::AutoDiffGrid;
|
||||
// Create the primary variables.
|
||||
const SolutionState state = variableState(x, xw);
|
||||
SolutionState state = variableState(x, xw);
|
||||
|
||||
// -------- Mass balance equations --------
|
||||
|
||||
@@ -695,8 +708,12 @@ namespace {
|
||||
|
||||
}
|
||||
|
||||
addWellEq(state, xw); // Note: this can change xw (switching well controls).
|
||||
addWellControlEq(state, xw);
|
||||
// Note: updateWellControls() can change all its arguments if
|
||||
// a well control is switched.
|
||||
updateWellControls(state.bhp, state.qs, xw);
|
||||
V aliveWells;
|
||||
addWellEq(state, aliveWells);
|
||||
addWellControlEq(state, xw, aliveWells);
|
||||
}
|
||||
|
||||
|
||||
@@ -705,7 +722,7 @@ namespace {
|
||||
|
||||
template <class T>
|
||||
void FullyImplicitBlackoilSolver<T>::addWellEq(const SolutionState& state,
|
||||
WellStateFullyImplicitBlackoil& xw)
|
||||
V& aliveWells)
|
||||
{
|
||||
const int nc = Opm::AutoDiffGrid::numCells(grid_);
|
||||
const int np = wells_.number_of_phases;
|
||||
@@ -722,6 +739,10 @@ namespace {
|
||||
// and corresponding perforation well pressures.
|
||||
const ADB p_perfcell = subset(state.pressure, well_cells);
|
||||
|
||||
// DUMPVAL(p_perfcell);
|
||||
// DUMPVAL(state.bhp);
|
||||
// DUMPVAL(ADB::constant(cdp));
|
||||
|
||||
// Pressure drawdown (also used to determine direction of flow)
|
||||
const ADB drawdown = p_perfcell - (wops_.w2p * state.bhp + cdp);
|
||||
|
||||
@@ -804,12 +825,13 @@ namespace {
|
||||
wbq[phase] = (isInj * compi.col(pos)) * qt_s - q_ps[phase];
|
||||
wbqt += wbq[phase];
|
||||
}
|
||||
// DUMPVAL(wbqt);
|
||||
|
||||
// check for dead wells
|
||||
V isNotDeadWells = V::Constant(nw,1.0);
|
||||
aliveWells = V::Constant(nw, 1.0);
|
||||
for (int w = 0; w < nw; ++w) {
|
||||
if (wbqt.value()[w] == 0) {
|
||||
isNotDeadWells[w] = 0;
|
||||
aliveWells[w] = 0.0;
|
||||
}
|
||||
}
|
||||
// compute wellbore mixture at std conds
|
||||
@@ -827,9 +849,13 @@ namespace {
|
||||
ADB mt = subset(rq_[0].mob,well_cells);
|
||||
for (int phase = 1; phase < np; ++phase) {
|
||||
mt += subset(rq_[phase].mob,well_cells);
|
||||
|
||||
}
|
||||
|
||||
// DUMPVAL(ADB::constant(isInjInx));
|
||||
// DUMPVAL(ADB::constant(Tw));
|
||||
// DUMPVAL(mt);
|
||||
// DUMPVAL(drawdown);
|
||||
|
||||
// injection connections total volumerates
|
||||
ADB cqt_i = -(isInjInx * Tw) * (mt * drawdown);
|
||||
|
||||
@@ -856,9 +882,11 @@ namespace {
|
||||
tmp = tmp - subset(state.rs,well_cells) * cmix_s[oilpos] / d;
|
||||
}
|
||||
volRat += tmp / subset(rq_[phase].b,well_cells);
|
||||
|
||||
}
|
||||
|
||||
// DUMPVAL(cqt_i);
|
||||
// DUMPVAL(volRat);
|
||||
|
||||
// injecting connections total volumerates at std cond
|
||||
ADB cqt_is = cqt_i/volRat;
|
||||
|
||||
@@ -868,6 +896,9 @@ namespace {
|
||||
cq_s[phase] = cq_ps[phase] + (wops_.w2p * mix_s[phase])*cqt_is;
|
||||
}
|
||||
|
||||
// DUMPVAL(mix_s[2]);
|
||||
// DUMPVAL(cq_ps[2]);
|
||||
|
||||
// Add well contributions to mass balance equations
|
||||
for (int phase = 0; phase < np; ++phase) {
|
||||
residual_.material_balance_eq[phase] -= superset(cq_s[phase],well_cells,nc);
|
||||
@@ -879,11 +910,8 @@ namespace {
|
||||
qs -= superset(wops_.p2w * cq_s[phase], Span(nw, 1, phase*nw), nw*np);
|
||||
|
||||
}
|
||||
residual_.well_flux_eq = qs;
|
||||
|
||||
// Updating the well controls is done from here, since we have
|
||||
// access to the necessary bhp and rate data in this method.
|
||||
updateWellControls(state.bhp, state.qs, xw);
|
||||
residual_.well_flux_eq = qs;
|
||||
}
|
||||
|
||||
|
||||
@@ -956,15 +984,17 @@ namespace {
|
||||
|
||||
|
||||
template<class T>
|
||||
void FullyImplicitBlackoilSolver<T>::updateWellControls(const ADB& bhp,
|
||||
const ADB& well_phase_flow_rate,
|
||||
WellStateFullyImplicitBlackoil& xw) const
|
||||
void FullyImplicitBlackoilSolver<T>::updateWellControls(ADB& bhp,
|
||||
ADB& well_phase_flow_rate,
|
||||
WellStateFullyImplicitBlackoil& xw) const
|
||||
{
|
||||
std::string modestring[3] = { "BHP", "RESERVOIR_RATE", "SURFACE_RATE" };
|
||||
// Find, for each well, if any constraints are broken. If so,
|
||||
// switch control to first broken constraint.
|
||||
const int np = wells_.number_of_phases;
|
||||
const int nw = wells_.number_of_wells;
|
||||
bool bhp_changed = false;
|
||||
bool rates_changed = false;
|
||||
for (int w = 0; w < nw; ++w) {
|
||||
const WellControls* wc = wells_.ctrls[w];
|
||||
// The current control in the well state overrides
|
||||
@@ -1002,8 +1032,38 @@ namespace {
|
||||
<< " from " << modestring[well_controls_iget_type(wc, current)]
|
||||
<< " to " << modestring[well_controls_iget_type(wc, ctrl_index)] << std::endl;
|
||||
xw.currentControls()[w] = ctrl_index;
|
||||
// Also updating well state and primary variables.
|
||||
// We can only be switching to BHP and SURFACE_RATE
|
||||
// controls since we do not support RESERVOIR_RATE.
|
||||
const double target = well_controls_iget_target(wc, ctrl_index);
|
||||
const double* distr = well_controls_iget_distr(wc, ctrl_index);
|
||||
switch (well_controls_iget_type(wc, ctrl_index)) {
|
||||
case BHP:
|
||||
xw.bhp()[w] = target;
|
||||
bhp_changed = true;
|
||||
break;
|
||||
case SURFACE_RATE:
|
||||
for (int phase = 0; phase < np; ++phase) {
|
||||
xw.wellRates()[np*w + phase] = target * distr[phase];
|
||||
}
|
||||
rates_changed = true;
|
||||
break;
|
||||
default:
|
||||
OPM_THROW(std::logic_error, "Programmer error: should not have switched "
|
||||
"to anything but BHP or SURFACE_RATE.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update primary variables, if necessary.
|
||||
if (bhp_changed) {
|
||||
ADB::V new_bhp = Eigen::Map<ADB::V>(xw.bhp().data(), nw);
|
||||
bhp = ADB::function(new_bhp, bhp.derivative());
|
||||
}
|
||||
if (rates_changed) {
|
||||
ADB::V new_qs = Eigen::Map<ADB::V>(xw.wellRates().data(), np*nw);
|
||||
well_phase_flow_rate = ADB::function(new_qs, well_phase_flow_rate.derivative());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1011,7 +1071,8 @@ namespace {
|
||||
|
||||
template<class T>
|
||||
void FullyImplicitBlackoilSolver<T>::addWellControlEq(const SolutionState& state,
|
||||
const WellStateFullyImplicitBlackoil& xw)
|
||||
const WellStateFullyImplicitBlackoil& xw,
|
||||
const V& aliveWells)
|
||||
{
|
||||
// Handling BHP and SURFACE_RATE wells.
|
||||
|
||||
@@ -1048,6 +1109,17 @@ namespace {
|
||||
// Choose bhp residual for positive bhp targets.
|
||||
Selector<double> bhp_selector(bhp_targets);
|
||||
residual_.well_eq = bhp_selector.select(bhp_residual, rate_residual);
|
||||
// For wells that are dead (not flowing), and therefore not communicating
|
||||
// with the reservoir, we set the equation to be equal to the well's total
|
||||
// flow. This will be a solution only if the target rate is also zero.
|
||||
M rate_summer(nw, np*nw);
|
||||
for (int w = 0; w < nw; ++w) {
|
||||
for (int phase = 0; phase < np; ++phase) {
|
||||
rate_summer.insert(w, phase*nw + w) = 1.0;
|
||||
}
|
||||
}
|
||||
Selector<double> alive_selector(aliveWells, Selector<double>::NotEqualZero);
|
||||
residual_.well_eq = alive_selector.select(residual_.well_eq, rate_summer * state.qs);
|
||||
// DUMP(residual_.well_eq);
|
||||
}
|
||||
|
||||
@@ -1501,15 +1573,23 @@ namespace {
|
||||
// convert the pressure offsets to the capillary pressures
|
||||
std::vector<ADB> pressure = fluid_.capPress(sw, so, sg, cells_);
|
||||
for (int phaseIdx = 0; phaseIdx < BlackoilPhases::MaxNumPhases; ++phaseIdx) {
|
||||
#warning "what's the reference phase??"
|
||||
// The reference pressure is always the liquid phase (oil) pressure.
|
||||
if (phaseIdx == BlackoilPhases::Liquid)
|
||||
continue;
|
||||
pressure[phaseIdx] = pressure[phaseIdx] - pressure[BlackoilPhases::Liquid];
|
||||
}
|
||||
|
||||
// add the total pressure to the capillary pressures
|
||||
// Since pcow = po - pw, but pcog = pg - po,
|
||||
// we have
|
||||
// pw = po - pcow
|
||||
// pg = po + pcgo
|
||||
// This is an unfortunate inconsistency, but a convention we must handle.
|
||||
for (int phaseIdx = 0; phaseIdx < BlackoilPhases::MaxNumPhases; ++phaseIdx) {
|
||||
pressure[phaseIdx] += state.pressure;
|
||||
if (phaseIdx == BlackoilPhases::Aqua) {
|
||||
pressure[phaseIdx] = state.pressure - pressure[phaseIdx];
|
||||
} else {
|
||||
pressure[phaseIdx] += state.pressure;
|
||||
}
|
||||
}
|
||||
|
||||
return pressure;
|
||||
|
||||
@@ -24,8 +24,14 @@
|
||||
#include <opm/autodiff/GridHelpers.hpp>
|
||||
//#include <opm/core/pressure/tpfa/trans_tpfa.h>
|
||||
#include <opm/core/pressure/tpfa/TransTpfa.hpp>
|
||||
|
||||
#include "disable_warning_pragmas.h"
|
||||
|
||||
#include <Eigen/Eigen>
|
||||
|
||||
#include "reenable_warning_pragmas.h"
|
||||
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
|
||||
|
||||
@@ -236,8 +236,6 @@ void extractInternalFaces(const Dune::CpGrid& grid,
|
||||
typedef Eigen::Array<bool, Eigen::Dynamic, 1> OneColBool;
|
||||
typedef Eigen::Array<int, Eigen::Dynamic, 2, Eigen::RowMajor> TwoColInt;
|
||||
typedef Eigen::Array<bool, Eigen::Dynamic, 2, Eigen::RowMajor> TwoColBool;
|
||||
ADFaceCellTraits<Dune::CpGrid>::Type nb = faceCells(grid);
|
||||
// std::cout << "nb = \n" << nb << std::endl;
|
||||
// Extracts the internal faces of the grid.
|
||||
// These are stored in internal_faces.
|
||||
int nf=numFaces(grid);
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <opm/core/grid.h>
|
||||
#include <opm/core/grid/GridHelpers.hpp>
|
||||
|
||||
#include "disable_warning_pragmas.h"
|
||||
|
||||
#include <Eigen/Eigen>
|
||||
#include <Eigen/Sparse>
|
||||
|
||||
@@ -32,6 +35,9 @@
|
||||
#include <dune/grid/CpGrid.hpp>
|
||||
#endif
|
||||
|
||||
#include "reenable_warning_pragmas.h"
|
||||
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace {
|
||||
|
||||
std::vector<int> f2hf(2 * numFaces(grid), -1);
|
||||
Eigen::Array<int, Eigen::Dynamic, 2, Eigen::RowMajor>
|
||||
face_cells;
|
||||
face_cells = faceCells(grid);
|
||||
|
||||
typedef typename Opm::UgGridHelpers::Cell2FacesTraits<UnstructuredGrid>::Type
|
||||
Cell2Faces;
|
||||
@@ -71,7 +71,7 @@ namespace {
|
||||
cell_faces = c2f[c];
|
||||
typedef typename Cell2Faces::row_type::iterator Iter;
|
||||
for (Iter f=cell_faces.begin(), end=cell_faces.end();
|
||||
f!=end; ++end) {
|
||||
f!=end; ++f) {
|
||||
const int p = 0 + (face_cells(*f,0) != c);
|
||||
f2hf[2*(*f) + p] = f-c2f[0].begin();
|
||||
}
|
||||
@@ -89,8 +89,6 @@ namespace {
|
||||
std::vector<Tri> grav; grav.reserve(2 * ni);
|
||||
for (HelperOps::IFaces::Index i = 0; i < ni; ++i) {
|
||||
const int f = ops.internal_faces[ i ];
|
||||
Eigen::Array<int, Eigen::Dynamic, 2, Eigen::RowMajor>
|
||||
face_cells=faceCells(grid);
|
||||
const int c1 = face_cells(f,0);
|
||||
const int c2 = face_cells(f,1);
|
||||
|
||||
|
||||
@@ -16,7 +16,10 @@
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#ifdef HAVE_DUNE_CORNERPOINT
|
||||
#include "disable_warning_pragmas.h"
|
||||
#include <dune/common/version.hh>
|
||||
#include <dune/grid/io/file/vtk/vtkwriter.hh>
|
||||
#include "reenable_warning_pragmas.h"
|
||||
#endif
|
||||
namespace Opm
|
||||
{
|
||||
@@ -175,7 +178,11 @@ namespace Opm
|
||||
OPM_THROW(std::runtime_error, "Creating directories failed: " << fpath);
|
||||
}
|
||||
vtkfilename << "output-" << std::setw(3) << std::setfill('0') << step;
|
||||
#if DUNE_VERSION_NEWER(DUNE_GRID, 2, 3)
|
||||
Dune::VTKWriter<Dune::CpGrid::LeafGridView> writer(grid.leafGridView(), Dune::VTK::nonconforming);
|
||||
#else
|
||||
Dune::VTKWriter<Dune::CpGrid::LeafGridView> writer(grid.leafView(), Dune::VTK::nonconforming);
|
||||
#endif
|
||||
writer.addCellData(state.saturation(), "saturation", state.numPhases());
|
||||
writer.addCellData(state.pressure(), "pressure", 1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user