setRDeltaT.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) 2013-2015 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 {
27  volScalarField& rDeltaT = trDeltaT();
28 
29  const dictionary& pimpleDict = pimple.dict();
30 
31  // Maximum flow Courant number
32  scalar maxCo(readScalar(pimpleDict.lookup("maxCo")));
33 
34  // Maximum time scale
35  scalar maxDeltaT(pimpleDict.lookupOrDefault<scalar>("maxDeltaT", GREAT));
36 
37  // Smoothing parameter (0-1) when smoothing iterations > 0
39  (
40  pimpleDict.lookupOrDefault<scalar>("rDeltaTSmoothingCoeff", 0.1)
41  );
42 
43  // Damping coefficient (1-0)
44  scalar rDeltaTDampingCoeff
45  (
46  pimpleDict.lookupOrDefault<scalar>("rDeltaTDampingCoeff", 1)
47  );
48 
49  // Maximum change in cell temperature per iteration
50  // (relative to previous value)
51  scalar alphaTemp(pimpleDict.lookupOrDefault("alphaTemp", 0.05));
52 
53 
54  Info<< "Time scales min/max:" << endl;
55 
56  // Cache old reciprocal time scale field
57  volScalarField rDeltaT0("rDeltaT0", rDeltaT);
58 
59  // Flow time scale
60  {
61  rDeltaT.dimensionedInternalField() =
62  (
64  /((2*maxCo)*mesh.V()*rho.dimensionedInternalField())
65  );
66 
67  // Limit the largest time scale
68  rDeltaT.max(1/maxDeltaT);
69 
70  Info<< " Flow = "
71  << gMin(1/rDeltaT.internalField()) << ", "
72  << gMax(1/rDeltaT.internalField()) << endl;
73  }
74 
75  // Reaction source time scale
76  if (alphaTemp < 1.0)
77  {
78  volScalarField::DimensionedInternalField rDeltaTT
79  (
80  mag(reaction->Sh())/(alphaTemp*rho*thermo.Cp()*T)
81  );
82 
83  Info<< " Temperature = "
84  << gMin(1/(rDeltaTT.field() + VSMALL)) << ", "
85  << gMax(1/(rDeltaTT.field() + VSMALL)) << endl;
86 
87  rDeltaT.dimensionedInternalField() = max
88  (
89  rDeltaT.dimensionedInternalField(),
90  rDeltaTT
91  );
92  }
93 
94  // Update tho boundary values of the reciprocal time-step
95  rDeltaT.correctBoundaryConditions();
96 
97  // Spatially smooth the time scale field
98  if (rDeltaTSmoothingCoeff < 1.0)
99  {
101  }
102 
103  // Limit rate of change of time scale
104  // - reduce as much as required
105  // - only increase at a fraction of old time scale
106  if
107  (
108  rDeltaTDampingCoeff < 1.0
109  && runTime.timeIndex() > runTime.startTimeIndex() + 1
110  )
111  {
112  rDeltaT = max
113  (
114  rDeltaT,
115  (scalar(1.0) - rDeltaTDampingCoeff)*rDeltaT0
116  );
117  }
118 
119  // Update tho boundary values of the reciprocal time-step
120  rDeltaT.correctBoundaryConditions();
121 
122  Info<< " Overall = "
123  << gMin(1/rDeltaT.internalField())
124  << ", " << gMax(1/rDeltaT.internalField()) << endl;
125 }
126 
127 
128 // ************************************************************************* //
Foam::fvc::surfaceSum
tmp< GeometricField< Type, fvPatchField, volMesh > > surfaceSum(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcSurfaceIntegrate.C:138
alphaTemp
scalar alphaTemp(pimpleDict.lookupOrDefault("alphaTemp", 0.05))
phi
surfaceScalarField & phi
Definition: setRegionFluidFields.H:8
dimensionedInternalField
rDeltaT dimensionedInternalField()
thermo
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::mag
dimensioned< scalar > mag(const dimensioned< Type > &)
rDeltaTSmoothingCoeff
scalar rDeltaTSmoothingCoeff(pimpleDict.lookupOrDefault< scalar >("rDeltaTSmoothingCoeff", 0.1))
pimpleDict
const dictionary & pimpleDict
Definition: setRDeltaT.H:29
Foam::Info
messageStream Info
maxCo
scalar maxCo(readScalar(pimpleDict.lookup("maxCo")))
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
maxDeltaT
scalar maxDeltaT(pimpleDict.lookupOrDefault< scalar >("maxDeltaT", GREAT))
reaction
Info<< "Creating reaction model\n"<< endl;autoPtr< combustionModels::psiCombustionModel > reaction(combustionModels::psiCombustionModel::New(mesh))
readScalar
#define readScalar
Definition: doubleScalar.C:38
rho
rho
Definition: pEqn.H:3
Foam::max
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
rDeltaTDampingCoeff
scalar rDeltaTDampingCoeff(pimpleDict.lookupOrDefault< scalar >("rDeltaTDampingCoeff", 1))
T
const volScalarField & T
Definition: createFields.H:25
trDeltaT
tmp< volScalarField > trDeltaT
Definition: createRDeltaT.H:3
pimple
const dictionary & pimple
Definition: readFluidMultiRegionPIMPLEControls.H:1
rDeltaT0
volScalarField rDeltaT0("rDeltaT0", rDeltaT)
Foam::gMin
Type gMin(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:563
Foam::gMax
Type gMax(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:562
Foam::fvc::smooth
void smooth(volScalarField &field, const scalar coeff)
Definition: fvcSmooth.C:35