Loading...
Searching...
No Matches
ActionX.hpp
/*
Copyright 2013 Statoil 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 ActionX_HPP_
#define ActionX_HPP_
#include <opm/input/eclipse/Schedule/Action/ActionAST.hpp>
#include <opm/input/eclipse/Schedule/Action/ActionResult.hpp>
#include <opm/input/eclipse/Schedule/Action/Condition.hpp>
#include <opm/input/eclipse/Deck/DeckKeyword.hpp>
#include <cstddef>
#include <ctime>
#include <string>
#include <unordered_set>
#include <utility>
#include <vector>
namespace Opm {
class WellMatcher;
class Actdims;
} // namespace Opm
namespace Opm::RestartIO {
struct RstAction;
} // namespace Opm::RestartIO
namespace Opm::Action {
class State;
} // namespace Opm::Action
namespace Opm::Action {
// The ActionX class internalizes the ACTIONX keyword. This keyword represents a
// small in-deck programming language for the SCHEDULE section. In the deck the
// ACTIONX keyword comes together with a 'ENDACTIO' kewyord and then a list of
// regular keywords in-between. The principle is then that ACTIONX represents
// a condition, and when that condition is satisfied the keywords are applied. In
// the example below the ACTIONX keyword defines a condition on well OPX having
// watercut above 0.75. When the condition is met the WELOPEN keyword is applied,
// shutting the well.
//
// ACTIONX
// 'NAME' /
// WWCT OPX > 0.50 /
// /
//
// WELOPEN
// 'OPX' OPEN /
// /
//
// ENDACTIO
class ActionX
{
public:
static bool valid_keyword(const std::string& keyword);
ActionX();
ActionX(const std::string& name,
std::size_t max_run,
double min_wait,
std::time_t start_time);
ActionX(const DeckRecord& record, std::time_t start_time);
explicit ActionX(const RestartIO::RstAction& rst_action);
ActionX(const std::string& name,
std::size_t max_run,
double min_wait,
std::time_t start_time,
std::vector<Condition>&& conditions,
const std::vector<std::string>& tokens);
static ActionX serializationTestObject();
void addKeyword(const DeckKeyword& kw);
bool ready(const State& state, std::time_t sim_time) const;
Result eval(const Context& context) const;
std::vector<std::string>
wellpi_wells(const WellMatcher& well_matcher,
const Result::MatchingEntities& matches) const;
void required_summary(std::unordered_set<std::string>& required_summary) const;
std::string name() const { return this->m_name; }
std::size_t max_run() const { return this->m_max_run; }
double min_wait() const { return this->m_min_wait; }
std::size_t id() const { return this->m_id; }
void update_id(std::size_t id);
std::time_t start_time() const { return this->m_start_time; }
auto begin() const { return this->keywords.begin(); }
auto end() const { return this->keywords.end(); }
const std::vector<Condition>& conditions() const
{
return this->m_conditions;
}
std::vector<std::string> keyword_strings() const;
bool operator==(const ActionX& data) const;
template<class Serializer>
void serializeOp(Serializer& serializer)
{
serializer(m_name);
serializer(m_max_run);
serializer(m_min_wait);
serializer(m_start_time);
serializer(m_id);
serializer(keywords);
serializer(condition);
serializer(m_conditions);
}
private:
std::string m_name{};
std::size_t m_max_run = 0;
double m_min_wait = 0.0;
std::time_t m_start_time;
AST condition{};
std::size_t m_id = 0;
std::vector<DeckKeyword> keywords{};
std::vector<Condition> m_conditions{};
};
std::pair<ActionX, std::vector<std::pair<std::string, std::string>>>
parseActionX(const DeckKeyword& kw, const Actdims& actimds, std::time_t start_time);
} // namespace Opm::Action
#endif // ActionX_HPP_
Opm::Actdims
Definition Actdims.hpp:30
Opm::Action::ActionX
Definition ActionX.hpp:72
Opm::Action::ActionX::keyword_strings
std::vector< std::string > keyword_strings() const
Textual representation of action block SCHEDULE keywords.
Definition ActionX.cpp:284
Opm::Action::ActionX::required_summary
void required_summary(std::unordered_set< std::string > &required_summary) const
Export all summary vectors needed to evaluate the conditions of the current ActionX object.
Definition ActionX.cpp:274
Opm::Action::ActionX::serializationTestObject
static ActionX serializationTestObject()
Create a serialisation test object.
Definition ActionX.cpp:184
Opm::Action::ActionX::serializeOp
void serializeOp(Serializer &serializer)
Convert between byte array and object representation.
Definition ActionX.hpp:283
Opm::Action::ActionX::eval
Result eval(const Context &context) const
Evaluate the action's conditions at current dynamic state.
Definition ActionX.cpp:230
Opm::Action::ActionX::update_id
void update_id(std::size_t id)
Assign distinguishing numeric ID of this action object.
Definition ActionX.cpp:279
Opm::Action::ActionX::begin
auto begin() const
Start of action block SCHEDULE keyword sequence.
Definition ActionX.hpp:252
Opm::Action::ActionX::operator==
bool operator==(const ActionX &data) const
Equality predicate.
Definition ActionX.cpp:315
Opm::Action::ActionX::id
std::size_t id() const
Retrieve distinguishing numeric ID of this action object.
Definition ActionX.hpp:236
Opm::Action::ActionX::addKeyword
void addKeyword(const DeckKeyword &kw)
Include SCHEDULE section keyword in block executed when action triggers.
Definition ActionX.cpp:207
Opm::Action::ActionX::wellpi_wells
std::vector< std::string > wellpi_wells(const WellMatcher &well_matcher, const Result::MatchingEntities &matches) const
Retrive list of well names used in action block WELPI keywords.
Definition ActionX.cpp:236
Opm::Action::ActionX::ready
bool ready(const State &state, std::time_t sim_time) const
Query whether or not the current ActionX object is ready to run.
Definition ActionX.cpp:212
Opm::Action::ActionX::max_run
std::size_t max_run() const
Retrieve maximum number of times this action can run/trigger.
Definition ActionX.hpp:229
Opm::Action::ActionX::min_wait
double min_wait() const
Retrieve minimum wait time, in seconds of simulated time, between action triggers.
Definition ActionX.hpp:233
Opm::Action::ActionX::name
std::string name() const
Retrieve name of action object.
Definition ActionX.hpp:226
Opm::Action::ActionX::conditions
const std::vector< Condition > & conditions() const
Intermediate representation of triggering conditions for restart file output purposes.
Definition ActionX.hpp:259
Opm::Action::ActionX::end
auto end() const
End of action block SCHEDULE keyword sequence.
Definition ActionX.hpp:255
Opm::Action::ActionX::valid_keyword
static bool valid_keyword(const std::string &keyword)
Keyword validity predicate.
Definition ActionX.cpp:97
Opm::Action::ActionX::ActionX
ActionX()
Default constructor.
Definition ActionX.cpp:132
Opm::Action::ActionX::start_time
std::time_t start_time() const
Retrieve point in time at which this action object is created.
Definition ActionX.hpp:249
Opm::Action::Context
Manager of summary vector values.
Definition ActionContext.hpp:42
Opm::Action::Result::MatchingEntities
Container of matching entities.
Definition ActionResult.hpp:174
Opm::Action::Result
Class Action::Result holds the boolean result of a ACTIONX condition like.
Definition ActionResult.hpp:69
Opm::Action::State
Management information about the current run's ACTION system, especially concerning the number of tim...
Definition State.hpp:51
Opm::DeckKeyword
Definition DeckKeyword.hpp:36
Opm::DeckRecord
Definition DeckRecord.hpp:32
Opm::Serializer
Class for (de-)serializing.
Definition Serializer.hpp:94
Opm
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
Opm::RestartIO::RstAction
Definition action.hpp:35