FreeFOAM The Cross-Platform CFD Toolkit
PDRFoamAutoRefine.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) 1991-2010 OpenCFD Ltd.
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  Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 
25 Application
26  PDRFoam
27 
28 Description
29  Solver for compressible premixed/partially-premixed combustion with
30  turbulence modelling.
31 
32  Combusting RANS code using the b-Xi two-equation model.
33  Xi may be obtained by either the solution of the Xi transport
34  equation or from an algebraic exression. Both approaches are
35  based on Gulder's flame speed correlation which has been shown
36  to be appropriate by comparison with the results from the
37  spectral model.
38 
39  Strain effects are incorporated directly into the Xi equation
40  but not in the algebraic approximation. Further work need to be
41  done on this issue, particularly regarding the enhanced removal rate
42  caused by flame compression. Analysis using results of the spectral
43  model will be required.
44 
45  For cases involving very lean Propane flames or other flames which are
46  very strain-sensitive, a transport equation for the laminar flame
47  speed is present. This equation is derived using heuristic arguments
48  involving the strain time scale and the strain-rate at extinction.
49  the transport velocity is the same as that for the Xi equation.
50 
51  For large flames e.g. explosions additional modelling for the flame
52  wrinkling due to surface instabilities may be applied.
53 
54  PDR (porosity/distributed resistance) modelling is included to handle
55  regions containing blockages which cannot be resolved by the mesh.
56 
57 \*---------------------------------------------------------------------------*/
58 
59 #include <finiteVolume/fvCFD.H>
66 #include <engine/ignition.H>
67 #include <OpenFOAM/Switch.H>
68 #include <finiteVolume/bound.H>
70 
71 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
72 
73 int main(int argc, char *argv[])
74 {
75  #include <OpenFOAM/setRootCase.H>
76 
77  #include <OpenFOAM/createTime.H>
81  #include "createFields.H"
84  #include <finiteVolume/CourantNo.H>
86 
87  scalar StCoNum = 0.0;
88 
89  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
90 
91  Info<< "\nStarting time loop\n" << endl;
92 
93  while (runTime.run())
94  {
97  #include <finiteVolume/CourantNo.H>
98 
99  #include "setDeltaT.H"
100 
101  // Indicators for refinement. Note: before runTime++
102  // only for postprocessing reasons.
103  tmp<volScalarField> tmagGradP = mag(fvc::grad(p));
104  volScalarField normalisedGradP
105  (
106  "normalisedGradP",
107  tmagGradP()/max(tmagGradP())
108  );
109  normalisedGradP.writeOpt() = IOobject::AUTO_WRITE;
110  tmagGradP.clear();
111 
112  runTime++;
113 
114  Info<< "\n\nTime = " << runTime.timeName() << endl;
115 
116 
117  bool meshChanged = false;
118  {
119  // Make the fluxes absolute
121 
122  // Test : disable refinement for some cells
123  PackedBoolList& protectedCell =
124  refCast<dynamicRefineFvMesh>(mesh).protectedCell();
125 
126  if (protectedCell.empty())
127  {
128  protectedCell.setSize(mesh.nCells());
129  protectedCell = 0;
130  }
131 
132  forAll(betav, cellI)
133  {
134  if (betav[cellI] < 0.99)
135  {
136  protectedCell[cellI] = 1;
137  }
138  }
139 
140  //volScalarField pIndicator("pIndicator",
141  // p*(fvc::laplacian(p))
142  // / (
143  // magSqr(fvc::grad(p))
144  // + dimensionedScalar
145  // (
146  // "smallish",
147  // sqr(p.dimensions()/dimLength),
148  // 1E-6
149  // )
150  // ));
151  //pIndicator.writeOpt() = IOobject::AUTO_WRITE;
152 
153  // Flux estimate for introduced faces.
154  volVectorField rhoU("rhoU", rho*U);
155 
156  // Do any mesh changes
157  meshChanged = mesh.update();
158 
159 // if (mesh.moving() || meshChanged)
160 // {
161 // #include "correctPhi.H"
162 // }
163 
164  // Make the fluxes relative to the mesh motion
166  }
167 
168 
169  #include "rhoEqn.H"
170  #include "UEqn.H"
171 
172  // --- PISO loop
173  for (int corr=1; corr<=nCorr; corr++)
174  {
175  #include "bEqn.H"
176  #include "ftEqn.H"
177  #include "huEqn.H"
178  #include "hEqn.H"
179 
180  if (!ign.ignited())
181  {
182  hu == h;
183  }
184 
185  #include "pEqn.H"
186  }
187 
188  turbulence->correct();
189 
190  runTime.write();
191 
192  Info<< "\nExecutionTime = "
193  << runTime.elapsedCpuTime()
194  << " s\n" << endl;
195  }
196 
197  Info<< "\n end\n";
198 
199  return 0;
200 }
201 
202 
203 // ************************ vim: set sw=4 sts=4 et: ************************ //