mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
makding the StandardWell and WellInterface templated
with the template parameter TypeTag.
This commit is contained in:
parent
182bf315f3
commit
1a4ceeec66
@ -49,8 +49,6 @@ list (APPEND MAIN_SOURCE_FILES
|
||||
opm/autodiff/VFPInjProperties.cpp
|
||||
opm/autodiff/WellMultiSegment.cpp
|
||||
opm/autodiff/MultisegmentWells.cpp
|
||||
opm/autodiff/WellInterface.cpp
|
||||
opm/autodiff/StandardWell.cpp
|
||||
opm/autodiff/MissingFeatures.cpp
|
||||
opm/polymer/PolymerState.cpp
|
||||
opm/polymer/PolymerBlackoilState.cpp
|
||||
|
@ -37,13 +37,15 @@
|
||||
namespace Opm
|
||||
{
|
||||
|
||||
class StandardWell: public WellInterface
|
||||
template<typename TypeTag>
|
||||
class StandardWell: public WellInterface<TypeTag>
|
||||
{
|
||||
|
||||
public:
|
||||
using WellInterface::Simulator;
|
||||
using WellInterface::WellState;
|
||||
|
||||
// using WellInterface<TypeTag>::Simulator;
|
||||
// using WellInterface<TypeTag>::WellState;
|
||||
typedef typename WellInterface<TypeTag>::Simulator Simulator;
|
||||
typedef typename WellInterface<TypeTag>::WellState WellState;
|
||||
// the positions of the primary variables for StandardWell
|
||||
// there are three primary variables, the second and the third ones are F_w and F_g
|
||||
// the first one can be total rate (G_t) or bhp, based on the control
|
||||
@ -107,7 +109,22 @@ namespace Opm
|
||||
|
||||
EvalWell wellSurfaceVolumeFraction(const int phase) const;
|
||||
|
||||
using WellInterface<TypeTag>::phaseUsage;
|
||||
using WellInterface<TypeTag>::active;
|
||||
using WellInterface<TypeTag>::numberOfPerforations;
|
||||
using WellInterface<TypeTag>::indexOfWell;
|
||||
using WellInterface<TypeTag>::name;
|
||||
using WellInterface<TypeTag>::wellType;
|
||||
using WellInterface<TypeTag>::wellControls;
|
||||
using WellInterface<TypeTag>::compFrac;
|
||||
using WellInterface<TypeTag>::numberOfPhases;
|
||||
using WellInterface<TypeTag>::perfDepth;
|
||||
|
||||
protected:
|
||||
|
||||
using WellInterface<TypeTag>::vfp_properties_;
|
||||
using WellInterface<TypeTag>::gravity_;
|
||||
|
||||
// densities of the fluid in each perforation
|
||||
std::vector<double> perf_densities_;
|
||||
// pressure drop between different perforations
|
||||
@ -136,4 +153,6 @@ namespace Opm
|
||||
|
||||
}
|
||||
|
||||
#include "StandardWell_impl.hpp"
|
||||
|
||||
#endif // OPM_STANDARDWELL_HEADER_INCLUDED
|
||||
|
@ -18,19 +18,15 @@
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <opm/autodiff/StandardWell.hpp>
|
||||
|
||||
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
StandardWell::
|
||||
template<typename TypeTag>
|
||||
StandardWell<TypeTag>::
|
||||
StandardWell(const Well* well, const int time_step, const Wells* wells)
|
||||
: WellInterface(well, time_step, wells)
|
||||
, perf_densities_(number_of_perforations_)
|
||||
, perf_pressure_diffs_(number_of_perforations_)
|
||||
: WellInterface<TypeTag>(well, time_step, wells)
|
||||
, perf_densities_(numberOfPerforations())
|
||||
, perf_pressure_diffs_(numberOfPerforations())
|
||||
, well_variables_(numWellEq) // the number of the primary variables
|
||||
{
|
||||
dune_B_.setBuildMode( Mat::row_wise );
|
||||
@ -42,8 +38,9 @@ namespace Opm
|
||||
|
||||
|
||||
|
||||
template<typename TypeTag>
|
||||
const std::vector<double>&
|
||||
StandardWell::
|
||||
StandardWell<TypeTag>::
|
||||
perfDensities() const
|
||||
{
|
||||
return perf_densities_;
|
||||
@ -53,8 +50,9 @@ namespace Opm
|
||||
|
||||
|
||||
|
||||
template<typename TypeTag>
|
||||
std::vector<double>&
|
||||
StandardWell::
|
||||
StandardWell<TypeTag>::
|
||||
perfDensities()
|
||||
{
|
||||
return perf_densities_;
|
||||
@ -64,8 +62,9 @@ namespace Opm
|
||||
|
||||
|
||||
|
||||
template<typename TypeTag>
|
||||
const std::vector<double>&
|
||||
StandardWell::
|
||||
StandardWell<TypeTag>::
|
||||
perfPressureDiffs() const
|
||||
{
|
||||
return perf_pressure_diffs_;
|
||||
@ -75,8 +74,9 @@ namespace Opm
|
||||
|
||||
|
||||
|
||||
template<typename TypeTag>
|
||||
std::vector<double>&
|
||||
StandardWell::
|
||||
StandardWell<TypeTag>::
|
||||
perfPressureDiffs()
|
||||
{
|
||||
return perf_pressure_diffs_;
|
||||
@ -86,8 +86,9 @@ namespace Opm
|
||||
|
||||
|
||||
|
||||
template<typename TypeTag>
|
||||
void
|
||||
StandardWell::
|
||||
StandardWell<TypeTag>::
|
||||
assembleWellEq(Simulator& ebos_simulator,
|
||||
const double dt,
|
||||
WellState& well_state,
|
||||
@ -99,10 +100,11 @@ namespace Opm
|
||||
|
||||
|
||||
|
||||
void StandardWell::
|
||||
template<typename TypeTag>
|
||||
void StandardWell<TypeTag>::
|
||||
setWellVariables(const WellState& well_state)
|
||||
{
|
||||
const int np = number_of_phases_;
|
||||
const int np = numberOfPhases();
|
||||
const int nw = well_state.bhp().size();
|
||||
// TODO: it should be the number of primary variables
|
||||
// TODO: this is from the old version of StandardWellsDense, it is a coincidence, 3 phases and 3 primary variables
|
||||
@ -110,7 +112,7 @@ namespace Opm
|
||||
// TODO: the following code has to be rewritten later for correctness purpose.
|
||||
for (int phase = 0; phase < np; ++phase) {
|
||||
well_variables_[phase] = 0.0;
|
||||
well_variables_[phase].setValue(well_state.wellSolutions()[index_of_well_ + nw * phase]);
|
||||
well_variables_[phase].setValue(well_state.wellSolutions()[indexOfWell() + nw * phase]);
|
||||
well_variables_[phase].setDerivative(numEq + phase, 1.0);
|
||||
}
|
||||
}
|
||||
@ -119,11 +121,12 @@ namespace Opm
|
||||
|
||||
|
||||
|
||||
StandardWell::EvalWell
|
||||
StandardWell::
|
||||
template<typename TypeTag>
|
||||
typename StandardWell<TypeTag>::EvalWell
|
||||
StandardWell<TypeTag>::
|
||||
getBhp() const
|
||||
{
|
||||
const WellControls* wc = well_controls_;
|
||||
const WellControls* wc = wellControls();
|
||||
if (well_controls_get_current_type(wc) == BHP) {
|
||||
EvalWell bhp = 0.0;
|
||||
const double target_rate = well_controls_get_current_target(wc);
|
||||
@ -162,7 +165,7 @@ namespace Opm
|
||||
// pick the density in the top layer
|
||||
const double rho = perf_densities_[0];
|
||||
// TODO: not sure whether it is always correct
|
||||
const double well_ref_depth = perf_depth_[0];
|
||||
const double well_ref_depth = perfDepth()[0];
|
||||
const double dp = wellhelpers::computeHydrostaticCorrection(well_ref_depth, vfp_ref_depth, rho, gravity_);
|
||||
bhp -= dp;
|
||||
return bhp;
|
||||
@ -175,19 +178,20 @@ namespace Opm
|
||||
|
||||
|
||||
|
||||
StandardWell::EvalWell
|
||||
StandardWell::
|
||||
template<typename TypeTag>
|
||||
typename StandardWell<TypeTag>::EvalWell
|
||||
StandardWell<TypeTag>::
|
||||
getQs(const int phase) const
|
||||
{
|
||||
EvalWell qs = 0.0;
|
||||
|
||||
const WellControls* wc = well_controls_;
|
||||
const int np = number_of_phases_;
|
||||
const WellControls* wc = wellControls();
|
||||
const int np = numberOfPhases();
|
||||
const double target_rate = well_controls_get_current_target(wc);
|
||||
|
||||
// TODO: we need to introduce numComponents() for StandardWell
|
||||
// assert(phase < numComponents());
|
||||
const auto pu = phase_usage_;
|
||||
const auto pu = phaseUsage();
|
||||
|
||||
// TODO: the formulation for the injectors decides it only work with single phase
|
||||
// surface rate injection control. Improvement will be required.
|
||||
@ -315,13 +319,14 @@ namespace Opm
|
||||
|
||||
|
||||
|
||||
StandardWell::EvalWell
|
||||
StandardWell::
|
||||
template<typename TypeTag>
|
||||
typename StandardWell<TypeTag>::EvalWell
|
||||
StandardWell<TypeTag>::
|
||||
wellVolumeFractionScaled(const int phase) const
|
||||
{
|
||||
// TODO: we should be able to set the g for the well based on the control type
|
||||
// instead of using explicit code for g all the times
|
||||
const WellControls* wc = well_controls_;
|
||||
const WellControls* wc = wellControls();
|
||||
if (well_controls_get_current_type(wc) == RESERVOIR_RATE) {
|
||||
const double* distr = well_controls_get_current_distr(wc);
|
||||
if (distr[phase] > 0.) {
|
||||
@ -340,8 +345,9 @@ namespace Opm
|
||||
|
||||
|
||||
|
||||
StandardWell::EvalWell
|
||||
StandardWell::
|
||||
template<typename TypeTag>
|
||||
typename StandardWell<TypeTag>::EvalWell
|
||||
StandardWell<TypeTag>::
|
||||
wellVolumeFraction(const int phase) const
|
||||
{
|
||||
if (phase == Water) {
|
||||
@ -368,12 +374,13 @@ namespace Opm
|
||||
|
||||
|
||||
|
||||
StandardWell::EvalWell
|
||||
StandardWell::
|
||||
template<typename TypeTag>
|
||||
typename StandardWell<TypeTag>::EvalWell
|
||||
StandardWell<TypeTag>::
|
||||
wellSurfaceVolumeFraction(const int phase) const
|
||||
{
|
||||
EvalWell sum_volume_fraction_scaled = 0.;
|
||||
const int np = number_of_phases_;
|
||||
const int np = numberOfPhases();
|
||||
for (int p = 0; p < np; ++p) {
|
||||
sum_volume_fraction_scaled += wellVolumeFractionScaled(p);
|
||||
}
|
@ -303,9 +303,10 @@ enum WellVariablePositions {
|
||||
// the name is just temporary
|
||||
// later, might make share_ptr const later.
|
||||
// TODO: forget why make it share_ptr instead of unique_ptr
|
||||
std::vector<std::shared_ptr<WellInterface> > well_container_;
|
||||
std::vector<std::shared_ptr<WellInterface<TypeTag> > > well_container_;
|
||||
|
||||
std::vector<std::shared_ptr<WellInterface> >
|
||||
// TODO: forgot why returning a vector here
|
||||
std::vector<std::shared_ptr<WellInterface<TypeTag> > >
|
||||
createWellContainer(const std::vector<const Well*>& wells_ecl,
|
||||
const Wells* wells_arg,
|
||||
const int time_step);
|
||||
|
@ -148,13 +148,13 @@ namespace Opm {
|
||||
|
||||
|
||||
template<typename TypeTag>
|
||||
std::vector<std::shared_ptr<WellInterface> >
|
||||
std::vector<std::shared_ptr<WellInterface<TypeTag> > >
|
||||
StandardWellsDense<TypeTag>::
|
||||
createWellContainer(const std::vector<const Well*>& wells_ecl,
|
||||
const Wells* wells_arg,
|
||||
const int time_step)
|
||||
{
|
||||
std::vector<std::shared_ptr<WellInterface> > wells_container;
|
||||
std::vector<std::shared_ptr<WellInterface<TypeTag> > > wells_container;
|
||||
|
||||
// There might be no wells in the process
|
||||
if (localWellsActive()) {
|
||||
@ -192,7 +192,7 @@ namespace Opm {
|
||||
|
||||
// Basically, we are handling all the wells as StandardWell for the moment
|
||||
// TODO: to be changed when we begin introducing MultisegmentWell
|
||||
wells_container.push_back(std::make_shared<StandardWell>(well_ecl, time_step, wells_arg) );
|
||||
wells_container.push_back(std::make_shared<StandardWell<TypeTag> >(well_ecl, time_step, wells_arg) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -2228,7 +2228,8 @@ namespace Opm {
|
||||
typename StandardWellsDense<TypeTag>::EvalWell
|
||||
StandardWellsDense<TypeTag>::
|
||||
getBhp(const int wellIdx) const {
|
||||
return well_container_(wellIdx)->getBhp();
|
||||
// return well_container_(wellIdx)->getBhp();
|
||||
return 0.0; // TODO: for debugging
|
||||
}
|
||||
|
||||
|
||||
|
@ -45,6 +45,7 @@ namespace Opm
|
||||
|
||||
class SimulatorFullyImplicitBlackoilEbos;
|
||||
|
||||
template<typename TypeTag>
|
||||
class WellInterface
|
||||
{
|
||||
public:
|
||||
@ -161,4 +162,6 @@ namespace Opm
|
||||
|
||||
}
|
||||
|
||||
#include "WellInterface_impl.hpp"
|
||||
|
||||
#endif // OPM_WELLINTERFACE_HEADER_INCLUDED
|
||||
|
@ -18,17 +18,13 @@
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
||||
#include <opm/autodiff/WellInterface.hpp>
|
||||
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
|
||||
|
||||
WellInterface::
|
||||
template<typename TypeTag>
|
||||
WellInterface<TypeTag>::
|
||||
WellInterface(const Well* well, const int time_step, const Wells* wells)
|
||||
{
|
||||
|
||||
@ -94,8 +90,9 @@ namespace Opm
|
||||
|
||||
|
||||
|
||||
template<typename TypeTag>
|
||||
void
|
||||
WellInterface::
|
||||
WellInterface<TypeTag>::
|
||||
init(const PhaseUsage* phase_usage_arg,
|
||||
const std::vector<bool>* active_arg,
|
||||
const VFPProperties* vfp_properties_arg,
|
||||
@ -111,8 +108,9 @@ namespace Opm
|
||||
|
||||
|
||||
|
||||
template<typename TypeTag>
|
||||
const std::string&
|
||||
WellInterface::
|
||||
WellInterface<TypeTag>::
|
||||
name() const
|
||||
{
|
||||
return name_;
|
||||
@ -122,8 +120,9 @@ namespace Opm
|
||||
|
||||
|
||||
|
||||
template<typename TypeTag>
|
||||
int
|
||||
WellInterface::
|
||||
WellInterface<TypeTag>::
|
||||
indexOfWell() const
|
||||
{
|
||||
return index_of_well_;
|
||||
@ -133,8 +132,9 @@ namespace Opm
|
||||
|
||||
|
||||
|
||||
template<typename TypeTag>
|
||||
WellType
|
||||
WellInterface::
|
||||
WellInterface<TypeTag>::
|
||||
wellType() const
|
||||
{
|
||||
return well_type_;
|
||||
@ -144,8 +144,9 @@ namespace Opm
|
||||
|
||||
|
||||
|
||||
template<typename TypeTag>
|
||||
int
|
||||
WellInterface::
|
||||
WellInterface<TypeTag>::
|
||||
numberOfPhases() const
|
||||
{
|
||||
return number_of_phases_;
|
||||
@ -154,8 +155,9 @@ namespace Opm
|
||||
|
||||
|
||||
|
||||
template<typename TypeTag>
|
||||
const std::vector<double>&
|
||||
WellInterface::
|
||||
WellInterface<TypeTag>::
|
||||
compFrac() const
|
||||
{
|
||||
return comp_frac_;
|
||||
@ -165,8 +167,9 @@ namespace Opm
|
||||
|
||||
|
||||
|
||||
template<typename TypeTag>
|
||||
WellControls*
|
||||
WellInterface::
|
||||
WellInterface<TypeTag>::
|
||||
wellControls() const
|
||||
{
|
||||
return well_controls_;
|
||||
@ -176,8 +179,9 @@ namespace Opm
|
||||
|
||||
|
||||
|
||||
template<typename TypeTag>
|
||||
int
|
||||
WellInterface::
|
||||
WellInterface<TypeTag>::
|
||||
numberOfPerforations() const
|
||||
{
|
||||
return number_of_perforations_;
|
||||
@ -187,8 +191,9 @@ namespace Opm
|
||||
|
||||
|
||||
|
||||
template<typename TypeTag>
|
||||
const std::vector<double>&
|
||||
WellInterface::
|
||||
WellInterface<TypeTag>::
|
||||
wellIndex() const
|
||||
{
|
||||
return well_index_;
|
||||
@ -198,8 +203,9 @@ namespace Opm
|
||||
|
||||
|
||||
|
||||
template<typename TypeTag>
|
||||
const std::vector<double>&
|
||||
WellInterface::
|
||||
WellInterface<TypeTag>::
|
||||
perfDepth() const
|
||||
{
|
||||
return perf_depth_;
|
||||
@ -209,8 +215,9 @@ namespace Opm
|
||||
|
||||
|
||||
|
||||
template<typename TypeTag>
|
||||
const std::vector<int>&
|
||||
WellInterface::
|
||||
WellInterface<TypeTag>::
|
||||
wellCells() const
|
||||
{
|
||||
return well_cell_;
|
||||
@ -220,8 +227,9 @@ namespace Opm
|
||||
|
||||
|
||||
|
||||
template<typename TypeTag>
|
||||
const std::vector<bool>&
|
||||
WellInterface::
|
||||
WellInterface<TypeTag>::
|
||||
active() const
|
||||
{
|
||||
assert(active_);
|
||||
@ -233,8 +241,9 @@ namespace Opm
|
||||
|
||||
|
||||
|
||||
template<typename TypeTag>
|
||||
const PhaseUsage&
|
||||
WellInterface::
|
||||
WellInterface<TypeTag>::
|
||||
phaseUsage() const
|
||||
{
|
||||
assert(phase_usage_);
|
Loading…
Reference in New Issue
Block a user