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  (coalParcels.hsTrans() + limestoneParcels.hsTrans())
85  /(mesh.V()*runTime.deltaT())
86  + Qdot
87  )
88  /(
89  alphaTemp
90  *rho()
91  *thermo.Cp()()()
92  *T()
93  )
94  );
95 
96  Info<< " Temperature = "
97  << gMin(1/(rDeltaTT.field() + VSMALL)) << ", "
98  << gMax(1/(rDeltaTT.field() + VSMALL)) << endl;
99 
100  rDeltaT.ref() = max
101  (
102  rDeltaT(),
103  rDeltaTT
104  );
105  }
106 
107  // Update tho boundary values of the reciprocal time-step
108  rDeltaT.correctBoundaryConditions();
109 
110  // Spatially smooth the time scale field
111  if (rDeltaTSmoothingCoeff < 1.0)
112  {
114  }
115 
116  // Limit rate of change of time scale
117  // - reduce as much as required
118  // - only increase at a fraction of old time scale
119  if
120  (
121  rDeltaTDampingCoeff < 1.0
122  && runTime.timeIndex() > runTime.startTimeIndex() + 1
123  )
124  {
125  rDeltaT = max
126  (
127  rDeltaT,
128  (scalar(1) - rDeltaTDampingCoeff)*rDeltaT0
129  );
130  }
131 
132  Info<< " Overall = "
133  << gMin(1/rDeltaT.primitiveField())
134  << ", " << gMax(1/rDeltaT.primitiveField()) << endl;
135 }
136 
137 
138 // ************************************************************************* //
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