adding a function calculateExplictQuantities to WellInterface

to hide some implementation details.
This commit is contained in:
Kai Bao 2017-09-05 11:09:58 +02:00
parent 47c7c54548
commit 8922f3e041
7 changed files with 63 additions and 43 deletions

View File

@ -128,13 +128,16 @@ namespace Opm
/// computing the well potentials for group control
virtual void computeWellPotentials(const Simulator& ebosSimulator,
const WellState& well_state,
std::vector<double>& well_potentials) const;
std::vector<double>& well_potentials);
virtual void updatePrimaryVariables(const WellState& well_state) const;
virtual void solveEqAndUpdateWellState(const ModelParameters& param,
WellState& well_state); // const?
virtual void calculateExplictQuantities(const Simulator& ebosSimulator,
const WellState& well_state); // should be const?
/// number of segments for this well
/// int number_of_segments_;
int numberOfSegments() const;

View File

@ -415,7 +415,7 @@ namespace Opm
MultisegmentWell<TypeTag>::
computeWellPotentials(const Simulator& ebosSimulator,
const WellState& well_state,
std::vector<double>& well_potentials) const
std::vector<double>& well_potentials)
{
@ -519,6 +519,18 @@ namespace Opm
template<typename TypeTag>
void
MultisegmentWell<TypeTag>::
calculateExplictQuantities(const Simulator& ebosSimulator,
const WellState& well_state)
{
}
template<typename TypeTag>
const SegmentSet&
MultisegmentWell<TypeTag>::

View File

@ -144,12 +144,15 @@ namespace Opm
/// computing the well potentials for group control
virtual void computeWellPotentials(const Simulator& ebosSimulator,
const WellState& well_state,
std::vector<double>& well_potentials) const;
std::vector<double>& well_potentials) /* const */;
virtual void updatePrimaryVariables(const WellState& well_state) const;
virtual void solveEqAndUpdateWellState(const ModelParameters& param,
WellState& well_state);
virtual void calculateExplictQuantities(const Simulator& ebosSimulator,
const WellState& well_state); // should be const?
protected:
// protected functions from the Base class

View File

@ -1504,6 +1504,20 @@ namespace Opm
template<typename TypeTag>
void
StandardWell<TypeTag>::
calculateExplictQuantities(const Simulator& ebosSimulator,
const WellState& well_state)
{
computeWellConnectionPressures(ebosSimulator, well_state);
computeAccumWell();
}
template<typename TypeTag>
void
StandardWell<TypeTag>::
@ -1730,10 +1744,16 @@ namespace Opm
StandardWell<TypeTag>::
computeWellPotentials(const Simulator& ebosSimulator,
const WellState& well_state,
std::vector<double>& well_potentials) const
std::vector<double>& well_potentials) // const
{
const int np = number_of_phases_;
updatePrimaryVariables(well_state);
computeWellConnectionPressures(ebosSimulator, well_state);
// initialize the primary variables in Evaluation, which is used in computePerfRate for computeWellPotentials
// TODO: for computeWellPotentials, no derivative is required actually
initPrimaryVariablesEvaluation();
const int np = number_of_phases_;
well_potentials.resize(np, 0.0);
// get the bhp value based on the bhp constraints

View File

@ -230,15 +230,18 @@ namespace Opm {
void calculateEfficiencyFactors();
void computeWellConnectionPressures(const Simulator& ebosSimulator,
const WellState& xw) const;
// it should be able to go to prepareTimeStep(), however, the updateWellControls() and initPrimaryVariablesEvaluation()
// makes it a little more difficult. unless we introduce if (iterationIdx != 0) to avoid doing the above functions
// twice at the beginning of the time step
/// Calculating the explict quantities used in the well calculation. By explicit, we mean they are cacluated
/// at the beginning of the time step and no derivatives are included in these quantities
void calculateExplictQuantities(const Simulator& ebosSimulator,
const WellState& xw) const;
SimulatorReport solveWellEq(Simulator& ebosSimulator,
const double dt,
WellState& well_state) const;
void computeAccumWells() const;
void initPrimaryVariablesEvaluation() const;
// The number of components in the model.

View File

@ -169,23 +169,21 @@ namespace Opm {
const double dt,
WellState& well_state)
{
if (iterationIdx == 0) {
prepareTimeStep(ebosSimulator, well_state);
}
SimulatorReport report;
if ( ! wellsActive() ) {
return report;
}
if (iterationIdx == 0) {
prepareTimeStep(ebosSimulator, well_state);
}
updateWellControls(well_state);
// Set the well primary variables based on the value of well solutions
initPrimaryVariablesEvaluation();
if (iterationIdx == 0) {
computeWellConnectionPressures(ebosSimulator, well_state);
computeAccumWells();
calculateExplictQuantities(ebosSimulator, well_state);
}
if (param_.solve_welleq_initially_ && iterationIdx == 0) {
@ -398,20 +396,6 @@ namespace Opm {
template<typename TypeTag>
void
StandardWellsDense<TypeTag>::
computeAccumWells() const
{
for (auto& well : well_container_) {
well->computeAccumWell();
}
}
template<typename TypeTag>
SimulatorReport
StandardWellsDense<TypeTag>::
@ -549,13 +533,11 @@ namespace Opm {
template<typename TypeTag>
void
StandardWellsDense<TypeTag>::
computeWellConnectionPressures(const Simulator& ebosSimulator,
const WellState& xw) const
calculateExplictQuantities(const Simulator& ebosSimulator,
const WellState& xw) const
{
if( ! localWellsActive() ) return ;
for (auto& well : well_container_) {
well->computeWellConnectionPressures(ebosSimulator, xw);
well->calculateExplictQuantities(ebosSimulator, xw);
}
}
@ -612,13 +594,6 @@ namespace Opm {
const WellState& well_state,
std::vector<double>& well_potentials) const
{
updatePrimaryVariables(well_state);
computeWellConnectionPressures(ebosSimulator, well_state);
// initialize the primary variables in Evaluation, which is used in computePerfRate for computeWellPotentials
// TODO: for computeWellPotentials, no derivative is required actually
initPrimaryVariablesEvaluation();
// number of wells and phases
const int nw = number_of_wells_;
const int np = number_of_phases_;

View File

@ -174,9 +174,10 @@ namespace Opm
/// r = r - C D^-1 Rw
virtual void apply(BVector& r) const = 0;
// TODO: before we decide to put more information under mutable, this function is not const
virtual void computeWellPotentials(const Simulator& ebosSimulator,
const WellState& well_state,
std::vector<double>& well_potentials) const = 0;
std::vector<double>& well_potentials) = 0;
virtual void computeAccumWell() = 0;
@ -193,6 +194,9 @@ namespace Opm
virtual void updatePrimaryVariables(const WellState& well_state) const = 0;
virtual void calculateExplictQuantities(const Simulator& ebosSimulator,
const WellState& xw) = 0; // should be const?
protected:
// to indicate a invalid connection