Add UDQEnum type for the different variable types
This commit is contained in:
@@ -128,6 +128,7 @@ if(ENABLE_ECL_INPUT)
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQSet.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQWellSet.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQAssign.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQEnums.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQInput.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQContext.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQExpression.cpp
|
||||
@@ -516,6 +517,7 @@ if(ENABLE_ECL_INPUT)
|
||||
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQAssign.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQContext.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQInput.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQEnums.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQParams.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQInput.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQWellSet.hpp
|
||||
|
||||
45
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQEnums.hpp
Normal file
45
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQEnums.hpp
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
Copyright 2019 Equinor ASA.
|
||||
|
||||
This file is part of the Open Porous Media project (OPM).
|
||||
|
||||
OPM is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OPM is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef UDQ_ENUMS_HPP
|
||||
#define UDQ_ENUMS_HPP
|
||||
|
||||
namespace Opm {
|
||||
|
||||
enum class UDQVarType {
|
||||
WELL_VAR = 1,
|
||||
CONNECTION_VAR= 2,
|
||||
FIELD_VAR = 3,
|
||||
GROUP_VAR = 4,
|
||||
REGION_VAR = 5,
|
||||
SEGMENT_VAR = 6,
|
||||
AQUIFER_VAR = 7,
|
||||
BLOCK_VAR = 8
|
||||
};
|
||||
|
||||
|
||||
namespace UDQ {
|
||||
|
||||
UDQVarType varType(const std::string& keyword);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
Copyright 2019 Equinor ASA.
|
||||
|
||||
This file is part of the Open Porous Media project (OPM).
|
||||
|
||||
OPM is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OPM is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQEnums.hpp>
|
||||
|
||||
|
||||
namespace Opm {
|
||||
namespace UDQ {
|
||||
|
||||
UDQVarType varType(const std::string& keyword) {
|
||||
if (keyword[1] != 'U')
|
||||
throw std::invalid_argument("Keyword: " + keyword + " is not of UDQ type");
|
||||
|
||||
char first_char = keyword[0];
|
||||
switch(first_char) {
|
||||
case 'W':
|
||||
return UDQVarType::WELL_VAR;
|
||||
case 'G':
|
||||
return UDQVarType::GROUP_VAR;
|
||||
case 'C':
|
||||
return UDQVarType::CONNECTION_VAR;
|
||||
case 'R':
|
||||
return UDQVarType::REGION_VAR;
|
||||
case 'F':
|
||||
return UDQVarType::FIELD_VAR;
|
||||
case 'S':
|
||||
return UDQVarType::SEGMENT_VAR;
|
||||
case 'A':
|
||||
return UDQVarType::AQUIFER_VAR;
|
||||
case 'B':
|
||||
return UDQVarType::BLOCK_VAR;
|
||||
default:
|
||||
throw std::invalid_argument("Keyword: " + keyword + " is not of UDQ type");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <opm/parser/eclipse/EclipseState/Runspec.hpp>
|
||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQEnums.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQInput.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQSet.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQWellSet.hpp>
|
||||
@@ -69,6 +70,21 @@ UDQPARAM
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ENUM_CONVERSION) {
|
||||
BOOST_CHECK_THROW(UDQ::varType("WWCT"), std::invalid_argument);
|
||||
BOOST_CHECK_THROW(UDQ::varType("XUCT"), std::invalid_argument);
|
||||
|
||||
BOOST_CHECK(UDQ::varType("WUBHP") == UDQVarType::WELL_VAR);
|
||||
BOOST_CHECK(UDQ::varType("GUBHP") == UDQVarType::GROUP_VAR);
|
||||
BOOST_CHECK(UDQ::varType("CUBHP") == UDQVarType::CONNECTION_VAR);
|
||||
BOOST_CHECK(UDQ::varType("FUBHP") == UDQVarType::FIELD_VAR);
|
||||
BOOST_CHECK(UDQ::varType("RUBHP") == UDQVarType::REGION_VAR);
|
||||
BOOST_CHECK(UDQ::varType("AUBHP") == UDQVarType::AQUIFER_VAR);
|
||||
BOOST_CHECK(UDQ::varType("SUBHP") == UDQVarType::SEGMENT_VAR);
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(UDQ_KEWYORDS) {
|
||||
const std::string input = R"(
|
||||
RUNSPEC
|
||||
|
||||
Reference in New Issue
Block a user