changed: put HandlerContext in separate compile unit
This commit is contained in:
parent
01c1fda1c9
commit
a7f709f9f3
@ -177,6 +177,7 @@ if(ENABLE_ECL_INPUT)
|
||||
src/opm/input/eclipse/Schedule/Group/GConSump.cpp
|
||||
src/opm/input/eclipse/Schedule/Group/GroupEconProductionLimits.cpp
|
||||
src/opm/input/eclipse/Schedule/Group/GTNode.cpp
|
||||
src/opm/input/eclipse/Schedule/HandlerContext.cpp
|
||||
src/opm/input/eclipse/Schedule/KeywordHandlers.cpp
|
||||
src/opm/input/eclipse/Schedule/MessageLimits.cpp
|
||||
src/opm/input/eclipse/Schedule/MSW/icd.cpp
|
||||
|
@ -43,8 +43,6 @@
|
||||
#include <opm/input/eclipse/Schedule/WriteRestartFileEvents.hpp>
|
||||
#include <opm/input/eclipse/Units/UnitSystem.hpp>
|
||||
|
||||
#include "src/opm/input/eclipse/Schedule/MSW/WelSegsSet.hpp"
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
namespace Action {
|
||||
@ -63,6 +61,7 @@ namespace Opm
|
||||
class GTNode;
|
||||
class GuideRateConfig;
|
||||
class GuideRateModel;
|
||||
class HandlerContext;
|
||||
enum class InputErrorAction;
|
||||
class ParseContext;
|
||||
class Python;
|
||||
@ -491,71 +490,6 @@ namespace Opm
|
||||
void dump_deck(std::ostream& os) const;
|
||||
|
||||
private:
|
||||
struct HandlerContext {
|
||||
|
||||
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;
|
||||
SimulatorUpdate* sim_update{nullptr};
|
||||
const std::unordered_map<std::string, double>* target_wellpi{nullptr};
|
||||
std::unordered_map<std::string, double>* wpimult_global_factor{nullptr};
|
||||
WelSegsSet* welsegs_wells{nullptr};
|
||||
std::set<std::string>* compsegs_wells{nullptr};
|
||||
const ScheduleGrid& grid;
|
||||
|
||||
/// \param welsegs_wells All wells with a WELSEGS entry for checks.
|
||||
/// \param compegs_wells All wells with a COMPSEGS entry for checks.
|
||||
HandlerContext(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_)
|
||||
, sim_update(sim_update_)
|
||||
, target_wellpi(target_wellpi_)
|
||||
, wpimult_global_factor(wpimult_global_factor_)
|
||||
, welsegs_wells(welsegs_wells_)
|
||||
, compsegs_wells(compsegs_wells_)
|
||||
, grid(grid_)
|
||||
{}
|
||||
|
||||
void affected_well(const std::string& well_name);
|
||||
void record_well_structure_change();
|
||||
|
||||
/// \brief Mark that the well occured in a WELSEGS keyword
|
||||
void welsegs_handled(const std::string& well_name)
|
||||
{
|
||||
if (welsegs_wells)
|
||||
welsegs_wells->insert(well_name, keyword.location());
|
||||
}
|
||||
|
||||
/// \brief Mark that the well occured in a COMPSEGS keyword
|
||||
void compsegs_handled(const std::string& well_name)
|
||||
{
|
||||
if (compsegs_wells)
|
||||
compsegs_wells->insert(well_name);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// Please update the member functions
|
||||
// - operator==(const Schedule&) const
|
||||
// - serializationTestObject()
|
||||
|
58
src/opm/input/eclipse/Schedule/HandlerContext.cpp
Normal file
58
src/opm/input/eclipse/Schedule/HandlerContext.cpp
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include "HandlerContext.hpp"
|
||||
|
||||
#include <opm/input/eclipse/Deck/DeckKeyword.hpp>
|
||||
|
||||
#include <opm/input/eclipse/Schedule/Action/SimulatorUpdate.hpp>
|
||||
|
||||
#include "MSW/WelSegsSet.hpp"
|
||||
|
||||
namespace Opm {
|
||||
|
||||
void HandlerContext::affected_well(const std::string& well_name)
|
||||
{
|
||||
if (sim_update) {
|
||||
sim_update->affected_wells.insert(well_name);
|
||||
}
|
||||
}
|
||||
|
||||
void HandlerContext::record_well_structure_change()
|
||||
{
|
||||
if (sim_update) {
|
||||
sim_update->well_structure_changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
void HandlerContext::welsegs_handled(const std::string& well_name)
|
||||
{
|
||||
if (welsegs_wells) {
|
||||
welsegs_wells->insert(well_name, keyword.location());
|
||||
}
|
||||
}
|
||||
|
||||
void HandlerContext::compsegs_handled(const std::string& well_name)
|
||||
{
|
||||
if (compsegs_wells) {
|
||||
compsegs_wells->insert(well_name);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
103
src/opm/input/eclipse/Schedule/HandlerContext.hpp
Normal file
103
src/opm/input/eclipse/Schedule/HandlerContext.hpp
Normal file
@ -0,0 +1,103 @@
|
||||
/*
|
||||
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 <set>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
class DeckKeyword;
|
||||
class ErrorGuard;
|
||||
class ParseContext;
|
||||
class ScheduleBlock;
|
||||
class ScheduleGrid;
|
||||
class ScheduleState;
|
||||
struct SimulatorUpdate;
|
||||
class WelSegsSet;
|
||||
|
||||
class HandlerContext
|
||||
{
|
||||
public:
|
||||
/// \param welsegs_wells All wells with a WELSEGS entry for checks.
|
||||
/// \param compegs_wells All wells with a COMPSEGS entry for checks.
|
||||
HandlerContext(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_)
|
||||
, sim_update(sim_update_)
|
||||
, target_wellpi(target_wellpi_)
|
||||
, wpimult_global_factor(wpimult_global_factor_)
|
||||
, welsegs_wells(welsegs_wells_)
|
||||
, compsegs_wells(compsegs_wells_)
|
||||
, grid(grid_)
|
||||
{}
|
||||
|
||||
//! \brief Mark that a well has changed.
|
||||
void affected_well(const std::string& well_name);
|
||||
|
||||
//! \brief Mark that well structure has changed.
|
||||
void record_well_structure_change();
|
||||
|
||||
/// \brief Mark that the well occured in a WELSEGS keyword.
|
||||
void welsegs_handled(const std::string& well_name);
|
||||
|
||||
/// \brief Mark that the well occured in a COMPSEGS keyword.
|
||||
void compsegs_handled(const std::string& well_name);
|
||||
|
||||
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;
|
||||
SimulatorUpdate* sim_update{nullptr};
|
||||
const std::unordered_map<std::string, double>* target_wellpi{nullptr};
|
||||
std::unordered_map<std::string, double>* wpimult_global_factor{nullptr};
|
||||
WelSegsSet* welsegs_wells{nullptr};
|
||||
std::set<std::string>* compsegs_wells{nullptr};
|
||||
const ScheduleGrid& grid;
|
||||
};
|
||||
|
||||
} // end namespace Opm
|
||||
|
||||
#endif // HANDLER_CONTEXT_HPP
|
@ -96,6 +96,7 @@
|
||||
#include <opm/input/eclipse/Parser/ParserKeywords/V.hpp>
|
||||
#include <opm/input/eclipse/Parser/ParserKeywords/W.hpp>
|
||||
|
||||
#include "HandlerContext.hpp"
|
||||
#include "Well/injection.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
@ -150,7 +151,7 @@ namespace {
|
||||
throw OpmInputError("AQUFETP is not supported as SCHEDULE keyword", handlerContext.keyword.location());
|
||||
}
|
||||
|
||||
void Schedule::handleAQUFLUX(Schedule::HandlerContext& handlerContext) {
|
||||
void Schedule::handleAQUFLUX(HandlerContext& handlerContext) {
|
||||
// auto& aqufluxs = this->snapshots.back().aqufluxs;
|
||||
auto& aqufluxs = this->snapshots.back().aqufluxs;
|
||||
for (const auto& record : handlerContext.keyword) {
|
||||
@ -159,7 +160,7 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
void Schedule::handleBCProp(Schedule::HandlerContext& handlerContext) {
|
||||
void Schedule::handleBCProp(HandlerContext& handlerContext) {
|
||||
auto& bcprop = this->snapshots.back().bcprop;
|
||||
for (const auto& record : handlerContext.keyword) {
|
||||
bcprop.updateBCProp(record);
|
||||
@ -2122,7 +2123,7 @@ Well{0} entered with 'FIELD' parent group:
|
||||
}
|
||||
}
|
||||
|
||||
void Schedule::handleWINJMULT(Opm::Schedule::HandlerContext& handlerContext) {
|
||||
void Schedule::handleWINJMULT(HandlerContext& handlerContext) {
|
||||
for (const auto& record : handlerContext.keyword) {
|
||||
const std::string& wellNamePattern = record.getItem("WELL_NAME").getTrimmedString(0);
|
||||
const auto well_names = wellNames(wellNamePattern);
|
||||
|
@ -91,9 +91,10 @@
|
||||
#include <opm/input/eclipse/Deck/DeckRecord.hpp>
|
||||
#include <opm/input/eclipse/Deck/DeckSection.hpp>
|
||||
|
||||
#include "Well/injection.hpp"
|
||||
#include "HandlerContext.hpp"
|
||||
#include "MSW/Compsegs.hpp"
|
||||
#include "MSW/WelSegsSet.hpp"
|
||||
#include "Well/injection.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <ctime>
|
||||
@ -2458,17 +2459,4 @@ std::ostream& operator<<(std::ostream& os, const Schedule& sched)
|
||||
return os;
|
||||
}
|
||||
|
||||
void Schedule::HandlerContext::affected_well(const std::string& well_name)
|
||||
{
|
||||
if (this->sim_update)
|
||||
this->sim_update->affected_wells.insert(well_name);
|
||||
}
|
||||
|
||||
void Schedule::HandlerContext::record_well_structure_change()
|
||||
{
|
||||
if (this->sim_update != nullptr) {
|
||||
this->sim_update->well_structure_changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user