Fix pressure renormalization conditions. Some formatting fixes.

Checking for both rock compressibility and pressure conditions
is necessary before we renormalize pressure.
This commit is contained in:
Atgeirr Flø Rasmussen 2012-08-21 14:52:43 +02:00
parent fe0581b69b
commit 81ca766b86
2 changed files with 62 additions and 30 deletions

View File

@ -268,7 +268,7 @@ main(int argc, char** argv)
warnIfUnusedParams(param); warnIfUnusedParams(param);
} }
SimulatorReport epoch_rep = simulator.run(simtimer, state, well_state); SimulatorReport epoch_rep = simulator.run(simtimer, state, well_state);
if(output){ if (output) {
epoch_rep.reportParam(epoch_os); epoch_rep.reportParam(epoch_os);
} }
// Update total timing report and remember step number. // Update total timing report and remember step number.
@ -277,7 +277,6 @@ main(int argc, char** argv)
} }
} }
epoch_os.close();
std::cout << "\n\n================ End of simulation ===============\n\n"; std::cout << "\n\n================ End of simulation ===============\n\n";
rep.report(std::cout); rep.report(std::cout);
@ -285,7 +284,6 @@ main(int argc, char** argv)
std::string filename = output_dir + "/walltime.param"; std::string filename = output_dir + "/walltime.param";
std::fstream tot_os(filename.c_str(),std::fstream::trunc | std::fstream::out); std::fstream tot_os(filename.c_str(),std::fstream::trunc | std::fstream::out);
rep.reportParam(tot_os); rep.reportParam(tot_os);
tot_os.close();
} }
} }

View File

@ -96,6 +96,7 @@ namespace Opm
WellsManager& wells_manager_; WellsManager& wells_manager_;
const Wells* wells_; const Wells* wells_;
const std::vector<double>& src_; const std::vector<double>& src_;
const FlowBoundaryConditions* bcs_;
// Solvers // Solvers
IncompTpfa psolver_; IncompTpfa psolver_;
TransportModelTwophase tsolver_; TransportModelTwophase tsolver_;
@ -224,6 +225,35 @@ namespace Opm
} }
static bool allNeumannBCs(const FlowBoundaryConditions* bcs)
{
if (bcs == NULL) {
return true;
} else {
return std::find(bcs->type, bcs->type + bcs->nbc, BC_PRESSURE)
== bcs->type + bcs->nbc;
}
}
static bool allRateWells(const Wells* wells)
{
if (wells == NULL) {
return true;
}
const int nw = wells->number_of_wells;
for (int w = 0; w < nw; ++w) {
const WellControls* wc = wells->ctrls[w];
if (wc->current >= 0) {
if (wc->type[wc->current] == BHP) {
return false;
}
}
}
return true;
}
@ -242,6 +272,7 @@ namespace Opm
wells_manager_(wells_manager), wells_manager_(wells_manager),
wells_(wells_manager.c_wells()), wells_(wells_manager.c_wells()),
src_(src), src_(src),
bcs_(bcs),
psolver_(grid, props, rock_comp, linsolver, psolver_(grid, props, rock_comp, linsolver,
param.getDefault("nl_pressure_residual_tolerance", 0.0), param.getDefault("nl_pressure_residual_tolerance", 0.0),
param.getDefault("nl_pressure_change_tolerance", 1.0), param.getDefault("nl_pressure_change_tolerance", 1.0),
@ -333,7 +364,7 @@ namespace Opm
wellreport.push(props_, *wells_, state.saturation(), 0.0, well_state.bhp(), well_state.perfRates()); wellreport.push(props_, *wells_, state.saturation(), 0.0, well_state.bhp(), well_state.perfRates());
} }
std::fstream tstep_os; std::fstream tstep_os;
if(output_){ if (output_) {
std::string filename = output_dir_ + "/step_timing.param"; std::string filename = output_dir_ + "/step_timing.param";
tstep_os.open(filename.c_str(), std::fstream::out | std::fstream::app); tstep_os.open(filename.c_str(), std::fstream::out | std::fstream::app);
} }
@ -363,8 +394,12 @@ namespace Opm
std::vector<double> initial_pressure = state.pressure(); std::vector<double> initial_pressure = state.pressure();
psolver_.solve(timer.currentStepLength(), state, well_state); psolver_.solve(timer.currentStepLength(), state, well_state);
// Renormalize if incompressible. // Renormalize pressure if rock is incompressible, and
if (!rock_comp_->isActive()) { // there are no pressure conditions (bcs or wells).
// It is deemed sufficient for now to renormalize
// using geometric volume instead of pore volume.
if ((rock_comp_ == NULL || !rock_comp_->isActive())
&& allNeumannBCs(bcs_) && allRateWells(wells_)) {
// Compute average pressures of previous and last // Compute average pressures of previous and last
// step, and total volume. // step, and total volume.
double av_prev_press = 0.0; double av_prev_press = 0.0;
@ -381,7 +416,8 @@ namespace Opm
for (int cell = 0; cell < num_cells; ++cell) { for (int cell = 0; cell < num_cells; ++cell) {
state.pressure()[cell] += ren_const; state.pressure()[cell] += ren_const;
} }
for (int well = 0; well < wells_->number_of_wells; ++well) { const int num_wells = (wells_ == NULL) ? 0 : wells_->number_of_wells;
for (int well = 0; well < num_wells; ++well) {
well_state.bhp()[well] += ren_const; well_state.bhp()[well] += ren_const;
} }
} }
@ -485,11 +521,9 @@ namespace Opm
well_state.bhp(), well_state.perfRates()); well_state.bhp(), well_state.perfRates());
} }
sreport.total_time = step_timer.secsSinceStart(); sreport.total_time = step_timer.secsSinceStart();
if(output_){ if (output_) {
sreport.reportParam(tstep_os); sreport.reportParam(tstep_os);
} }
} }
if (output_) { if (output_) {