StartWrapper.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014 by Andreas Lauser
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 OPM_PARSER_START_WRAPPER_HPP
20 #define OPM_PARSER_START_WRAPPER_HPP
21 
23 
24 #include <boost/date_time/gregorian/gregorian.hpp>
25 
26 #include <stdexcept>
27 
28 namespace Opm {
29  class StartWrapper {
30  public:
36  {
37  int day = keyword->getRecord(0)->getItem(0)->getInt(0);
38  std::string month = keyword->getRecord(0)->getItem(1)->getString(0);
39  int year = keyword->getRecord(0)->getItem(2)->getInt(0);
40 
41  int monthNum = 0;
42  if (month == "JAN")
43  monthNum = 1;
44  else if (month == "FEB")
45  monthNum = 2;
46  else if (month == "MAR")
47  monthNum = 3;
48  else if (month == "APR")
49  monthNum = 4;
50  else if (month == "MAY")
51  monthNum = 5;
52  else if (month == "JUN")
53  monthNum = 6;
54  else if (month == "JUL")
55  monthNum = 7;
56  else if (month == "AUG")
57  monthNum = 8;
58  else if (month == "SEP")
59  monthNum = 9;
60  else if (month == "OCT")
61  monthNum = 10;
62  else if (month == "NOV")
63  monthNum = 11;
64  else if (month == "DEC")
65  monthNum = 12;
66  else
67  throw std::runtime_error("Invalid month specified for START keyword");
68 
69  m_startDate = boost::gregorian::date(year, monthNum, day);
70  }
71 
75  const boost::gregorian::date &getStartDate() const
76  { return m_startDate; }
77 
78  private:
79  boost::gregorian::date m_startDate;
80  };
81 }
82 
83 #endif // OPM_PARSER_START_KEYWORD_HPP
84 
Definition: Deck.hpp:29
std::shared_ptr< const DeckKeyword > DeckKeywordConstPtr
Definition: DeckKeyword.hpp:71
Definition: StartWrapper.hpp:29
const double day
Definition: ConversionFactors.hpp:101
const double year
Definition: ConversionFactors.hpp:102
const boost::gregorian::date & getStartDate() const
Return calendar date at which the simulation starts.
Definition: StartWrapper.hpp:75
StartWrapper(Opm::DeckKeywordConstPtr keyword)
A wrapper class to provide convenient access to the data exposed by the 'START' keyword.
Definition: StartWrapper.hpp:35