Flow123d  jenkins-Flow123d-windows-release-multijob-285
substance.hh
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2007 Technical University of Liberec. All rights reserved.
4  *
5  * Please make a following refer to Flow123d on your project site if you use the program for any purpose,
6  * especially for academic research:
7  * Flow123d, Research Centre: Advanced Remedial Technologies, Technical University of Liberec, Czech Republic
8  *
9  * This program is free software; you can redistribute it and/or modify it under the terms
10  * of the GNU General Public License version 3 as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along with this program; if not,
17  * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 021110-1307, USA.
18  *
19  *
20  * $Id$
21  * $Revision$
22  * $LastChangedBy$
23  * $LastChangedDate$
24  *
25  * @file
26  * @brief Classes for storing substance data.
27  * @author Jan Stebel
28  */
29 
30 
31 #ifndef SUBSTANCE_HH_
32 #define SUBSTANCE_HH_
33 
34 
35 
36 
37 #include "input/accessors.hh"
38 
39 
40 /**
41  * Class Substance is a storage for data which are specific for a (chemical) substance.
42  * The purpose is to easily share them among equations (e.g. between transport and reactions).
43  */
44 class Substance {
45 
46 public:
47 
48  /// Default constructor.
49  Substance();
50 
51  /// Initialization from input tree.
52  Substance(const Input::Record &in_rec);
53 
54  /// Getter for substance name.
55  std::string name() const { return name_; }
56 
57  /// Getter for molar mass.
58  double molar_mass() const { return molar_mass_; }
59 
60 
61  /// Input type for a substance.
63 
64 protected:
65 
66  /// Name of a chemical substance.
67  std::string name_;
68 
69  /// Molar mass [kg/mol] of the substance.
70  double molar_mass_;
71 
72  friend class SubstanceList;
73 };
74 
75 
76 /**
77  * SubstanceList is an envelope around a vector of substances, which provides
78  * some additional functionality such as:
79  * - various ways of initialization (fron JSON input, reference, or list of names)
80  * - export of vector of names (required e.g. by some field classes)
81  */
83 
84 public:
85 
86  /// Read from input array.
87  void initialize(const Input::Array &in_array);
88 
89  /// Bind to existing list.
91 
92  /// Construct from a list of names.
94 
95  inline const Substance &operator[](unsigned int index) { return (*substances_)[index]; }
96 
97  inline const std::vector<std::string> &names() { return (*names_); }
98 
99  unsigned int size() const { return substances_->size(); }
100 
101 private:
102 
103  /// The actual list of substances.
104  boost::shared_ptr<std::vector<Substance> > substances_;
105 
106  /// Auxiliary list of substance names used in some classes.
107  boost::shared_ptr<std::vector<std::string> > names_;
108 };
109 
110 
111 
112 
113 
114 
115 
116 
117 #endif // SUBSTANCE_HH_
Accessor to input data conforming to declared Array.
Definition: accessors.hh:558
Substance()
Default constructor.
Definition: substance.cc:50
const std::vector< std::string > & names()
Definition: substance.hh:97
boost::shared_ptr< std::vector< Substance > > substances_
The actual list of substances.
Definition: substance.hh:104
void initialize(const Input::Array &in_array)
Read from input array.
Definition: substance.cc:68
const Substance & operator[](unsigned int index)
Definition: substance.hh:95
boost::shared_ptr< std::vector< std::string > > names_
Auxiliary list of substance names used in some classes.
Definition: substance.hh:107
unsigned int size() const
Definition: substance.hh:99
double molar_mass() const
Getter for molar mass.
Definition: substance.hh:58
std::string name_
Name of a chemical substance.
Definition: substance.hh:67
double molar_mass_
Molar mass [kg/mol] of the substance.
Definition: substance.hh:70
Accessor to the data with type Type::Record.
Definition: accessors.hh:327
Record type proxy class.
Definition: type_record.hh:169
static Input::Type::Record input_type
Input type for a substance.
Definition: substance.hh:62
std::string name() const
Getter for substance name.
Definition: substance.hh:55