00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00027 #ifndef OPM_ECL_HYSTERESIS_CONFIG_HPP
00028 #define OPM_ECL_HYSTERESIS_CONFIG_HPP
00029
00030 #if HAVE_OPM_PARSER
00031 #include <opm/parser/eclipse/Deck/Deck.hpp>
00032 #include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
00033 #include <opm/parser/eclipse/Deck/DeckRecord.hpp>
00034 #include <opm/parser/eclipse/Deck/DeckItem.hpp>
00035 #endif
00036
00037 #include <opm/common/ErrorMacros.hpp>
00038 #include <opm/common/Exceptions.hpp>
00039
00040 #include <string>
00041 #include <cassert>
00042 #include <algorithm>
00043
00044 namespace Opm {
00050 class EclHysteresisConfig
00051 {
00052 public:
00053 EclHysteresisConfig()
00054 {
00055 enableHysteresis_ = false;
00056 pcHysteresisModel_ = 0;
00057 krHysteresisModel_ = 0;
00058 }
00059
00063 void setEnableHysteresis(bool yesno)
00064 { enableHysteresis_ = yesno; }
00065
00069 bool enableHysteresis() const
00070 { return enableHysteresis_; }
00071
00078 void setPcHysteresisModel(int value)
00079 { pcHysteresisModel_ = value; }
00080
00087 int pcHysteresisModel() const
00088 { return pcHysteresisModel_; }
00089
00096 void setKrHysteresisModel(int value)
00097 { krHysteresisModel_ = value; }
00098
00105 int krHysteresisModel() const
00106 { return krHysteresisModel_; }
00107
00108 #if HAVE_OPM_PARSER
00109
00114 void initFromDeck(const Opm::Deck& deck)
00115 {
00116 enableHysteresis_ = false;
00117
00118 if (!deck.hasKeyword("SATOPTS"))
00119 return;
00120
00121 const auto& satoptsItem = deck.getKeyword("SATOPTS").getRecord(0).getItem(0);
00122 for (unsigned i = 0; i < satoptsItem.size(); ++i) {
00123 std::string satoptsValue = satoptsItem.get< std::string >(0);
00124 std::transform(satoptsValue.begin(),
00125 satoptsValue.end(),
00126 satoptsValue.begin(),
00127 ::toupper);
00128
00129 if (satoptsValue == "HYSTER")
00130 enableHysteresis_ = true;
00131 }
00132
00133
00134 if (deck.hasKeyword("HYST"))
00135 enableHysteresis_ = true;
00136
00137 if (!enableHysteresis_)
00138 return;
00139
00140 if (!deck.hasKeyword("EHYSTR"))
00141 OPM_THROW(std::runtime_error,
00142 "Enabling hysteresis via the HYST parameter for SATOPTS requires the "
00143 "presence of the EHYSTR keyword");
00144
00145 const auto& ehystrKeyword = deck.getKeyword("EHYSTR");
00146 if (deck.hasKeyword("NOHYKR"))
00147 krHysteresisModel_ = -1;
00148 else {
00149 krHysteresisModel_ = ehystrKeyword.getRecord(0).getItem("relative_perm_hyst").get< int >(0);
00150 if (krHysteresisModel_ != 0)
00151 OPM_THROW(std::runtime_error,
00152 "Only the Carlson kr hystersis model (indicated by a 0 on the second item"
00153 " of the 'EHYSTR' keyword) is supported");
00154 }
00155
00156 if (deck.hasKeyword("NOHYPC"))
00157 pcHysteresisModel_ = -1;
00158 else {
00159
00160
00161 pcHysteresisModel_ = 0;
00162 }
00163 }
00164 #endif
00165
00166 private:
00167
00168 bool enableHysteresis_;
00169
00170
00171 int pcHysteresisModel_;
00172 int krHysteresisModel_;
00173 };
00174
00175 }
00176
00177 #endif