opm-simulators
BlackOilEnergyIntensiveQuantitiesGlobalIndex.hpp
Go to the documentation of this file.
1 // -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 // vi: set et ts=4 sw=4 sts=4:
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 2 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  Consult the COPYING file in the top-level source directory of this
20  module for the precise wording of the license and the list of
21  copyright holders.
22 */
28 #ifndef OPM_BLACK_OIL_ENERGY_MODULE_GLOBAL_INDEX_HH
29 #define OPM_BLACK_OIL_ENERGY_MODULE_GLOBAL_INDEX_HH
30 
32 
33 namespace Opm {
34 
35 template <class TypeTag, EnergyModules activeModule>
37 
43 template <class TypeTag>
44 class BlackOilEnergyIntensiveQuantitiesGlobalIndex<TypeTag, EnergyModules::FullyImplicitThermal>
45  : public BlackOilEnergyIntensiveQuantities<TypeTag,EnergyModules::FullyImplicitThermal>
46 {
54  using ThermalConductionLaw = GetPropType<TypeTag, Properties::ThermalConductionLaw>;
55  using ParamCache = typename FluidSystem::template ParameterCache<Evaluation>;
56 
58  static constexpr unsigned temperatureIdx = Indices::temperatureIdx;
59  static constexpr unsigned numPhases = FluidSystem::numPhases;
60 
61 public:
62  OPM_HOST_DEVICE void updateTemperature_([[maybe_unused]] const Problem& problem,
63  const PrimaryVariables& priVars,
64  [[maybe_unused]] unsigned globalSpaceIndex,
65  unsigned timeIdx)
66  {
67  auto& fs = Parent::asImp_().fluidState_;
68  // set temperature
69  fs.setTemperature(priVars.makeEvaluation(temperatureIdx, timeIdx));
70  }
71  OPM_HOST_DEVICE void updateEnergyQuantities_(const Problem& problem,
72  [[maybe_unused]] const PrimaryVariables& priVars,
73  unsigned globalSpaceIndex,
74  unsigned timeIdx,
75  const ParamCache& paramCache)
76  {
77  auto& fs = Parent::asImp_().fluidState_;
78 
79  // compute the specific enthalpy of the fluids, the specific enthalpy of the rock
80  // and the thermal conductivity coefficients
81  for (int phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) {
82  if (!FluidSystem::phaseIsActive(phaseIdx)) {
83  continue;
84  }
85 
86  const auto& h = FluidSystem::enthalpy(fs, paramCache, phaseIdx);
87  fs.setEnthalpy(phaseIdx, h);
88  }
89 
90  const auto& solidEnergyLawParams = problem().solidEnergyLawParams(globalSpaceIndex, timeIdx);
91  this->rockInternalEnergy_ = SolidEnergyLaw::solidInternalEnergy(solidEnergyLawParams, fs);
92 
93  const auto& thermalConductionLawParams = problem.thermalConductionLawParams(globalSpaceIndex, timeIdx);
94  this->totalThermalConductivity_ = ThermalConductionLaw::thermalConductivity(thermalConductionLawParams, fs);
95 
96  // Retrieve the rock fraction from the problem
97  // Usually 1 - porosity, but if pvmult is used to modify porosity
98  // we will apply the same multiplier to the rock fraction
99  // i.e. pvmult*(1 - porosity) and thus interpret multpv as a volume
100  // multiplier. This is to avoid negative rock volume for pvmult*porosity > 1
101  this->rockFraction_ = problem.rockFraction(globalSpaceIndex, timeIdx);
102  }
103 };
104 
105 template <class TypeTag>
106 class BlackOilEnergyIntensiveQuantitiesGlobalIndex<TypeTag, EnergyModules::SequentialImplicitThermal>
107  : public BlackOilEnergyIntensiveQuantities<TypeTag, EnergyModules::SequentialImplicitThermal>
108 {
116  using ThermalConductionLaw = GetPropType<TypeTag, Properties::ThermalConductionLaw>;
117  using ParamCache = typename FluidSystem::template ParameterCache<Evaluation>;
118 
120  static constexpr unsigned numPhases = FluidSystem::numPhases;
121 public:
122 
123  OPM_HOST_DEVICE void updateTemperature_([[maybe_unused]] const Problem& problem,
124  [[maybe_unused]] const PrimaryVariables& priVars,
125  [[maybe_unused]] unsigned globalSpaceIndex,
126  [[maybe_unused]] unsigned timeIdx)
127  {
128  OPM_THROW(std::logic_error,
129  "updateTemperature not implemented "
130  "SequentialImplicitThermal can not be used with"
131  "global intensive quantites yet.");
132  }
133 
134  OPM_HOST_DEVICE void updateEnergyQuantities_([[maybe_unused]] const Problem& problem,
135  [[maybe_unused]] const PrimaryVariables& priVars,
136  [[maybe_unused]] unsigned globalSpaceIndex,
137  [[maybe_unused]] unsigned timeIdx,
138  [[maybe_unused]] const ParamCache& paramCache)
139  {
140  OPM_THROW(std::logic_error,
141  "updateEnergyQuantities_ not implemented "
142  "SequentialImplicitThermal can not be used with"
143  "global intensive quantites yet.");
144  }
145 
146 };
147 
148 template <class TypeTag>
149 class BlackOilEnergyIntensiveQuantitiesGlobalIndex<TypeTag, EnergyModules::ConstantTemperature>
150  : public BlackOilEnergyIntensiveQuantities<TypeTag, EnergyModules::ConstantTemperature>
151 {
158 
159 public:
160  OPM_HOST_DEVICE void updateTemperature_([[maybe_unused]] const Problem& problem,
161  [[maybe_unused]] const PrimaryVariables& priVars,
162  [[maybe_unused]] unsigned globalSpaceIdx,
163  [[maybe_unused]] unsigned timeIdx)
164  {
165  auto& fs = this->asImp_().fluidState_;
166  Scalar T = problem.temperature(globalSpaceIdx, timeIdx);
167  fs.setTemperature(T);
168  }
169 
170  OPM_HOST_DEVICE void updateEnergyQuantities_([[maybe_unused]] const Problem& problem,
171  [[maybe_unused]] const PrimaryVariables& priVars,
172  [[maybe_unused]] unsigned globalSpaceIdx,
173  [[maybe_unused]] unsigned timeIdx,
174  const typename FluidSystem::template ParameterCache<Evaluation>&)
175  { }
176 };
177 
178 template <class TypeTag>
179 class BlackOilEnergyIntensiveQuantitiesGlobalIndex<TypeTag, EnergyModules::NoTemperature>
180  : public BlackOilEnergyIntensiveQuantities<TypeTag, EnergyModules::NoTemperature>
181 {
188 
189 public:
190  OPM_HOST_DEVICE void updateTemperature_([[maybe_unused]] const Problem& problem,
191  [[maybe_unused]] const PrimaryVariables& priVars,
192  [[maybe_unused]] unsigned globalSpaceIdx,
193  [[maybe_unused]] unsigned timeIdx)
194  { }
195 
196  OPM_HOST_DEVICE void updateEnergyQuantities_([[maybe_unused]] const Problem& problem,
197  [[maybe_unused]] const PrimaryVariables& priVars,
198  [[maybe_unused]] unsigned globalSpaceIdx,
199  [[maybe_unused]] unsigned timeIdx,
200  const typename FluidSystem::template ParameterCache<Evaluation>&)
201  { }
202 };
203 
204 } // namespace Opm
205 
206 #endif
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
Definition: BlackOilEnergyIntensiveQuantitiesGlobalIndex.hpp:36
Structs needed for tpfalinearizer and its gpuparams struct extracted to be defined in one place that ...
Definition: blackoilbioeffectsmodules.hh:45
Provides the volumetric quantities required for the equations needed by the energys extension of the ...
Definition: blackoilmodules.hpp:67
Contains the classes required to extend the black-oil model by energy.