timeScales.H
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-2013 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 Info<< "Time scales min/max:" << endl;
27 
28 
29 {
30  // Cache old time scale field
31  tmp<volScalarField> trDeltaT
32  (
33  new volScalarField
34  (
35  IOobject
36  (
37  "rDeltaT0",
38  runTime.timeName(),
39  mesh,
40  IOobject::NO_READ,
41  IOobject::NO_WRITE,
42  false
43  ),
44  rDeltaT
45  )
46  );
47  const volScalarField& rDeltaT0 = trDeltaT();
48 
49 
50  // Flow time scale
51  // ~~~~~~~~~~~~~~~
52  {
53  rDeltaT =
55  (
56  mag(phi)*mesh.deltaCoeffs()/(maxCo*mesh.magSf())
57  )
58  /rho;
59 
60  rDeltaT.max(1.0/maxDeltaT);
61 
62  Info<< " Flow = "
63  << gMin(1/rDeltaT.internalField()) << ", "
64  << gMax(1/rDeltaT.internalField()) << endl;
65  }
66 
67 
68  // Temperature source time scale
69  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
70 
71  {
72  scalarField tau
73  (
74  runTime.deltaTValue()
75  *mag
76  (
77  parcels.hsTrans()/(mesh.V()*runTime.deltaT())
78  // + fvOptions(rho, hs)
79  + combustion->Sh()()
80  - fvc::div(phi, 0.5*magSqr(U), "div(phi,K)")()
81  )
82  /rho
83  );
84 
85  tau = alphaTemp*thermo.Cp()*T/(tau + ROOTVSMALL);
86 
87  Info<< " Temperature = " << min(maxDeltaT, gMin(tau)) << ", "
88  << min(maxDeltaT, gMax(tau)) << endl;
89 
90  rDeltaT.internalField() = max(rDeltaT.internalField(), 1/tau);
91  }
92 
93 
94  // Limit rate of change of time scale
95  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
96  // - reduce as much as required for flow, but limit source contributions
97  const dimensionedScalar deltaTRamp("deltaTRamp", dimless, 1/(1 + 0.2));
98  rDeltaT = max(rDeltaT, rDeltaT0*deltaTRamp);
99 
100 
101  // Limit the largest time scale
102  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
103  rDeltaT.max(1/maxDeltaT);
104 
105 
106  // Spatially smooth the time scale field
107  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
109 
110  Info<< " Overall = " << min(1/rDeltaT).value()
111  << ", " << max(1/rDeltaT).value() << nl << endl;
112 }
113 
114 
115 // ************************************************************************* //
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
scalar maxCo
dynamicFvMesh & mesh
tmp< GeometricField< Type, fvPatchField, volMesh > > surfaceSum(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Type gMax(const FieldField< Field, Type > &f)
scalar maxDeltaT
Info<< "Creating combustion model\n"<< endl;autoPtr< combustionModels::psiCombustionModel > combustion(combustionModels::psiCombustionModel::New(mesh))
U
Definition: pEqn.H:86
dimensioned< scalar > mag(const dimensioned< Type > &)
Type gMin(const FieldField< Field, Type > &f)
psiReactionThermo & thermo
Definition: createFields.H:32
rDeltaT max(1.0/maxDeltaT)
tmp< GeometricField< Type, fvPatchField, volMesh > > div(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcDiv.C:47
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:249
Scalar magSqr(const Scalar s)
Definition: Scalar.H:153
scalar rDeltaTSmoothingCoeff(pimple.dict().lookupOrDefault< scalar >("rDeltaTSmoothingCoeff", 1))
volScalarField scalarField(fieldObject, mesh)
Info<< "Time scales min/max:"<< endl;{tmp< volScalarField > trDeltaT(new volScalarField(IOobject("rDeltaT0", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE, false), rDeltaT))
surfaceScalarField & phi
const volScalarField & T
Definition: createFields.H:25
scalar alphaTemp(pimple.dict().lookupOrDefault("alphaTemp", 0.05))
volScalarField rDeltaT(IOobject("rDeltaT", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), mesh, dimensionedScalar("one", dimless/dimTime, 1), zeroGradientFvPatchScalarField::typeName)
void smooth(volScalarField &field, const scalar coeff)
Definition: fvcSmooth.C:35