mixture.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::mixture
26 
27 Description
28 
29 SourceFiles
30  mixtureI.H
31  mixture.C
32  mixtureIO.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef mixture_H
37 #define mixture_H
38 
39 #include "error.H"
40 
41 #include "List.H"
42 #include "substance.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 /*---------------------------------------------------------------------------*\
50  Class mixture Declaration
51 \*---------------------------------------------------------------------------*/
52 
53 class mixture
54 :
55  public List<substance>
56 {
57  // Private Data
58 
59  word name_;
60 
61 
62 public:
63 
64  // Constructors
65 
66  //- Construct from Istream
67  mixture(Istream& is)
68  :
69  List<substance>(is),
70  name_(is)
71  {
72  scalar volTot = 0;
73 
74  for (label i = 0; i < size(); i++)
75  {
76  volTot += operator[](i).volFrac();
77  }
78 
79  if (volTot > 1.001 || volTot < 0.999)
80  {
82  << "Sum of volume fractions for Mixture " << name_
83  << " = " << volTot << endl
84  << "Should equal one."
85  << abort(FatalError);
86  }
87  }
88 
89 
90  // Member Functions
91 
92  // Access
93 
94  const word& name() const
95  {
96  return name_;
97  }
98 };
99 
100 
101 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
102 
103 } // End namespace Foam
104 
105 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
106 
107 #endif
108 
109 // ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:91
label size() const
Return the number of elements in the UList.
Definition: ListI.H:171
T & operator[](const label)
Return element of UList.
Definition: UListI.H:167
mixture(Istream &is)
Construct from Istream.
Definition: mixture.H:66
const word & name() const
Definition: mixture.H:93
A class for handling words, derived from string.
Definition: word.H:62
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:257
errorManip< error > abort(error &err)
Definition: errorManip.H:131
error FatalError