moving addWellFluxEq() to StandardWells

Conflicts:
	opm/autodiff/BlackoilModelBase_impl.hpp
This commit is contained in:
Kai Bao 2016-04-18 11:22:19 +02:00
parent ef05a64a88
commit eb278c3c9a
5 changed files with 39 additions and 38 deletions

View File

@ -410,13 +410,6 @@ namespace Opm {
const std::vector<ADB>& mob_perfcells, const std::vector<ADB>& mob_perfcells,
const std::vector<ADB>& b_perfcells, const std::vector<ADB>& b_perfcells,
WellState& well_state); WellState& well_state);
void
addWellFluxEq(const std::vector<ADB>& cq_s,
const SolutionState& state);
void
addWellContributionToMassBalanceEq(const std::vector<ADB>& cq_s, addWellContributionToMassBalanceEq(const std::vector<ADB>& cq_s,
const SolutionState& state, const SolutionState& state,
const WellState& xw); const WellState& xw);

View File

@ -901,7 +901,7 @@ namespace detail {
std::vector<ADB> cq_s; std::vector<ADB> cq_s;
asImpl().stdWells().computeWellFlux(state, fluid_.phaseUsage(), active_, mob_perfcells, b_perfcells, aliveWells, cq_s); asImpl().stdWells().computeWellFlux(state, fluid_.phaseUsage(), active_, mob_perfcells, b_perfcells, aliveWells, cq_s);
asImpl().stdWells().updatePerfPhaseRatesAndPressures(cq_s, state, well_state); asImpl().stdWells().updatePerfPhaseRatesAndPressures(cq_s, state, well_state);
asImpl().addWellFluxEq(cq_s, state); asImpl().stdWells().addWellFluxEq(cq_s, state, residual_);
asImpl().addWellContributionToMassBalanceEq(cq_s, state, well_state); asImpl().addWellContributionToMassBalanceEq(cq_s, state, well_state);
asImpl().addWellControlEq(state, well_state, aliveWells); asImpl().addWellControlEq(state, well_state, aliveWells);
asImpl().computeWellPotentials(state, mob_perfcells, b_perfcells, well_state); asImpl().computeWellPotentials(state, mob_perfcells, b_perfcells, well_state);
@ -1069,34 +1069,6 @@ namespace detail {
template <class Grid, class WellModel, class Implementation>
void
BlackoilModelBase<Grid, WellModel, Implementation>::
addWellFluxEq(const std::vector<ADB>& cq_s,
const SolutionState& state)
{
if( !asImpl().localWellsActive() )
{
// If there are no wells in the subdomain of the proces then
// cq_s has zero size and will cause a segmentation fault below.
return;
}
const int np = wells().number_of_phases;
const int nw = wells().number_of_wells;
ADB qs = state.qs;
for (int phase = 0; phase < np; ++phase) {
qs -= superset(stdWells().wellOps().p2w * cq_s[phase], Span(nw, 1, phase*nw), nw*np);
}
residual_.well_flux_eq = qs;
}
template <class Grid, class WellModel, class Implementation> template <class Grid, class WellModel, class Implementation>
bool bool
BlackoilModelBase<Grid, WellModel, Implementation>:: BlackoilModelBase<Grid, WellModel, Implementation>::
@ -1174,7 +1146,7 @@ namespace detail {
asImpl().variableStateExtractWellsVars(indices, vars, wellSolutionState); asImpl().variableStateExtractWellsVars(indices, vars, wellSolutionState);
asImpl().stdWells().computeWellFlux(wellSolutionState, fluid_.phaseUsage(), active_, mob_perfcells_const, b_perfcells_const, aliveWells, cq_s); asImpl().stdWells().computeWellFlux(wellSolutionState, fluid_.phaseUsage(), active_, mob_perfcells_const, b_perfcells_const, aliveWells, cq_s);
asImpl().stdWells().updatePerfPhaseRatesAndPressures(cq_s, wellSolutionState, well_state); asImpl().stdWells().updatePerfPhaseRatesAndPressures(cq_s, wellSolutionState, well_state);
asImpl().addWellFluxEq(cq_s, wellSolutionState); asImpl().stdWells().addWellFluxEq(cq_s, wellSolutionState, residual_);
asImpl().addWellControlEq(wellSolutionState, well_state, aliveWells); asImpl().addWellControlEq(wellSolutionState, well_state, aliveWells);
converged = getWellConvergence(it); converged = getWellConvergence(it);

View File

@ -141,6 +141,13 @@ namespace Opm {
const std::vector<bool>& active, const std::vector<bool>& active,
WellState& xw) const; WellState& xw) const;
// TODO: should LinearisedBlackoilResidual also be a template class?
template <class SolutionState>
void addWellFluxEq(const std::vector<ADB>& cq_s,
const SolutionState& state,
LinearisedBlackoilResidual& residual);
protected: protected:
bool wells_active_; bool wells_active_;

View File

@ -778,4 +778,33 @@ namespace Opm
} }
template <class SolutionState>
void
StandardWells::
addWellFluxEq(const std::vector<ADB>& cq_s,
const SolutionState& state,
LinearisedBlackoilResidual& residual)
{
if( !localWellsActive() )
{
// If there are no wells in the subdomain of the proces then
// cq_s has zero size and will cause a segmentation fault below.
return;
}
const int np = wells().number_of_phases;
const int nw = wells().number_of_wells;
ADB qs = state.qs;
for (int phase = 0; phase < np; ++phase) {
qs -= superset(wellOps().p2w * cq_s[phase], Span(nw, 1, phase*nw), nw*np);
}
residual.well_flux_eq = qs;
}
} }

View File

@ -573,7 +573,7 @@ namespace Opm {
stdWells().computeWellFlux(state, fluid_.phaseUsage(), active_, mob_perfcells, b_perfcells, aliveWells, cq_s); stdWells().computeWellFlux(state, fluid_.phaseUsage(), active_, mob_perfcells, b_perfcells, aliveWells, cq_s);
stdWells().updatePerfPhaseRatesAndPressures(cq_s, state, well_state); stdWells().updatePerfPhaseRatesAndPressures(cq_s, state, well_state);
Base::addWellFluxEq(cq_s, state); stdWells().addWellFluxEq(cq_s, state, residual_);
addWellContributionToMassBalanceEq(cq_s, state, well_state); addWellContributionToMassBalanceEq(cq_s, state, well_state);
addWellControlEq(state, well_state, aliveWells); addWellControlEq(state, well_state, aliveWells);
} }