UnitSystem.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 
20 #ifndef UNITSYSTEM_H
21 #define UNITSYSTEM_H
22 
23 #include <string>
24 #include <map>
25 #include <memory>
26 
28 
29 namespace Opm {
30 
31  class UnitSystem {
32  public:
33  enum UnitType {
37  };
38 
39  UnitSystem(UnitType unit);
40 
41  const std::string& getName() const;
42  UnitType getType() const;
43 
44  void addDimension(const std::string& dimension, double SIfactor, double SIoffset = 0.0);
45  void addDimension(std::shared_ptr<const Dimension> dimension);
46  std::shared_ptr<const Dimension> getNewDimension(const std::string& dimension);
47  std::shared_ptr<const Dimension> getDimension(const std::string& dimension) const;
48  bool hasDimension(const std::string& dimension) const;
49  bool equal(const UnitSystem& other) const;
50 
51  std::shared_ptr<const Dimension> parse(const std::string& dimension) const;
52 
53  static UnitSystem * newMETRIC();
54  static UnitSystem * newFIELD();
55  private:
56  std::shared_ptr<const Dimension> parseFactor(const std::string& dimension) const;
57 
58  std::string m_name;
59  UnitType m_unittype;
60  std::map<std::string , std::shared_ptr<const Dimension> > m_dimensions;
61  };
62 }
63 
64 
65 #endif
66 
void addDimension(const std::string &dimension, double SIfactor, double SIoffset=0.0)
UnitType
Definition: UnitSystem.hpp:33
Definition: UnitSystem.hpp:36
Definition: Deck.hpp:29
std::shared_ptr< const Dimension > parse(const std::string &dimension) const
std::shared_ptr< const Dimension > getNewDimension(const std::string &dimension)
static UnitSystem * newMETRIC()
bool equal(const UnitSystem &other) const
Definition: UnitSystem.hpp:31
std::shared_ptr< const Dimension > getDimension(const std::string &dimension) const
UnitType getType() const
const std::string & getName() const
static UnitSystem * newFIELD()
bool hasDimension(const std::string &dimension) const
UnitSystem(UnitType unit)
Definition: UnitSystem.hpp:34
Definition: UnitSystem.hpp:35