reactingTwoPhaseEulerFoam.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 | Copyright (C) 2011-2016 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 Application
25  reactingTwoPhaseEulerFoam
26 
27 Description
28  Solver for a system of 2 compressible fluid phases with a common pressure,
29  but otherwise separate properties. The type of phase model is run time
30  selectable and can optionally represent multiple species and in-phase
31  reactions. The phase system is also run time selectable and can optionally
32  represent different types of momentun, heat and mass transfer.
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #include "fvCFD.H"
37 #include "twoPhaseSystem.H"
38 #include "phaseCompressibleTurbulenceModel.H"
39 #include "pimpleControl.H"
40 #include "localEulerDdtScheme.H"
41 #include "fvcSmooth.H"
42 
43 namespace Foam
44 {
45  tmp<volScalarField> byDt(const volScalarField& vf)
46  {
47  if (fv::localEulerDdt::enabled(vf.mesh()))
48  {
49  return fv::localEulerDdt::localRDeltaT(vf.mesh())*vf;
50  }
51  else
52  {
53  return vf/vf.mesh().time().deltaT();
54  }
55  }
56 
57  tmp<surfaceScalarField> byDt(const surfaceScalarField& sf)
58  {
59  if (fv::localEulerDdt::enabled(sf.mesh()))
60  {
61  return fv::localEulerDdt::localRDeltaTf(sf.mesh())*sf;
62  }
63  else
64  {
65  return sf/sf.mesh().time().deltaT();
66  }
67  }
68 }
69 
70 
71 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
72 
73 int main(int argc, char *argv[])
74 {
75  #include "postProcess.H"
76 
77  #include "setRootCase.H"
78  #include "createTime.H"
79  #include "createMesh.H"
80  #include "createControl.H"
81  #include "createTimeControls.H"
82  #include "createFields.H"
83  #include "createFieldRefs.H"
84 
85  if (!LTS)
86  {
87  #include "CourantNo.H"
88  #include "setInitialDeltaT.H"
89  }
90 
91  Switch faceMomentum
92  (
93  pimple.dict().lookupOrDefault<Switch>("faceMomentum", false)
94  );
95 
96  Switch implicitPhasePressure
97  (
98  mesh.solverDict(alpha1.name()).lookupOrDefault<Switch>
99  (
100  "implicitPhasePressure", false
101  )
102  );
103 
104  #include "pUf/createRDeltaTf.H"
105  #include "pUf/createDDtU.H"
106 
107  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
108 
109  Info<< "\nStarting time loop\n" << endl;
110 
111  while (runTime.run())
112  {
113  #include "readTimeControls.H"
114 
115  int nEnergyCorrectors
116  (
117  pimple.dict().lookupOrDefault<int>("nEnergyCorrectors", 1)
118  );
119 
120  if (LTS)
121  {
122  #include "setRDeltaT.H"
123  if (faceMomentum)
124  {
125  #include "setRDeltaTf.H"
126  }
127  }
128  else
129  {
130  #include "CourantNos.H"
131  #include "setDeltaT.H"
132  }
133 
134  runTime++;
135  Info<< "Time = " << runTime.timeName() << nl << endl;
136 
137  // --- Pressure-velocity PIMPLE corrector loop
138  while (pimple.loop())
139  {
140  fluid.solve();
141  fluid.correct();
142 
143  #include "YEqns.H"
144 
145  if (faceMomentum)
146  {
147  #include "pUf/UEqns.H"
148  #include "EEqns.H"
149  #include "pUf/pEqn.H"
150  #include "pUf/DDtU.H"
151  }
152  else
153  {
154  #include "pU/UEqns.H"
155  #include "EEqns.H"
156  #include "pU/pEqn.H"
157  }
158 
160 
161  if (pimple.turbCorr())
162  {
164  }
165  }
166 
167  runTime.write();
168 
169  Info<< "ExecutionTime = "
170  << runTime.elapsedCpuTime()
171  << " s\n\n" << endl;
172  }
173 
174  Info<< "End\n" << endl;
175 
176  return 0;
177 }
178 
179 
180 // ************************************************************************* //
virtual void correctTurbulence()
Correct the turbulence.
const word & name() const
Return name.
Definition: IOobject.H:291
static const surfaceScalarField & localRDeltaTf(const fvMesh &mesh)
Return the reciprocal of the local face time-step.
Definition: localEulerDdt.C:58
multiphaseSystem & fluid
Definition: createFields.H:11
const dictionary & pimple
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
Read the control parameters used by setDeltaT.
const dictionary & solverDict(const word &name) const
Return the solver controls dictionary for the given field.
Definition: solution.C:342
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
virtual void correctKinematics()
Correct the kinematics.
dynamicFvMesh & mesh
static bool enabled(const fvMesh &mesh)
Return true if LTS is enabled.
Definition: localEulerDdt.C:37
static const volScalarField & localRDeltaT(const fvMesh &mesh)
Return the reciprocal of the local time-step.
Definition: localEulerDdt.C:46
void solve()
Solve for the mixture phase-fractions.
static const char nl
Definition: Ostream.H:262
bool LTS
Definition: createRDeltaT.H:1
const Mesh & mesh() const
Return mesh.
volScalarField & alpha1
void correct()
Dummy correct.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
messageStream Info
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
Execute application functionObjects to post-process existing results.
Provides functions smooth spread and sweep which use the FaceCellWave algorithm to smooth and redistr...
Read the control parameters used by setDeltaT.
Namespace for OpenFOAM.