Schedule.hpp
Go to the documentation of this file.
1 /*
2  Copyright 2013 Statoil ASA.
3 
4  This file is part of the Open Porous Media project (OPM).
5 
6  OPM is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  OPM is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with OPM. If not, see <http://www.gnu.org/licenses/>.
18 */
19 #ifndef SCHEDULE_HPP
20 #define SCHEDULE_HPP
21 
36 
37 #include <memory>
38 #include <boost/date_time/posix_time/posix_time.hpp>
39 
40 #include <map>
41 
42 namespace Opm
43 {
44 
45  const boost::gregorian::date defaultStartDate( 1983 , boost::gregorian::Jan , 1);
46 
47  class Schedule {
48  public:
49  Schedule(const ParseMode& parseMode , std::shared_ptr<const EclipseGrid> grid , DeckConstPtr deck, IOConfigPtr ioConfig);
50  boost::posix_time::ptime getStartTime() const
51  { return m_timeMap->getStartTime(/*timeStepIdx=*/0); }
53 
54  size_t numWells() const;
55  size_t numWells(size_t timestep) const;
56  size_t getMaxNumCompletionsForWells(size_t timestep) const;
57  bool hasWell(const std::string& wellName) const;
58  WellPtr getWell(const std::string& wellName) const;
59  std::vector<WellPtr> getOpenWells(size_t timeStep) const;
60  std::vector<WellConstPtr> getWells() const;
61  std::vector<WellConstPtr> getWells(size_t timeStep) const;
62  std::vector<WellPtr> getWells(const std::string& wellNamePattern) const;
64 
65  GroupTreePtr getGroupTree(size_t t) const;
66  size_t numGroups() const;
67  bool hasGroup(const std::string& groupName) const;
68  GroupPtr getGroup(const std::string& groupName) const;
69  TuningPtr getTuning() const;
70 
71  bool initOnly() const;
72  const Events& getEvents() const;
74 
75 
76 
77 
78  private:
79  TimeMapPtr m_timeMap;
80  OrderedMap<WellPtr> m_wells;
81  std::shared_ptr<const EclipseGrid> m_grid;
82  std::map<std::string , GroupPtr> m_groups;
83  std::shared_ptr<DynamicState<GroupTreePtr> > m_rootGroupTree;
84  std::shared_ptr<DynamicState<OilVaporizationPropertiesPtr> > m_oilvaporizationproperties;
85  Events m_events;
86  TuningPtr m_tuning;
87  bool nosim;
88 
89 
90  void updateWellStatus(std::shared_ptr<Well> well, size_t reportStep , WellCommon::StatusEnum status);
91  void addWellToGroup( GroupPtr newGroup , WellPtr well , size_t timeStep);
92  void initFromDeck(const ParseMode& parseMode , DeckConstPtr deck, IOConfigPtr ioConfig);
93  void initializeNOSIM(DeckConstPtr deck);
94  void createTimeMap(DeckConstPtr deck);
95  void initRootGroupTreeNode(TimeMapConstPtr timeMap);
96  void initOilVaporization(TimeMapConstPtr timeMap);
97  void iterateScheduleSection(const ParseMode& parseMode , std::shared_ptr<const SCHEDULESection> section, IOConfigPtr ioConfig);
98  bool handleGroupFromWELSPECS(const std::string& groupName, GroupTreePtr newTree) const;
99  void addGroup(const std::string& groupName , size_t timeStep);
100  void addWell(const std::string& wellName, DeckRecordConstPtr record, size_t timeStep, WellCompletion::CompletionOrderEnum wellCompletionOrder);
101  void handleCOMPORD(const ParseMode& parseMode, std::shared_ptr<const DeckKeyword> compordKeyword, size_t currentStep);
102  void checkWELSPECSConsistency(WellConstPtr well, DeckKeywordConstPtr keyword, size_t recordIdx) const;
103  void handleWELSPECS(std::shared_ptr<const SCHEDULESection> section, DeckKeywordConstPtr keyword, size_t currentStep);
104  void handleWCONProducer(DeckKeywordConstPtr keyword, size_t currentStep, bool isPredictionMode);
105  void handleWCONHIST(DeckKeywordConstPtr keyword, size_t currentStep);
106  void handleWCONPROD(DeckKeywordConstPtr keyword, size_t currentStep);
107  void handleWGRUPCON(DeckKeywordConstPtr keyword, size_t currentStep);
108  void handleCOMPDAT(DeckKeywordConstPtr keyword, size_t currentStep);
109  void handleWCONINJE(std::shared_ptr<const SCHEDULESection> section, DeckKeywordConstPtr keyword, size_t currentStep);
110  void handleWPOLYMER(DeckKeywordConstPtr keyword, size_t currentStep);
111  void handleWSOLVENT(DeckKeywordConstPtr keyword, size_t currentStep);
112  void handleWCONINJH(std::shared_ptr<const SCHEDULESection> section, DeckKeywordConstPtr keyword, size_t currentStep);
113  void handleWELOPEN(DeckKeywordConstPtr keyword, size_t currentStep, bool hascomplump);
114  void handleWELTARG(std::shared_ptr<const SCHEDULESection> section, DeckKeywordConstPtr keyword, size_t currentStep);
115  void handleGCONINJE(std::shared_ptr<const SCHEDULESection> section, DeckKeywordConstPtr keyword, size_t currentStep);
116  void handleGCONPROD(DeckKeywordConstPtr keyword, size_t currentStep);
117  void handleTUNING(DeckKeywordConstPtr keyword, size_t currentStep);
118  void handleNOSIM();
119  void handleRPTRST(DeckKeywordConstPtr keyword, size_t currentStep, IOConfigPtr ioConfig);
120  void handleRPTSCHED(DeckKeywordConstPtr keyword, size_t currentStep, IOConfigPtr ioConfig);
121  void handleDATES(DeckKeywordConstPtr keyword);
122  void handleTSTEP(DeckKeywordConstPtr keyword);
123  void handleGRUPTREE(DeckKeywordConstPtr keyword, size_t currentStep);
124  void handleWRFT(DeckKeywordConstPtr keyword, size_t currentStep);
125  void handleWRFTPLT(DeckKeywordConstPtr keyword, size_t currentStep);
126  void handleWPIMULT(DeckKeywordConstPtr keyword, size_t currentStep);
127  void handleDRSDT(DeckKeywordConstPtr keyword, size_t currentStep);
128  void handleDRVDT(DeckKeywordConstPtr keyword, size_t currentStep);
129  void handleVAPPARS(DeckKeywordConstPtr keyword, size_t currentStep);
130 
131  void checkUnhandledKeywords(std::shared_ptr<const SCHEDULESection> section) const;
132 
133  static double convertInjectionRateToSI(double rawRate, WellInjector::TypeEnum wellType, const Opm::UnitSystem &unitSystem);
134  static double convertInjectionRateToSI(double rawRate, Phase::PhaseEnum wellPhase, const Opm::UnitSystem &unitSystem);
135  static bool convertEclipseStringToBool(const std::string& eclipseString);
136 
137 
138  void setOilVaporizationProperties(const OilVaporizationPropertiesPtr vapor, size_t timestep);
139 
140  };
141  typedef std::shared_ptr<Schedule> SchedulePtr;
142  typedef std::shared_ptr<const Schedule> ScheduleConstPtr;
143 }
144 
145 #endif
OilVaporizationPropertiesConstPtr getOilVaporizationProperties(size_t timestep)
std::shared_ptr< GroupTree > GroupTreePtr
Definition: GroupTree.hpp:56
Definition: Events.hpp:85
std::shared_ptr< const TimeMap > TimeMapConstPtr
Definition: TimeMap.hpp:77
StatusEnum
Definition: ScheduleEnums.hpp:29
bool hasGroup(const std::string &groupName) const
Definition: Deck.hpp:29
Schedule(const ParseMode &parseMode, std::shared_ptr< const EclipseGrid > grid, DeckConstPtr deck, IOConfigPtr ioConfig)
GroupTreePtr getGroupTree(size_t t) const
TypeEnum
Definition: ScheduleEnums.hpp:88
std::shared_ptr< const DeckKeyword > DeckKeywordConstPtr
Definition: DeckKeyword.hpp:71
size_t numWells() const
bool initOnly() const
std::shared_ptr< Group > GroupPtr
Definition: Group.hpp:111
std::shared_ptr< Well > WellPtr
Definition: Well.hpp:148
std::shared_ptr< const Deck > DeckConstPtr
Definition: Deck.hpp:86
std::vector< WellConstPtr > getWells() const
std::vector< WellPtr > getOpenWells(size_t timeStep) const
Definition: UnitSystem.hpp:31
const Events & getEvents() const
std::shared_ptr< const OilVaporizationProperties > OilVaporizationPropertiesConstPtr
Definition: OilVaporizationProperties.hpp:41
std::shared_ptr< const Schedule > ScheduleConstPtr
Definition: Schedule.hpp:142
boost::posix_time::ptime getStartTime() const
Definition: Schedule.hpp:50
std::shared_ptr< Schedule > SchedulePtr
Definition: Schedule.hpp:141
PhaseEnum
Definition: ScheduleEnums.hpp:75
Definition: ParseMode.hpp:78
bool hasOilVaporizationProperties()
bool hasWell(const std::string &wellName) const
Definition: Schedule.hpp:47
size_t getMaxNumCompletionsForWells(size_t timestep) const
CompletionOrderEnum
Definition: ScheduleEnums.hpp:56
std::shared_ptr< Tuning > TuningPtr
Definition: Tuning.hpp:179
TuningPtr getTuning() const
GroupPtr getGroup(const std::string &groupName) const
TimeMapConstPtr getTimeMap() const
std::shared_ptr< const DeckRecord > DeckRecordConstPtr
Definition: DeckRecord.hpp:54
size_t numGroups() const
WellPtr getWell(const std::string &wellName) const
const boost::gregorian::date defaultStartDate(1983, boost::gregorian::Jan, 1)
std::shared_ptr< IOConfig > IOConfigPtr
Definition: IOConfig.hpp:203
std::shared_ptr< OilVaporizationProperties > OilVaporizationPropertiesPtr
Definition: OilVaporizationProperties.hpp:40
std::shared_ptr< const Well > WellConstPtr
Definition: Well.hpp:149
std::shared_ptr< TimeMap > TimeMapPtr
Definition: TimeMap.hpp:76