adjustTimeStepToChemistry.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2023 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 
27 #include "basicChemistryModel.H"
28 #include "solver.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 namespace functionObjects
36 {
38 
40  (
44  );
45 }
46 }
47 
48 
49 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50 
52 (
53  const word& name,
54  const Time& runTime,
55  const dictionary& dict
56 )
57 :
58  regionFunctionObject(name, runTime, dict),
59  phaseName_(word::null)
60 {
61  read(dict);
62 }
63 
64 
65 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
66 
68 {}
69 
70 
71 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
72 
74 (
75  const dictionary& dict
76 )
77 {
78  phaseName_ = dict.lookupOrDefault<word>("phase", word::null);
79 
80  return true;
81 }
82 
83 
85 {
86  if (!time_.controlDict().lookupOrDefault("adjustTimeStep", false))
87  {
88  return true;
89  }
90 
92  obr_.lookupObject<basicChemistryModel>
93  (
94  IOobject::groupName("chemistryProperties", phaseName_)
95  );
96 
97  const scalar deltaT = gMin(chemistry.deltaTChem());
98 
99  // The solver has not adjusted the time-step yet. When it does, if it is
100  // within the physical and specified limits it will increase it by a
101  // fixed factor. So, we clip it here to the chemical time-step divided by
102  // that factor. The solver will then increase it to the chemical time-step
103  // if it can.
104  const_cast<Time&>(time_).setDeltaTNoAdjust
105  (
106  min(deltaT/solver::deltaTFactor, time_.deltaTValue())
107  );
108 
109  return true;
110 }
111 
112 
114 {
115  return true;
116 }
117 
118 
119 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
static word groupName(Name name, const word &group)
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
Base class for chemistry models.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
Abstract base-class for Time/database functionObjects.
Adjusts the time step to match a chemistry model's stored chemical time step. This allows the solver ...
adjustTimeStepToChemistry(const word &name, const Time &runTime, const dictionary &dict)
Construct from components.
virtual bool execute()
Reset the timeStep from the Function1 of time.
virtual bool read(const dictionary &)
Read and reset the timeStep Function1.
Specialisation of Foam::functionObject for a region and providing a reference to the region Foam::obj...
static scalar deltaTFactor
deltaT increase factor
Definition: solver.H:103
A class for handling words, derived from string.
Definition: word.H:62
static const word null
An empty word.
Definition: word.H:77
defineTypeNameAndDebug(adjustTimeStepToCombustion, 0)
addToRunTimeSelectionTable(functionObject, adjustTimeStepToCombustion, dictionary)
Namespace for OpenFOAM.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
Type gMin(const FieldField< Field, Type > &f)
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
dictionary dict
basicChemistryModel & chemistry