Move check for legitimate keywords to ActionX
This commit is contained in:
@@ -73,7 +73,7 @@ public:
|
||||
std::time_t start_time() const { return this->m_start_time; }
|
||||
std::vector<DeckKeyword>::const_iterator begin() const;
|
||||
std::vector<DeckKeyword>::const_iterator end() const;
|
||||
|
||||
static bool valid_keyword(const std::string& keyword);
|
||||
private:
|
||||
std::string m_name;
|
||||
size_t m_max_run = 0;
|
||||
|
||||
@@ -38,7 +38,6 @@ public:
|
||||
bool ready(std::time_t sim_time) const;
|
||||
ActionX& at(const std::string& name);
|
||||
std::vector<const ActionX *> pending(std::time_t sim_time) const;
|
||||
|
||||
private:
|
||||
std::map<std::string, ActionX> actions;
|
||||
};
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <unordered_set>
|
||||
|
||||
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Action/ActionX.hpp>
|
||||
|
||||
@@ -25,6 +27,11 @@ namespace Opm {
|
||||
|
||||
|
||||
|
||||
bool ActionX::valid_keyword(const std::string& keyword) {
|
||||
static std::unordered_set<std::string> actionx_whitelist = {"WELSPECS","WELOPEN"};
|
||||
return (actionx_whitelist.find(keyword) != actionx_whitelist.end());
|
||||
}
|
||||
|
||||
|
||||
ActionX::ActionX(const std::string& name, size_t max_run, double min_wait, std::time_t start_time) :
|
||||
m_name(name),
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include <vector>
|
||||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
#include <set>
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
@@ -66,8 +65,6 @@
|
||||
|
||||
namespace Opm {
|
||||
|
||||
static std::set<std::string> actionx_whitelist = {"WELSPECS","WELOPEN"};
|
||||
|
||||
|
||||
Schedule::Schedule( const Deck& deck,
|
||||
const EclipseGrid& grid,
|
||||
@@ -371,11 +368,12 @@ namespace Opm {
|
||||
if (action_keyword.name() == "ENDACTIO")
|
||||
break;
|
||||
|
||||
if (actionx_whitelist.find(action_keyword.name()) == actionx_whitelist.end()) {
|
||||
if (ActionX::valid_keyword(action_keyword.name()))
|
||||
action.addKeyword(action_keyword);
|
||||
else {
|
||||
std::string msg = "The keyword " + action_keyword.name() + " is not supported in a ACTIONX block.";
|
||||
parseContext.handleError( ParseContext::ACTIONX_ILLEGAL_KEYWORD, msg, errors);
|
||||
} else
|
||||
action.addKeyword(action_keyword);
|
||||
}
|
||||
}
|
||||
this->m_actions.add(action);
|
||||
} else
|
||||
@@ -2178,7 +2176,7 @@ namespace Opm {
|
||||
ErrorGuard errors;
|
||||
|
||||
for (const auto& keyword : action) {
|
||||
if (actionx_whitelist.find(keyword.name()) == actionx_whitelist.end())
|
||||
if (!ActionX::valid_keyword(keyword.name()))
|
||||
throw std::invalid_argument("The keyword: " + keyword.name() + " can not be handled in the ACTION body");
|
||||
|
||||
if (keyword.name() == "WELOPEN")
|
||||
|
||||
Reference in New Issue
Block a user