basicMultiComponentMixture.C
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-2017 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 \*---------------------------------------------------------------------------*/
27 
29 
30 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34  defineTypeNameAndDebug(basicMultiComponentMixture, 0);
35 }
36 
37 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
38 
40 (
41  const dictionary& thermoDict,
42  const wordList& specieNames,
43  const fvMesh& mesh,
44  const word& phaseName
45 )
46 :
47  basicMixture(thermoDict, mesh, phaseName),
48  species_(specieNames),
49  active_(species_.size(), true),
50  Y_(species_.size())
51 {
52  tmp<volScalarField> tYdefault;
53 
54  forAll(species_, i)
55  {
56  IOobject header
57  (
58  IOobject::groupName(species_[i], phaseName),
59  mesh.time().timeName(),
60  mesh,
61  IOobject::NO_READ
62  );
63 
64  // Check if field exists and can be read
65  if (header.typeHeaderOk<volScalarField>(true))
66  {
67  DebugInfo
68  << "basicMultiComponentMixture: reading " << species_[i]
69  << endl;
70 
71  Y_.set
72  (
73  i,
74  new volScalarField
75  (
76  IOobject
77  (
78  IOobject::groupName(species_[i], phaseName),
79  mesh.time().timeName(),
80  mesh,
81  IOobject::MUST_READ,
82  IOobject::AUTO_WRITE
83  ),
84  mesh
85  )
86  );
87  }
88  else
89  {
90  // Read Ydefault if not already read
91  if (!tYdefault.valid())
92  {
93  word YdefaultName(IOobject::groupName("Ydefault", phaseName));
94 
95  IOobject timeIO
96  (
97  YdefaultName,
98  mesh.time().timeName(),
99  mesh,
100  IOobject::MUST_READ,
101  IOobject::NO_WRITE
102  );
103 
104  IOobject constantIO
105  (
106  YdefaultName,
107  mesh.time().constant(),
108  mesh,
109  IOobject::MUST_READ,
110  IOobject::NO_WRITE
111  );
112 
113  IOobject time0IO
114  (
115  YdefaultName,
116  Time::timeName(0),
117  mesh,
118  IOobject::MUST_READ,
119  IOobject::NO_WRITE
120  );
121 
122  if (timeIO.typeHeaderOk<volScalarField>(true))
123  {
124  tYdefault = new volScalarField(timeIO, mesh);
125  }
126  else if (constantIO.typeHeaderOk<volScalarField>(true))
127  {
128  tYdefault = new volScalarField(constantIO, mesh);
129  }
130  else
131  {
132  tYdefault = new volScalarField(time0IO, mesh);
133  }
134  }
135 
136  Y_.set
137  (
138  i,
139  new volScalarField
140  (
141  IOobject
142  (
143  IOobject::groupName(species_[i], phaseName),
144  mesh.time().timeName(),
145  mesh,
146  IOobject::NO_READ,
147  IOobject::AUTO_WRITE
148  ),
149  tYdefault()
150  )
151  );
152  }
153  }
154 
155  // Do not enforce constraint of sum of mass fractions to equal 1 here
156  // - not applicable to all models
157 }
158 
159 
160 // ************************************************************************* //
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:57
timeName
word timeName
Definition: getTimeIndex.H:3
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
basicMultiComponentMixture.H
thermoDict
const dictionary & thermoDict
Definition: EEqn.H:16
Foam::basicMultiComponentMixture::basicMultiComponentMixture
basicMultiComponentMixture(const dictionary &thermoDict, const wordList &specieNames, const fvMesh &mesh, const word &phaseName)
Construct from dictionary, species names, mesh and phase name.
Definition: basicMultiComponentMixture.C:40
DebugInfo
#define DebugInfo
Report an information message using Foam::Info.
Definition: messageStream.H:382
Foam::List< word >
Foam::tmp::valid
bool valid() const noexcept
Identical to good(), or bool operator.
Definition: tmp.H:292
Foam::basicMixture
Foam::basicMixture.
Definition: basicMixture.H:51
Foam::GeometricField< scalar, fvPatchField, volMesh >
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)