AquiferInterface.hpp
Go to the documentation of this file.
1/*
2 Copyright 2017 SINTEF Digital, Mathematics and Cybernetics.
3 Copyright 2017 Statoil ASA.
4 Copyright 2017 IRIS
5
6 This file is part of the Open Porous Media project (OPM).
7
8 OPM is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 OPM is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with OPM. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22#ifndef OPM_AQUIFERINTERFACE_HEADER_INCLUDED
23#define OPM_AQUIFERINTERFACE_HEADER_INCLUDED
24
25#include <opm/common/ErrorMacros.hpp>
26
29
30#include <opm/output/data/Aquifer.hpp>
31
32#include <fmt/format.h>
33
34#include <stdexcept>
35
36namespace Opm::Concepts
37{
38
39// Black-oil fluid systems name a primary component for each phase. Aquifer
40// inflow is added to the equation of that component.
41template <class FluidSystem>
42concept HasBlackoilComponents = requires {
43 FluidSystem::canonicalToActiveCompIdx(FluidSystem::solventComponentIndex(0u));
44};
45
46} // namespace Opm::Concepts
47
48namespace Opm
49{
50
51template <typename TypeTag>
53{
54public:
59
60 // Constructor
62 const Simulator& simulator)
63 : aquiferID_(aqID)
64 , simulator_(simulator)
65 {
66 const auto phaseIdx = this->phaseIdx_();
67
68 if (! FluidSystem::phaseIsActive(phaseIdx)) {
69 OPM_THROW(std::logic_error,
70 fmt::format("Aquifer {} needs an active {} phase",
71 this->aquiferID_,
72 FluidSystem::phaseName(phaseIdx)));
73 }
74 }
75
76 // Destructor
77 virtual ~AquiferInterface() = default;
78
79 virtual void initFromRestart(const data::Aquifers& aquiferSoln) = 0;
80
81 virtual void initialSolutionApplied() = 0;
82
83 virtual void beginTimeStep() = 0;
84 virtual void endTimeStep() = 0;
85
86 virtual data::AquiferData aquiferData() const = 0;
87
88 virtual void computeFaceAreaFraction(const std::vector<Scalar>& total_face_area) = 0;
89 virtual Scalar totalFaceArea() const = 0;
90
91 template <class Context>
93 const Context& context,
94 const unsigned spaceIdx,
95 const unsigned timeIdx)
96 {
97 const unsigned cellIdx = context.globalSpaceIndex(spaceIdx, timeIdx);
98 addToSource(rates, cellIdx, timeIdx);
99 }
100
101 virtual void addToSource(RateVector& rates,
102 const unsigned cellIdx,
103 const unsigned timeIdx) = 0;
104
107 virtual Scalar cachedConnectionInfluxRate([[maybe_unused]] unsigned cellIdx) const
108 {
109 return Scalar{0};
110 }
111
112 int aquiferID() const { return this->aquiferID_; }
113
114protected:
116 {
117 const auto& rspec = simulator_.vanguard().eclState().runspec();
118 return rspec.co2Storage() || rspec.h2Storage();
119 }
120
121 // Brine properties come from the internal brine model rather than PVTW/DENSITY
123 {
124 const auto& rspec = simulator_.vanguard().eclState().runspec();
125 return rspec.co2Storage() || rspec.h2Storage() || rspec.co2Sol() || rspec.h2Sol();
126 }
127
128 int phaseIdx_() const
129 {
130 // If OIL is used to model brine the aquifer should do the same
131 if (co2store_or_h2store_() && FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx))
132 return FluidSystem::oilPhaseIdx;
133
134 return FluidSystem::waterPhaseIdx;
135 }
136
137 const int aquiferID_{};
139};
140
141} // namespace Opm
142
143#endif
Definition: AquiferInterface.hpp:53
const int aquiferID_
Definition: AquiferInterface.hpp:137
const Simulator & simulator_
Definition: AquiferInterface.hpp:138
virtual void beginTimeStep()=0
virtual void computeFaceAreaFraction(const std::vector< Scalar > &total_face_area)=0
virtual void initialSolutionApplied()=0
virtual void initFromRestart(const data::Aquifers &aquiferSoln)=0
AquiferInterface(int aqID, const Simulator &simulator)
Definition: AquiferInterface.hpp:61
virtual Scalar totalFaceArea() const =0
virtual data::AquiferData aquiferData() const =0
void addToSource(RateVector &rates, const Context &context, const unsigned spaceIdx, const unsigned timeIdx)
Definition: AquiferInterface.hpp:92
virtual ~AquiferInterface()=default
int phaseIdx_() const
Definition: AquiferInterface.hpp:128
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: AquiferInterface.hpp:58
bool internal_brine_model_() const
Definition: AquiferInterface.hpp:122
virtual void endTimeStep()=0
GetPropType< TypeTag, Properties::Simulator > Simulator
Definition: AquiferInterface.hpp:57
virtual Scalar cachedConnectionInfluxRate(unsigned cellIdx) const
Definition: AquiferInterface.hpp:107
GetPropType< TypeTag, Properties::FluidSystem > FluidSystem
Definition: AquiferInterface.hpp:55
bool co2store_or_h2store_() const
Definition: AquiferInterface.hpp:115
virtual void addToSource(RateVector &rates, const unsigned cellIdx, const unsigned timeIdx)=0
int aquiferID() const
Definition: AquiferInterface.hpp:112
GetPropType< TypeTag, Properties::RateVector > RateVector
Definition: AquiferInterface.hpp:56
Definition: AquiferInterface.hpp:42
Declare the properties used by the infrastructure code of the finite volume discretizations.
Defines the common properties required by the porous medium multi-phase models.
Definition: blackoilprimaryvariables.hh:62
Definition: blackoilbioeffectsmodules.hh:45
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