EclHysteresisConfig.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 */
27 #ifndef OPM_ECL_HYSTERESIS_CONFIG_HPP
28 #define OPM_ECL_HYSTERESIS_CONFIG_HPP
29 
30 #if HAVE_OPM_PARSER
31 #include <opm/parser/eclipse/Deck/Deck.hpp>
32 #include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
33 #include <opm/parser/eclipse/Deck/DeckRecord.hpp>
34 #include <opm/parser/eclipse/Deck/DeckItem.hpp>
35 #endif
36 
37 #include <opm/common/ErrorMacros.hpp>
38 #include <opm/common/Exceptions.hpp>
39 
40 #include <string>
41 #include <cassert>
42 #include <algorithm>
43 
44 namespace Opm {
51 {
52 public:
54  {
55  enableHysteresis_ = false;
56  pcHysteresisModel_ = 0;
57  krHysteresisModel_ = 0;
58  }
59 
63  void setEnableHysteresis(bool yesno)
64  { enableHysteresis_ = yesno; }
65 
69  bool enableHysteresis() const
70  { return enableHysteresis_; }
71 
78  void setPcHysteresisModel(int value)
79  { pcHysteresisModel_ = value; }
80 
87  int pcHysteresisModel() const
88  { return pcHysteresisModel_; }
89 
96  void setKrHysteresisModel(int value)
97  { krHysteresisModel_ = value; }
98 
105  int krHysteresisModel() const
106  { return krHysteresisModel_; }
107 
108 #if HAVE_OPM_PARSER
109 
114  void initFromDeck(const Opm::Deck& deck)
115  {
116  enableHysteresis_ = false;
117 
118  if (!deck.hasKeyword("SATOPTS"))
119  return;
120 
121  const auto& satoptsItem = deck.getKeyword("SATOPTS").getRecord(0).getItem(0);
122  for (unsigned i = 0; i < satoptsItem.size(); ++i) {
123  std::string satoptsValue = satoptsItem.get< std::string >(0);
124  std::transform(satoptsValue.begin(),
125  satoptsValue.end(),
126  satoptsValue.begin(),
127  ::toupper);
128 
129  if (satoptsValue == "HYSTER")
130  enableHysteresis_ = true;
131  }
132 
133  // check for the (deprecated) HYST keyword
134  if (deck.hasKeyword("HYST"))
135  enableHysteresis_ = true;
136 
137  if (!enableHysteresis_)
138  return;
139 
140  if (!deck.hasKeyword("EHYSTR"))
141  OPM_THROW(std::runtime_error,
142  "Enabling hysteresis via the HYST parameter for SATOPTS requires the "
143  "presence of the EHYSTR keyword");
144 
145  const auto& ehystrKeyword = deck.getKeyword("EHYSTR");
146  if (deck.hasKeyword("NOHYKR"))
147  krHysteresisModel_ = -1;
148  else {
149  krHysteresisModel_ = ehystrKeyword.getRecord(0).getItem("relative_perm_hyst").get< int >(0);
150  if (krHysteresisModel_ != 0)
151  OPM_THROW(std::runtime_error,
152  "Only the Carlson kr hystersis model (indicated by a 0 on the second item"
153  " of the 'EHYSTR' keyword) is supported");
154  }
155 
156  if (deck.hasKeyword("NOHYPC"))
157  pcHysteresisModel_ = -1;
158  else {
159  // if capillary pressure hysteresis is enabled, Eclipse always uses the
160  // Killough model
161  pcHysteresisModel_ = 0;
162  }
163  }
164 #endif
165 
166 private:
167  // enable hysteresis at all
168  bool enableHysteresis_;
169 
170  // the capillary pressure and the relperm hysteresis models to be used
171  int pcHysteresisModel_;
172  int krHysteresisModel_;
173 };
174 
175 } // namespace Opm
176 
177 #endif
void setKrHysteresisModel(int value)
Set the type of the hysteresis model which is used for relative permeability.
Definition: EclHysteresisConfig.hpp:96
Definition: Air_Mesitylene.hpp:33
void setPcHysteresisModel(int value)
Set the type of the hysteresis model which is used for capillary pressure.
Definition: EclHysteresisConfig.hpp:78
Specifies the configuration used by the ECL kr/pC hysteresis code.
Definition: EclHysteresisConfig.hpp:50
bool enableHysteresis() const
Returns whether hysteresis is enabled.
Definition: EclHysteresisConfig.hpp:69
void setEnableHysteresis(bool yesno)
Specify whether hysteresis is enabled or not.
Definition: EclHysteresisConfig.hpp:63
int pcHysteresisModel() const
Return the type of the hysteresis model which is used for capillary pressure.
Definition: EclHysteresisConfig.hpp:87
int krHysteresisModel() const
Return the type of the hysteresis model which is used for relative permeability.
Definition: EclHysteresisConfig.hpp:105