Loading...
Searching...
No Matches
HandlerContext.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 HANDLER_CONTEXT_HPP
#define HANDLER_CONTEXT_HPP
#include <opm/common/OpmLog/KeywordLocation.hpp>
#include <opm/input/eclipse/Schedule/Action/ActionResult.hpp>
#include <cstddef>
#include <cstdint>
#include <optional>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
namespace Opm::Action {
class WGNames;
}
namespace Opm {
class DeckKeyword;
class DeckRecord;
class ErrorGuard;
class ParseContext;
class Schedule;
class ScheduleBlock;
class ScheduleGrid;
class ScheduleState;
struct ScheduleStatic;
struct SimulatorUpdate;
enum class WellStatus : std::uint8_t;
class WelSegsSet;
}
namespace Opm {
class HandlerContext
{
public:
HandlerContext(Schedule& schedule,
const ScheduleBlock& block_,
const DeckKeyword& keyword_,
const ScheduleGrid& grid_,
const std::size_t currentStep_,
const Action::Result::MatchingEntities& matches_,
bool action_mode_,
const ParseContext& parseContext_,
ErrorGuard& errors_,
SimulatorUpdate* sim_update_,
const std::unordered_map<std::string, double>* target_wellpi_,
std::unordered_map<std::string, double>& wpimult_global_factor_,
WelSegsSet* welsegs_wells_,
std::set<std::string>* compsegs_wells_)
: block(block_)
, keyword(keyword_)
, currentStep(currentStep_)
, matches(matches_)
, action_mode(action_mode_)
, parseContext(parseContext_)
, errors(errors_)
, wpimult_global_factor(wpimult_global_factor_)
, grid(grid_)
, target_wellpi(target_wellpi_)
, welsegs_wells(welsegs_wells_)
, compsegs_wells(compsegs_wells_)
, sim_update(sim_update_)
, schedule_(schedule)
{}
void affected_well(const std::string& well_name);
void welpi_well(const std::string& well_name);
void record_tran_change();
void record_well_structure_change();
ScheduleState& state();
const ScheduleStatic& static_schedule() const;
void welsegs_handled(const std::string& well_name);
void compsegs_handled(const std::string& well_name);
void setExitCode(int code);
bool updateWellStatus(const std::string& well,
WellStatus status,
const std::optional<KeywordLocation>& location = {});
WellStatus getWellStatus(const std::string& well) const;
void addGroup(const std::string& groupName);
void addGroupToGroup(const std::string& parent_group,
const std::string& child_group);
void welspecsCreateNewWell(const DeckRecord& record,
const std::string& wellName,
const std::string& groupName);
void welspecsUpdateExistingWells(const DeckRecord& record,
const std::vector<std::string>& wellNames,
const std::string& groupName);
double getWellPI(const std::string& well_name) const;
double elapsed_seconds() const;
void invalidNamePattern(const std::string& namePattern) const;
const Action::WGNames& action_wgnames() const;
std::vector<std::string> groupNames(const std::string& pattern) const;
bool hasWell(const std::string& pattern) const;
bool hasGroup(const std::string& pattern) const;
std::vector<std::string>
wellNames(const std::string& pattern) const;
std::vector<std::string>
wellNames(const std::string& pattern, bool allowEmpty) const;
const ScheduleBlock& block;
const DeckKeyword& keyword;
const std::size_t currentStep;
const Action::Result::MatchingEntities& matches;
const bool action_mode;
const ParseContext& parseContext;
ErrorGuard& errors;
std::unordered_map<std::string, double>& wpimult_global_factor;
const ScheduleGrid& grid;
private:
const std::unordered_map<std::string, double>* target_wellpi{nullptr};
WelSegsSet* welsegs_wells{nullptr};
std::set<std::string>* compsegs_wells{nullptr};
SimulatorUpdate* sim_update{nullptr};
Schedule& schedule_;
};
} // end namespace Opm
#endif // HANDLER_CONTEXT_HPP
Opm::Action::Result::MatchingEntities
Container of matching entities.
Definition ActionResult.hpp:174
Opm::Action::WGNames
Definition WGNames.hpp:29
Opm::DeckKeyword
Definition DeckKeyword.hpp:36
Opm::DeckRecord
Definition DeckRecord.hpp:32
Opm::ErrorGuard
Definition ErrorGuard.hpp:30
Opm::HandlerContext::compsegs_handled
void compsegs_handled(const std::string &well_name)
Mark that the well occured in a COMPSEGS keyword.
Definition HandlerContext.cpp:79
Opm::HandlerContext::addGroupToGroup
void addGroupToGroup(const std::string &parent_group, const std::string &child_group)
Adds a group to a group.
Definition HandlerContext.cpp:194
Opm::HandlerContext::setExitCode
void setExitCode(int code)
Set exit code.
Definition HandlerContext.cpp:91
Opm::HandlerContext::welspecsCreateNewWell
void welspecsCreateNewWell(const DeckRecord &record, const std::string &wellName, const std::string &groupName)
Create a new Well from a WELSPECS record.
Definition HandlerContext.cpp:200
Opm::HandlerContext::state
ScheduleState & state()
Returns a reference to current state.
Definition HandlerContext.cpp:86
Opm::HandlerContext::addGroup
void addGroup(const std::string &groupName)
Adds a group to the schedule.
Definition HandlerContext.cpp:189
Opm::HandlerContext::record_well_structure_change
void record_well_structure_change()
Mark that well structure has changed.
Definition HandlerContext.cpp:65
Opm::HandlerContext::welpi_well
void welpi_well(const std::string &well_name)
Mark that a well is affected by WELPI.
Definition HandlerContext.cpp:51
Opm::HandlerContext::groupNames
std::vector< std::string > groupNames(const std::string &pattern) const
Obtain well group names from a pattern.
Definition HandlerContext.cpp:171
Opm::HandlerContext::welspecsUpdateExistingWells
void welspecsUpdateExistingWells(const DeckRecord &record, const std::vector< std::string > &wellNames, const std::string &groupName)
Update one or more existing wells from a WELSPECS record.
Definition HandlerContext.cpp:229
Opm::HandlerContext::hasWell
bool hasWell(const std::string &pattern) const
Whether or not any existing well matches a name pattern.
Definition HandlerContext.cpp:155
Opm::HandlerContext::getWellStatus
WellStatus getWellStatus(const std::string &well) const
Get status of a well.
Definition HandlerContext.cpp:104
Opm::HandlerContext::updateWellStatus
bool updateWellStatus(const std::string &well, WellStatus status, const std::optional< KeywordLocation > &location={})
Update status of a well.
Definition HandlerContext.cpp:96
Opm::HandlerContext::action_wgnames
const Action::WGNames & action_wgnames() const
Obtain action well group names.
Definition HandlerContext.cpp:150
Opm::HandlerContext::record_tran_change
void record_tran_change()
Mark that transmissibilities must be recalculated.
Definition HandlerContext.cpp:58
Opm::HandlerContext::getWellPI
double getWellPI(const std::string &well_name) const
Obtain PI for a well.
Definition HandlerContext.cpp:114
Opm::HandlerContext::hasGroup
bool hasGroup(const std::string &pattern) const
Whether or not any existing group matches a name pattern.
Definition HandlerContext.cpp:165
Opm::HandlerContext::invalidNamePattern
void invalidNamePattern(const std::string &namePattern) const
Adds parse error for an invalid name pattern.
Definition HandlerContext.cpp:133
Opm::HandlerContext::wellNames
std::vector< std::string > wellNames(const std::string &pattern) const
Obtain well names from a pattern.
Definition HandlerContext.cpp:183
Opm::HandlerContext::HandlerContext
HandlerContext(Schedule &schedule, const ScheduleBlock &block_, const DeckKeyword &keyword_, const ScheduleGrid &grid_, const std::size_t currentStep_, const Action::Result::MatchingEntities &matches_, bool action_mode_, const ParseContext &parseContext_, ErrorGuard &errors_, SimulatorUpdate *sim_update_, const std::unordered_map< std::string, double > *target_wellpi_, std::unordered_map< std::string, double > &wpimult_global_factor_, WelSegsSet *welsegs_wells_, std::set< std::string > *compsegs_wells_)
Definition HandlerContext.hpp:71
Opm::HandlerContext::elapsed_seconds
double elapsed_seconds() const
Returns elapsed time since simulation start in seconds.
Definition HandlerContext.cpp:128
Opm::HandlerContext::welsegs_handled
void welsegs_handled(const std::string &well_name)
Mark that the well occured in a WELSEGS keyword.
Definition HandlerContext.cpp:72
Opm::HandlerContext::static_schedule
const ScheduleStatic & static_schedule() const
Returns a const-ref to the static schedule.
Definition HandlerContext.cpp:109
Opm::HandlerContext::affected_well
void affected_well(const std::string &well_name)
Mark that a well has changed.
Definition HandlerContext.cpp:44
Opm::ParseContext
Definition ParseContext.hpp:84
Opm::ScheduleBlock
Definition ScheduleBlock.hpp:52
Opm::ScheduleGrid
Collection of intersected cells and associate properties for all simulation grids,...
Definition ScheduleGrid.hpp:50
Opm::ScheduleState
Definition ScheduleState.hpp:101
Opm::Schedule
Definition Schedule.hpp:101
Opm::WelSegsSet
Definition WelSegsSet.hpp:34
Opm
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
Opm::ScheduleStatic
Initial state of Schedule object created from information in SOLUTION section.
Definition ScheduleStatic.hpp:48
Opm::SimulatorUpdate
This struct is used to communicate back from the Schedule::applyAction() what needs to be updated in ...
Definition SimulatorUpdate.hpp:33