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