Loading...
Searching...
No Matches
StandardWellPrimaryVariables.hpp
/*
Copyright 2017 SINTEF Digital, Mathematics and Cybernetics.
Copyright 2017 Statoil ASA.
Copyright 2016 - 2017 IRIS AS.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPM_STANDARDWELL_PRIMARY_VARIABLES_HEADER_INCLUDED
#define OPM_STANDARDWELL_PRIMARY_VARIABLES_HEADER_INCLUDED
#include <opm/material/densead/Evaluation.hpp>
#include <opm/simulators/wells/StandardWellEquations.hpp>
#include <vector>
namespace Opm
{
class DeferredLogger;
template<class FluidSystem, class Indices> class WellInterfaceIndices;
template<typename Scalar, typename IndexTraits> class WellState;
template<class FluidSystem, class Indices>
class StandardWellPrimaryVariables {
protected:
// the positions of the primary variables for StandardWell
// the first one is the weighted total rate (WQ_t), the second and the third ones are F_w and F_g,
// which represent the fraction of Water and Gas based on the weighted total rate, the last one is BHP.
// correspondingly, we have four well equations for blackoil model, the first three are mass
// converstation equations, and the last one is the well control equation.
// primary variables related to other components, will be before the Bhp and after F_g.
// well control equation is always the last well equation.
// TODO: in the current implementation, we use the well rate as the first primary variables for injectors,
// instead of G_t.
// Table showing the primary variable indices, depending on what phases are present:
//
// WOG OG WG WO W/O/G (single phase)
// WQTotal 0 0 0 0 0
// WFrac 1 -1000 -1000 1 -1000
// GFrac 2 1 1 -1000 -1000
// Spres 3 2 2 2 1
static constexpr int numWellControlEq = 1;
public:
static constexpr int numWellConservationEq = Indices::numPhases + Indices::numSolvents;
static constexpr int numStaticWellEq = numWellConservationEq + numWellControlEq;
static constexpr int WQTotal = 0;
static constexpr int Bhp = numStaticWellEq - numWellControlEq;
static constexpr bool has_wfrac_variable = Indices::waterEnabled && Indices::oilEnabled;
static constexpr bool has_gfrac_variable = Indices::gasEnabled && Indices::numPhases > 1;
static constexpr int WFrac = has_wfrac_variable ? 1 : -1000;
static constexpr int GFrac = has_gfrac_variable ? has_wfrac_variable + 1 : -1000;
static constexpr int SFrac = !Indices::enableSolvent ? -1000 : has_wfrac_variable+has_gfrac_variable+1;
using Scalar = typename FluidSystem::Scalar;
using IndexTraits = typename FluidSystem::IndexTraitsType;
using EvalWell = DenseAd::DynamicEvaluation<Scalar, numStaticWellEq + Indices::numEq + 1>;
using BVectorWell = typename StandardWellEquations<Scalar, IndexTraits, Indices::numEq>::BVectorWell;
explicit StandardWellPrimaryVariables(const WellInterfaceIndices<FluidSystem,Indices>& well)
: well_(well)
{}
void resize(const int numWellEq);
int numWellEq() const { return numWellEq_; }
void update(const WellState<Scalar, IndexTraits>& well_state,
const bool stop_or_zero_rate_target,
DeferredLogger& deferred_logger);
void updatePolyMW(const WellState<Scalar, IndexTraits>& well_state);
void updateNewton(const BVectorWell& dwells,
const bool stop_or_zero_rate_target,
const Scalar dFLimit,
const Scalar dBHPLimit,
DeferredLogger& deferred_logger);
void updateNewtonPolyMW(const BVectorWell& dwells);
void checkFinite(DeferredLogger& deferred_logger) const;
void copyToWellState(WellState<Scalar, IndexTraits>& well_state,
DeferredLogger& deferred_logger) const;
void copyToWellStatePolyMW(WellState<Scalar, IndexTraits>& well_state) const;
EvalWell volumeFractionScaled(const int compIdx) const;
EvalWell surfaceVolumeFraction(const int compIdx) const;
EvalWell getQs(const int compIdx) const;
Scalar value(const int idx) const
{ return value_[idx]; }
const EvalWell& eval(const int idx) const
{ return evaluation_[idx]; }
void setValue(const int idx, const Scalar val)
{ value_[idx] = val; }
private:
void setEvaluationsFromValues();
Scalar relaxationFactorFractionsProducer(const BVectorWell& dwells,
DeferredLogger& deferred_logger) const;
EvalWell volumeFraction(const int compIdx) const;
void processFractions();
std::vector<Scalar> value_;
std::vector<EvalWell> evaluation_;
const WellInterfaceIndices<FluidSystem,Indices>& well_;
int numWellEq_ = numStaticWellEq;
};
}
#endif // OPM_STANDARDWELL_PRIMARY_VARIABLES_HEADER_INCLUDED
Opm::DeferredLogger
Definition DeferredLogger.hpp:57
Opm::StandardWellPrimaryVariables::checkFinite
void checkFinite(DeferredLogger &deferred_logger) const
Check that all values are finite.
Definition StandardWellPrimaryVariables.cpp:751
Opm::StandardWellPrimaryVariables::updateNewtonPolyMW
void updateNewtonPolyMW(const BVectorWell &dwells)
Update polymer molecular weight values from newton update vector.
Definition StandardWellPrimaryVariables.cpp:323
Opm::StandardWellPrimaryVariables::surfaceVolumeFraction
EvalWell surfaceVolumeFraction(const int compIdx) const
Returns surface volume fraction for a component.
Definition StandardWellPrimaryVariables.cpp:519
Opm::StandardWellPrimaryVariables::numWellEq
int numWellEq() const
Returns number of well equations.
Definition StandardWellPrimaryVariables.hpp:100
Opm::StandardWellPrimaryVariables::resize
void resize(const int numWellEq)
Resize values and evaluations.
Definition StandardWellPrimaryVariables.cpp:113
Opm::StandardWellPrimaryVariables::EvalWell
DenseAd::DynamicEvaluation< Scalar, numStaticWellEq+Indices::numEq+1 > EvalWell
Evaluation for the well equations.
Definition StandardWellPrimaryVariables.hpp:88
Opm::StandardWellPrimaryVariables::value
Scalar value(const int idx) const
Returns a value.
Definition StandardWellPrimaryVariables.hpp:140
Opm::StandardWellPrimaryVariables::updateNewton
void updateNewton(const BVectorWell &dwells, const bool stop_or_zero_rate_target, const Scalar dFLimit, const Scalar dBHPLimit, DeferredLogger &deferred_logger)
Update values from newton update vector.
Definition StandardWellPrimaryVariables.cpp:260
Opm::StandardWellPrimaryVariables::numWellControlEq
static constexpr int numWellControlEq
Number of the well control equations.
Definition StandardWellPrimaryVariables.hpp:62
Opm::StandardWellPrimaryVariables::update
void update(const WellState< Scalar, IndexTraits > &well_state, const bool stop_or_zero_rate_target, DeferredLogger &deferred_logger)
Copy values from well state.
Definition StandardWellPrimaryVariables.cpp:122
Opm::StandardWellPrimaryVariables::WQTotal
static constexpr int WQTotal
The index for the weighted total rate.
Definition StandardWellPrimaryVariables.hpp:72
Opm::StandardWellPrimaryVariables::updatePolyMW
void updatePolyMW(const WellState< Scalar, IndexTraits > &well_state)
Copy polymer molecular weigt values from well state.
Definition StandardWellPrimaryVariables.cpp:243
Opm::StandardWellPrimaryVariables::eval
const EvalWell & eval(const int idx) const
Returns a const ref to an evaluation.
Definition StandardWellPrimaryVariables.hpp:144
Opm::StandardWellPrimaryVariables::numStaticWellEq
static constexpr int numStaticWellEq
Number of the well equations that will always be used.
Definition StandardWellPrimaryVariables.hpp:70
Opm::StandardWellPrimaryVariables::getQs
EvalWell getQs(const int compIdx) const
Returns scaled rate for a component.
Definition StandardWellPrimaryVariables.cpp:534
Opm::StandardWellPrimaryVariables::setValue
void setValue(const int idx, const Scalar val)
Set a value. Note that this does not also set the corresponding evaluation.
Definition StandardWellPrimaryVariables.hpp:148
Opm::StandardWellPrimaryVariables::copyToWellState
void copyToWellState(WellState< Scalar, IndexTraits > &well_state, DeferredLogger &deferred_logger) const
Copy values to well state.
Definition StandardWellPrimaryVariables.cpp:343
Opm::StandardWellPrimaryVariables::volumeFractionScaled
EvalWell volumeFractionScaled(const int compIdx) const
Returns scaled volume fraction for a component.
Definition StandardWellPrimaryVariables.cpp:505
Opm::StandardWellPrimaryVariables::numWellConservationEq
static constexpr int numWellConservationEq
Number of the conservation equations.
Definition StandardWellPrimaryVariables.hpp:66
Opm::StandardWellPrimaryVariables::StandardWellPrimaryVariables
StandardWellPrimaryVariables(const WellInterfaceIndices< FluidSystem, Indices > &well)
Constructor initializes reference to well interface.
Definition StandardWellPrimaryVariables.hpp:92
Opm::StandardWellPrimaryVariables::Bhp
static constexpr int Bhp
The index for Bhp in primary variables and the index of well control equation.
Definition StandardWellPrimaryVariables.hpp:77
Opm::StandardWellPrimaryVariables::copyToWellStatePolyMW
void copyToWellStatePolyMW(WellState< Scalar, IndexTraits > &well_state) const
Copy polymer molecular weight values to well state.
Definition StandardWellPrimaryVariables.cpp:451
Opm::WellInterfaceIndices
Definition WellInterfaceIndices.hpp:34
Opm::WellState
The state of a set of wells, tailored for use by the fully implicit blackoil simulator.
Definition WellState.hpp:66
Opm
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilbioeffectsmodules.hh:43