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-------------------------------------------------------------------------------
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
26\*---------------------------------------------------------------------------*/
27
29
30// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
31
32namespace Foam
33{
35}
36
37// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
38
40(
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
55 {
56 IOobject header
57 (
58 IOobject::groupName(species_[i], phaseName),
59 mesh.time().timeName(),
60 mesh,
62 );
63
64 // Check if field exists and can be read
65 if (header.typeHeaderOk<volScalarField>(true))
66 {
68 << "basicMultiComponentMixture: reading " << species_[i]
69 << endl;
70
71 Y_.set
72 (
73 i,
75 (
77 (
78 IOobject::groupName(species_[i], phaseName),
79 mesh.time().timeName(),
80 mesh,
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,
102 );
103
104 IOobject constantIO
105 (
106 YdefaultName,
107 mesh.time().constant(),
108 mesh,
111 );
112
113 IOobject time0IO
114 (
115 YdefaultName,
117 mesh,
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,
140 (
142 (
143 IOobject::groupName(species_[i], phaseName),
144 mesh.time().timeName(),
145 mesh,
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// ************************************************************************* //
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
bool typeHeaderOk(const bool checkType=true, const bool search=true, const bool verbose=true)
Read header (uses typeFilePath to find file) and check its info.
static word groupName(StringType base, const word &group)
Create dot-delimited name.group string.
const word & constant() const
Return constant name.
Definition: TimePathsI.H:96
static word timeName(const scalar t, const int precision=precision_)
Definition: Time.C:780
virtual word timeName() const
Return current time name.
Definition: Time.C:790
Foam::basicMixture.
Definition: basicMixture.H:52
speciesTable species_
Table of specie names.
PtrList< volScalarField > Y_
Species mass fractions.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:290
A class for managing temporary objects.
Definition: tmp.H:65
bool valid() const noexcept
Identical to good(), or bool operator.
Definition: tmp.H:292
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
const dictionary & thermoDict
Definition: EEqn.H:16
dynamicFvMesh & mesh
#define DebugInfo
Report an information message using Foam::Info.
Namespace for OpenFOAM.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:82
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333