opm-simulators
ComponentName_impl.hpp
1 /*
2  Copyright 2026, SINTEF Digital
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 3 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 
20 #ifndef OPM_COMPONENT_NAME_IMPL_HPP
21 #define OPM_COMPONENT_NAME_IMPL_HPP
22 
23 #include <cassert>
24 #include <limits>
25 
26 namespace Opm {
27 
28 template<class FluidSystem, class Indices>
29 ComponentName<FluidSystem,Indices>::ComponentName()
30  : names_(Indices::numEq)
31 {
32  if constexpr (requires {
33  FluidSystem::solventComponentIndex(0u);
34  FluidSystem::canonicalToActiveCompIdx(0u);
35  }) {
36  for (unsigned phaseIdx = 0; phaseIdx < FluidSystem::numPhases; ++phaseIdx) {
37  if (!FluidSystem::phaseIsActive(phaseIdx)) {
38  continue;
39  }
40 
41  const unsigned canonicalCompIdx = FluidSystem::solventComponentIndex(phaseIdx);
42  names_[FluidSystem::canonicalToActiveCompIdx(canonicalCompIdx)]
43  = FluidSystem::componentName(canonicalCompIdx);
44  }
45  }
46  else {
47  constexpr auto numNamedComponents =
48  (Indices::numEq < FluidSystem::numComponents) ? Indices::numEq : FluidSystem::numComponents;
49 
50  for (unsigned compIdx = 0; compIdx < numNamedComponents; ++compIdx) {
51  names_[compIdx] = FluidSystem::componentName(compIdx);
52  }
53 
54  if constexpr (requires { Indices::waterEnabled; Indices::water0Idx; }) {
55  if constexpr (Indices::waterEnabled
56  && (Indices::water0Idx >= 0)
57  && (Indices::water0Idx < Indices::numEq)) {
58  names_[Indices::water0Idx] = "Water";
59  }
60  }
61  }
62 
63  if constexpr (requires { Indices::enableSolvent; Indices::solventSaturationIdx; }) {
64  if constexpr (Indices::enableSolvent) {
65  names_[Indices::solventSaturationIdx] = "Solvent";
66  }
67  }
68 
69  if constexpr (requires { Indices::enableExtbo; Indices::zFractionIdx; }) {
70  if constexpr (Indices::enableExtbo) {
71  names_[Indices::zFractionIdx] = "ZFraction";
72  }
73  }
74 
75  if constexpr (requires { Indices::enablePolymer; Indices::polymerConcentrationIdx; }) {
76  if constexpr (Indices::enablePolymer) {
77  names_[Indices::polymerConcentrationIdx] = "Polymer";
78  }
79  }
80 
81  if constexpr (requires { Indices::polymerMoleWeightIdx; }) {
82  if constexpr (Indices::polymerMoleWeightIdx != std::numeric_limits<unsigned>::max()) {
83  assert(Indices::enablePolymer);
84  names_[Indices::polymerMoleWeightIdx] = "MolecularWeightP";
85  }
86  }
87 
88  if constexpr (requires { Indices::enableFullyImplicitThermal; Indices::temperatureIdx; }) {
89  if constexpr (Indices::enableFullyImplicitThermal) {
90  names_[Indices::temperatureIdx] = "Energy";
91  }
92  }
93 
94  if constexpr (requires { Indices::numFoam; Indices::foamConcentrationIdx; }) {
95  if constexpr (Indices::numFoam == 1) {
96  names_[Indices::foamConcentrationIdx] = "Foam";
97  }
98  }
99 
100  if constexpr (requires { Indices::numBrine; Indices::saltConcentrationIdx; }) {
101  if constexpr (Indices::numBrine == 1) {
102  names_[Indices::saltConcentrationIdx] = "Brine";
103  }
104  }
105 
106  if constexpr (requires {
107  Indices::enableMICP;
108  Indices::microbialConcentrationIdx;
109  Indices::oxygenConcentrationIdx;
110  Indices::ureaConcentrationIdx;
111  Indices::biofilmVolumeFractionIdx;
112  Indices::calciteVolumeFractionIdx;
113  }) {
114  if constexpr (Indices::enableMICP) {
115  names_[Indices::microbialConcentrationIdx] = "Microbes";
116  names_[Indices::oxygenConcentrationIdx] = "Oxygen";
117  names_[Indices::ureaConcentrationIdx] = "Urea";
118  names_[Indices::biofilmVolumeFractionIdx] = "Biofilm";
119  names_[Indices::calciteVolumeFractionIdx] = "Calcite";
120  }
121  }
122 
123  if constexpr (requires { Indices::enableBiofilm; Indices::microbialConcentrationIdx; Indices::biofilmVolumeFractionIdx; }) {
124  if constexpr (Indices::enableBiofilm) {
125  names_[Indices::microbialConcentrationIdx] = "Microbes";
126  names_[Indices::biofilmVolumeFractionIdx] = "Biofilm";
127  }
128  }
129 }
130 
131 } // namespace Opm
132 
133 #endif
Structs needed for tpfalinearizer and its gpuparams struct extracted to be defined in one place that ...
Definition: blackoilbioeffectsmodules.hh:45