Sending initial pressures to assembly function.

This commit is contained in:
Atgeirr Flø Rasmussen 2012-05-21 10:36:10 +02:00
parent af76b390d2
commit 2add19a2e1
2 changed files with 26 additions and 16 deletions

View File

@ -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<UnstructuredGrid*>(&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_);
}

View File

@ -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<double>& 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<double> initial_press_;
std::vector<double> initial_bhp_;
const double* cell_z_;
std::vector<double> wellperf_gpot_;
// ------ Data that will be modified for every solver iteration. ------