From 9aa0c89603738fa552b522d3c0cef3f29eeb4405 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Mon, 21 May 2012 10:36:10 +0200 Subject: [PATCH] Sending initial pressures to assembly function. --- opm/core/pressure/CompressibleTpfa.cpp | 30 +++++++++++++++----------- opm/core/pressure/CompressibleTpfa.hpp | 12 +++++++---- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/opm/core/pressure/CompressibleTpfa.cpp b/opm/core/pressure/CompressibleTpfa.cpp index 76916ffd6..1ebf7d598 100644 --- a/opm/core/pressure/CompressibleTpfa.cpp +++ b/opm/core/pressure/CompressibleTpfa.cpp @@ -101,12 +101,14 @@ namespace Opm BlackoilState& state, WellState& well_state) { + const int nc = grid_.number_of_cells; + // Set up dynamic data. - computePerSolveDynamicData(state); + computePerSolveDynamicData(dt, state, well_state); computePerIterationDynamicData(dt, state, well_state); // Assemble J and F. - assemble(dt, state, well_state); + assemble(); bool residual_ok = false; // Replace with tolerance check. while (!residual_ok) { @@ -116,12 +118,14 @@ namespace Opm solveIncrement(); // Update pressure vars with increment. + std::copy(pressure_increment_.begin(), pressure_increment_.begin() + nc, state.pressure().begin()); + std::copy(pressure_increment_.begin() + nc, pressure_increment_.end(), well_state.bhp().begin()); // Set up dynamic data. computePerIterationDynamicData(dt, state, well_state); // Assemble J and F. - assemble(dt, state, well_state); + assemble(); // Check for convergence. // Include both tolerance check for residual @@ -178,8 +182,14 @@ namespace Opm /// Compute per-solve dynamic properties. - void CompressibleTpfa::computePerSolveDynamicData(const BlackoilState& state) + void CompressibleTpfa::computePerSolveDynamicData(const double dt, + const BlackoilState& state, + const WellState& well_state) { + dt_ = dt; + initial_press_ = state.pressure(); + initial_bhp_ = well_state.bhp(); + cell_z_ = &state.surfacevol()[0]; computeWellPotentials(state); } @@ -397,15 +407,11 @@ namespace Opm /// Compute the residual and Jacobian. - void CompressibleTpfa::assemble(const double dt, - const BlackoilState& state, - const WellState& well_state) + void CompressibleTpfa::assemble() { - const double* z = &state.surfacevol()[0]; - const double* cell_press = &state.pressure()[0]; - const double* well_bhp = well_state.bhp().empty() ? NULL : &well_state.bhp()[0]; + const double* cell_press = &initial_press_[0]; + const double* well_bhp = initial_bhp_.empty() ? NULL : &initial_bhp_[0]; UnstructuredGrid* gg = const_cast(&grid_); - CompletionData completion_data; completion_data.gpot = &wellperf_gpot_[0]; completion_data.A = &wellperf_A_[0]; @@ -422,7 +428,7 @@ namespace Opm cq.Af = &face_A_[0]; cq.phasemobf = &face_phasemob_[0]; cq.voldiscr = &cell_voldisc_[0]; - cfs_tpfa_res_assemble(gg, dt, &forces, z, &cq, &trans_[0], + cfs_tpfa_res_assemble(gg, dt_, &forces, cell_z_, &cq, &trans_[0], &face_gravcap_[0], cell_press, well_bhp, &porevol_[0], h_); } diff --git a/opm/core/pressure/CompressibleTpfa.hpp b/opm/core/pressure/CompressibleTpfa.hpp index 5f10b8c99..e4ebb02a7 100644 --- a/opm/core/pressure/CompressibleTpfa.hpp +++ b/opm/core/pressure/CompressibleTpfa.hpp @@ -70,7 +70,9 @@ namespace Opm WellState& well_state); private: - void computePerSolveDynamicData(const BlackoilState& state); + void computePerSolveDynamicData(const double dt, + const BlackoilState& state, + const WellState& well_state); void computeWellPotentials(const BlackoilState& state); void computePerIterationDynamicData(const double dt, const BlackoilState& state, @@ -84,9 +86,7 @@ namespace Opm void computeWellDynamicData(const double dt, const BlackoilState& state, const WellState& well_state); - void assemble(const double dt, - const BlackoilState& state, - const WellState& well_state); + void assemble(); void solveIncrement(); void computeResults(std::vector& pressure, @@ -109,6 +109,10 @@ namespace Opm struct cfs_tpfa_res_data* h_; // ------ Data that will be modified for every solve. ------ + double dt_; + std::vector initial_press_; + std::vector initial_bhp_; + const double* cell_z_; std::vector wellperf_gpot_; // ------ Data that will be modified for every solver iteration. ------