opm-simulators
CompWellInterface.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_WELLINTERFACE_HPP
21 #define OPM_COMP_WELLINTERFACE_HPP
22 
24 #include <opm/simulators/wells/PerforationData.hpp>
25 
26 #include <flowexperimental/comp/wells/SingleCompWellState.hpp>
27 
28 #include <string>
29 
30 namespace Opm {
31 
32 template <typename TypeTag> // TODO: do we need to use TypeTag here?
34 {
35 public:
41  using RateVector = GetPropType<TypeTag, Properties::RateVector>; // FlashRateVector at the moment
42 
43  using VectorBlockType = Dune::FieldVector<Scalar, Indices::numEq>;
44  using BVector = Dune::BlockVector<VectorBlockType>;
47 
48  CompWellInterface(const Well& well,
49  const int index_of_well,
50  const std::vector<CompConnectionData>& well_connection_data);
51 
52  virtual ~CompWellInterface() = default;
53 
54  virtual void init();
55 
56  const std::string& name() const;
57 
58  virtual void calculateExplicitQuantities(const Simulator& simulator,
59  const SingleWellState& well_state) = 0;
60 
61  virtual void updatePrimaryVariables(const Simulator& simulator,
62  const SingleWellState& well_state) = 0;
63 
64  virtual bool iterateWellEq(const Simulator& simulator,
65  const Scalar dt,
66  SingleWellState& well_state) = 0;
67 
68  void addCellRates(RateVector& rates, unsigned cellIdx) const;
69 
70  const std::vector<std::size_t>& cells() const { return well_cells_; }
71 
72  virtual void apply(BVector& r) const = 0;
73 
76  virtual void recoverWellSolutionAndUpdateWellState(const BVector& x,
77  SingleWellState& well_state) = 0;
78  virtual bool getConvergence() const = 0;
79 
80  virtual void addWellContributions(SparseMatrixAdapter&) const = 0;
81 
82 protected:
83 
84  const Well& well_ecl_;
85  int index_of_well_{-1};
86 
87  int number_of_connection_ {};
88  Scalar reference_depth_ {}; // TODO: we might not need it since it in well_ecl_.
89 
90  std::vector<RateVector> connectionRates_;
91 
92  // cell index for each well connection
93  // TODO: maybe it should be called connection_cells
94  std::vector<std::size_t> well_cells_;
95  // cell index for each well connection
96  // TODO: should it called trans_index
97  std::vector<Scalar> well_index_;
98  std::vector<int> saturation_table_number_;
99 
100  // std::string name_;
101 
102 };
103 
104 
105 } // end of namespace Opm
106 
107 #include "CompWellInterface_impl.hpp"
108 
109 #endif // OPM_COMP_WELLINTERFACE_HPP
Definition: CompWellInterface.hpp:33
Definition: CompWellPrimaryVariables.hpp:32
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(...))
Definition: propertysystem.hh:233
virtual void recoverWellSolutionAndUpdateWellState(const BVector &x, SingleWellState &well_state)=0
using the solution x to recover the solution xw for wells and applying xw to update Well State ...
Structs needed for tpfalinearizer and its gpuparams struct extracted to be defined in one place that ...
Definition: blackoilbioeffectsmodules.hh:45
Static data associated with a well perforation.
Definition: BlackoilWellModelRestart.hpp:41
The Opm property system, traits with inheritance.