From 148038939d80dc330e619ba1a99a9f0d511460ed Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Fri, 8 Jul 2016 14:42:02 +0800 Subject: [PATCH 01/18] add computeFIP method. --- opm/autodiff/SimulatorBase.hpp | 2 ++ opm/autodiff/SimulatorBase_impl.hpp | 33 +++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/opm/autodiff/SimulatorBase.hpp b/opm/autodiff/SimulatorBase.hpp index 39f223e82..315b946c9 100644 --- a/opm/autodiff/SimulatorBase.hpp +++ b/opm/autodiff/SimulatorBase.hpp @@ -157,6 +157,8 @@ namespace Opm const Wells* wells, const BlackoilState& x, WellState& xw); + double computeFIP(const ReservoirState& state); + void computeWellPotentials(const Wells* wells, const WellState& xw, diff --git a/opm/autodiff/SimulatorBase_impl.hpp b/opm/autodiff/SimulatorBase_impl.hpp index bf46f5935..5e17cd07c 100644 --- a/opm/autodiff/SimulatorBase_impl.hpp +++ b/opm/autodiff/SimulatorBase_impl.hpp @@ -178,6 +178,12 @@ namespace Opm // Compute reservoir volumes for RESV controls. asImpl().computeRESV(timer.currentStepNum(), wells, state, well_state); + // Comput original FIP. + OpmLog::info("PORV: " + std::to_string(unit::convert::to(geo_.poreVolume().sum(), unit::stb))); + const V OOIP = asImpl().computeFIP(state); + OpmLog::info("Original Fluid oil in place: " + std::to_string(unit::convert::to(original_fip, unit::stb))); + + //OpmLog::info("Original Fluid oil in place: " + std::to_string(original_fip)); // Run a multiple steps of the solver depending on the time step control. solver_timer.start(); @@ -249,9 +255,12 @@ namespace Opm // Report timing. const double st = solver_timer.secsSinceStart(); + const double current_fip = asImpl().computeFIP(state); + OpmLog::info("Currnet Fluid oil in place: " + std::to_string(unit::convert::to(current_fip, unit::stb))); + //OpmLog::info("Currnet Fluid oil in place: " + std::to_string(current_fip)); // accumulate total time stime += st; - + if ( terminal_output_ ) { std::string msg; @@ -626,7 +635,27 @@ namespace Opm } - + template + V SimulatorBase::computeFIP(const ReservoirState& state) + { + using namespace Opm::AutoDiffGrid; + const int np = state.numPhases(); + const int nc = numCells(grid_); + const Opm::PhaseUsage& pu = props_.phaseUsage(); + V so = V::Zero(nc); + V sw = V::Zero(nc); + V sg = V::Zero(nc); + for (int c = 0; c < nc; ++c) { + so[c] = state.saturation()[c*np + pu.phase_pos[BlackoilPhases::Liquid]]; + sw[c] = state.saturation()[c*np + pu.phase_pos[BlackoilPhases::Aqua]]; + sg[c] = state.saturation()[c*np + pu.phase_pos[BlackoilPhases::Vapour]]; + } + V fip(V::Zero(np)); + fip[0] = (geo_.poreVolume() * so).sum(); + fip[1] = (geo_.poreVolume() * sw).sum(); + fip[2] = (geo_.poreVolume() * sg).sum(); + return fip; + } template From 78a5381f5d317e8797d81e01fb559776de19e468 Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Mon, 11 Jul 2016 09:28:54 +0800 Subject: [PATCH 02/18] output water and gas fluid in place. --- opm/autodiff/SimulatorBase.hpp | 2 +- opm/autodiff/SimulatorBase_impl.hpp | 23 ++++++++++++++--------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/opm/autodiff/SimulatorBase.hpp b/opm/autodiff/SimulatorBase.hpp index 315b946c9..d66ab5c17 100644 --- a/opm/autodiff/SimulatorBase.hpp +++ b/opm/autodiff/SimulatorBase.hpp @@ -157,7 +157,7 @@ namespace Opm const Wells* wells, const BlackoilState& x, WellState& xw); - double computeFIP(const ReservoirState& state); + V computeFIP(const ReservoirState& state); void computeWellPotentials(const Wells* wells, diff --git a/opm/autodiff/SimulatorBase_impl.hpp b/opm/autodiff/SimulatorBase_impl.hpp index 5e17cd07c..ebaedd37b 100644 --- a/opm/autodiff/SimulatorBase_impl.hpp +++ b/opm/autodiff/SimulatorBase_impl.hpp @@ -135,6 +135,12 @@ namespace Opm std::vector well_potentials; DynamicListEconLimited dynamic_list_econ_limited; + OpmLog::info("PORV: " + std::to_string(unit::convert::to(geo_.poreVolume().sum(), unit::stb))); + V OOIP = asImpl().computeFIP(state); + OOIP[0] = unit::convert::to(OOIP[0], unit::stb); + OOIP[1] = unit::convert::to(OOIP[1], unit::stb); + OOIP[2] = unit::convert::to(OOIP[2], 1000*unit::cubic(unit::feet)); + // Main simulation loop. while (!timer.done()) { // Report timestep. @@ -178,12 +184,6 @@ namespace Opm // Compute reservoir volumes for RESV controls. asImpl().computeRESV(timer.currentStepNum(), wells, state, well_state); - // Comput original FIP. - OpmLog::info("PORV: " + std::to_string(unit::convert::to(geo_.poreVolume().sum(), unit::stb))); - const V OOIP = asImpl().computeFIP(state); - OpmLog::info("Original Fluid oil in place: " + std::to_string(unit::convert::to(original_fip, unit::stb))); - - //OpmLog::info("Original Fluid oil in place: " + std::to_string(original_fip)); // Run a multiple steps of the solver depending on the time step control. solver_timer.start(); @@ -255,9 +255,14 @@ namespace Opm // Report timing. const double st = solver_timer.secsSinceStart(); - const double current_fip = asImpl().computeFIP(state); - OpmLog::info("Currnet Fluid oil in place: " + std::to_string(unit::convert::to(current_fip, unit::stb))); - //OpmLog::info("Currnet Fluid oil in place: " + std::to_string(current_fip)); + V COIP = asImpl().computeFIP(state); + COIP[0] = unit::convert::to(COIP[0], unit::stb); + COIP[1] = unit::convert::to(COIP[1], unit::stb); + COIP[2] = unit::convert::to(COIP[2], 1000*unit::cubic(unit::feet)); + OpmLog::info("*********************Fluid in Place******************"); + OpmLog::info("----------Oil--------Wat---------Gas"); + OpmLog::info("Currently : " + std::to_string(COIP[0]) + " " + std::to_string(COIP[1]) + " " + std::to_string(COIP[2])); + OpmLog::info("Originally: " + std::to_string(OOIP[0]) + " " + std::to_string(OOIP[1]) + " " + std::to_string(OOIP[2])); // accumulate total time stime += st; From 28583e4237eacf3a35d5aa71289f6c8550b18bb1 Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Mon, 18 Jul 2016 08:50:50 +0800 Subject: [PATCH 03/18] Add computeFluidInPlace function. --- opm/autodiff/BlackoilModelBase.hpp | 4 ++ opm/autodiff/BlackoilModelBase_impl.hpp | 51 +++++++++++++++++++ opm/autodiff/BlackoilSequentialModel.hpp | 7 ++- opm/autodiff/BlackoilTransportModel.hpp | 9 ++++ opm/autodiff/NonlinearSolver.hpp | 4 ++ opm/autodiff/NonlinearSolver_impl.hpp | 8 +++ opm/autodiff/SimulatorBase_impl.hpp | 45 +++++++++++----- ...FullyImplicitCompressiblePolymerSolver.cpp | 35 ++++++++++++- ...FullyImplicitCompressiblePolymerSolver.hpp | 19 ++++--- 9 files changed, 159 insertions(+), 23 deletions(-) diff --git a/opm/autodiff/BlackoilModelBase.hpp b/opm/autodiff/BlackoilModelBase.hpp index cd4117443..0b961b42e 100644 --- a/opm/autodiff/BlackoilModelBase.hpp +++ b/opm/autodiff/BlackoilModelBase.hpp @@ -260,6 +260,10 @@ namespace Opm { WellModel& wellModel() { return well_model_; } const WellModel& wellModel() const { return well_model_; } + /// Calculate FIP + V computeFluidInPlace(const ReservoirState& x, + const WellState& xw); + protected: // --------- Types and enums --------- diff --git a/opm/autodiff/BlackoilModelBase_impl.hpp b/opm/autodiff/BlackoilModelBase_impl.hpp index 084fe7b0a..debfca712 100644 --- a/opm/autodiff/BlackoilModelBase_impl.hpp +++ b/opm/autodiff/BlackoilModelBase_impl.hpp @@ -2295,6 +2295,57 @@ namespace detail { + + template + V + BlackoilModelBase:: + computeFluidInPlace(const ReservoirState& x, + const WellState& xw) + { + SolutionState state = asImpl().variableState(x, xw); + const Opm::PhaseUsage& pu = fluid_.phaseUsage(); + using namespace Opm::AutoDiffGrid; + const int nc = numCells(grid_); + const ADB& press = state.pressure; + const ADB& temp = state.temperature; + const std::vector& sat = state.saturation; + const ADB& rs = state.rs; + const ADB& rv = state.rv; + + const std::vector cond = phaseCondition(); + + const ADB pv_mult = poroMult(press); + const V& pv = geo_.poreVolume(); + const int maxnp = Opm::BlackoilPhases::MaxNumPhases; + std::vector fip(5, V::Zero(nc)); + // std::cout << "Oil sat: \n"; + //std::cout << sat[pu.phase_pos[Oil]].value() << std::endl; + //std::cout << "Gas sat: \n"; + //std::cout << sat[pu.phase_pos[Gas]].value() << std::endl; + for (int phase = 0; phase < maxnp; ++phase) { + if (active_[ phase ]) { + const int pos = pu.phase_pos[ phase ]; + const auto& b = asImpl().fluidReciprocFVF(phase, state.canonical_phase_pressures[phase], temp, rs, rv, cond); + fip[phase] = ((pv_mult * b * sat[pos] * pv).value()); + } + } + + if (active_[ Oil ] && active_[ Gas ]) { + // Account for gas dissolved in oil and vaporized oil + const int po = pu.phase_pos[Oil]; + const int pg = pu.phase_pos[Gas]; + fip[3] = state.rs.value() * fip[po]; + fip[4] = state.rv.value() * fip[pg]; + } + + V values(5); + for (int i = 0; i < 5; ++i) { + values[i] = int(fip[i].sum()); + } + return values; + + } + } // namespace Opm #endif // OPM_BLACKOILMODELBASE_IMPL_HEADER_INCLUDED diff --git a/opm/autodiff/BlackoilSequentialModel.hpp b/opm/autodiff/BlackoilSequentialModel.hpp index bb05cbcd4..13985b2ae 100644 --- a/opm/autodiff/BlackoilSequentialModel.hpp +++ b/opm/autodiff/BlackoilSequentialModel.hpp @@ -247,7 +247,12 @@ namespace Opm { } - + /// Compute fluid in place. + V computeFluidInPlace(const ReservoirState& x, + const WellState& xw) const + { + return transport_solver_.computeFluidInPlace(x, xw); + } diff --git a/opm/autodiff/BlackoilTransportModel.hpp b/opm/autodiff/BlackoilTransportModel.hpp index fed6f64cd..4373f07d5 100644 --- a/opm/autodiff/BlackoilTransportModel.hpp +++ b/opm/autodiff/BlackoilTransportModel.hpp @@ -159,6 +159,11 @@ namespace Opm { + V computeFluidInPlace(const ReservoirState& x, + const WellState& xw) + { + return asImpl().computeFluidInPlace(x, xw); + } @@ -275,6 +280,10 @@ namespace Opm { + + + + void assembleMassBalanceEq(const SolutionState& state) { // Compute b_p and the accumulation term b_p*s_p for each phase, diff --git a/opm/autodiff/NonlinearSolver.hpp b/opm/autodiff/NonlinearSolver.hpp index f0efb7733..3dc29f367 100644 --- a/opm/autodiff/NonlinearSolver.hpp +++ b/opm/autodiff/NonlinearSolver.hpp @@ -125,6 +125,10 @@ namespace Opm { /// Number of well iterations used in all calls to step(). int wellIterationsLastStep() const; + /// Compute fluid in place. + V computeFluidInPlace(const ReservoirState& x, + const WellState& xw) const; + /// Reference to physical model. const PhysicalModel& model() const; diff --git a/opm/autodiff/NonlinearSolver_impl.hpp b/opm/autodiff/NonlinearSolver_impl.hpp index a94f1b0a9..87f0a92ff 100644 --- a/opm/autodiff/NonlinearSolver_impl.hpp +++ b/opm/autodiff/NonlinearSolver_impl.hpp @@ -99,6 +99,14 @@ namespace Opm return wellIterationsLast_; } + template + V NonlinearSolver::computeFluidInPlace(const ReservoirState& x, + const WellState& xw) const + { + return model_->computeFluidInPlace(x, xw); + } + + template int NonlinearSolver:: diff --git a/opm/autodiff/SimulatorBase_impl.hpp b/opm/autodiff/SimulatorBase_impl.hpp index ebaedd37b..1079b8b5d 100644 --- a/opm/autodiff/SimulatorBase_impl.hpp +++ b/opm/autodiff/SimulatorBase_impl.hpp @@ -135,12 +135,10 @@ namespace Opm std::vector well_potentials; DynamicListEconLimited dynamic_list_econ_limited; - OpmLog::info("PORV: " + std::to_string(unit::convert::to(geo_.poreVolume().sum(), unit::stb))); - V OOIP = asImpl().computeFIP(state); - OOIP[0] = unit::convert::to(OOIP[0], unit::stb); - OOIP[1] = unit::convert::to(OOIP[1], unit::stb); - OOIP[2] = unit::convert::to(OOIP[2], 1000*unit::cubic(unit::feet)); - + const auto& units = eclipse_state_->getUnits(); + bool ooip_computed = false; + V OOIP; + double pv = geo_.poreVolume().sum(); // Main simulation loop. while (!timer.done()) { // Report timestep. @@ -191,6 +189,20 @@ namespace Opm auto solver = asImpl().createSolver(well_model); + // Compute FIP; + if (!ooip_computed) { + OOIP = solver->computeFluidInPlace(state, well_state); + if (units.getType() == UnitSystem::UnitType::UNIT_TYPE_FIELD) { + pv = unit::convert::to(pv, unit::stb); + OOIP[0] = unit::convert::to(OOIP[0], unit::stb); + OOIP[1] = unit::convert::to(OOIP[1], unit::stb); + OOIP[2] = unit::convert::to(OOIP[2], 1000*unit::cubic(unit::feet)); + OOIP[3] = unit::convert::to(OOIP[3], 1000*unit::cubic(unit::feet)); + OOIP[4] = unit::convert::to(OOIP[4], unit::stb); + ooip_computed = true; + } + } + if( terminal_output_ ) { std::ostringstream step_msg; @@ -254,15 +266,19 @@ namespace Opm // Report timing. const double st = solver_timer.secsSinceStart(); - - V COIP = asImpl().computeFIP(state); - COIP[0] = unit::convert::to(COIP[0], unit::stb); - COIP[1] = unit::convert::to(COIP[1], unit::stb); - COIP[2] = unit::convert::to(COIP[2], 1000*unit::cubic(unit::feet)); + V COIP = solver->computeFluidInPlace(state, well_state); + if (units.getType() == UnitSystem::UnitType::UNIT_TYPE_FIELD) { + COIP[0] = unit::convert::to(COIP[0], unit::stb); + COIP[1] = unit::convert::to(COIP[1], unit::stb); + COIP[2] = unit::convert::to(COIP[2], 1000*unit::cubic(unit::feet)); + COIP[3] = unit::convert::to(COIP[3], 1000*unit::cubic(unit::feet)); + COIP[4] = unit::convert::to(COIP[4], unit::stb); + } OpmLog::info("*********************Fluid in Place******************"); - OpmLog::info("----------Oil--------Wat---------Gas"); - OpmLog::info("Currently : " + std::to_string(COIP[0]) + " " + std::to_string(COIP[1]) + " " + std::to_string(COIP[2])); - OpmLog::info("Originally: " + std::to_string(OOIP[0]) + " " + std::to_string(OOIP[1]) + " " + std::to_string(OOIP[2])); + OpmLog::info("PORV : " + std::to_string(pv)); + OpmLog::info("----------Oil--------VapOil-------Wat---------Gas--------DisGas"); + OpmLog::info("Currently : " + std::to_string(COIP[1]) + " " + std::to_string(COIP[4]) + " " + std::to_string(COIP[0]) + " " + std::to_string(COIP[2]) + " " + std::to_string(COIP[3])); + OpmLog::info("Originally: " + std::to_string(OOIP[1]) + " " + std::to_string(OOIP[4]) + " " + std::to_string(OOIP[0]) + " " + std::to_string(OOIP[2]) + " " + std::to_string(OOIP[3])); // accumulate total time stime += st; @@ -655,6 +671,7 @@ namespace Opm sw[c] = state.saturation()[c*np + pu.phase_pos[BlackoilPhases::Aqua]]; sg[c] = state.saturation()[c*np + pu.phase_pos[BlackoilPhases::Vapour]]; } + // Get Bo, Bw, Bg. V fip(V::Zero(np)); fip[0] = (geo_.poreVolume() * so).sum(); fip[1] = (geo_.poreVolume() * sw).sum(); diff --git a/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.cpp b/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.cpp index 91c1aeaf3..507e7393a 100644 --- a/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.cpp +++ b/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.cpp @@ -520,7 +520,7 @@ namespace { } rq_[0].accum[aix] = pv_mult * rq_[0].b * sat[0]; rq_[1].accum[aix] = pv_mult * rq_[1].b * sat[1]; - const ADB cmax = ADB::constant(cmax_, state.concentration.blockPattern()); + const ADB cmax = ADB::constant(cmax_, state.concentration.blockPattern()); const ADB ads = polymer_props_ad_.adsorption(state.concentration, cmax); const double rho_rock = polymer_props_ad_.rockDensity(); const V phi = Eigen::Map(&fluid_.porosity()[0], grid_.number_of_cells, 1); @@ -532,6 +532,39 @@ namespace { + V + FullyImplicitCompressiblePolymerSolver::computeFluidInPlace(const PolymerBlackoilState& x, + const WellStateFullyImplicitBlackoilPolymer& xw) + { + const SolutionState state = variableState(x, xw); + const int nc = grid_.number_of_cells; + + const ADB& press = state.pressure; + const ADB& temp = state.temperature; + const std::vector& sat = state.saturation; + + const std::vector cond = phaseCondition(); + std::vector pressure = computePressures(state); + + const ADB pv_mult = poroMult(press); + const V& pv = geo_.poreVolume(); + std::vector fip(5, V::Zero(nc)); + for (int phase = 0; phase < 2; ++phase) { + const ADB& b = fluidReciprocFVF(phase, pressure[phase], temp, cond, cells_); + fip[phase] = (pv_mult * b * sat[phase] * pv).value(); + } + + V values(5); + for (int i = 0; i < 5; ++i) { + values[i] = fip[i].sum(); + } + + return values; + } + + + + void FullyImplicitCompressiblePolymerSolver:: diff --git a/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.hpp b/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.hpp index 1d309a9b8..96a8cf34f 100644 --- a/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.hpp +++ b/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.hpp @@ -54,6 +54,13 @@ namespace Opm { class FullyImplicitCompressiblePolymerSolver { public: + typedef AutoDiffBlock ADB; + typedef ADB::V V; + typedef ADB::M M; + typedef Eigen::Array DataBlock; /// Construct a solver. It will retain references to the /// arguments of this functions, and they are expected to /// remain in scope for the lifetime of the solver. @@ -102,14 +109,12 @@ namespace Opm { double relativeChange(const PolymerBlackoilState& previous, const PolymerBlackoilState& current ) const; + /// Compute fluid in place. + V computeFluidInPlace(const PolymerBlackoilState& x, + const WellStateFullyImplicitBlackoilPolymer& xw); + private: - typedef AutoDiffBlock ADB; - typedef ADB::V V; - typedef ADB::M M; - typedef Eigen::Array DataBlock; + struct ReservoirResidualQuant { ReservoirResidualQuant(); From 056708574c93a519e436d0862e214fac4fb6b792 Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Tue, 19 Jul 2016 09:33:03 +0800 Subject: [PATCH 04/18] compute fluid in place by regions. --- opm/autodiff/BlackoilModelBase.hpp | 6 +- opm/autodiff/BlackoilModelBase_impl.hpp | 56 +++++++---- opm/autodiff/BlackoilSequentialModel.hpp | 8 +- opm/autodiff/BlackoilTransportModel.hpp | 8 +- opm/autodiff/NonlinearSolver.hpp | 6 +- opm/autodiff/NonlinearSolver_impl.hpp | 8 +- opm/autodiff/SimulatorBase.hpp | 8 +- opm/autodiff/SimulatorBase_impl.hpp | 93 ++++++++++--------- ...FullyImplicitCompressiblePolymerSolver.cpp | 24 +++-- ...FullyImplicitCompressiblePolymerSolver.hpp | 6 +- 10 files changed, 136 insertions(+), 87 deletions(-) diff --git a/opm/autodiff/BlackoilModelBase.hpp b/opm/autodiff/BlackoilModelBase.hpp index 0b961b42e..aa5f22e18 100644 --- a/opm/autodiff/BlackoilModelBase.hpp +++ b/opm/autodiff/BlackoilModelBase.hpp @@ -261,8 +261,10 @@ namespace Opm { const WellModel& wellModel() const { return well_model_; } /// Calculate FIP - V computeFluidInPlace(const ReservoirState& x, - const WellState& xw); + std::vector + computeFluidInPlace(const ReservoirState& x, + const WellState& xw, + const std::vector& fipnum); protected: diff --git a/opm/autodiff/BlackoilModelBase_impl.hpp b/opm/autodiff/BlackoilModelBase_impl.hpp index debfca712..2c26ab9dd 100644 --- a/opm/autodiff/BlackoilModelBase_impl.hpp +++ b/opm/autodiff/BlackoilModelBase_impl.hpp @@ -2297,36 +2297,45 @@ namespace detail { template - V + std::vector BlackoilModelBase:: computeFluidInPlace(const ReservoirState& x, - const WellState& xw) + const WellState& xw, + const std::vector& fipnum) { - SolutionState state = asImpl().variableState(x, xw); - const Opm::PhaseUsage& pu = fluid_.phaseUsage(); using namespace Opm::AutoDiffGrid; const int nc = numCells(grid_); - const ADB& press = state.pressure; - const ADB& temp = state.temperature; - const std::vector& sat = state.saturation; - const ADB& rs = state.rs; - const ADB& rv = state.rv; + const int np = x.numPhases(); + + SolutionState state(np); + const DataBlock s = Eigen::Map(& x.saturation()[0], nc, np); + state.pressure = ADB::constant(Eigen::Map(& x.pressure()[0], nc, 1)); + state.temperature = ADB::constant(Eigen::Map(& x.temperature()[0], nc, 1)); + state.saturation[Water] = ADB::constant(s.col(Water)); + state.saturation[Oil] = ADB::constant(s.col(Oil)); + state.saturation[Gas] = ADB::constant(s.col(Gas)); + state.rs = ADB::constant(Eigen::Map(& x.gasoilratio()[0], nc, 1)); + state.rv = ADB::constant(Eigen::Map(& x.rv()[0], nc, 1)); + state.canonical_phase_pressures = computePressures(state.pressure, + state.saturation[Water], + state.saturation[Oil], + state.saturation[Gas]); + + const Opm::PhaseUsage& pu = fluid_.phaseUsage(); const std::vector cond = phaseCondition(); - const ADB pv_mult = poroMult(press); + + + const ADB pv_mult = poroMult(state.pressure); const V& pv = geo_.poreVolume(); const int maxnp = Opm::BlackoilPhases::MaxNumPhases; std::vector fip(5, V::Zero(nc)); - // std::cout << "Oil sat: \n"; - //std::cout << sat[pu.phase_pos[Oil]].value() << std::endl; - //std::cout << "Gas sat: \n"; - //std::cout << sat[pu.phase_pos[Gas]].value() << std::endl; for (int phase = 0; phase < maxnp; ++phase) { if (active_[ phase ]) { const int pos = pu.phase_pos[ phase ]; - const auto& b = asImpl().fluidReciprocFVF(phase, state.canonical_phase_pressures[phase], temp, rs, rv, cond); - fip[phase] = ((pv_mult * b * sat[pos] * pv).value()); + const auto& b = asImpl().fluidReciprocFVF(phase, state.canonical_phase_pressures[phase], state.temperature, state.rs, state.rv, cond); + fip[phase] = ((pv_mult * b * state.saturation[pos] * pv).value()); } } @@ -2338,10 +2347,19 @@ namespace detail { fip[4] = state.rv.value() * fip[pg]; } - V values(5); - for (int i = 0; i < 5; ++i) { - values[i] = int(fip[i].sum()); + const int dims = *std::max_element(fipnum.begin(), fipnum.end()) + 1; + std::vector values(dims, V::Zero(5)); + + for (int d = 0; d < dims; ++d) { + for (int c = 0; c < nc; ++c) { + if (fipnum[c] == d) { + for (int i = 0; i < 5; ++i) { + values[d][i] += fip[i][c]; + } + } + } } + return values; } diff --git a/opm/autodiff/BlackoilSequentialModel.hpp b/opm/autodiff/BlackoilSequentialModel.hpp index 13985b2ae..e5ee22866 100644 --- a/opm/autodiff/BlackoilSequentialModel.hpp +++ b/opm/autodiff/BlackoilSequentialModel.hpp @@ -248,10 +248,12 @@ namespace Opm { /// Compute fluid in place. - V computeFluidInPlace(const ReservoirState& x, - const WellState& xw) const + std::vector + computeFluidInPlace(const ReservoirState& x, + const WellState& xw, + const std::vector& fipnum) const { - return transport_solver_.computeFluidInPlace(x, xw); + return transport_solver_.computeFluidInPlace(x, xw, fipnum); } diff --git a/opm/autodiff/BlackoilTransportModel.hpp b/opm/autodiff/BlackoilTransportModel.hpp index 4373f07d5..801a4065f 100644 --- a/opm/autodiff/BlackoilTransportModel.hpp +++ b/opm/autodiff/BlackoilTransportModel.hpp @@ -159,10 +159,12 @@ namespace Opm { - V computeFluidInPlace(const ReservoirState& x, - const WellState& xw) + std::vector + computeFluidInPlace(const ReservoirState& x, + const WellState& xw, + const std::vector& fipnum) { - return asImpl().computeFluidInPlace(x, xw); + return asImpl().computeFluidInPlace(x, xw, fipnum); } diff --git a/opm/autodiff/NonlinearSolver.hpp b/opm/autodiff/NonlinearSolver.hpp index 3dc29f367..d6ab0cc70 100644 --- a/opm/autodiff/NonlinearSolver.hpp +++ b/opm/autodiff/NonlinearSolver.hpp @@ -126,8 +126,10 @@ namespace Opm { int wellIterationsLastStep() const; /// Compute fluid in place. - V computeFluidInPlace(const ReservoirState& x, - const WellState& xw) const; + std::vector + computeFluidInPlace(const ReservoirState& x, + const WellState& xw, + const std::vector& fipnum) const; /// Reference to physical model. const PhysicalModel& model() const; diff --git a/opm/autodiff/NonlinearSolver_impl.hpp b/opm/autodiff/NonlinearSolver_impl.hpp index 87f0a92ff..e5e690d10 100644 --- a/opm/autodiff/NonlinearSolver_impl.hpp +++ b/opm/autodiff/NonlinearSolver_impl.hpp @@ -100,10 +100,12 @@ namespace Opm } template - V NonlinearSolver::computeFluidInPlace(const ReservoirState& x, - const WellState& xw) const + std::vector + NonlinearSolver::computeFluidInPlace(const ReservoirState& x, + const WellState& xw, + const std::vector& fipnum) const { - return model_->computeFluidInPlace(x, xw); + return model_->computeFluidInPlace(x, xw, fipnum); } diff --git a/opm/autodiff/SimulatorBase.hpp b/opm/autodiff/SimulatorBase.hpp index d66ab5c17..b2cb3f1d2 100644 --- a/opm/autodiff/SimulatorBase.hpp +++ b/opm/autodiff/SimulatorBase.hpp @@ -157,7 +157,13 @@ namespace Opm const Wells* wells, const BlackoilState& x, WellState& xw); - V computeFIP(const ReservoirState& state); + + void + FIPUnitConvert(const UnitSystem& units, + std::vector& fip); + + V + FIPTotals(const std::vector& fip); void computeWellPotentials(const Wells* wells, diff --git a/opm/autodiff/SimulatorBase_impl.hpp b/opm/autodiff/SimulatorBase_impl.hpp index 1079b8b5d..1b5cb7c8c 100644 --- a/opm/autodiff/SimulatorBase_impl.hpp +++ b/opm/autodiff/SimulatorBase_impl.hpp @@ -135,10 +135,13 @@ namespace Opm std::vector well_potentials; DynamicListEconLimited dynamic_list_econ_limited; - const auto& units = eclipse_state_->getUnits(); bool ooip_computed = false; - V OOIP; - double pv = geo_.poreVolume().sum(); + std::vector fipnum = eclipse_state_->get3DProperties().getRegions("FIPNUM"); + if (fipnum.empty()) { + fipnum.resize(AutoDiffGrid::numCells(grid_)); + std::fill(fipnum.begin(), fipnum.end(), 0); + } + std::vector OOIP; // Main simulation loop. while (!timer.done()) { // Report timestep. @@ -189,18 +192,11 @@ namespace Opm auto solver = asImpl().createSolver(well_model); - // Compute FIP; + // Compute orignal FIP; if (!ooip_computed) { - OOIP = solver->computeFluidInPlace(state, well_state); - if (units.getType() == UnitSystem::UnitType::UNIT_TYPE_FIELD) { - pv = unit::convert::to(pv, unit::stb); - OOIP[0] = unit::convert::to(OOIP[0], unit::stb); - OOIP[1] = unit::convert::to(OOIP[1], unit::stb); - OOIP[2] = unit::convert::to(OOIP[2], 1000*unit::cubic(unit::feet)); - OOIP[3] = unit::convert::to(OOIP[3], 1000*unit::cubic(unit::feet)); - OOIP[4] = unit::convert::to(OOIP[4], unit::stb); - ooip_computed = true; - } + OOIP = solver->computeFluidInPlace(state, well_state, fipnum); + FIPUnitConvert(eclipse_state_->getUnits(), OOIP); + ooip_computed = true; } if( terminal_output_ ) @@ -266,19 +262,17 @@ namespace Opm // Report timing. const double st = solver_timer.secsSinceStart(); - V COIP = solver->computeFluidInPlace(state, well_state); - if (units.getType() == UnitSystem::UnitType::UNIT_TYPE_FIELD) { - COIP[0] = unit::convert::to(COIP[0], unit::stb); - COIP[1] = unit::convert::to(COIP[1], unit::stb); - COIP[2] = unit::convert::to(COIP[2], 1000*unit::cubic(unit::feet)); - COIP[3] = unit::convert::to(COIP[3], 1000*unit::cubic(unit::feet)); - COIP[4] = unit::convert::to(COIP[4], unit::stb); - } - OpmLog::info("*********************Fluid in Place******************"); - OpmLog::info("PORV : " + std::to_string(pv)); - OpmLog::info("----------Oil--------VapOil-------Wat---------Gas--------DisGas"); - OpmLog::info("Currently : " + std::to_string(COIP[1]) + " " + std::to_string(COIP[4]) + " " + std::to_string(COIP[0]) + " " + std::to_string(COIP[2]) + " " + std::to_string(COIP[3])); - OpmLog::info("Originally: " + std::to_string(OOIP[1]) + " " + std::to_string(OOIP[4]) + " " + std::to_string(OOIP[0]) + " " + std::to_string(OOIP[2]) + " " + std::to_string(OOIP[3])); + // Compute current FIP. + std::vector COIP; + COIP = solver->computeFluidInPlace(state, well_state, fipnum); + FIPUnitConvert(eclipse_state_->getUnits(), COIP); + V OOIP_totals = FIPTotals(OOIP); + V COIP_totals = FIPTotals(COIP); + OpmLog::info("*****************************Field Totals**************************"); + OpmLog::info(" Liquid VAPOUR Water Free Gas Dissolved Gas"); + OpmLog::info("Currently in place: " + std::to_string(COIP_totals[1]) + " " + std::to_string(COIP_totals[4]) + " " + std::to_string(COIP_totals[0]) + " " + std::to_string(COIP_totals[2]) + " " + std::to_string(COIP_totals[3])); + OpmLog::info("Originally in place: " + std::to_string(OOIP_totals[1]) + " " + std::to_string(OOIP_totals[4]) + " " + std::to_string(OOIP_totals[0]) + " " + std::to_string(OOIP_totals[2]) + " " + std::to_string(OOIP_totals[3]) + "\n"); + // accumulate total time stime += st; @@ -657,29 +651,38 @@ namespace Opm template - V SimulatorBase::computeFIP(const ReservoirState& state) + void + SimulatorBase::FIPUnitConvert(const UnitSystem& units, + std::vector& fip) { - using namespace Opm::AutoDiffGrid; - const int np = state.numPhases(); - const int nc = numCells(grid_); - const Opm::PhaseUsage& pu = props_.phaseUsage(); - V so = V::Zero(nc); - V sw = V::Zero(nc); - V sg = V::Zero(nc); - for (int c = 0; c < nc; ++c) { - so[c] = state.saturation()[c*np + pu.phase_pos[BlackoilPhases::Liquid]]; - sw[c] = state.saturation()[c*np + pu.phase_pos[BlackoilPhases::Aqua]]; - sg[c] = state.saturation()[c*np + pu.phase_pos[BlackoilPhases::Vapour]]; + if (units.getType() == UnitSystem::UnitType::UNIT_TYPE_FIELD) { + for (int i = 0; i < fip.size(); ++i) { + fip[i][0] = unit::convert::to(fip[i][0], unit::stb); + fip[i][1] = unit::convert::to(fip[i][1], unit::stb); + fip[i][2] = unit::convert::to(fip[i][2], 1000*unit::cubic(unit::feet)); + fip[i][3] = unit::convert::to(fip[i][3], 1000*unit::cubic(unit::feet)); + fip[i][4] = unit::convert::to(fip[i][4], unit::stb); + } } - // Get Bo, Bw, Bg. - V fip(V::Zero(np)); - fip[0] = (geo_.poreVolume() * so).sum(); - fip[1] = (geo_.poreVolume() * sw).sum(); - fip[2] = (geo_.poreVolume() * sg).sum(); - return fip; } + template + V + SimulatorBase::FIPTotals(const std::vector& fip) + { + V totals(V::Zero(5)); + for (int i = 0; i < 5; ++i) { + for (size_t reg = 0; reg < fip.size(); ++reg) { + totals[i] += fip[reg][i]; + } + } + + return totals; + } + + + template void SimulatorBase:: diff --git a/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.cpp b/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.cpp index 507e7393a..234594016 100644 --- a/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.cpp +++ b/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.cpp @@ -532,11 +532,12 @@ namespace { - V + std::vector FullyImplicitCompressiblePolymerSolver::computeFluidInPlace(const PolymerBlackoilState& x, - const WellStateFullyImplicitBlackoilPolymer& xw) + const WellStateFullyImplicitBlackoilPolymer& xw, + const std::vector& fipnum) { - const SolutionState state = variableState(x, xw); + const SolutionState state = constantState(x, xw); const int nc = grid_.number_of_cells; const ADB& press = state.pressure; @@ -554,12 +555,21 @@ namespace { fip[phase] = (pv_mult * b * sat[phase] * pv).value(); } - V values(5); - for (int i = 0; i < 5; ++i) { - values[i] = fip[i].sum(); + + const int dims = *std::max_element(fipnum.begin(), fipnum.end()); + std::vector values(dims, V::Zero(5)); + + for (int d = 0; d < dims; ++d) { + for (int c = 0; c < nc; ++c) { + for (int i = 0; i < 5; ++i) { + if (fipnum[c] == d) { + values[d][i] += fip[c][i]; + } + } + } } - return values; + return values; } diff --git a/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.hpp b/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.hpp index 96a8cf34f..e42e15a50 100644 --- a/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.hpp +++ b/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.hpp @@ -110,8 +110,10 @@ namespace Opm { const PolymerBlackoilState& current ) const; /// Compute fluid in place. - V computeFluidInPlace(const PolymerBlackoilState& x, - const WellStateFullyImplicitBlackoilPolymer& xw); + std::vector + computeFluidInPlace(const PolymerBlackoilState& x, + const WellStateFullyImplicitBlackoilPolymer& xw, + const std::vector& fipnum); private: From 90086f690e3580d47525b845e1d18a27e8e2645a Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Fri, 29 Jul 2016 11:07:21 +0800 Subject: [PATCH 05/18] only compute field fluid in place. --- opm/autodiff/BlackoilModelBase_impl.hpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/opm/autodiff/BlackoilModelBase_impl.hpp b/opm/autodiff/BlackoilModelBase_impl.hpp index 2c26ab9dd..fbeda4f92 100644 --- a/opm/autodiff/BlackoilModelBase_impl.hpp +++ b/opm/autodiff/BlackoilModelBase_impl.hpp @@ -2347,15 +2347,13 @@ namespace detail { fip[4] = state.rv.value() * fip[pg]; } - const int dims = *std::max_element(fipnum.begin(), fipnum.end()) + 1; + const int dims = 1; std::vector values(dims, V::Zero(5)); for (int d = 0; d < dims; ++d) { for (int c = 0; c < nc; ++c) { - if (fipnum[c] == d) { - for (int i = 0; i < 5; ++i) { - values[d][i] += fip[i][c]; - } + for (int i = 0; i < 5; ++i) { + values[d][i] += fip[i][c]; } } } From 7c3148c1f3d6b0c6970d30b87194281fd6bcebd4 Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Tue, 2 Aug 2016 16:28:42 +0800 Subject: [PATCH 06/18] get cell FIPNUM values. --- opm/autodiff/SimulatorBase_impl.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opm/autodiff/SimulatorBase_impl.hpp b/opm/autodiff/SimulatorBase_impl.hpp index 1b5cb7c8c..f5cf23598 100644 --- a/opm/autodiff/SimulatorBase_impl.hpp +++ b/opm/autodiff/SimulatorBase_impl.hpp @@ -136,7 +136,7 @@ namespace Opm DynamicListEconLimited dynamic_list_econ_limited; bool ooip_computed = false; - std::vector fipnum = eclipse_state_->get3DProperties().getRegions("FIPNUM"); + std::vector fipnum = eclipse_state_->get3DProperties().getIntGridProperty("FIPNUM").getData(); if (fipnum.empty()) { fipnum.resize(AutoDiffGrid::numCells(grid_)); std::fill(fipnum.begin(), fipnum.end(), 0); From 59a2668152f7f930295566c1f2d2bd68997d5e1e Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Tue, 9 Aug 2016 15:16:15 +0800 Subject: [PATCH 07/18] compute different fip regions. --- opm/autodiff/BlackoilModelBase_impl.hpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/opm/autodiff/BlackoilModelBase_impl.hpp b/opm/autodiff/BlackoilModelBase_impl.hpp index fbeda4f92..ee45ee5c6 100644 --- a/opm/autodiff/BlackoilModelBase_impl.hpp +++ b/opm/autodiff/BlackoilModelBase_impl.hpp @@ -2347,13 +2347,14 @@ namespace detail { fip[4] = state.rv.value() * fip[pg]; } - const int dims = 1; + const int dims = *std::max_element(fipnum.begin(), fipnum.end()); std::vector values(dims, V::Zero(5)); - for (int d = 0; d < dims; ++d) { - for (int c = 0; c < nc; ++c) { - for (int i = 0; i < 5; ++i) { - values[d][i] += fip[i][c]; + for (int i = 0; i < 5; ++i) { + for (int c = 0; c < nc; ++c) { + if (fipnum[c] == (d + 1)) { + values[d][i] += fip[i][c]; + } } } } From aa96931f690e09e9ed7061275f0e439f8f16efc4 Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Tue, 9 Aug 2016 15:17:49 +0800 Subject: [PATCH 08/18] use a separate function to output fip and compress fipnum from eclipseState. --- opm/autodiff/SimulatorBase.hpp | 2 ++ opm/autodiff/SimulatorBase_impl.hpp | 34 ++++++++++++++++++++++------- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/opm/autodiff/SimulatorBase.hpp b/opm/autodiff/SimulatorBase.hpp index b2cb3f1d2..e1c53ffac 100644 --- a/opm/autodiff/SimulatorBase.hpp +++ b/opm/autodiff/SimulatorBase.hpp @@ -165,6 +165,8 @@ namespace Opm V FIPTotals(const std::vector& fip); + void + outputFluidInPlace(const V& oip, const V& cip); void computeWellPotentials(const Wells* wells, const WellState& xw, diff --git a/opm/autodiff/SimulatorBase_impl.hpp b/opm/autodiff/SimulatorBase_impl.hpp index f5cf23598..bf871ac54 100644 --- a/opm/autodiff/SimulatorBase_impl.hpp +++ b/opm/autodiff/SimulatorBase_impl.hpp @@ -136,10 +136,15 @@ namespace Opm DynamicListEconLimited dynamic_list_econ_limited; bool ooip_computed = false; - std::vector fipnum = eclipse_state_->get3DProperties().getIntGridProperty("FIPNUM").getData(); - if (fipnum.empty()) { - fipnum.resize(AutoDiffGrid::numCells(grid_)); + std::vector fipnum_global = eclipse_state_->get3DProperties().getIntGridProperty("FIPNUM").getData(); + //Get compressed cell fipnum. + std::vector fipnum(AutoDiffGrid::numCells(grid_)); + if (fipnum_global.empty()) { std::fill(fipnum.begin(), fipnum.end(), 0); + } else { + for (size_t c = 0; c < fipnum.size(); ++c) { + fipnum[c] = fipnum_global[AutoDiffGrid::globalCell(grid_)[c]]; + } } std::vector OOIP; // Main simulation loop. @@ -268,10 +273,13 @@ namespace Opm FIPUnitConvert(eclipse_state_->getUnits(), COIP); V OOIP_totals = FIPTotals(OOIP); V COIP_totals = FIPTotals(COIP); - OpmLog::info("*****************************Field Totals**************************"); - OpmLog::info(" Liquid VAPOUR Water Free Gas Dissolved Gas"); - OpmLog::info("Currently in place: " + std::to_string(COIP_totals[1]) + " " + std::to_string(COIP_totals[4]) + " " + std::to_string(COIP_totals[0]) + " " + std::to_string(COIP_totals[2]) + " " + std::to_string(COIP_totals[3])); - OpmLog::info("Originally in place: " + std::to_string(OOIP_totals[1]) + " " + std::to_string(OOIP_totals[4]) + " " + std::to_string(OOIP_totals[0]) + " " + std::to_string(OOIP_totals[2]) + " " + std::to_string(OOIP_totals[3]) + "\n"); + OpmLog::note("*****************************Field Totals**************************"); + outputFluidInPlace(OOIP_totals, COIP_totals); + for (size_t reg = 0; reg < OOIP.size(); ++reg) { + OpmLog::note("*****************************FIPNUM report region " + std::to_string(reg+1) + "**************************"); + outputFluidInPlace(OOIP[reg], COIP[reg]); + } + // accumulate total time stime += st; @@ -680,7 +688,17 @@ namespace Opm return totals; } - + + + + template + void + SimulatorBase::outputFluidInPlace(const V& oip, const V& cip) + { + OpmLog::note(" Liquid VAPOUR Water Free Gas Dissolved Gas"); + OpmLog::note("Currently in place: " + std::to_string(cip[1]) + " " + std::to_string(cip[4]) + " " + std::to_string(cip[0]) + " " + std::to_string(cip[2]) + " " + std::to_string(cip[3])); + OpmLog::note("Originaly in place: " + std::to_string(oip[1]) + " " + std::to_string(oip[4]) + " " + std::to_string(oip[0]) + " " + std::to_string(oip[2]) + " " + std::to_string(oip[3])); + } template From b2432c871f9c314e1eb4171f82584ba2d699b1f9 Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Tue, 9 Aug 2016 15:20:56 +0800 Subject: [PATCH 09/18] fix typo. --- opm/autodiff/SimulatorBase_impl.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opm/autodiff/SimulatorBase_impl.hpp b/opm/autodiff/SimulatorBase_impl.hpp index bf871ac54..8fb4fe8ad 100644 --- a/opm/autodiff/SimulatorBase_impl.hpp +++ b/opm/autodiff/SimulatorBase_impl.hpp @@ -697,7 +697,7 @@ namespace Opm { OpmLog::note(" Liquid VAPOUR Water Free Gas Dissolved Gas"); OpmLog::note("Currently in place: " + std::to_string(cip[1]) + " " + std::to_string(cip[4]) + " " + std::to_string(cip[0]) + " " + std::to_string(cip[2]) + " " + std::to_string(cip[3])); - OpmLog::note("Originaly in place: " + std::to_string(oip[1]) + " " + std::to_string(oip[4]) + " " + std::to_string(oip[0]) + " " + std::to_string(oip[2]) + " " + std::to_string(oip[3])); + OpmLog::note("Originally in place: " + std::to_string(oip[1]) + " " + std::to_string(oip[4]) + " " + std::to_string(oip[0]) + " " + std::to_string(oip[2]) + " " + std::to_string(oip[3])); } From a492a60a64871643c1aacf4693a1931a60261031 Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Tue, 9 Aug 2016 15:30:25 +0800 Subject: [PATCH 10/18] document computeFluidInPlace function. --- opm/autodiff/BlackoilModelBase.hpp | 6 +++++- opm/autodiff/BlackoilSequentialModel.hpp | 4 ++++ opm/autodiff/NonlinearSolver.hpp | 4 ++++ .../FullyImplicitCompressiblePolymerSolver.hpp | 4 ++++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/opm/autodiff/BlackoilModelBase.hpp b/opm/autodiff/BlackoilModelBase.hpp index aa5f22e18..c1368e0a6 100644 --- a/opm/autodiff/BlackoilModelBase.hpp +++ b/opm/autodiff/BlackoilModelBase.hpp @@ -260,7 +260,11 @@ namespace Opm { WellModel& wellModel() { return well_model_; } const WellModel& wellModel() const { return well_model_; } - /// Calculate FIP + /// Compute fluid in place. + /// \param[in] ReservoirState + /// \param[in] WellState + /// \param[in] FIPNUM for active cells not global cells. + /// \return fluid in place, number of fip regions, each region contains 5 values which are liquid, vapour, water, free gas and dissolved gas. std::vector computeFluidInPlace(const ReservoirState& x, const WellState& xw, diff --git a/opm/autodiff/BlackoilSequentialModel.hpp b/opm/autodiff/BlackoilSequentialModel.hpp index e5ee22866..c1f10fe48 100644 --- a/opm/autodiff/BlackoilSequentialModel.hpp +++ b/opm/autodiff/BlackoilSequentialModel.hpp @@ -248,6 +248,10 @@ namespace Opm { /// Compute fluid in place. + /// \param[in] ReservoirState + /// \param[in] WellState + /// \param[in] FIPNUM for active cells not global cells. + /// \return fluid in place, number of fip regions, each region contains 5 values which are liquid, vapour, water, free gas and dissolved gas. std::vector computeFluidInPlace(const ReservoirState& x, const WellState& xw, diff --git a/opm/autodiff/NonlinearSolver.hpp b/opm/autodiff/NonlinearSolver.hpp index d6ab0cc70..07cfc91f5 100644 --- a/opm/autodiff/NonlinearSolver.hpp +++ b/opm/autodiff/NonlinearSolver.hpp @@ -126,6 +126,10 @@ namespace Opm { int wellIterationsLastStep() const; /// Compute fluid in place. + /// \param[in] ReservoirState + /// \param[in] WellState + /// \param[in] FIPNUM for active cells not global cells. + /// \return fluid in place, number of fip regions, each region contains 5 values which are liquid, vapour, water, free gas and dissolved gas. std::vector computeFluidInPlace(const ReservoirState& x, const WellState& xw, diff --git a/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.hpp b/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.hpp index e42e15a50..6a377476c 100644 --- a/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.hpp +++ b/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.hpp @@ -110,6 +110,10 @@ namespace Opm { const PolymerBlackoilState& current ) const; /// Compute fluid in place. + /// \param[in] ReservoirState + /// \param[in] WellState + /// \param[in] FIPNUM for active cells not global cells. + /// \return fluid in place, number of fip regions, each region contains 5 values which are liquid, vapour, water, free gas and dissolved gas. std::vector computeFluidInPlace(const PolymerBlackoilState& x, const WellStateFullyImplicitBlackoilPolymer& xw, From 2ac3306c1892490eb1e020a1041c2a0f1ee926b4 Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Wed, 17 Aug 2016 14:22:17 +0800 Subject: [PATCH 11/18] drop the for loop over fip regions. --- opm/autodiff/BlackoilModelBase_impl.hpp | 10 ++++------ opm/autodiff/SimulatorBase_impl.hpp | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/opm/autodiff/BlackoilModelBase_impl.hpp b/opm/autodiff/BlackoilModelBase_impl.hpp index ee45ee5c6..fd5f384e0 100644 --- a/opm/autodiff/BlackoilModelBase_impl.hpp +++ b/opm/autodiff/BlackoilModelBase_impl.hpp @@ -2349,12 +2349,10 @@ namespace detail { const int dims = *std::max_element(fipnum.begin(), fipnum.end()); std::vector values(dims, V::Zero(5)); - for (int d = 0; d < dims; ++d) { - for (int i = 0; i < 5; ++i) { - for (int c = 0; c < nc; ++c) { - if (fipnum[c] == (d + 1)) { - values[d][i] += fip[i][c]; - } + for (int i = 0; i < 5; ++i) { + for (int c = 0; c < nc; ++c) { + if (fipnum[c] != 0) { + values[fipnum[c]-1][i] += fip[i][c]; } } } diff --git a/opm/autodiff/SimulatorBase_impl.hpp b/opm/autodiff/SimulatorBase_impl.hpp index 8fb4fe8ad..d2c1adb23 100644 --- a/opm/autodiff/SimulatorBase_impl.hpp +++ b/opm/autodiff/SimulatorBase_impl.hpp @@ -664,7 +664,7 @@ namespace Opm std::vector& fip) { if (units.getType() == UnitSystem::UnitType::UNIT_TYPE_FIELD) { - for (int i = 0; i < fip.size(); ++i) { + for (size_t i = 0; i < fip.size(); ++i) { fip[i][0] = unit::convert::to(fip[i][0], unit::stb); fip[i][1] = unit::convert::to(fip[i][1], unit::stb); fip[i][2] = unit::convert::to(fip[i][2], 1000*unit::cubic(unit::feet)); From c9c7a5c744eea99f091fea744e8b1d176e94db79 Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Fri, 26 Aug 2016 17:04:50 +0800 Subject: [PATCH 12/18] compute hydrocarbon weighted pore voulme pressue and pv for fip regions. --- opm/autodiff/BlackoilModelBase_impl.hpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/opm/autodiff/BlackoilModelBase_impl.hpp b/opm/autodiff/BlackoilModelBase_impl.hpp index fd5f384e0..b8bfee1c6 100644 --- a/opm/autodiff/BlackoilModelBase_impl.hpp +++ b/opm/autodiff/BlackoilModelBase_impl.hpp @@ -2348,7 +2348,7 @@ namespace detail { } const int dims = *std::max_element(fipnum.begin(), fipnum.end()); - std::vector values(dims, V::Zero(5)); + std::vector values(dims, V::Zero(7)); for (int i = 0; i < 5; ++i) { for (int c = 0; c < nc; ++c) { if (fipnum[c] != 0) { @@ -2357,6 +2357,18 @@ namespace detail { } } + // compute PAV and PORV or every regions. + for (int c = 0; c < nc; ++c) { + if (fipnum[c] != 0) { + values[fipnum[c]-1][5] += pv[c]; + values[fipnum[c]-1][6] += pv[c] * state.pressure.value()[c]; + } + } + + for (auto& x : values) { + x[6] = x[6] / x[5]; + } + return values; } From a1bf3769fe32850b90dbc28f87b6e3b9a420f747 Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Fri, 26 Aug 2016 17:05:45 +0800 Subject: [PATCH 13/18] format fip output. --- opm/autodiff/SimulatorBase.hpp | 4 +- opm/autodiff/SimulatorBase_impl.hpp | 63 +++++++++++++++++++++++------ 2 files changed, 53 insertions(+), 14 deletions(-) diff --git a/opm/autodiff/SimulatorBase.hpp b/opm/autodiff/SimulatorBase.hpp index e1c53ffac..c6aa06381 100644 --- a/opm/autodiff/SimulatorBase.hpp +++ b/opm/autodiff/SimulatorBase.hpp @@ -163,10 +163,10 @@ namespace Opm std::vector& fip); V - FIPTotals(const std::vector& fip); + FIPTotals(const std::vector& fip, const std::vector& press); void - outputFluidInPlace(const V& oip, const V& cip); + outputFluidInPlace(const V& oip, const V& cip, const UnitSystem& units, const int reg); void computeWellPotentials(const Wells* wells, const WellState& xw, diff --git a/opm/autodiff/SimulatorBase_impl.hpp b/opm/autodiff/SimulatorBase_impl.hpp index d2c1adb23..e9481597d 100644 --- a/opm/autodiff/SimulatorBase_impl.hpp +++ b/opm/autodiff/SimulatorBase_impl.hpp @@ -271,13 +271,11 @@ namespace Opm std::vector COIP; COIP = solver->computeFluidInPlace(state, well_state, fipnum); FIPUnitConvert(eclipse_state_->getUnits(), COIP); - V OOIP_totals = FIPTotals(OOIP); - V COIP_totals = FIPTotals(COIP); - OpmLog::note("*****************************Field Totals**************************"); - outputFluidInPlace(OOIP_totals, COIP_totals); + V OOIP_totals = FIPTotals(OOIP, state.pressure()); + V COIP_totals = FIPTotals(COIP, state.pressure()); + outputFluidInPlace(OOIP_totals, COIP_totals,eclipse_state_->getUnits(), 0); for (size_t reg = 0; reg < OOIP.size(); ++reg) { - OpmLog::note("*****************************FIPNUM report region " + std::to_string(reg+1) + "**************************"); - outputFluidInPlace(OOIP[reg], COIP[reg]); + outputFluidInPlace(OOIP[reg], COIP[reg], eclipse_state_->getUnits(), reg+1); } @@ -670,6 +668,13 @@ namespace Opm fip[i][2] = unit::convert::to(fip[i][2], 1000*unit::cubic(unit::feet)); fip[i][3] = unit::convert::to(fip[i][3], 1000*unit::cubic(unit::feet)); fip[i][4] = unit::convert::to(fip[i][4], unit::stb); + fip[i][5] = unit::convert::to(fip[i][5], unit::stb); + fip[i][6] = unit::convert::to(fip[i][6], unit::psia); + } + } + if (units.getType() == UnitSystem::UnitType::UNIT_TYPE_METRIC) { + for (size_t i = 0; i < fip.size(); ++i) { + fip[i][6] = unit::convert::to(fip[i][6], unit::barsa); } } } @@ -677,14 +682,17 @@ namespace Opm template V - SimulatorBase::FIPTotals(const std::vector& fip) + SimulatorBase::FIPTotals(const std::vector& fip, const std::vector& press) { - V totals(V::Zero(5)); + V totals(V::Zero(7)); for (int i = 0; i < 5; ++i) { for (size_t reg = 0; reg < fip.size(); ++reg) { totals[i] += fip[reg][i]; } } + const V p = Eigen::Map(& press[0], press.size()); + totals[5] = geo_.poreVolume().sum(); + totals[6] = unit::convert::to((p * geo_.poreVolume()).sum() / totals[5], unit::barsa); return totals; } @@ -693,11 +701,42 @@ namespace Opm template void - SimulatorBase::outputFluidInPlace(const V& oip, const V& cip) + SimulatorBase::outputFluidInPlace(const V& oip, const V& cip, const UnitSystem& units, const int reg) { - OpmLog::note(" Liquid VAPOUR Water Free Gas Dissolved Gas"); - OpmLog::note("Currently in place: " + std::to_string(cip[1]) + " " + std::to_string(cip[4]) + " " + std::to_string(cip[0]) + " " + std::to_string(cip[2]) + " " + std::to_string(cip[3])); - OpmLog::note("Originally in place: " + std::to_string(oip[1]) + " " + std::to_string(oip[4]) + " " + std::to_string(oip[0]) + " " + std::to_string(oip[2]) + " " + std::to_string(oip[3])); + std::ostringstream ss; + if (!reg) { + ss << " ==================================================\n" + << " : Field Totals :\n"; + } else { + ss << " ==================================================\n" + << " : FIPNUM report region " + << std::setw(2) << reg << " :\n"; + } + if (units.getType() == UnitSystem::UnitType::UNIT_TYPE_METRIC) { + ss << " : PAV =" << std::setw(14) << cip[6] << " BARSA :\n" + << std::fixed << std::setprecision(0) + << " : PORV =" << std::setw(14) << cip[5] << " RM3 :\n" + << " : Pressure is weighted by hydrocarbon pore voulme:\n" + << " : Porv volume are taken at reference conditions :\n" + << " :--------------- Oil SM3 ---------------:-- Wat SM3 --:--------------- Gas SM3 ---------------:\n"; + } + if (units.getType() == UnitSystem::UnitType::UNIT_TYPE_FIELD) { + ss << " : PAV =" << std::setw(14) << cip[6] << " PSIA :" + << std::fixed << std::setprecision(0) + << " : PORV =" << std::setprecision(14) << cip[5] << " STB :" + << " : Pressure is weighted by hydrocarbon pore voulme :" + << " : Porv volume are taken at reference conditions :" + << " :--------------- Oil STB ---------------:-- Wat STB --:--------------- Gas MSCF ---------------:\n"; + } + ss << " : Liquid Vapour Total : Total : Free Dissolved Total :" << "\n" + << ":------------------------:------------------------------------------:----------------:------------------------------------------:" << "\n" + << ":Currently in place :" << std::setw(14) << cip[1] << std::setw(14) << cip[4] << std::setw(14) << (cip[1]+cip[4]) << ":" + << std::setw(13) << cip[0] << " :" << std::setw(14) << (cip[2]) << std::setw(14) << cip[3] << std::setw(14) << (cip[2] + cip[3]) << ":\n" + << ":------------------------:------------------------------------------:----------------:------------------------------------------:\n" + << ":Originally in place :" << std::setw(14) << oip[1] << std::setw(14) << oip[4] << std::setw(14) << (oip[1]+oip[4]) << ":" + << std::setw(13) << oip[0] << " :" << std::setw(14) << oip[2] << std::setw(14) << oip[3] << std::setw(14) << (oip[2] + oip[3]) << ":\n" + << ":========================:==========================================:================:==========================================:\n"; + OpmLog::note(ss.str()); } From 46b0ef635b1571f2cd016cb449169d89303a56df Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Mon, 29 Aug 2016 09:57:03 +0800 Subject: [PATCH 14/18] fix typo. --- opm/autodiff/SimulatorBase_impl.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opm/autodiff/SimulatorBase_impl.hpp b/opm/autodiff/SimulatorBase_impl.hpp index e9481597d..39657d043 100644 --- a/opm/autodiff/SimulatorBase_impl.hpp +++ b/opm/autodiff/SimulatorBase_impl.hpp @@ -725,7 +725,7 @@ namespace Opm << std::fixed << std::setprecision(0) << " : PORV =" << std::setprecision(14) << cip[5] << " STB :" << " : Pressure is weighted by hydrocarbon pore voulme :" - << " : Porv volume are taken at reference conditions :" + << " : Pore volume are taken at reference conditions :" << " :--------------- Oil STB ---------------:-- Wat STB --:--------------- Gas MSCF ---------------:\n"; } ss << " : Liquid Vapour Total : Total : Free Dissolved Total :" << "\n" From 61af1fa53d7cd04bf00ac8252d34e3d270cab094 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Tue, 30 Aug 2016 13:18:06 +0200 Subject: [PATCH 15/18] Remove unused nnc arg from BlackoilOutputWriter constructor. --- examples/sim_poly_fi2p_comp_ad.cpp | 2 +- opm/autodiff/FlowMain.hpp | 1 - opm/autodiff/SimulatorFullyImplicitBlackoilOutput.hpp | 2 -- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/examples/sim_poly_fi2p_comp_ad.cpp b/examples/sim_poly_fi2p_comp_ad.cpp index a8533fa04..4318bb6d9 100644 --- a/examples/sim_poly_fi2p_comp_ad.cpp +++ b/examples/sim_poly_fi2p_comp_ad.cpp @@ -240,7 +240,7 @@ try << std::flush; Opm::BlackoilOutputWriter - outputWriter(cGrid, param, eclipseState, Opm::NNC(), pu, + outputWriter(cGrid, param, eclipseState, pu, new_props->permeability() ); SimulatorReport fullReport; diff --git a/opm/autodiff/FlowMain.hpp b/opm/autodiff/FlowMain.hpp index dd1235077..2d1f3b39f 100644 --- a/opm/autodiff/FlowMain.hpp +++ b/opm/autodiff/FlowMain.hpp @@ -663,7 +663,6 @@ namespace Opm output_writer_.reset(new BlackoilOutputWriter(grid_init_->grid(), param_, eclipse_state_, - geoprops_->nonCartesianConnections(), Opm::phaseUsageFromDeck(deck_), fluidprops_->permeability())); } diff --git a/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.hpp b/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.hpp index 6e199d4db..198a190ea 100644 --- a/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.hpp +++ b/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.hpp @@ -212,7 +212,6 @@ namespace Opm BlackoilOutputWriter(const Grid& grid, const parameter::ParameterGroup& param, Opm::EclipseStateConstPtr eclipseState, - const NNC&, const Opm::PhaseUsage &phaseUsage, const double* permeability ); @@ -285,7 +284,6 @@ namespace Opm BlackoilOutputWriter(const Grid& grid, const parameter::ParameterGroup& param, Opm::EclipseStateConstPtr eclipseState, - const NNC& nnc, const Opm::PhaseUsage &phaseUsage, const double* permeability ) : output_( param.getDefault("output", true) ), From 69812fddd238c8080fa85a2d741ea0c896308b15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Tue, 30 Aug 2016 13:18:54 +0200 Subject: [PATCH 16/18] Remove unnecessary override of computeFluidInPlace(). It also called itself, causing infinite recursion. --- opm/autodiff/BlackoilTransportModel.hpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/opm/autodiff/BlackoilTransportModel.hpp b/opm/autodiff/BlackoilTransportModel.hpp index 801a4065f..5dd103706 100644 --- a/opm/autodiff/BlackoilTransportModel.hpp +++ b/opm/autodiff/BlackoilTransportModel.hpp @@ -159,15 +159,6 @@ namespace Opm { - std::vector - computeFluidInPlace(const ReservoirState& x, - const WellState& xw, - const std::vector& fipnum) - { - return asImpl().computeFluidInPlace(x, xw, fipnum); - } - - /// Solve the Jacobian system Jx = r where J is the Jacobian and /// r is the residual. From a2001ca2e107eb01fc11ea28cd338170ce4cc9a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Tue, 30 Aug 2016 13:33:50 +0200 Subject: [PATCH 17/18] Avoid variable shadowing. --- opm/autodiff/BlackoilModelBase_impl.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opm/autodiff/BlackoilModelBase_impl.hpp b/opm/autodiff/BlackoilModelBase_impl.hpp index b8bfee1c6..bc643fc44 100644 --- a/opm/autodiff/BlackoilModelBase_impl.hpp +++ b/opm/autodiff/BlackoilModelBase_impl.hpp @@ -2365,8 +2365,8 @@ namespace detail { } } - for (auto& x : values) { - x[6] = x[6] / x[5]; + for (auto& val : values) { + val[6] = val[6] / val[5]; } return values; From b5e986df5fb5cf1384f4ba8eb9422ca26d17aa8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Tue, 30 Aug 2016 13:34:18 +0200 Subject: [PATCH 18/18] Remove well state argument from computeFluidInPlace(). --- opm/autodiff/BlackoilModelBase.hpp | 2 -- opm/autodiff/BlackoilModelBase_impl.hpp | 1 - opm/autodiff/BlackoilSequentialModel.hpp | 3 +-- opm/autodiff/NonlinearSolver.hpp | 2 -- opm/autodiff/NonlinearSolver_impl.hpp | 3 +-- opm/autodiff/SimulatorBase_impl.hpp | 4 ++-- .../FullyImplicitCompressiblePolymerSolver.cpp | 11 +++++++++-- .../FullyImplicitCompressiblePolymerSolver.hpp | 1 - 8 files changed, 13 insertions(+), 14 deletions(-) diff --git a/opm/autodiff/BlackoilModelBase.hpp b/opm/autodiff/BlackoilModelBase.hpp index c1368e0a6..95857c3c0 100644 --- a/opm/autodiff/BlackoilModelBase.hpp +++ b/opm/autodiff/BlackoilModelBase.hpp @@ -262,12 +262,10 @@ namespace Opm { /// Compute fluid in place. /// \param[in] ReservoirState - /// \param[in] WellState /// \param[in] FIPNUM for active cells not global cells. /// \return fluid in place, number of fip regions, each region contains 5 values which are liquid, vapour, water, free gas and dissolved gas. std::vector computeFluidInPlace(const ReservoirState& x, - const WellState& xw, const std::vector& fipnum); protected: diff --git a/opm/autodiff/BlackoilModelBase_impl.hpp b/opm/autodiff/BlackoilModelBase_impl.hpp index bc643fc44..2bbee317e 100644 --- a/opm/autodiff/BlackoilModelBase_impl.hpp +++ b/opm/autodiff/BlackoilModelBase_impl.hpp @@ -2300,7 +2300,6 @@ namespace detail { std::vector BlackoilModelBase:: computeFluidInPlace(const ReservoirState& x, - const WellState& xw, const std::vector& fipnum) { using namespace Opm::AutoDiffGrid; diff --git a/opm/autodiff/BlackoilSequentialModel.hpp b/opm/autodiff/BlackoilSequentialModel.hpp index c1f10fe48..d5a8f77ee 100644 --- a/opm/autodiff/BlackoilSequentialModel.hpp +++ b/opm/autodiff/BlackoilSequentialModel.hpp @@ -254,10 +254,9 @@ namespace Opm { /// \return fluid in place, number of fip regions, each region contains 5 values which are liquid, vapour, water, free gas and dissolved gas. std::vector computeFluidInPlace(const ReservoirState& x, - const WellState& xw, const std::vector& fipnum) const { - return transport_solver_.computeFluidInPlace(x, xw, fipnum); + return transport_solver_.computeFluidInPlace(x, fipnum); } diff --git a/opm/autodiff/NonlinearSolver.hpp b/opm/autodiff/NonlinearSolver.hpp index 07cfc91f5..09af664b9 100644 --- a/opm/autodiff/NonlinearSolver.hpp +++ b/opm/autodiff/NonlinearSolver.hpp @@ -127,12 +127,10 @@ namespace Opm { /// Compute fluid in place. /// \param[in] ReservoirState - /// \param[in] WellState /// \param[in] FIPNUM for active cells not global cells. /// \return fluid in place, number of fip regions, each region contains 5 values which are liquid, vapour, water, free gas and dissolved gas. std::vector computeFluidInPlace(const ReservoirState& x, - const WellState& xw, const std::vector& fipnum) const; /// Reference to physical model. diff --git a/opm/autodiff/NonlinearSolver_impl.hpp b/opm/autodiff/NonlinearSolver_impl.hpp index e5e690d10..8c2cffb9b 100644 --- a/opm/autodiff/NonlinearSolver_impl.hpp +++ b/opm/autodiff/NonlinearSolver_impl.hpp @@ -102,10 +102,9 @@ namespace Opm template std::vector NonlinearSolver::computeFluidInPlace(const ReservoirState& x, - const WellState& xw, const std::vector& fipnum) const { - return model_->computeFluidInPlace(x, xw, fipnum); + return model_->computeFluidInPlace(x, fipnum); } diff --git a/opm/autodiff/SimulatorBase_impl.hpp b/opm/autodiff/SimulatorBase_impl.hpp index 39657d043..726296131 100644 --- a/opm/autodiff/SimulatorBase_impl.hpp +++ b/opm/autodiff/SimulatorBase_impl.hpp @@ -199,7 +199,7 @@ namespace Opm // Compute orignal FIP; if (!ooip_computed) { - OOIP = solver->computeFluidInPlace(state, well_state, fipnum); + OOIP = solver->computeFluidInPlace(state, fipnum); FIPUnitConvert(eclipse_state_->getUnits(), OOIP); ooip_computed = true; } @@ -269,7 +269,7 @@ namespace Opm const double st = solver_timer.secsSinceStart(); // Compute current FIP. std::vector COIP; - COIP = solver->computeFluidInPlace(state, well_state, fipnum); + COIP = solver->computeFluidInPlace(state, fipnum); FIPUnitConvert(eclipse_state_->getUnits(), COIP); V OOIP_totals = FIPTotals(OOIP, state.pressure()); V COIP_totals = FIPTotals(COIP, state.pressure()); diff --git a/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.cpp b/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.cpp index 234594016..75f541e0a 100644 --- a/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.cpp +++ b/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.cpp @@ -534,12 +534,19 @@ namespace { std::vector FullyImplicitCompressiblePolymerSolver::computeFluidInPlace(const PolymerBlackoilState& x, - const WellStateFullyImplicitBlackoilPolymer& xw, const std::vector& fipnum) { - const SolutionState state = constantState(x, xw); + const int np = x.numPhases(); const int nc = grid_.number_of_cells; + SolutionState state(np); + state.pressure = ADB::constant(Eigen::Map(& x.pressure()[0], nc, 1)); + state.temperature = ADB::constant(Eigen::Map(& x.temperature()[0], nc, 1)); + const DataBlock s = Eigen::Map(& x.saturation()[0], nc, np); + for (int phase = 0; phase < np; ++phase) { + state.saturation[phase] = ADB::constant(s.col(phase)); + } + const ADB& press = state.pressure; const ADB& temp = state.temperature; const std::vector& sat = state.saturation; diff --git a/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.hpp b/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.hpp index 6a377476c..605d33cc5 100644 --- a/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.hpp +++ b/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.hpp @@ -116,7 +116,6 @@ namespace Opm { /// \return fluid in place, number of fip regions, each region contains 5 values which are liquid, vapour, water, free gas and dissolved gas. std::vector computeFluidInPlace(const PolymerBlackoilState& x, - const WellStateFullyImplicitBlackoilPolymer& xw, const std::vector& fipnum); private: