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 <cstddef>
#include <optional>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
namespace Opm {
namespace Action { class WGNames; }
class DeckKeyword;
class DeckRecord;
class ErrorGuard;
class ParseContext;
class Schedule;
class ScheduleBlock;
class ScheduleGrid;
class ScheduleState;
struct ScheduleStatic;
struct SimulatorUpdate;
enum class WellStatus;
class WelSegsSet;
class HandlerContext
{
public:
HandlerContext(Schedule& schedule,
const ScheduleBlock& block_,
const DeckKeyword& keyword_,
const ScheduleGrid& grid_,
const std::size_t currentStep_,
const std::vector<std::string>& matching_wells_,
bool actionx_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_)
, matching_wells(matching_wells_)
, actionx_mode(actionx_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,
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;
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 std::vector<std::string>& matching_wells;
const bool actionx_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::DeckKeyword
Definition DeckKeyword.hpp:36
Opm::ErrorGuard
Definition ErrorGuard.hpp:29
Opm::HandlerContext
Definition HandlerContext.hpp:48
Opm::HandlerContext::compsegs_handled
void compsegs_handled(const std::string &well_name)
Mark that the well occured in a COMPSEGS keyword.
Definition HandlerContext.cpp:78
Opm::HandlerContext::addGroupToGroup
void addGroupToGroup(const std::string &parent_group, const std::string &child_group)
Adds a group to a group.
Definition HandlerContext.cpp:178
Opm::HandlerContext::HandlerContext
HandlerContext(Schedule &schedule, const ScheduleBlock &block_, const DeckKeyword &keyword_, const ScheduleGrid &grid_, const std::size_t currentStep_, const std::vector< std::string > &matching_wells_, bool actionx_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:52
Opm::HandlerContext::setExitCode
void setExitCode(int code)
Set exit code.
Definition HandlerContext.cpp:90
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:184
Opm::HandlerContext::state
ScheduleState & state()
Returns a reference to current state.
Definition HandlerContext.cpp:85
Opm::HandlerContext::addGroup
void addGroup(const std::string &groupName)
Adds a group to the schedule.
Definition HandlerContext.cpp:173
Opm::HandlerContext::record_well_structure_change
void record_well_structure_change()
Mark that well structure has changed.
Definition HandlerContext.cpp:64
Opm::HandlerContext::welpi_well
void welpi_well(const std::string &well_name)
Mark that a well is affected by WELPI.
Definition HandlerContext.cpp:50
Opm::HandlerContext::groupNames
std::vector< std::string > groupNames(const std::string &pattern) const
Obtain well group names from a pattern.
Definition HandlerContext.cpp:155
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:213
Opm::HandlerContext::getWellStatus
WellStatus getWellStatus(const std::string &well) const
Get status of a well.
Definition HandlerContext.cpp:103
Opm::HandlerContext::action_wgnames
const Action::WGNames & action_wgnames() const
Obtain action well group names.
Definition HandlerContext.cpp:149
Opm::HandlerContext::record_tran_change
void record_tran_change()
Mark that transmissibilities must be recalculated.
Definition HandlerContext.cpp:57
Opm::HandlerContext::getWellPI
double getWellPI(const std::string &well_name) const
Obtain PI for a well.
Definition HandlerContext.cpp:113
Opm::HandlerContext::invalidNamePattern
void invalidNamePattern(const std::string &namePattern) const
Adds parse error for an invalid name pattern.
Definition HandlerContext.cpp:132
Opm::HandlerContext::wellNames
std::vector< std::string > wellNames(const std::string &pattern) const
Obtain well names from a pattern.
Definition HandlerContext.cpp:167
Opm::HandlerContext::elapsed_seconds
double elapsed_seconds() const
Returns elapsed time since simulation start in seconds.
Definition HandlerContext.cpp:127
Opm::HandlerContext::welsegs_handled
void welsegs_handled(const std::string &well_name)
Mark that the well occured in a WELSEGS keyword.
Definition HandlerContext.cpp:71
Opm::HandlerContext::updateWellStatus
bool updateWellStatus(const std::string &well, WellStatus status, std::optional< KeywordLocation > location={})
Update status of a well.
Definition HandlerContext.cpp:95
Opm::HandlerContext::static_schedule
const ScheduleStatic & static_schedule() const
Returns a const-ref to the static schedule.
Definition HandlerContext.cpp:108
Opm::HandlerContext::affected_well
void affected_well(const std::string &well_name)
Mark that a well has changed.
Definition HandlerContext.cpp:43
Opm::ParseContext
Definition ParseContext.hpp:84
Opm::ScheduleBlock
Definition ScheduleBlock.hpp:52
Opm::ScheduleGrid
Definition ScheduleGrid.hpp:37
Opm::ScheduleState
Definition ScheduleState.hpp:94
Opm::Schedule
Definition Schedule.hpp:89
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
Definition ScheduleStatic.hpp:40
Opm::SimulatorUpdate
This struct is used to communicate back from the Schedule::applyAction() what needs to be updated in ...
Definition SimulatorUpdate.hpp:33