opm-simulators
Loading...
Searching...
No Matches
BlackoilWellModelNetworkGeneric.hpp
1/*
2 Copyright 2016 SINTEF ICT, Applied Mathematics.
3 Copyright 2016 - 2017 Statoil ASA.
4 Copyright 2017 Dr. Blatt - HPC-Simulation-Software & Services
5 Copyright 2016 - 2018 IRIS AS
6
7 This file is part of the Open Porous Media project (OPM).
8
9 OPM is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 OPM is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with OPM. If not, see <http://www.gnu.org/licenses/>.
21*/
22
23#ifndef OPM_BLACKOILWELLMODEL_NETWORK_GENERIC_HEADER_INCLUDED
24#define OPM_BLACKOILWELLMODEL_NETWORK_GENERIC_HEADER_INCLUDED
25
26#include <opm/input/eclipse/Schedule/Network/ExtNetwork.hpp>
27
28#include <opm/output/data/Groups.hpp>
29
30#include <opm/simulators/flow/NewtonIterationContext.hpp>
31#include <opm/simulators/utils/ParallelCommunication.hpp>
32
33#include <map>
34#include <optional>
35#include <string>
36
37namespace Opm {
38 class Schedule;
39 class UnitSystem;
40 template<class Scalar, class IndexTraits> class BlackoilWellModelGeneric;
41 template<typename Scalar, typename IndexTraits> class WellInterfaceGeneric;
42 template<typename Scalar> class VFPProdProperties;
43}
44
45namespace Opm {
46
48template<typename Scalar, typename IndexTraits>
49class BlackoilWellModelNetworkGeneric
50{
51public:
52 BlackoilWellModelNetworkGeneric(BlackoilWellModelGeneric<Scalar,IndexTraits>& well_model);
53
54 virtual ~BlackoilWellModelNetworkGeneric() = default;
55
57 bool active() const
58 { return active_; }
59
60 const std::map<std::string, Scalar>&
61 nodePressures() const { return node_pressures_; }
62
63 // do not use, only needed for serialization testing
64 void setNodePressures(const std::map<std::string, Scalar>& values)
65 { node_pressures_ = values; }
66
67 void setFromRestart(const std::optional<std::map<std::string, double>>& restart_pressures);
68
70 void initialize(const int report_step);
71
74
76 void updateActiveState(const int report_step);
77
81 bool needPreStepRebalance(const int report_step) const;
82
85 bool shouldBalance(const int reportStepIndex,
86 const NewtonIterationContext& iterCtx) const;
88 bool willBalanceOnNextIteration(const int reportStepIndex,
89 const NewtonIterationContext& iterCtx) const;
90
91 Scalar updatePressures(const int reportStepIdx,
92 const Scalar damping_factor,
93 const Scalar update_upper_bound);
94
95 void assignNodeValues(std::map<std::string, data::NodeData>& nodevalues,
96 const int reportStepIdx) const;
97
98 void commitState()
99 { this->last_valid_node_pressures_ = this->node_pressures_; }
100
101 void resetState()
102 { this->node_pressures_ = this->last_valid_node_pressures_; }
103
104 template<class Serializer>
105 void serializeOp(Serializer& serializer)
106 {
107 serializer(node_pressures_);
108 serializer(last_valid_node_pressures_);
109 }
110
111 bool operator==(const BlackoilWellModelNetworkGeneric<Scalar,IndexTraits>& rhs) const;
112
113protected:
114 std::map<std::string, Scalar>
115 computePressures(const Network::ExtNetwork& network,
116 const VFPProdProperties<Scalar>& vfp_prod_props,
117 const UnitSystem& unit_system,
118 const int reportStepIdx,
119 const Parallel::Communication& comm) const;
120
121
122 bool active_{false};
123 BlackoilWellModelGeneric<Scalar,IndexTraits>& well_model_;
124
125 // Network pressures for output and initialization
126 std::map<std::string, Scalar> node_pressures_;
127 // Valid network pressures for output and initialization for safe restart after failed iterations
128 std::map<std::string, Scalar> last_valid_node_pressures_;
129};
130
131} // namespace Opm
132
133#endif
Class for handling the blackoil well model.
Definition BlackoilWellModelGeneric.hpp:97
bool willBalanceOnNextIteration(const int reportStepIndex, const NewtonIterationContext &iterCtx) const
Checks if we will perform a network re-balance on the next Newton iteration.
Definition BlackoilWellModelNetworkGeneric.cpp:133
void initialize(const int report_step)
Initialize wells according to network configuration.
Definition BlackoilWellModelNetworkGeneric.cpp:282
bool needPreStepRebalance(const int report_step) const
Checks if there are reasons to perform a pre-step network re-balance.
Definition BlackoilWellModelNetworkGeneric.cpp:89
void updateActiveState(const int report_step)
Checks if network is active (at least one network well on prediction).
Definition BlackoilWellModelNetworkGeneric.cpp:67
bool active() const
return true if network is active (at least one network well in prediction mode)
Definition BlackoilWellModelNetworkGeneric.hpp:57
void initializeWell(WellInterfaceGeneric< Scalar, IndexTraits > &well)
Initialize a single well according to network configuration.
Definition BlackoilWellModelNetworkGeneric.cpp:294
bool shouldBalance(const int reportStepIndex, const NewtonIterationContext &iterCtx) const
Checks if we shall perform a network re-balance.
Definition BlackoilWellModelNetworkGeneric.cpp:108
Class which linearly interpolates BHP as a function of rate, tubing head pressure,...
Definition VFPProdProperties.hpp:38
Definition WellInterfaceGeneric.hpp:53
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilbioeffectsmodules.hh:45
Context for iteration-dependent decisions in the Newton solver.
Definition NewtonIterationContext.hpp:43