Loading...
Searching...
No Matches
Events.hpp
/*
Copyright 2015 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 SCHEDULE_EVENTS_HPP
#define SCHEDULE_EVENTS_HPP
#include <cstdint>
#include <string>
#include <unordered_map>
namespace Opm
{
namespace ScheduleEvents {
// These values are used as bitmask - 2^n structure is essential.
enum Events : std::uint64_t {
NEW_WELL = (UINT64_C(1) << 0),
WELL_WELSPECS_UPDATE = (UINT64_C(1) << 1),
// WELL_POLYMER_UPDATE = (UINT64_C(1) << 2),
NEW_GROUP = (UINT64_C(1) << 3),
PRODUCTION_UPDATE = (UINT64_C(1) << 4),
INJECTION_UPDATE = (UINT64_C(1) << 5),
//POLYMER_UPDATES = (UINT64_C(1) << 6),
WELL_STATUS_CHANGE = (UINT64_C(1) << 7),
COMPLETION_CHANGE = (UINT64_C(1) << 8),
GROUP_CHANGE = (UINT64_C(1) << 9),
GEO_MODIFIER = (UINT64_C(1) << 10),
TUNING_CHANGE = (UINT64_C(1) << 11),
VFPINJ_UPDATE = (UINT64_C(1) << 12),
VFPPROD_UPDATE = (UINT64_C(1) << 13),
GROUP_PRODUCTION_UPDATE = (UINT64_C(1) << 14),
GROUP_INJECTION_UPDATE = (UINT64_C(1) << 15),
WELL_PRODUCTIVITY_INDEX = (UINT64_C(1) << 16),
WELLGROUP_EFFICIENCY_UPDATE = (UINT64_C(1) << 17),
INJECTION_TYPE_CHANGED = (UINT64_C(1) << 18),
WELL_SWITCHED_INJECTOR_PRODUCER = (UINT64_C(1) << 19),
ACTIONX_WELL_EVENT = (UINT64_C(1) << 20),
REQUEST_OPEN_WELL = (UINT64_C(1) << 21),
REQUEST_SHUT_WELL = (UINT64_C(1) << 22),
};
} // namespace ScheduleEvents
class Events
{
public:
static Events serializationTestObject();
void addEvent(ScheduleEvents::Events event);
void clearEvent(std::uint64_t eventMask);
void reset();
void merge(const Events& events);
bool hasEvent(std::uint64_t eventMask) const;
bool operator==(const Events& data) const;
template<class Serializer>
void serializeOp(Serializer& serializer)
{
serializer(m_events);
}
private:
std::uint64_t m_events = 0;
};
class WellGroupEvents
{
public:
static WellGroupEvents serializationTestObject();
void addWell(const std::string& wname);
void addGroup(const std::string& gname);
void addEvent(const std::string& wgname, ScheduleEvents::Events event);
void clearEvent(const std::string& wgname, std::uint64_t eventMask);
void reset();
void merge(const WellGroupEvents& events);
bool has(const std::string& wgname) const;
bool hasEvent(const std::string& wgname, std::uint64_t eventMask) const;
const Events& at(const std::string& wgname) const;
bool operator==(const WellGroupEvents& data) const;
template<class Serializer>
void serializeOp(Serializer& serializer)
{
serializer(m_wellgroup_events);
}
private:
std::unordered_map<std::string, Events> m_wellgroup_events{};
};
} // namespace Opm
#endif // SCHEDULE_EVENTS_HPP
Opm::Events
Events tied to a time and applicable to the simulation or an individual well or group.
Definition Events.hpp:129
Opm::Events::clearEvent
void clearEvent(std::uint64_t eventMask)
Remove one or more events from collection.
Definition Events.cpp:43
Opm::Events::reset
void reset()
Remove all events from collection.
Definition Events.cpp:50
Opm::Events::merge
void merge(const Events &events)
Merge current event collection with other.
Definition Events.cpp:55
Opm::Events::operator==
bool operator==(const Events &data) const
Equality predicate.
Definition Events.cpp:65
Opm::Events::serializationTestObject
static Events serializationTestObject()
Create a serialisation test object.
Definition Events.cpp:31
Opm::Events::addEvent
void addEvent(ScheduleEvents::Events event)
Incorporate a new event into collection.
Definition Events.cpp:38
Opm::Events::hasEvent
bool hasEvent(std::uint64_t eventMask) const
Event existence predicate.
Definition Events.cpp:60
Opm::Events::serializeOp
void serializeOp(Serializer &serializer)
Convert between byte array and object representation.
Definition Events.hpp:178
Opm::Serializer
Class for (de-)serializing.
Definition Serializer.hpp:94
Opm::WellGroupEvents
Collection of events tied to a time and associated to specific, named wells or groups.
Definition Events.hpp:191
Opm::WellGroupEvents::merge
void merge(const WellGroupEvents &events)
Merge current event collection with other.
Definition Events.cpp:129
Opm::WellGroupEvents::addWell
void addWell(const std::string &wname)
Include a named well into the events collection.
Definition Events.cpp:80
Opm::WellGroupEvents::operator==
bool operator==(const WellGroupEvents &data) const
Equality predicate.
Definition Events.cpp:167
Opm::WellGroupEvents::hasEvent
bool hasEvent(const std::string &wgname, std::uint64_t eventMask) const
Query current collection for one or more specific events associated to a specific well or group.
Definition Events.cpp:144
Opm::WellGroupEvents::at
const Events & at(const std::string &wgname) const
Look up collection of events for named well or group.
Definition Events.cpp:155
Opm::WellGroupEvents::serializeOp
void serializeOp(Serializer &serializer)
Convert between byte array and object representation.
Definition Events.hpp:284
Opm::WellGroupEvents::addGroup
void addGroup(const std::string &gname)
Include a named group in the events collection.
Definition Events.cpp:88
Opm::WellGroupEvents::addEvent
void addEvent(const std::string &wgname, ScheduleEvents::Events event)
Add a single event for a named well or group.
Definition Events.cpp:96
Opm::WellGroupEvents::has
bool has(const std::string &wgname) const
Check if any events have ever been registered for a named well or group.
Definition Events.cpp:138
Opm::WellGroupEvents::reset
void reset()
Remove all events for all known wells and groups.
Definition Events.cpp:118
Opm::WellGroupEvents::clearEvent
void clearEvent(const std::string &wgname, std::uint64_t eventMask)
Remove one or more individual events from the collection tied to a single named well or group.
Definition Events.cpp:109
Opm::WellGroupEvents::serializationTestObject
static WellGroupEvents serializationTestObject()
Create a serialisation test object.
Definition Events.cpp:72
Opm
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30