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 -------------------------------------------------------------------------------
10 License
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 
26 Class
27  Foam::mixture
28 
29 Description
30 
31 SourceFiles
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 
48 namespace Foam
49 {
50 
51 /*---------------------------------------------------------------------------*\
52  Class mixture Declaration
53 \*---------------------------------------------------------------------------*/
54 
55 class mixture
56 :
57  public List<substance>
58 {
59  // Private data
60 
61  word name_;
62 
63 
64 public:
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
95 
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 // ************************************************************************* //
Foam::substance
Definition: substance.H:53
List.H
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::mixture::mixture
mixture(Istream &is)
Construct from Istream.
Definition: mixture.H:68
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
substance.H
error.H
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::mixture::name
const word & name() const
Definition: mixture.H:95
Foam::FatalError
error FatalError
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:144
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::mixture
Definition: mixture.H:54