adjustTimeStepToNucleation.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) 2025 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 "fvModels.H"
28 #include "nucleation.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  fvMeshFunctionObject(name, runTime, dict),
59  modelName_(word::null),
60  maxCo_(NaN)
61 {
62  read(dict);
63 }
64 
65 
66 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
67 
69 {}
70 
71 
72 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
73 
75 (
76  const dictionary& dict
77 )
78 {
79  modelName_ = dict.lookupOrDefault<word>("model", word::null);
80  maxCo_ = dict.lookupOrDefault<scalar>("maxCo", 1);
81 
82  return true;
83 }
84 
85 
87 {
88  return true;
89 }
90 
91 
93 {
94  return true;
95 }
96 
97 
98 Foam::scalar
100 {
101  if (!time_.controlDict().lookupOrDefault("adjustTimeStep", false))
102  {
103  return vGreat;
104  }
105 
107 
108  if (modelName_ == word::null)
109  {
110  bool found = false;
111 
114  (
115  typedName("tau"),
116  mesh(),
117  dimensionedScalar(dimTime, vGreat)
118  );
119 
120  forAll(fvModels, fvModeli)
121  {
122  if (isA<fv::nucleation>(fvModels[fvModeli]))
123  {
124  found = true;
125 
126  const fv::nucleation& nucleationModel =
127  refCast<const fv::nucleation>(fvModels[fvModeli]);
128 
129  tTau = min(tTau, nucleationModel.tau());
130  }
131  }
132 
133  if (!found)
134  {
136  << "No nucleation models found"
137  << exit(FatalError);
138  }
139 
140  return gMin(tTau());
141  }
142  else
143  {
144  const fv::nucleation& nucleationModel =
145  refCast<const fv::nucleation>(fvModels[modelName_]);
146 
147  return gMin(nucleationModel.tau()());
148  }
149 }
150 
151 
152 // ************************************************************************* //
bool found
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:433
Macros for easy insertion into run-time selection tables.
static tmp< DimensionedField< Type, GeoMesh, PrimitiveField > > New(const word &name, const Mesh &mesh, const dimensionSet &, const PrimitiveField< Type > &)
Return a temporary field constructed from name, mesh,.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
static autoPtr< dictionary > New(Istream &)
Construct top-level dictionary on freestore from Istream.
Definition: dictionaryIO.C:103
Abstract base-class for Time/database functionObjects.
Controls the time-step to the minimum nucleation time scale. A specific nucleation model can be speci...
adjustTimeStepToNucleation(const word &name, const Time &runTime, const dictionary &dict)
Construct from components.
virtual scalar maxDeltaT() const
Return the minimum chemistry.deltaTChem()
virtual bool read(const dictionary &)
Read and reset the timeStep Function1.
Specialisation of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Finite volume models.
Definition: fvModels.H:65
Mix-in interface for nucleation models. Provides access to properties of the nucleation process,...
Definition: nucleation.H:53
virtual tmp< DimensionedField< scalar, volMesh > > tau() const =0
Return the nucleation time scale.
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:62
static const word null
An empty word.
Definition: word.H:77
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define WarningInFunction
Report a warning using Foam::Warning.
defineTypeNameAndDebug(adjustTimeStepToCombustion, 0)
addToRunTimeSelectionTable(functionObject, adjustTimeStepToCombustion, dictionary)
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
const dimensionSet dimTime
word typedName(Name name)
Return the name of the object within the given type.
Definition: typeInfo.H:181
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
error FatalError
Type gMin(const FieldField< Field, Type > &f)
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
dictionary dict