BlackoilWellModelNetworkGeneric.hpp
Go to the documentation of this file.
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
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>
50{
51public:
53
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) const;
87 bool willBalanceOnNextIteration(const int reportStepIndex) const;
88
89 Scalar updatePressures(const int reportStepIdx,
90 const Scalar damping_factor,
91 const Scalar update_upper_bound);
92
93 void assignNodeAndBranchValues(std::map<std::string, data::NodeData>& nodevalues,
94 std::map<std::string, data::BranchData>& branchvalues,
95 std::map<std::string, data::BranchData>& converged_branchvalues,
96 const int reportStepIdx) const;
97
99 {
102 }
103
105 {
108 }
109
110 template<class Serializer>
111 void serializeOp(Serializer& serializer)
112 {
113 serializer(node_pressures_);
114 serializer(last_valid_node_pressures_);
115 serializer(branch_data_);
116 serializer(last_valid_branch_data_);
117 }
118
120
121protected:
122 std::pair<std::map<std::string, Scalar>, std::map<std::string, data::BranchData>>
123 computePressures(const Network::ExtNetwork& network,
124 const VFPProdProperties<Scalar>& vfp_prod_props,
125 const UnitSystem& unit_system,
126 const int reportStepIdx,
127 const Parallel::Communication& comm) const;
128
129
130 bool active_{false};
132
133 // Network pressures for output and initialization
134 std::map<std::string, Scalar> node_pressures_;
135 // Network branch pressure drops and flow rates for output (outlet branch for production network, inlet branch for injection network)
136 std::map<std::string, data::BranchData> branch_data_;
137 // Valid network pressures for output and initialization for safe restart after failed iterations
138 std::map<std::string, Scalar> last_valid_node_pressures_;
139 // Valid network branch pressure drops and flow rates for output (outlet branch for production network, inlet branch for injection network) for safe restart after failed iterations
140 std::map<std::string, data::BranchData> last_valid_branch_data_;
141};
142
143} // namespace Opm
144
145#endif
Class for handling the blackoil well network model.
Definition: BlackoilWellModelNetworkGeneric.hpp:50
std::pair< std::map< std::string, Scalar >, std::map< std::string, data::BranchData > > computePressures(const Network::ExtNetwork &network, const VFPProdProperties< Scalar > &vfp_prod_props, const UnitSystem &unit_system, const int reportStepIdx, const Parallel::Communication &comm) const
std::map< std::string, Scalar > node_pressures_
Definition: BlackoilWellModelNetworkGeneric.hpp:134
bool shouldBalance(const int reportStepIndex) const
virtual ~BlackoilWellModelNetworkGeneric()=default
bool willBalanceOnNextIteration(const int reportStepIndex) const
Checks if we will perform a network re-balance on the next Newton iteration.
void commitState()
Definition: BlackoilWellModelNetworkGeneric.hpp:98
void assignNodeAndBranchValues(std::map< std::string, data::NodeData > &nodevalues, std::map< std::string, data::BranchData > &branchvalues, std::map< std::string, data::BranchData > &converged_branchvalues, const int reportStepIdx) const
bool active_
Definition: BlackoilWellModelNetworkGeneric.hpp:130
void setNodePressures(const std::map< std::string, Scalar > &values)
Definition: BlackoilWellModelNetworkGeneric.hpp:64
void initialize(const int report_step)
Initialize wells according to network configuration.
BlackoilWellModelGeneric< Scalar, IndexTraits > & well_model_
Definition: BlackoilWellModelNetworkGeneric.hpp:131
Scalar updatePressures(const int reportStepIdx, const Scalar damping_factor, const Scalar update_upper_bound)
std::map< std::string, data::BranchData > branch_data_
Definition: BlackoilWellModelNetworkGeneric.hpp:136
std::map< std::string, Scalar > last_valid_node_pressures_
Definition: BlackoilWellModelNetworkGeneric.hpp:138
bool needPreStepRebalance(const int report_step) const
bool operator==(const BlackoilWellModelNetworkGeneric< Scalar, IndexTraits > &rhs) const
void updateActiveState(const int report_step)
Checks if network is active (at least one network well on prediction).
BlackoilWellModelNetworkGeneric(BlackoilWellModelGeneric< Scalar, IndexTraits > &well_model)
std::map< std::string, data::BranchData > last_valid_branch_data_
Definition: BlackoilWellModelNetworkGeneric.hpp:140
void serializeOp(Serializer &serializer)
Definition: BlackoilWellModelNetworkGeneric.hpp:111
bool active() const
return true if network is active (at least one network well in prediction mode)
Definition: BlackoilWellModelNetworkGeneric.hpp:57
void setFromRestart(const std::optional< std::map< std::string, double > > &restart_pressures)
void initializeWell(WellInterfaceGeneric< Scalar, IndexTraits > &well)
Initialize a single well according to network configuration.
void resetState()
Definition: BlackoilWellModelNetworkGeneric.hpp:104
const std::map< std::string, Scalar > & nodePressures() const
Definition: BlackoilWellModelNetworkGeneric.hpp:61
Definition: VFPProdProperties.hpp:38
Definition: WellInterfaceGeneric.hpp:53
Dune::Communication< MPIComm > Communication
Definition: ParallelCommunication.hpp:30
Definition: blackoilbioeffectsmodules.hh:45