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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 {
30  volScalarField& rDeltaT = trDeltaT.ref();
31 
32  const dictionary& pimpleDict = pimple.dict();
33 
34  // Maximum flow Courant number
35  scalar maxCo(pimpleDict.get<scalar>("maxCo"));
36 
37  // Maximum time scale
38  scalar maxDeltaT(pimpleDict.getOrDefault<scalar>("maxDeltaT", GREAT));
39 
40  // Smoothing parameter (0-1) when smoothing iterations > 0
42  (
43  pimpleDict.getOrDefault<scalar>("rDeltaTSmoothingCoeff", 0.1)
44  );
45 
46  // Damping coefficient (1-0)
47  scalar rDeltaTDampingCoeff
48  (
49  pimpleDict.getOrDefault<scalar>("rDeltaTDampingCoeff", 0.2)
50  );
51 
52  // Maximum change in cell temperature per iteration
53  // (relative to previous value)
54  scalar alphaTemp(pimpleDict.getOrDefault("alphaTemp", 0.05));
55 
56 
57  Info<< "Time scales min/max:" << endl;
58 
59  // Cache old reciprocal time scale field
60  volScalarField rDeltaT0("rDeltaT0", rDeltaT);
61 
62  // Flow time scale
63  {
64  rDeltaT.ref() =
65  (
66  fvc::surfaceSum(mag(phi))()()
67  /((2*maxCo)*mesh.V()*rho())
68  );
69 
70  // Limit the largest time scale
71  rDeltaT.max(1/maxDeltaT);
72 
73  Info<< " Flow = "
74  << gMin(1/rDeltaT.primitiveField()) << ", "
75  << gMax(1/rDeltaT.primitiveField()) << endl;
76  }
77 
78  // Reaction source time scale
79  {
80  volScalarField::Internal rDeltaTT
81  (
82  mag
83  (
84  parcels.hsTrans()/(mesh.V()*runTime.deltaT())
85  + Qdot
86  )
87  /(
88  alphaTemp
89  *rho()
90  *thermo.Cp()()()
91  *T()
92  )
93  );
94 
95  Info<< " Temperature = "
96  << gMin(1/(rDeltaTT.field() + VSMALL)) << ", "
97  << gMax(1/(rDeltaTT.field() + VSMALL)) << endl;
98 
99  rDeltaT.ref() = max
100  (
101  rDeltaT(),
102  rDeltaTT
103  );
104  }
105 
106  // Update the boundary values of the reciprocal time-step
107  rDeltaT.correctBoundaryConditions();
108 
109  // Spatially smooth the time scale field
110  if (rDeltaTSmoothingCoeff < 1.0)
111  {
113  }
114 
115  // Limit rate of change of time scale
116  // - reduce as much as required
117  // - only increase at a fraction of old time scale
118  if
119  (
120  rDeltaTDampingCoeff < 1.0
121  && runTime.timeIndex() > runTime.startTimeIndex() + 1
122  )
123  {
124  rDeltaT = max
125  (
126  rDeltaT,
127  (scalar(1) - rDeltaTDampingCoeff)*rDeltaT0
128  );
129  }
130 
131  Info<< " Overall = "
132  << gMin(1/rDeltaT.primitiveField())
133  << ", " << gMax(1/rDeltaT.primitiveField()) << endl;
134 }
135 
136 
137 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::fvc::surfaceSum
tmp< GeometricField< Type, fvPatchField, volMesh > > surfaceSum(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcSurfaceIntegrate.C:135
rDeltaTSmoothingCoeff
scalar rDeltaTSmoothingCoeff(pimpleDict.getOrDefault< scalar >("rDeltaTSmoothingCoeff", 0.1))
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:369
rho
rho
Definition: readInitialConditions.H:88
maxCo
scalar maxCo(pimpleDict.get< scalar >("maxCo"))
pimpleDict
const dictionary & pimpleDict
Definition: setRDeltaT.H:32
pimple
pimpleControl & pimple
Definition: setRegionFluidFields.H:56
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
alphaTemp
scalar alphaTemp(pimpleDict.getOrDefault< scalar >("alphaTemp", 0.05))
phi
surfaceScalarField & phi
Definition: setRegionFluidFields.H:8
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:57
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
Qdot
scalar Qdot
Definition: solveChemistry.H:2
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
T
const volScalarField & T
Definition: createFieldRefs.H:2
maxDeltaT
scalar maxDeltaT(pimpleDict.getOrDefault< scalar >("maxDeltaT", GREAT))
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
trDeltaT
tmp< volScalarField > trDeltaT
Definition: createRDeltaT.H:3
rDeltaT0
volScalarField rDeltaT0("rDeltaT0", rDeltaT)
Foam::gMin
Type gMin(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:593
Foam::gMax
Type gMax(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:592
rDeltaTDampingCoeff
scalar rDeltaTDampingCoeff(pimpleDict.getOrDefault< scalar >("rDeltaTDampingCoeff", 1.0))
Foam::fvc::smooth
void smooth(volScalarField &field, const scalar coeff)
Definition: fvcSmooth.C:44