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  Copyright (C) 2015 by Andreas Lauser
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 2 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 */
25 #ifndef OPM_ECL_HYSTERESIS_CONFIG_HPP
26 #define OPM_ECL_HYSTERESIS_CONFIG_HPP
27 
28 #if HAVE_OPM_PARSER
29 #include <opm/parser/eclipse/Deck/Deck.hpp>
30 #endif
31 
32 #include <opm/common/ErrorMacros.hpp>
33 #include <opm/common/Exceptions.hpp>
34 
35 #include <string>
36 #include <cassert>
37 #include <algorithm>
38 
39 namespace Opm {
46 {
47 public:
49  {
50  enableHysteresis_ = false;
51  pcHysteresisModel_ = 0;
52  krHysteresisModel_ = 0;
53  }
54 
58  void setEnableHysteresis(bool yesno)
59  { enableHysteresis_ = yesno; }
60 
64  bool enableHysteresis() const
65  { return enableHysteresis_; }
66 
73  void setPcHysteresisModel(int value)
74  { pcHysteresisModel_ = value; }
75 
82  int pcHysteresisModel() const
83  { return pcHysteresisModel_; }
84 
91  void setKrHysteresisModel(int value)
92  { krHysteresisModel_ = value; }
93 
100  int krHysteresisModel() const
101  { return krHysteresisModel_; }
102 
103 #if HAVE_OPM_PARSER
104 
109  void initFromDeck(Opm::DeckConstPtr deck)
110  {
111  enableHysteresis_ = false;
112 
113  if (!deck->hasKeyword("SATOPTS"))
114  return;
115 
116  Opm::DeckItemConstPtr satoptsItem = deck->getKeyword("SATOPTS")->getRecord(0)->getItem(0);
117  for (unsigned i = 0; i < satoptsItem->size(); ++i) {
118  std::string satoptsValue = satoptsItem->getString(0);
119  std::transform(satoptsValue.begin(),
120  satoptsValue.end(),
121  satoptsValue.begin(),
122  ::toupper);
123 
124  if (satoptsValue == "HYSTER")
125  enableHysteresis_ = true;
126  }
127 
128  // check for the (deprecated) HYST keyword
129  if (deck->hasKeyword("HYST"))
130  enableHysteresis_ = true;
131 
132  if (!enableHysteresis_)
133  return;
134 
135  if (!deck->hasKeyword("EHYSTR"))
136  OPM_THROW(std::runtime_error,
137  "Enabling hysteresis via the HYST parameter for SATOPTS requires the "
138  "presence of the EHYSTR keyword");
139 
140  Opm::DeckKeywordConstPtr ehystrKeyword = deck->getKeyword("EHYSTR");
141  if (deck->hasKeyword("NOHYKR"))
142  krHysteresisModel_ = -1;
143  else {
144  krHysteresisModel_ = ehystrKeyword->getRecord(0)->getItem("relative_perm_hyst")->getInt(0);
145  if (krHysteresisModel_ != 0)
146  OPM_THROW(std::runtime_error,
147  "Only the Carlson kr hystersis model (indicated by a 0 on the second item"
148  " of the 'EHYSTR' keyword) is supported");
149  }
150 
151  if (deck->hasKeyword("NOHYPC"))
152  pcHysteresisModel_ = -1;
153  else {
154  // if capillary pressure hysteresis is enabled, Eclipse always uses the
155  // Killough model
156  pcHysteresisModel_ = 0;
157  }
158  }
159 #endif
160 
161 private:
162  // enable hysteresis at all
163  bool enableHysteresis_;
164 
165  // the capillary pressure and the relperm hysteresis models to be used
166  int pcHysteresisModel_;
167  int krHysteresisModel_;
168 };
169 
170 } // namespace Opm
171 
172 #endif
void setKrHysteresisModel(int value)
Set the type of the hysteresis model which is used for relative permeability.
Definition: EclHysteresisConfig.hpp:91
int krHysteresisModel() const
Return the type of the hysteresis model which is used for relative permeability.
Definition: EclHysteresisConfig.hpp:100
Definition: Air_Mesitylene.hpp:31
EclHysteresisConfig()
Definition: EclHysteresisConfig.hpp:48
bool enableHysteresis() const
Returns whether hysteresis is enabled.
Definition: EclHysteresisConfig.hpp:64
int pcHysteresisModel() const
Return the type of the hysteresis model which is used for capillary pressure.
Definition: EclHysteresisConfig.hpp:82
Specifies the configuration used by the ECL kr/pC hysteresis code.
Definition: EclHysteresisConfig.hpp:45
void setPcHysteresisModel(int value)
Set the type of the hysteresis model which is used for capillary pressure.
Definition: EclHysteresisConfig.hpp:73
void setEnableHysteresis(bool yesno)
Specify whether hysteresis is enabled or not.
Definition: EclHysteresisConfig.hpp:58