twoPhaseMixture.C
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-2021 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 \*---------------------------------------------------------------------------*/
25 
26 #include "twoPhaseMixture.H"
27 #include "viscosityModel.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33  defineTypeNameAndDebug(twoPhaseMixture, 0);
34 }
35 
36 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * //
37 
39 Foam::twoPhaseMixture::readPhasePropertiesDict
40 (
41  const objectRegistry& obr
42 )
43 {
44  typeIOobject<IOdictionary> phasePropertiesIO
45  (
46  "phaseProperties",
47  obr.time().constant(),
48  obr,
51  true
52  );
53 
54  if (phasePropertiesIO.headerOk())
55  {
56  return phasePropertiesIO;
57  }
58  else
59  {
60  typeIOobject<IOdictionary> thermophysicalPropertiesIO
61  (
62  "thermophysicalProperties",
63  obr.time().constant(),
64  obr,
67  true
68  );
69 
70  if (thermophysicalPropertiesIO.headerOk())
71  {
72  IOdictionary phasePropertiesDict(thermophysicalPropertiesIO);
73  phasePropertiesDict.rename("phaseProperties");
74  return phasePropertiesDict;
75  }
76  else
77  {
78  typeIOobject<IOdictionary> transportPropertiesIO
79  (
80  "transportProperties",
81  obr.time().constant(),
82  obr,
85  true
86  );
87 
88  if (transportPropertiesIO.headerOk())
89  {
90  IOdictionary phasePropertiesDict(transportPropertiesIO);
91  phasePropertiesDict.rename("phaseProperties");
92 
93  const wordList phases(phasePropertiesDict.lookup("phases"));
94 
95  forAll(phases, i)
96  {
97  IOdictionary phaseDict
98  (
99  IOobject
100  (
102  (
103  physicalProperties::typeName,
104  phases[i]
105  ),
106  obr.time().constant(),
107  obr,
110  true
111  )
112  );
113 
114  phaseDict.merge(phasePropertiesDict.subDict(phases[i]));
115 
116  phaseDict.changeKeyword
117  (
118  "transportModel",
119  viscosityModel::typeName
120  );
121 
122  phaseDict.writeObject
123  (
127  true
128  );
129 
130  phasePropertiesDict.remove(phases[i]);
131  }
132 
133  phasePropertiesDict.writeObject
134  (
138  true
139  );
140 
142  << "Upgrading case by "
143  "converting transportProperties into phaseProperties, "
145  (
146  physicalProperties::typeName,
147  phases[0]
148  )
149  << " and "
151  (
152  physicalProperties::typeName,
153  phases[1]
154  )
155  << nl << endl;
156 
157  return phasePropertiesDict;
158  }
159  else
160  {
161  return phasePropertiesIO;
162  }
163  }
164  }
165 }
166 
167 
168 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
169 
171 :
172  IOdictionary(readPhasePropertiesDict(mesh)),
173 
174  phase1Name_(wordList(lookup("phases"))[0]),
175  phase2Name_(wordList(lookup("phases"))[1]),
176 
177  alpha1_
178  (
179  IOobject
180  (
181  IOobject::groupName("alpha", phase1Name_),
182  mesh.time().timeName(),
183  mesh,
184  IOobject::MUST_READ,
185  IOobject::AUTO_WRITE
186  ),
187  mesh
188  ),
189 
190  alpha2_
191  (
192  IOobject
193  (
194  IOobject::groupName("alpha", phase2Name_),
195  mesh.time().timeName(),
196  mesh
197  ),
198  1.0 - alpha1_
199  )
200 {}
201 
202 
203 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
204 
206 {
207  return regIOobject::read();
208 }
209 
210 
211 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
virtual bool read()
Read object.
Templated form of IOobject providing type information for file reading and header type checking...
Definition: IOobject.H:537
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
fvMesh & mesh
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:53
stressControl lookup("compactNormalStress") >> compactNormalStress
static word groupName(Name name, const word &group)
twoPhaseMixture(const fvMesh &mesh)
Construct from components.
word timeName
Definition: getTimeIndex.H:3
static const char nl
Definition: Ostream.H:260
defineTypeNameAndDebug(combustionModel, 0)
List< word > wordList
A List of words.
Definition: fileName.H:54
#define WarningInFunction
Report a warning using Foam::Warning.
static const versionNumber currentVersion
Current version number.
Definition: IOstream.H:203
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:95
phaseSystem::phaseModelList & phases
Definition: createFields.H:12
virtual bool read()=0
Read base phaseProperties dictionary.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:98
Namespace for OpenFOAM.