UDQConfig object has merged DEFINE & ASSIGN
This commit is contained in:
committed by
Jostein Alvestad
parent
28c2e7024c
commit
4d1b747b42
@@ -143,6 +143,7 @@ if(ENABLE_ECL_INPUT)
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQContext.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunction.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunctionTable.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQInput.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/VFPInjTable.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/VFPProdTable.cpp
|
||||
src/opm/parser/eclipse/Parser/ErrorGuard.cpp
|
||||
@@ -565,6 +566,7 @@ if(ENABLE_ECL_INPUT)
|
||||
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQConfig.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/UDQSet.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunction.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunctionTable.hpp
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQInput.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQDefine.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQAssign.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQEnums.hpp>
|
||||
@@ -38,6 +39,7 @@ namespace Opm {
|
||||
class DeckRecord;
|
||||
class Deck;
|
||||
|
||||
|
||||
class UDQConfig {
|
||||
public:
|
||||
explicit UDQConfig(const Deck& deck);
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
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 UDQINPUT__HPP_
|
||||
#define UDQINPUT__HPP_
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
class UDQAssign;
|
||||
class UDQDefine;
|
||||
|
||||
class UDQInput{
|
||||
public:
|
||||
UDQInput(const UDQDefine& udq_define);
|
||||
UDQInput(const UDQAssign& udq_assign);
|
||||
|
||||
template<typename T>
|
||||
const T& get() const;
|
||||
|
||||
template<typename T>
|
||||
bool is() const;
|
||||
|
||||
private:
|
||||
const UDQDefine * define;
|
||||
const UDQAssign * assign;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQConfig.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQEnums.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQInput.hpp>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
@@ -41,10 +42,12 @@ namespace Opm {
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
const UDQParams& UDQConfig::params() const {
|
||||
return this->udq_params;
|
||||
}
|
||||
|
||||
|
||||
void UDQConfig::add_record(const DeckRecord& record) {
|
||||
auto action = UDQ::actionType(record.getItem("ACTION").get<std::string>(0));
|
||||
const auto& quantity = record.getItem("QUANTITY").get<std::string>(0);
|
||||
@@ -105,12 +108,15 @@ namespace Opm {
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::pair<size_t, UDQDefine>> UDQConfig::input_definitions() const {
|
||||
std::vector<std::pair<size_t, UDQDefine>> res;
|
||||
std::vector<UDQInput> UDQConfig::input() const {
|
||||
std::vector<UDQInput> res;
|
||||
for (const auto& index_pair : this->input_index) {
|
||||
if (index_pair.second.second == UDQAction::DEFINE) {
|
||||
const std::string& key = index_pair.first;
|
||||
res.emplace_back(index_pair.second.first, this->m_definitions.at(key));
|
||||
res.push_back(UDQInput(this->m_definitions.at(key)));
|
||||
} else if (index_pair.second.second == UDQAction::ASSIGN) {
|
||||
const std::string& key = index_pair.first;
|
||||
res.push_back(UDQInput(this->m_assignments.at(key)));
|
||||
}
|
||||
}
|
||||
return res;
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
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 <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQDefine.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQAssign.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQInput.hpp>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
|
||||
UDQInput::UDQInput(const UDQDefine& udq_define) :
|
||||
define(std::addressof(udq_define)),
|
||||
assign(nullptr)
|
||||
{}
|
||||
|
||||
|
||||
UDQInput::UDQInput(const UDQAssign& udq_assign):
|
||||
define(nullptr),
|
||||
assign(std::addressof(udq_assign))
|
||||
{}
|
||||
|
||||
|
||||
template<>
|
||||
bool UDQInput::is<UDQAssign>() const {
|
||||
if (this->assign)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
bool UDQInput::is<UDQDefine>() const {
|
||||
if (this->define)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
template<>
|
||||
const UDQAssign& UDQInput::get<UDQAssign>() const {
|
||||
if (this->assign)
|
||||
return *this->assign;
|
||||
|
||||
throw std::runtime_error("Invalid get");
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
const UDQDefine& UDQInput::get<UDQDefine>() const {
|
||||
if (this->define)
|
||||
return *this->define;
|
||||
|
||||
throw std::runtime_error("Invalid get");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
+16
-14
@@ -1173,21 +1173,27 @@ UDQ
|
||||
const auto& udq = schedule.getUDQConfig(0);
|
||||
|
||||
|
||||
const auto& def_input = udq.input_definitions();
|
||||
const auto& input = udq.input();
|
||||
const auto& def = udq.definitions();
|
||||
BOOST_CHECK_EQUAL(def_input.size(), 3);
|
||||
for (std::size_t i = 0; i < def_input.size(); i++)
|
||||
BOOST_CHECK_EQUAL(def[i].input_string(), def_input[i].second.input_string());
|
||||
BOOST_CHECK_EQUAL(input.size(), 7);
|
||||
|
||||
BOOST_CHECK_EQUAL(def_input[0].first, 3);
|
||||
BOOST_CHECK_EQUAL(def_input[1].first, 4);
|
||||
BOOST_CHECK_EQUAL(def_input[2].first, 6);
|
||||
BOOST_CHECK( input[0].is<UDQAssign>() );
|
||||
BOOST_CHECK( input[1].is<UDQAssign>() );
|
||||
BOOST_CHECK( input[2].is<UDQAssign>() );
|
||||
BOOST_CHECK( input[3].is<UDQDefine>() );
|
||||
BOOST_CHECK( input[4].is<UDQDefine>() );
|
||||
BOOST_CHECK( input[5].is<UDQAssign>() );
|
||||
BOOST_CHECK( input[6].is<UDQDefine>() );
|
||||
|
||||
|
||||
BOOST_CHECK_EQUAL(def[0].keyword(), "WUWCT");
|
||||
BOOST_CHECK_EQUAL(def[1].keyword(), "FUOPR");
|
||||
BOOST_CHECK_EQUAL(def[2].keyword(), "FUOPRX");
|
||||
|
||||
BOOST_CHECK_EQUAL( input[3].get<UDQDefine>().keyword(), "WUWCT");
|
||||
BOOST_CHECK_EQUAL( input[4].get<UDQDefine>().keyword(), "FUOPR");
|
||||
BOOST_CHECK_EQUAL( input[6].get<UDQDefine>().keyword(), "FUOPRX");
|
||||
|
||||
BOOST_CHECK( udq.has_keyword("FUXXX") );
|
||||
}
|
||||
|
||||
@@ -1217,14 +1223,10 @@ UDQ
|
||||
const auto& udq = schedule.getUDQConfig(0);
|
||||
|
||||
|
||||
const auto& def_input = udq.input_definitions();
|
||||
const auto& input = udq.input();
|
||||
const auto& def = udq.definitions();
|
||||
BOOST_CHECK_EQUAL(def_input.size(), 3);
|
||||
for (std::size_t i = 0; i < def_input.size(); i++)
|
||||
BOOST_CHECK_EQUAL(def[i].input_string(), def_input[i].second.input_string());
|
||||
BOOST_CHECK_EQUAL(input.size(), 5);
|
||||
|
||||
BOOST_CHECK_EQUAL(def_input[0].first, 0);
|
||||
BOOST_CHECK_EQUAL(def_input[1].first, 3);
|
||||
BOOST_CHECK_EQUAL(def_input[2].first, 4);
|
||||
BOOST_CHECK( input[0].is<UDQDefine>());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user