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 /// computing the well potentials for group control
virtual void computeWellPotentials(const Simulator& ebosSimulator, virtual void computeWellPotentials(const Simulator& ebosSimulator,
const WellState& well_state, 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 updatePrimaryVariables(const WellState& well_state) const;
virtual void solveEqAndUpdateWellState(const ModelParameters& param, virtual void solveEqAndUpdateWellState(const ModelParameters& param,
WellState& well_state); // const? WellState& well_state); // const?
virtual void calculateExplictQuantities(const Simulator& ebosSimulator,
const WellState& well_state); // should be const?
/// number of segments for this well /// number of segments for this well
/// int number_of_segments_; /// int number_of_segments_;
int numberOfSegments() const; int numberOfSegments() const;

View File

@@ -415,7 +415,7 @@ namespace Opm
MultisegmentWell<TypeTag>:: MultisegmentWell<TypeTag>::
computeWellPotentials(const Simulator& ebosSimulator, computeWellPotentials(const Simulator& ebosSimulator,
const WellState& well_state, 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> template<typename TypeTag>
const SegmentSet& const SegmentSet&
MultisegmentWell<TypeTag>:: MultisegmentWell<TypeTag>::

View File

@@ -144,12 +144,15 @@ namespace Opm
/// computing the well potentials for group control /// computing the well potentials for group control
virtual void computeWellPotentials(const Simulator& ebosSimulator, virtual void computeWellPotentials(const Simulator& ebosSimulator,
const WellState& well_state, 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 updatePrimaryVariables(const WellState& well_state) const;
virtual void solveEqAndUpdateWellState(const ModelParameters& param, virtual void solveEqAndUpdateWellState(const ModelParameters& param,
WellState& well_state); WellState& well_state);
virtual void calculateExplictQuantities(const Simulator& ebosSimulator,
const WellState& well_state); // should be const?
protected: protected:
// protected functions from the Base class // 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> template<typename TypeTag>
void void
StandardWell<TypeTag>:: StandardWell<TypeTag>::
@@ -1730,10 +1744,16 @@ namespace Opm
StandardWell<TypeTag>:: StandardWell<TypeTag>::
computeWellPotentials(const Simulator& ebosSimulator, computeWellPotentials(const Simulator& ebosSimulator,
const WellState& well_state, 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); well_potentials.resize(np, 0.0);
// get the bhp value based on the bhp constraints // get the bhp value based on the bhp constraints

View File

@@ -230,15 +230,18 @@ namespace Opm {
void calculateEfficiencyFactors(); void calculateEfficiencyFactors();
void computeWellConnectionPressures(const Simulator& ebosSimulator, // it should be able to go to prepareTimeStep(), however, the updateWellControls() and initPrimaryVariablesEvaluation()
const WellState& xw) const; // 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, SimulatorReport solveWellEq(Simulator& ebosSimulator,
const double dt, const double dt,
WellState& well_state) const; WellState& well_state) const;
void computeAccumWells() const;
void initPrimaryVariablesEvaluation() const; void initPrimaryVariablesEvaluation() const;
// The number of components in the model. // The number of components in the model.

View File

@@ -169,23 +169,21 @@ namespace Opm {
const double dt, const double dt,
WellState& well_state) WellState& well_state)
{ {
if (iterationIdx == 0) {
prepareTimeStep(ebosSimulator, well_state);
}
SimulatorReport report; SimulatorReport report;
if ( ! wellsActive() ) { if ( ! wellsActive() ) {
return report; return report;
} }
if (iterationIdx == 0) {
prepareTimeStep(ebosSimulator, well_state);
}
updateWellControls(well_state); updateWellControls(well_state);
// Set the well primary variables based on the value of well solutions // Set the well primary variables based on the value of well solutions
initPrimaryVariablesEvaluation(); initPrimaryVariablesEvaluation();
if (iterationIdx == 0) { if (iterationIdx == 0) {
computeWellConnectionPressures(ebosSimulator, well_state); calculateExplictQuantities(ebosSimulator, well_state);
computeAccumWells();
} }
if (param_.solve_welleq_initially_ && iterationIdx == 0) { 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> template<typename TypeTag>
SimulatorReport SimulatorReport
StandardWellsDense<TypeTag>:: StandardWellsDense<TypeTag>::
@@ -549,13 +533,11 @@ namespace Opm {
template<typename TypeTag> template<typename TypeTag>
void void
StandardWellsDense<TypeTag>:: StandardWellsDense<TypeTag>::
computeWellConnectionPressures(const Simulator& ebosSimulator, calculateExplictQuantities(const Simulator& ebosSimulator,
const WellState& xw) const const WellState& xw) const
{ {
if( ! localWellsActive() ) return ;
for (auto& well : well_container_) { for (auto& well : well_container_) {
well->computeWellConnectionPressures(ebosSimulator, xw); well->calculateExplictQuantities(ebosSimulator, xw);
} }
} }
@@ -612,13 +594,6 @@ namespace Opm {
const WellState& well_state, const WellState& well_state,
std::vector<double>& well_potentials) const 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 // number of wells and phases
const int nw = number_of_wells_; const int nw = number_of_wells_;
const int np = number_of_phases_; const int np = number_of_phases_;

View File

@@ -174,9 +174,10 @@ namespace Opm
/// r = r - C D^-1 Rw /// r = r - C D^-1 Rw
virtual void apply(BVector& r) const = 0; 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, virtual void computeWellPotentials(const Simulator& ebosSimulator,
const WellState& well_state, const WellState& well_state,
std::vector<double>& well_potentials) const = 0; std::vector<double>& well_potentials) = 0;
virtual void computeAccumWell() = 0; virtual void computeAccumWell() = 0;
@@ -193,6 +194,9 @@ namespace Opm
virtual void updatePrimaryVariables(const WellState& well_state) const = 0; virtual void updatePrimaryVariables(const WellState& well_state) const = 0;
virtual void calculateExplictQuantities(const Simulator& ebosSimulator,
const WellState& xw) = 0; // should be const?
protected: protected:
// to indicate a invalid connection // to indicate a invalid connection