Merge remote-tracking branch 'upstream/master' into PR/async-output

This commit is contained in:
Robert Kloefkorn 2016-04-08 13:07:44 +02:00
commit e80ad5a9fe
31 changed files with 527 additions and 337 deletions

View File

@ -27,7 +27,7 @@ install:
- git clone https://github.com/OPM/opm-parser.git
- git clone https://github.com/OPM/opm-material.git
- git clone https://github.com/OPM/opm-core.git
- git clone https://github.com/OPM/dune-cornerpoint.git
- git clone https://github.com/OPM/opm-grid.git
- git clone https://github.com/OPM/opm-output.git
- git clone https://github.com/OPM/opm-data.git
@ -35,14 +35,14 @@ install:
- opm-material/travis/clone-and-build-dune-common.sh
- opm-core/travis/clone-and-build-dune-istl.sh
- opm-core/travis/clone-and-build-superlu.sh
- dune-cornerpoint/travis/clone-and-build-dune-geometry.sh
- dune-cornerpoint/travis/clone-and-build-dune-grid.sh
- opm-grid/travis/clone-and-build-dune-geometry.sh
- opm-grid/travis/clone-and-build-dune-grid.sh
- opm-common/travis/build-opm-common.sh
- opm-parser/travis/build-opm-parser.sh
- opm-material/travis/build-opm-material.sh
- opm-core/travis/build-opm-core.sh
- dune-cornerpoint/travis/build-dune-cornerpoint.sh
- opm-grid/travis/build-opm-grid.sh
- opm-output/travis/build-opm-output.sh
script: opm-autodiff/travis/build-and-test-opm-autodiff.sh

View File

@ -87,7 +87,7 @@ macro (prereqs_hook)
endmacro (prereqs_hook)
macro (sources_hook)
if(DUNE_CORNERPOINT_FOUND OR dune-cornerpoint_FOUND)
if(OPM_GRID_FOUND OR opm-grid_FOUND)
list (APPEND examples_SOURCES
${PROJECT_SOURCE_DIR}/examples/flow_mpi.cpp
${PROJECT_SOURCE_DIR}/examples/flow_multisegment_mpi.cpp

View File

@ -47,8 +47,9 @@ list (APPEND MAIN_SOURCE_FILES
opm/autodiff/VFPProdProperties.cpp
opm/autodiff/VFPInjProperties.cpp
opm/autodiff/WellMultiSegment.cpp
opm/autodiff/ThreadHandle.hpp
opm/autodiff/StandardWells.cpp
opm/autodiff/BlackoilSolventState.cpp
opm/autodiff/ThreadHandle.hpp
opm/polymer/PolymerState.cpp
opm/polymer/PolymerBlackoilState.cpp
opm/polymer/CompressibleTpfaPolymer.cpp
@ -186,6 +187,7 @@ list (APPEND PUBLIC_HEADER_FILES
opm/autodiff/VFPInjProperties.hpp
opm/autodiff/WellStateMultiSegment.hpp
opm/autodiff/WellMultiSegment.hpp
opm/autodiff/StandardWells.hpp
opm/polymer/CompressibleTpfaPolymer.hpp
opm/polymer/GravityColumnSolverPolymer.hpp
opm/polymer/GravityColumnSolverPolymer_impl.hpp

View File

@ -10,4 +10,4 @@ Label: 2016.04-pre
Maintainer: atgeirr@sintef.no
MaintainerName: Atgeirr F. Rasmussen
Url: http://opm-project.org
Depends: opm-common opm-parser opm-output opm-material opm-core dune-cornerpoint dune-istl (>=2.2)
Depends: opm-common opm-parser opm-output opm-material opm-core opm-grid dune-istl (>=2.2)

View File

@ -12,17 +12,17 @@ It is intended for post-merge builds of the master branch.
This script will build dependencies, then build opm-autodiff and execute its tests.
It inspects the $ghbPrBuildComment environmental variable to obtain a pull request
to use for ert, opm-common, opm-parser, opm-material, opm-core and
dune-cornerpoint (defaults to master) and then builds $sha1 of opm-autodiff.
opm-grid (defaults to master) and then builds $sha1 of opm-autodiff.
It is intended for pre-merge builds of pull requests.
You can optionally specify a given pull request to use for ert, opm-common,
opm-parser, opm-material, opm-core and dune-cornerpoint through the trigger.
opm-parser, opm-material, opm-core and opm-grid through the trigger.
The trigger line needs to contain ert=<pull request number> and/or
opm-common=<pull request number> and/or opm-parser=<pull request number>
and/or opm-material=<pull request number>
and/or opm-core=<pull request number>
and/or dune-cornerpoint=<pull request number>
and/or opm-grid=<pull request number>
and/or opm-output=<pull request number>.
**run-spe.sh**:

View File

@ -50,8 +50,8 @@ function build_opm_autodiff {
clone_and_build_module opm-core "-DCMAKE_PREFIX_PATH=$WORKSPACE/serial/install -DCMAKE_INSTALL_PREFIX=$WORKSPACE/serial/install" $OPM_CORE_REVISION $WORKSPACE/serial
test $? -eq 0 || exit 1
# Build dune-cornerpoint
clone_and_build_module dune-cornerpoint "-DCMAKE_PREFIX_PATH=$WORKSPACE/serial/install -DCMAKE_INSTALL_PREFIX=$WORKSPACE/serial/install" $DUNE_CORNERPOINT_REVISION $WORKSPACE/serial
# Build opm-grid
clone_and_build_module opm-grid "-DCMAKE_PREFIX_PATH=$WORKSPACE/serial/install -DCMAKE_INSTALL_PREFIX=$WORKSPACE/serial/install" $OPM_GRID_REVISION $WORKSPACE/serial
test $? -eq 0 || exit 1
# Build opm-output

View File

@ -7,7 +7,7 @@ OPM_COMMON_REVISION=master
OPM_PARSER_REVISION=master
OPM_MATERIAL_REVISION=master
OPM_CORE_REVISION=master
DUNE_CORNERPOINT_REVISION=master
OPM_GRID_REVISION=master
OPM_OUTPUT_REVISION=master
OPM_AUTODIFF_REVISION=$sha1
@ -36,9 +36,9 @@ then
OPM_CORE_REVISION=pull/`echo $ghprbCommentBody | sed -r 's/.*opm-core=([0-9]+).*/\1/g'`/merge
fi
if grep -q "dune-cornerpoint=" <<< $ghprbCommentBody
if grep -q "opm-grid=" <<< $ghprbCommentBody
then
DUNE_CORNERPOINT_REVISION=pull/`echo $ghprbCommentBody | sed -r 's/.*dune-cornerpoint=([0-9]+).*/\1/g'`/merge
OPM_GRID_REVISION=pull/`echo $ghprbCommentBody | sed -r 's/.*opm-grid=([0-9]+).*/\1/g'`/merge
fi
if grep -q "opm-output=" <<< $ghprbCommentBody
@ -46,7 +46,7 @@ then
OPM_OUTPUT_REVISION=pull/`echo $ghprbCommentBody | sed -r 's/.*opm-output=([0-9]+).*/\1/g'`/merge
fi
echo "Building with ert=$ERT_REVISION opm-common=$OPM_COMMON_REVISION opm-parser=$OPM_PARSER_REVISION opm-material=$OPM_MATERIAL_REVISION opm-core=$OPM_CORE_REVISION dune-cornerpoint=$DUNE_CORNERPOINT_REVISION opm-output=$OPM_OUTPUT_REVISION opm-autodiff=$OPM_AUTODIFF_REVISION"
echo "Building with ert=$ERT_REVISION opm-common=$OPM_COMMON_REVISION opm-parser=$OPM_PARSER_REVISION opm-material=$OPM_MATERIAL_REVISION opm-core=$OPM_CORE_REVISION opm-grid=$OPM_GRID_REVISION opm-output=$OPM_OUTPUT_REVISION opm-autodiff=$OPM_AUTODIFF_REVISION"
build_opm_autodiff
test $? -eq 0 || exit 1

View File

@ -7,7 +7,7 @@ OPM_COMMON_REVISION=master
OPM_PARSER_REVISION=master
OPM_MATERIAL_REVISION=master
OPM_CORE_REVISION=master
DUNE_CORNERPOINT_REVISION=master
OPM_GRID_REVISION=master
OPM_OUTPUT_REVISION=master
build_opm_autodiff

View File

@ -32,6 +32,7 @@
#include <opm/autodiff/NewtonIterationBlackoilInterface.hpp>
#include <opm/autodiff/BlackoilModelEnums.hpp>
#include <opm/autodiff/VFPProperties.hpp>
#include <opm/autodiff/StandardWells.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/NNC.hpp>
#include <array>
@ -269,20 +270,13 @@ namespace Opm {
ADB mob; // Phase mobility (per cell)
};
struct WellOps {
WellOps(const Wells* wells);
Eigen::SparseMatrix<double> w2p; // well -> perf (scatter)
Eigen::SparseMatrix<double> p2w; // perf -> well (gather)
std::vector<int> well_cells; // the set of perforated cells
};
// --------- Data members ---------
const Grid& grid_;
const BlackoilPropsAdInterface& fluid_;
const DerivedGeology& geo_;
const RockCompressibility* rock_comp_props_;
const Wells* wells_;
StandardWells std_wells_;
VFPProperties vfp_properties_;
const NewtonIterationBlackoilInterface& linsolver_;
// For each canonical phase -> true if active
@ -291,13 +285,11 @@ namespace Opm {
const std::vector<int> canph_;
const std::vector<int> cells_; // All grid cells
HelperOps ops_;
const WellOps wops_;
const bool has_disgas_;
const bool has_vapoil_;
ModelParameters param_;
bool use_threshold_pressure_;
bool wells_active_;
V threshold_pressures_by_connection_;
std::vector<ReservoirResidualQuant> rq_;
@ -305,8 +297,6 @@ namespace Opm {
V isRs_;
V isRv_;
V isSg_;
V well_perforation_densities_; //Density of each well perforation
V well_perforation_pressure_diffs_; // Diff to bhp for each well perforation.
LinearisedBlackoilResidual residual_;
@ -338,12 +328,18 @@ namespace Opm {
return static_cast<const Implementation&>(*this);
}
// return true if wells are available in the reservoir
bool wellsActive() const { return wells_active_; }
// return true if wells are available on this process
bool localWellsActive() const { return wells_ ? (wells_->number_of_wells > 0 ) : false; }
// return wells object
const Wells& wells () const { assert( bool(wells_ != 0) ); return *wells_; }
/// return the StandardWells object
StandardWells& stdWells() { return std_wells_; }
const StandardWells& stdWells() const { return std_wells_; }
/// return the Well struct in the StandardWells
const Wells& wells() const { return std_wells_.wells(); }
/// return true if wells are available in the reservoir
bool wellsActive() const { return std_wells_.wellsActive(); }
/// return true if wells are available on this process
bool localWellsActive() const { return std_wells_.localWellsActive(); }
int numWellVars() const;

View File

@ -159,14 +159,13 @@ namespace detail {
, fluid_ (fluid)
, geo_ (geo)
, rock_comp_props_(rock_comp_props)
, wells_ (wells_arg)
, std_wells_ (wells_arg)
, vfp_properties_(eclState->getTableManager()->getVFPInjTables(), eclState->getTableManager()->getVFPProdTables())
, linsolver_ (linsolver)
, active_(detail::activePhases(fluid.phaseUsage()))
, canph_ (detail::active2Canonical(fluid.phaseUsage()))
, cells_ (detail::buildAllCells(Opm::AutoDiffGrid::numCells(grid)))
, ops_ (grid, geo.nnc())
, wops_ (wells_)
, has_disgas_(has_disgas)
, has_vapoil_(has_vapoil)
, param_( param )
@ -195,9 +194,10 @@ namespace detail {
// Only rank 0 does print to std::cout if terminal_output is enabled
terminal_output_ = (info.communicator().rank()==0);
}
int local_number_of_wells = wells_ ? wells_->number_of_wells : 0;
int local_number_of_wells = localWellsActive() ? wells().number_of_wells : 0;
int global_number_of_wells = info.communicator().sum(local_number_of_wells);
wells_active_ = ( wells_ && global_number_of_wells > 0 );
const bool wells_active = ( wells_arg && global_number_of_wells > 0 );
stdWells().setWellsActive(wells_active);
// Compute the global number of cells
std::vector<int> v( Opm::AutoDiffGrid::numCells(grid_), 1);
global_nc_ = 0;
@ -205,7 +205,7 @@ namespace detail {
}else
#endif
{
wells_active_ = ( wells_ && wells_->number_of_wells > 0 );
stdWells().setWellsActive( localWellsActive() );
global_nc_ = Opm::AutoDiffGrid::numCells(grid_);
}
}
@ -418,51 +418,12 @@ namespace detail {
template <class Grid, class Implementation>
BlackoilModelBase<Grid, Implementation>::
WellOps::WellOps(const Wells* wells)
: w2p(),
p2w(),
well_cells()
{
if( wells )
{
w2p = Eigen::SparseMatrix<double>(wells->well_connpos[ wells->number_of_wells ], wells->number_of_wells);
p2w = Eigen::SparseMatrix<double>(wells->number_of_wells, wells->well_connpos[ wells->number_of_wells ]);
const int nw = wells->number_of_wells;
const int* const wpos = wells->well_connpos;
typedef Eigen::Triplet<double> Tri;
std::vector<Tri> scatter, gather;
scatter.reserve(wpos[nw]);
gather .reserve(wpos[nw]);
for (int w = 0, i = 0; w < nw; ++w) {
for (; i < wpos[ w + 1 ]; ++i) {
scatter.push_back(Tri(i, w, 1.0));
gather .push_back(Tri(w, i, 1.0));
}
}
w2p.setFromTriplets(scatter.begin(), scatter.end());
p2w.setFromTriplets(gather .begin(), gather .end());
well_cells.assign(wells->well_cells, wells->well_cells + wells->well_connpos[wells->number_of_wells]);
}
}
template <class Grid, class Implementation>
int
BlackoilModelBase<Grid, Implementation>::numWellVars() const
{
// For each well, we have a bhp variable, and one flux per phase.
const int nw = localWellsActive() ? wells().number_of_wells : 0;
const int nw = stdWells().localWellsActive() ? wells().number_of_wells : 0;
return (numPhases() + 1) * nw;
}
@ -578,7 +539,7 @@ namespace detail {
BlackoilModelBase<Grid, Implementation>::variableWellStateInitials(const WellState& xw, std::vector<V>& vars0) const
{
// Initial well rates.
if ( localWellsActive() )
if ( stdWells().localWellsActive() )
{
// Need to reshuffle well rates, from phase running fastest
// to wells running fastest.
@ -817,7 +778,7 @@ namespace detail {
}
}
const std::vector<int>& well_cells = wops_.well_cells;
const std::vector<int>& well_cells = stdWells().wellOps().well_cells;
// Use cell values for the temperature as the wells don't knows its temperature yet.
const ADB perf_temp = subset(state.temperature, well_cells);
@ -895,7 +856,7 @@ namespace detail {
b_perf, rsmax_perf, rvmax_perf, surf_dens_perf);
const int nperf = wells().well_connpos[wells().number_of_wells];
const std::vector<int>& well_cells = wops_.well_cells;
const std::vector<int>& well_cells = stdWells().wellOps().well_cells;
// Extract well connection depths.
const V depth = cellCentroidsZToEigen(grid_);
@ -911,8 +872,8 @@ namespace detail {
wells(), perf_depth, cd, grav);
// 4. Store the results
well_perforation_densities_ = Eigen::Map<const V>(cd.data(), nperf);
well_perforation_pressure_diffs_ = Eigen::Map<const V>(cdp.data(), nperf);
stdWells().wellPerforationDensities() = Eigen::Map<const V>(cd.data(), nperf);
stdWells().wellPerforationPressureDiffs() = Eigen::Map<const V>(cdp.data(), nperf);
}
@ -1111,7 +1072,7 @@ namespace detail {
const int nc = Opm::AutoDiffGrid::numCells(grid_);
const int np = asImpl().numPhases();
for (int phase = 0; phase < np; ++phase) {
residual_.material_balance_eq[phase] -= superset(cq_s[phase], wops_.well_cells, nc);
residual_.material_balance_eq[phase] -= superset(cq_s[phase], stdWells().wellOps().well_cells, nc);
}
}
@ -1134,7 +1095,7 @@ namespace detail {
return;
} else {
const int np = asImpl().numPhases();
const std::vector<int>& well_cells = wops_.well_cells;
const std::vector<int>& well_cells = stdWells().wellOps().well_cells;
mob_perfcells.resize(np, ADB::null());
b_perfcells.resize(np, ADB::null());
for (int phase = 0; phase < np; ++phase) {
@ -1164,17 +1125,17 @@ namespace detail {
const int nperf = wells().well_connpos[nw];
const Opm::PhaseUsage& pu = fluid_.phaseUsage();
V Tw = Eigen::Map<const V>(wells().WI, nperf);
const std::vector<int>& well_cells = wops_.well_cells;
const std::vector<int>& well_cells = stdWells().wellOps().well_cells;
// pressure diffs computed already (once per step, not changing per iteration)
const V& cdp = well_perforation_pressure_diffs_;
const V& cdp = stdWells().wellPerforationPressureDiffs();
// Extract needed quantities for the perforation cells
const ADB& p_perfcells = subset(state.pressure, well_cells);
const ADB& rv_perfcells = subset(state.rv, well_cells);
const ADB& rs_perfcells = subset(state.rs, well_cells);
// Perforation pressure
const ADB perfpressure = (wops_.w2p * state.bhp) + cdp;
const ADB perfpressure = (stdWells().wellOps().w2p * state.bhp) + cdp;
// Pressure drawdown (also used to determine direction of flow)
const ADB drawdown = p_perfcells - perfpressure;
@ -1194,8 +1155,8 @@ namespace detail {
}
// Handle cross flow
const V numInjectingPerforations = (wops_.p2w * ADB::constant(selectInjectingPerforations)).value();
const V numProducingPerforations = (wops_.p2w * ADB::constant(selectProducingPerforations)).value();
const V numInjectingPerforations = (stdWells().wellOps().p2w * ADB::constant(selectInjectingPerforations)).value();
const V numProducingPerforations = (stdWells().wellOps().p2w * ADB::constant(selectProducingPerforations)).value();
for (int w = 0; w < nw; ++w) {
if (!wells().allow_cf[w]) {
for (int perf = wells().well_connpos[w] ; perf < wells().well_connpos[w+1]; ++perf) {
@ -1246,7 +1207,7 @@ namespace detail {
std::vector<ADB> wbq(np, ADB::null());
ADB wbqt = ADB::constant(V::Zero(nw));
for (int phase = 0; phase < np; ++phase) {
const ADB& q_ps = wops_.p2w * cq_ps[phase];
const ADB& q_ps = stdWells().wellOps().p2w * cq_ps[phase];
const ADB& q_s = subset(state.qs, Span(nw, 1, phase*nw));
Selector<double> injectingPhase_selector(q_s.value(), Selector<double>::GreaterZero);
const int pos = pu.phase_pos[phase];
@ -1258,7 +1219,7 @@ namespace detail {
std::vector<ADB> cmix_s(np, ADB::null());
for (int phase = 0; phase < np; ++phase) {
const int pos = pu.phase_pos[phase];
cmix_s[phase] = wops_.w2p * notDeadWells_selector.select(ADB::constant(compi.col(pos)), wbq[phase]/wbqt);
cmix_s[phase] = stdWells().wellOps().w2p * notDeadWells_selector.select(ADB::constant(compi.col(pos)), wbq[phase]/wbqt);
}
// compute volume ratio between connection at standard conditions
@ -1323,8 +1284,8 @@ namespace detail {
xw.perfPhaseRates().assign(cq.data(), cq.data() + nperf*np);
// Update the perforation pressures.
const V& cdp = well_perforation_pressure_diffs_;
const V perfpressure = (wops_.w2p * state.bhp.value().matrix()).array() + cdp;
const V& cdp = stdWells().wellPerforationPressureDiffs();
const V perfpressure = (stdWells().wellOps().w2p * state.bhp.value().matrix()).array() + cdp;
xw.perfPress().assign(perfpressure.data(), perfpressure.data() + nperf);
}
@ -1347,7 +1308,7 @@ namespace detail {
const int nw = wells().number_of_wells;
ADB qs = state.qs;
for (int phase = 0; phase < np; ++phase) {
qs -= superset(wops_.p2w * cq_s[phase], Span(nw, 1, phase*nw), nw*np);
qs -= superset(stdWells().wellOps().p2w * cq_s[phase], Span(nw, 1, phase*nw), nw*np);
}
@ -1608,14 +1569,14 @@ namespace detail {
if (well_type == INJECTOR) {
double dp = detail::computeHydrostaticCorrection(
wells(), w, vfp_properties_.getInj()->getTable(vfp)->getDatumDepth(),
well_perforation_densities_, gravity);
stdWells().wellPerforationDensities(), gravity);
xw.bhp()[w] = vfp_properties_.getInj()->bhp(vfp, aqua, liquid, vapour, thp) - dp;
}
else if (well_type == PRODUCER) {
double dp = detail::computeHydrostaticCorrection(
wells(), w, vfp_properties_.getProd()->getTable(vfp)->getDatumDepth(),
well_perforation_densities_, gravity);
stdWells().wellPerforationDensities(), gravity);
xw.bhp()[w] = vfp_properties_.getProd()->bhp(vfp, aqua, liquid, vapour, thp, alq) - dp;
}
@ -1847,7 +1808,7 @@ namespace detail {
case THP:
{
const int perf = wells().well_connpos[w];
rho_v[w] = well_perforation_densities_[perf];
rho_v[w] = stdWells().wellPerforationDensities()[perf];
const int table_id = well_controls_iget_vfp(wc, current);
const double target = well_controls_iget_target(wc, current);
@ -1910,7 +1871,7 @@ namespace detail {
//Perform hydrostatic correction to computed targets
double gravity = detail::getGravity(geo_.gravity(), UgGridHelpers::dimensions(grid_));
const ADB::V dp_v = detail::computeHydrostaticCorrection(wells(), vfp_ref_depth_v, well_perforation_densities_, gravity);
const ADB::V dp_v = detail::computeHydrostaticCorrection(wells(), vfp_ref_depth_v, stdWells().wellPerforationDensities(), gravity);
const ADB dp = ADB::constant(dp_v);
const ADB dp_inj = superset(subset(dp, thp_inj_elems), thp_inj_elems, nw);
const ADB dp_prod = superset(subset(dp, thp_prod_elems), thp_prod_elems, nw);
@ -2351,14 +2312,14 @@ namespace detail {
if (well_type == INJECTOR) {
double dp = detail::computeHydrostaticCorrection(
wells(), w, vfp_properties_.getInj()->getTable(table_id)->getDatumDepth(),
well_perforation_densities_, gravity);
stdWells().wellPerforationDensities(), gravity);
well_state.thp()[w] = vfp_properties_.getInj()->thp(table_id, aqua, liquid, vapour, bhp[w] + dp);
}
else if (well_type == PRODUCER) {
double dp = detail::computeHydrostaticCorrection(
wells(), w, vfp_properties_.getProd()->getTable(table_id)->getDatumDepth(),
well_perforation_densities_, gravity);
stdWells().wellPerforationDensities(), gravity);
well_state.thp()[w] = vfp_properties_.getProd()->thp(table_id, aqua, liquid, vapour, bhp[w] + dp, alq);
}

View File

@ -116,7 +116,6 @@ namespace Opm {
// For non-segmented wells, it should be the density calculated with AVG or SEG way.
// while usually SEG way by default.
using Base::well_perforation_densities_; //Density of each well perforation
using Base::pvdt_;
using Base::geo_;
using Base::active_;
@ -136,10 +135,6 @@ namespace Opm {
using Base::param_;
using Base::linsolver_;
// Diff to bhp for each well perforation. only for usual wells.
// For segmented wells, they are zeros.
using Base::well_perforation_pressure_diffs_;
// Pressure correction due to the different depth of the perforation
// and the cell center of the grid block
// For the non-segmented wells, since the perforation are forced to be
@ -211,11 +206,10 @@ namespace Opm {
MultiSegmentWellOps wops_ms_;
// return wells object
// TODO: remove this wells structure
using Base::stdWells;
using Base::wells;
using Base::updatePrimalVariableFromState;
using Base::wellsActive;
using Base::updatePrimalVariableFromState;
using Base::phaseCondition;
using Base::fluidRvSat;
using Base::fluidRsSat;

View File

@ -370,7 +370,7 @@ namespace Opm {
std::vector<int>& well_cells = wops_ms_.well_cells;
well_perforation_densities_ = V::Zero(nperf_total);
stdWells().wellPerforationDensities() = V::Zero(nperf_total);
const V perf_press = Eigen::Map<const V>(xw.perfPress().data(), nperf_total);
@ -471,8 +471,8 @@ namespace Opm {
wells(), perf_cell_depth, cd, grav);
// 4. Store the results
well_perforation_densities_ = Eigen::Map<const V>(cd.data(), nperf_total); // This one is not useful for segmented wells at all
well_perforation_pressure_diffs_ = Eigen::Map<const V>(cdp.data(), nperf_total);
stdWells().wellPerforationDensities() = Eigen::Map<const V>(cd.data(), nperf_total); // This one is not useful for segmented wells at all
stdWells().wellPerforationPressureDiffs() = Eigen::Map<const V>(cdp.data(), nperf_total);
if ( !wops_ms_.has_multisegment_wells ) {
well_perforation_cell_densities_ = V::Zero(nperf_total);
@ -698,7 +698,7 @@ namespace Opm {
// Compute drawdown.
ADB h_nc = msperf_selector.select(well_segment_perforation_pressure_diffs_,
ADB::constant(well_perforation_pressure_diffs_));
ADB::constant( stdWells().wellPerforationPressureDiffs() ));
const V h_cj = msperf_selector.select(well_perforation_cell_pressure_diffs_, V::Zero(nperf));
// Special handling for when we are called from solveWellEq().
@ -862,7 +862,7 @@ namespace Opm {
// we need th concept of preforation pressures
xw.perfPress().resize(nperf_total, -1.e100);
const V& cdp = well_perforation_pressure_diffs_;
const V& cdp = stdWells().wellPerforationPressureDiffs();
int start_segment = 0;
int start_perforation = 0;
for (int i = 0; i < nw; ++i) {

View File

@ -54,7 +54,7 @@ namespace Opm
init_rock);
}
#ifdef HAVE_DUNE_CORNERPOINT
#ifdef HAVE_OPM_GRID
/// Constructor wrapping an opm-core black oil interface.
BlackoilPropsAdFromDeck::BlackoilPropsAdFromDeck(Opm::DeckConstPtr deck,
Opm::EclipseStateConstPtr eclState,
@ -95,7 +95,7 @@ namespace Opm
init_rock);
}
#ifdef HAVE_DUNE_CORNERPOINT
#ifdef HAVE_OPM_GRID
/// Constructor wrapping an opm-core black oil interface.
BlackoilPropsAdFromDeck::BlackoilPropsAdFromDeck(Opm::DeckConstPtr deck,
Opm::EclipseStateConstPtr eclState,

View File

@ -42,7 +42,7 @@
#include <array>
#include <vector>
#ifdef HAVE_DUNE_CORNERPOINT
#ifdef HAVE_OPM_GRID
#include <opm/common/utility/platform_dependent/disable_warnings.h>
#include <dune/grid/CpGrid.hpp>
#include <opm/common/utility/platform_dependent/reenable_warnings.h>
@ -91,7 +91,7 @@ namespace Opm
const UnstructuredGrid& grid,
const bool init_rock = true );
#ifdef HAVE_DUNE_CORNERPOINT
#ifdef HAVE_OPM_GRID
/// Constructor to create a blackoil properties from an ECL deck.
///
/// The materialLawManager parameter represents the object from opm-material
@ -125,7 +125,7 @@ namespace Opm
const UnstructuredGrid& grid,
const bool init_rock = true );
#ifdef HAVE_DUNE_CORNERPOINT
#ifdef HAVE_OPM_GRID
/// Constructor to create a blackoil properties from an ECL deck.
///
/// \param deck The unprocessed ECL deck from opm-parser

View File

@ -110,13 +110,11 @@ namespace Opm {
using Base::fluid_;
using Base::geo_;
using Base::rock_comp_props_;
using Base::wells_;
using Base::linsolver_;
using Base::active_;
using Base::canph_;
using Base::cells_;
using Base::ops_;
using Base::wops_;
using Base::has_disgas_;
using Base::has_vapoil_;
using Base::param_;
@ -124,7 +122,6 @@ namespace Opm {
using Base::threshold_pressures_by_connection_;
using Base::rq_;
using Base::phaseCondition_;
using Base::well_perforation_pressure_diffs_;
using Base::residual_;
using Base::terminal_output_;
using Base::primalVariable_;
@ -133,7 +130,7 @@ namespace Opm {
// --------- Protected methods ---------
// Need to declare Base members we want to use here.
using Base::wellsActive;
using Base::stdWells;
using Base::wells;
using Base::variableState;
using Base::computeGasPressure;

View File

@ -389,7 +389,6 @@ namespace Opm {
std::vector<double>& rvmax_perf,
std::vector<double>& surf_dens_perf)
{
using namespace Opm::AutoDiffGrid;
// 1. Compute properties required by computeConnectionPressureDelta().
// Note that some of the complexity of this part is due to the function
@ -765,7 +764,7 @@ namespace Opm {
Base::extractWellPerfProperties(state, mob_perfcells, b_perfcells);
if (has_solvent_) {
int gas_pos = fluid_.phaseUsage().phase_pos[Gas];
const std::vector<int>& well_cells = wops_.well_cells;
const std::vector<int>& well_cells = stdWells().wellOps().well_cells;
const int nperf = well_cells.size();
// Gas and solvent is combinded and solved together
// The input in the well equation is then the

View File

@ -24,7 +24,7 @@
#include <dune/common/shared_ptr.hh>
namespace Opm
{
#if defined(HAVE_DUNE_CORNERPOINT)
#if defined(HAVE_OPM_GRID)
#if defined(HAVE_MPI) && defined(HAVE_DUNE_ISTL) && DUNE_VERSION_NEWER(DUNE_GRID, 2, 3)
// Extracts the information about the data decomposition from the grid for dune-istl
void extractParallelGridInformationToISTL(const Dune::CpGrid& grid, boost::any& anyComm)
@ -45,5 +45,5 @@ void extractParallelGridInformationToISTL(const Dune::CpGrid& grid, boost::any&
void extractParallelGridInformationToISTL(const Dune::CpGrid&, boost::any&)
{}
#endif //defined(HAVE_MPI) && defined(HAVE_DUNE_ISTL) && DUNE_VERSION_NEWER(DUNE_GRID, 2, 3)
#endif //defined(HAVE_DUNE_CORNERPOINT)
#endif //defined(HAVE_OPM_GRID)
} // end namespace Opm

View File

@ -19,7 +19,7 @@
*/
#ifndef OPM_EXTRACTPARALLELGRIDINFORMATIONTOISTL_HEADER_INCLUDED
#define OPM_EXTRACTPARALLELGRIDINFORMATIONTOISTL_HEADER_INCLUDED
#ifdef HAVE_DUNE_CORNERPOINT
#ifdef HAVE_OPM_GRID
#include<dune/grid/CpGrid.hpp>
#include<boost/any.hpp>
@ -40,5 +40,5 @@ namespace Opm
void extractParallelGridInformationToISTL(const Dune::CpGrid& grid, boost::any& anyComm);
} // end namespace Opm
#endif //defined(HAVE_DUNE_CORNERPOINT)
#endif //defined(HAVE_OPM_GRID)
#endif // OPM_EXTRACTPARALLELGRIDINFORMATIONTOISTL_HEADER_INCLUDED

View File

@ -36,7 +36,7 @@
#include <Eigen/Eigen>
#ifdef HAVE_DUNE_CORNERPOINT
#ifdef HAVE_OPM_GRID
#include <dune/common/version.hh>
#include <dune/grid/CpGrid.hpp>
#include <dune/grid/common/mcmgmapper.hh>
@ -432,7 +432,7 @@ namespace Opm
const int dim = Opm::UgGridHelpers::dimensions(grid);
const double* faceNormal = Opm::UgGridHelpers::faceNormal(grid, faceIdx);
#if HAVE_DUNE_CORNERPOINT
#if HAVE_OPM_GRID
assert( dim <= 3 );
Dune::FieldVector< double, 3 > scaledFaceNormal( 0 );
for (int indx = 0; indx < dim; ++indx) {

View File

@ -77,7 +77,7 @@ void extractInternalFaces(const UnstructuredGrid& grid,
}
} // end namespace AutoDiffGrid
#ifdef HAVE_DUNE_CORNERPOINT
#ifdef HAVE_OPM_GRID
namespace AutoDiffGrid
{
@ -131,5 +131,5 @@ void extractInternalFaces(const Dune::CpGrid& grid,
}
} // end namespace AutoDiffGrid
#endif // HAVE_DUNE_CORNERPOINT
#endif // HAVE_OPM_GRID
} // end namespace Opm

View File

@ -33,7 +33,7 @@
#include <boost/range/iterator_range.hpp>
#ifdef HAVE_DUNE_CORNERPOINT
#ifdef HAVE_OPM_GRID
#include <dune/grid/CpGrid.hpp>
#include <dune/grid/cpgrid/GridHelpers.hpp>
#include <dune/grid/polyhedralgrid.hh>
@ -78,7 +78,7 @@ void extractInternalFaces(const UnstructuredGrid& grid,
} // end namespace AutoDiffGrid
} // end namespace Opm
#ifdef HAVE_DUNE_CORNERPOINT
#ifdef HAVE_OPM_GRID
namespace Opm
{
@ -144,7 +144,7 @@ struct ADFaceCellTraits<UnstructuredGrid>
typedef Eigen::Array<int, Eigen::Dynamic, 2, Eigen::RowMajor> Type;
};
#ifdef HAVE_DUNE_CORNERPOINT
#ifdef HAVE_OPM_GRID
// specialization for PolyhedralGrid as a fallback to UnstructuredGrid
template< int dim, int dimworld >
struct ADFaceCellTraits< Dune::PolyhedralGrid< dim, dimworld > >

View File

@ -24,7 +24,7 @@
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <opm/core/grid/GridManager.hpp>
#if HAVE_DUNE_CORNERPOINT
#if HAVE_OPM_GRID
#include <dune/grid/CpGrid.hpp>
#endif
@ -67,7 +67,7 @@ namespace Opm
};
#if HAVE_DUNE_CORNERPOINT
#if HAVE_OPM_GRID
/// Specialization for CpGrid.
template <>
class GridInit<Dune::CpGrid>
@ -86,7 +86,7 @@ namespace Opm
private:
Dune::CpGrid grid_;
};
#endif // HAVE_DUNE_CORNERPOINT
#endif // HAVE_OPM_GRID
} // namespace Opm

View File

@ -29,7 +29,7 @@
#include <opm/autodiff/WellStateFullyImplicitBlackoil.hpp>
#include <opm/autodiff/WellStateFullyImplicitBlackoil.hpp>
#if HAVE_DUNE_CORNERPOINT
#if HAVE_OPM_GRID
#include <dune/grid/common/p2pcommunicator.hh>
#endif
@ -91,7 +91,7 @@ namespace Opm
virtual const int* globalCell() const { return grid_.global_cell; }
};
#if HAVE_DUNE_CORNERPOINT
#if HAVE_OPM_GRID
template <>
class ParallelDebugOutput< Dune::CpGrid> : public ParallelDebugOutputInterface
{
@ -583,7 +583,7 @@ namespace Opm
// true if we are on I/O rank
const bool isIORank_;
};
#endif // #if HAVE_DUNE_CORNERPOINT
#endif // #if HAVE_OPM_GRID
} // end namespace Opm
#endif

View File

@ -46,7 +46,7 @@ inline void distributeGridAndData( Grid& ,
{
}
#if HAVE_DUNE_CORNERPOINT && HAVE_MPI
#if HAVE_OPM_GRID && HAVE_MPI
/// \brief a data handle to distribute the threshold pressures
class ThresholdPressureDataHandle
{

View File

@ -41,7 +41,7 @@
#include <boost/filesystem.hpp>
#ifdef HAVE_DUNE_CORNERPOINT
#ifdef HAVE_OPM_GRID
#include <opm/common/utility/platform_dependent/disable_warnings.h>
#include <dune/common/version.hh>
#include <dune/grid/io/file/vtk/vtkwriter.hh>
@ -203,7 +203,7 @@ namespace Opm
}
#endif
#ifdef HAVE_DUNE_CORNERPOINT
#ifdef HAVE_OPM_GRID
void outputStateVtk(const Dune::CpGrid& grid,
const Opm::SimulationDataContainer& state,
const int step,

View File

@ -48,7 +48,7 @@
#include <boost/filesystem.hpp>
#ifdef HAVE_DUNE_CORNERPOINT
#ifdef HAVE_OPM_GRID
#include <dune/grid/CpGrid.hpp>
#endif
namespace Opm
@ -71,7 +71,7 @@ namespace Opm
void outputWellStateMatlab(const Opm::WellState& well_state,
const int step,
const std::string& output_dir);
#ifdef HAVE_DUNE_CORNERPOINT
#ifdef HAVE_OPM_GRID
void outputStateVtk(const Dune::CpGrid& grid,
const Opm::SimulationDataContainer& state,
const int step,

View File

@ -0,0 +1,159 @@
/*
Copyright 2016 SINTEF ICT, Applied Mathematics.
Copyright 2016 Statoil ASA.
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 <opm/autodiff/StandardWells.hpp>
namespace Opm
{
StandardWells::
WellOps::WellOps(const Wells* wells)
: w2p(),
p2w(),
well_cells()
{
if( wells )
{
w2p = Eigen::SparseMatrix<double>(wells->well_connpos[ wells->number_of_wells ], wells->number_of_wells);
p2w = Eigen::SparseMatrix<double>(wells->number_of_wells, wells->well_connpos[ wells->number_of_wells ]);
const int nw = wells->number_of_wells;
const int* const wpos = wells->well_connpos;
typedef Eigen::Triplet<double> Tri;
std::vector<Tri> scatter, gather;
scatter.reserve(wpos[nw]);
gather .reserve(wpos[nw]);
for (int w = 0, i = 0; w < nw; ++w) {
for (; i < wpos[ w + 1 ]; ++i) {
scatter.push_back(Tri(i, w, 1.0));
gather .push_back(Tri(w, i, 1.0));
}
}
w2p.setFromTriplets(scatter.begin(), scatter.end());
p2w.setFromTriplets(gather .begin(), gather .end());
well_cells.assign(wells->well_cells, wells->well_cells + wells->well_connpos[wells->number_of_wells]);
}
}
StandardWells::StandardWells(const Wells* wells_arg)
: wells_(wells_arg)
, wops_(wells_arg)
, well_perforation_densities_(Vector())
, well_perforation_pressure_diffs_(Vector())
{
}
const Wells& StandardWells::wells() const
{
assert(wells_ != 0);
return *(wells_);
}
bool StandardWells::wellsActive() const
{
return wells_active_;
}
void StandardWells::setWellsActive(const bool wells_active)
{
wells_active_ = wells_active;
}
bool StandardWells::localWellsActive() const
{
return wells_ ? (wells_->number_of_wells > 0 ) : false;
}
const StandardWells::WellOps&
StandardWells::wellOps() const
{
return wops_;
}
Vector& StandardWells::wellPerforationDensities()
{
return well_perforation_densities_;
}
const Vector& StandardWells::wellPerforationDensities() const
{
return well_perforation_densities_;
}
Vector& StandardWells::wellPerforationPressureDiffs()
{
return well_perforation_pressure_diffs_;
}
const Vector& StandardWells::wellPerforationPressureDiffs() const
{
return well_perforation_pressure_diffs_;
}
}

View File

@ -0,0 +1,84 @@
/*
Copyright 2016 SINTEF ICT, Applied Mathematics.
Copyright 2016 Statoil ASA.
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/>.
*/
#ifndef OPM_STANDARDWELLS_HEADER_INCLUDED
#define OPM_STANDARDWELLS_HEADER_INCLUDED
#include <opm/common/utility/platform_dependent/disable_warnings.h>
#include <Eigen/Eigen>
#include <Eigen/Sparse>
#include <opm/common/utility/platform_dependent/reenable_warnings.h>
#include <cassert>
#include <opm/core/wells.h>
#include <opm/autodiff/AutoDiffBlock.hpp>
namespace Opm {
// --------- Types ---------
typedef AutoDiffBlock<double> ADB;
typedef ADB::V Vector;
/// Class for handling the standard well model.
class StandardWells {
protected:
struct WellOps {
explicit WellOps(const Wells* wells);
Eigen::SparseMatrix<double> w2p; // well -> perf (scatter)
Eigen::SparseMatrix<double> p2w; // perf -> well (gather)
std::vector<int> well_cells; // the set of perforated cells
};
public:
// --------- Public methods ---------
explicit StandardWells(const Wells* wells);
const Wells& wells() const;
/// return true if wells are available in the reservoir
bool wellsActive() const;
void setWellsActive(const bool wells_active);
/// return true if wells are available on this process
bool localWellsActive() const;
const WellOps& wellOps() const;
/// Density of each well perforation
Vector& wellPerforationDensities();
const Vector& wellPerforationDensities() const;
/// Diff to bhp for each well perforation.
Vector& wellPerforationPressureDiffs();
const Vector& wellPerforationPressureDiffs() const;
protected:
bool wells_active_;
const Wells* wells_;
const WellOps wops_;
Vector well_perforation_densities_;
Vector well_perforation_pressure_diffs_;
};
} // namespace Opm
#endif

View File

@ -158,13 +158,11 @@ namespace Opm {
using Base::fluid_;
using Base::geo_;
using Base::rock_comp_props_;
using Base::wells_;
using Base::linsolver_;
using Base::active_;
using Base::canph_;
using Base::cells_;
using Base::ops_;
using Base::wops_;
using Base::has_disgas_;
using Base::has_vapoil_;
using Base::param_;
@ -172,7 +170,6 @@ namespace Opm {
using Base::threshold_pressures_by_connection_;
using Base::rq_;
using Base::phaseCondition_;
using Base::well_perforation_pressure_diffs_;
using Base::residual_;
using Base::terminal_output_;
using Base::primalVariable_;
@ -181,8 +178,9 @@ namespace Opm {
// --------- Protected methods ---------
// Need to declare Base members we want to use here.
using Base::wellsActive;
using Base::stdWells;
using Base::wells;
using Base::wellsActive;
using Base::variableState;
using Base::computePressures;
using Base::computeGasPressure;

View File

@ -731,8 +731,8 @@ namespace Opm {
ADB b_perfcells = subset(rq_[water_pos].b, well_cells);
const ADB& p_perfcells = subset(state.pressure, well_cells);
const V& cdp = well_perforation_pressure_diffs_;
const ADB perfpressure = (wops_.w2p * state.bhp) + cdp;
const V& cdp = stdWells().wellPerforationPressureDiffs();
const ADB perfpressure = (stdWells().wellOps().w2p * state.bhp) + cdp;
// Pressure drawdown (also used to determine direction of flow)
const ADB drawdown = p_perfcells - perfpressure;

View File

@ -35,7 +35,7 @@
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#if HAVE_DUNE_CORNERPOINT
#if HAVE_OPM_GRID
#include <dune/common/version.hh>
#if DUNE_VERSION_NEWER(DUNE_GRID, 2,3)
#include <dune/common/parallel/mpihelper.hh>
@ -261,7 +261,7 @@ void checkTransmissibilityValues(const G& grid,
}
}
#if HAVE_DUNE_CORNERPOINT
#if HAVE_OPM_GRID
BOOST_AUTO_TEST_CASE(TransmissibilityMultipliersCpGrid)
{
int argc = 1;