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,
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
100
103
104 template<class Serializer>
105 void serializeOp(Serializer& serializer)
106 {
107 serializer(node_pressures_);
108 serializer(last_valid_node_pressures_);
109 }
110
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};
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
Class for handling the blackoil well network model.
Definition: BlackoilWellModelNetworkGeneric.hpp:50
std::map< std::string, Scalar > node_pressures_
Definition: BlackoilWellModelNetworkGeneric.hpp:126
virtual ~BlackoilWellModelNetworkGeneric()=default
bool willBalanceOnNextIteration(const int reportStepIndex, const NewtonIterationContext &iterCtx) const
Checks if we will perform a network re-balance on the next Newton iteration.
void commitState()
Definition: BlackoilWellModelNetworkGeneric.hpp:98
bool active_
Definition: BlackoilWellModelNetworkGeneric.hpp:122
std::map< std::string, Scalar > computePressures(const Network::ExtNetwork &network, const VFPProdProperties< Scalar > &vfp_prod_props, const UnitSystem &unit_system, const int reportStepIdx, const Parallel::Communication &comm) const
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:123
Scalar updatePressures(const int reportStepIdx, const Scalar damping_factor, const Scalar update_upper_bound)
std::map< std::string, Scalar > last_valid_node_pressures_
Definition: BlackoilWellModelNetworkGeneric.hpp:128
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)
void serializeOp(Serializer &serializer)
Definition: BlackoilWellModelNetworkGeneric.hpp:105
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.
bool shouldBalance(const int reportStepIndex, const NewtonIterationContext &iterCtx) const
void assignNodeValues(std::map< std::string, data::NodeData > &nodevalues, const int reportStepIdx) const
void resetState()
Definition: BlackoilWellModelNetworkGeneric.hpp:101
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
Context for iteration-dependent decisions in the Newton solver.
Definition: NewtonIterationContext.hpp:43