opm-simulators
CompWellPrimaryVariables.hpp
1 /*
2  Copyright 2024, SINTEF Digital
3 
4  This file is part of the Open Porous Media project (OPM).
5 
6  OPM is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  OPM is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with OPM. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #ifndef OPM_COMP_WELL_PRIMARY_VARIABLES_HPP
21 #define OPM_COMP_WELL_PRIMARY_VARIABLES_HPP
22 
23 #include <opm/material/densead/Evaluation.hpp>
24 
25 #include <flowexperimental/comp/wells/CompWellEquations.hpp>
26 
27 #include <array>
28 
29 namespace Opm {
30 
31 template <typename FluidSystem>
33 
34 template <typename FluidSystem, typename Indices>
36 {
37 public:
38  static constexpr int numWellConservationEq = FluidSystem::numComponents;
39  static constexpr int numWellControlEq = 1;
40  static constexpr int numWellEq = numWellConservationEq + numWellControlEq;
41  // the indices for the primary variables
42  // the first primary variable will be the total surface rate
43  // the last primary variable will be the BHP
44  // the one in the middle with will the mole fractions for the numWellEq - 1 components
45  // this can be changed based on the implementation itself
46  static constexpr int QTotal = 0; // TODO: for now, it is the total surface rate, but later, we might make it total mass rate
47  static constexpr int Bhp = numWellEq - numWellControlEq;
48 
49  using Scalar = typename FluidSystem::Scalar;
50 
51  // this is the number of the equations for the reservoir conservation equations
52  static constexpr int numResEq = Indices::numEq;
53  // we use hard-coded Evaluation type for now
54  // TODO: we can try to use DyanmicEvaluation here
55  using EvalWell = DenseAd::Evaluation<Scalar, numWellEq + numResEq>;
56  using Eval = DenseAd::Evaluation<Scalar, numResEq>;
57 
58  using BVectorWell = typename CompWellEquations<Scalar, numWellEq, numResEq>::BVectorWell;
60 
61  template <typename T>
62  using FluidState = CompositionalFluidState<T, FluidSystem>;
63 
64  template <typename T>
65  FluidState<T> toFluidState() const;
66 
67  void update(const SingleWellState& well_state);
68 
69  void updateEvaluation();
70 
71  EvalWell getBhp() const;
72 
73  EvalWell getTotalRate() const;
74 
75  static EvalWell extendEval(const Eval& in);
76 
77  static Eval restrictEval(const EvalWell& in);
78 
79  void updateNewton(const BVectorWell& dwells);
80 
81 private:
82  std::array<Scalar, numWellEq> value_;
83  std::array<EvalWell, numWellEq> evaluation_;
84  // temperature for now is constant, so it is not part of the primary variables
85  // we need it for the flash calculation
86  Scalar temperature_{0.};
87 
88  template <typename T>
89  T getValue_(int index) const;
90 
91 };
92 
93 } // end of namespace Opm
94 
95 #include "CompWellPrimaryVariables_impl.hpp"
96 
97 #endif // OPM_COMP_WELL_PRIMARY_VARIABLES_HPP
Definition: CompWellPrimaryVariables.hpp:32
Structs needed for tpfalinearizer and its gpuparams struct extracted to be defined in one place that ...
Definition: blackoilbioeffectsmodules.hh:45
Definition: CompWellPrimaryVariables.hpp:35