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-2026 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 "Time.H"
29 #include "volFields.H"
30 #include "nucleation.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 namespace functionObjects
38 {
40 
42  (
46  );
47 }
48 }
49 
50 
51 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
52 
54 (
55  const word& name,
56  const Time& runTime,
57  const dictionary& dict
58 )
59 :
60  fvMeshFunctionObject(name, runTime, dict),
61  modelName_(word::null),
62  maxCo_(NaN)
63 {
64  read(dict);
65 }
66 
67 
68 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
69 
71 {}
72 
73 
74 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
75 
77 (
78  const dictionary& dict
79 )
80 {
81  modelName_ = dict.lookupOrDefault<word>("model", word::null);
82  maxCo_ = dict.lookupOrDefault<scalar>("maxCo", 1);
83 
84  return true;
85 }
86 
87 
89 {
90  return true;
91 }
92 
93 
95 {
96  return true;
97 }
98 
99 
100 Foam::scalar
102 {
103  if (!time_.controlDict().lookupOrDefault("adjustTimeStep", false))
104  {
105  return vGreat;
106  }
107 
109 
110  if (modelName_ == word::null)
111  {
112  bool found = false;
113 
116  (
117  typedName("tau"),
118  mesh(),
119  dimensionedScalar(dimTime, vGreat)
120  );
121 
122  forAll(fvModels, fvModeli)
123  {
124  if (isA<fv::nucleation>(fvModels[fvModeli]))
125  {
126  found = true;
127 
128  const fv::nucleation& nucleationModel =
129  refCast<const fv::nucleation>(fvModels[fvModeli]);
130 
131  tTau = min(tTau, nucleationModel.tau());
132  }
133  }
134 
135  if (!found)
136  {
138  << "No nucleation models found"
139  << exit(FatalError);
140  }
141 
142  return gMin(tTau());
143  }
144  else
145  {
146  const fv::nucleation& nucleationModel =
147  refCast<const fv::nucleation>(fvModels[modelName_]);
148 
149  return gMin(nucleationModel.tau()());
150  }
151 }
152 
153 
154 // ************************************************************************* //
bool found
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
Macros for easy insertion into run-time selection tables.
static fvModels & New(const word &name, const fvMesh &mesh)
Construct and return the named DemandDrivenMeshObject.
static tmp< DimensionedField< Type, GeoMesh, PrimitiveField > > New(const word &name, const GeoMesh &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
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:69
Mix-in interface for nucleation models. Provides access to properties of the nucleation process,...
Definition: nucleation.H:53
virtual tmp< DimensionedField< scalar, fvMesh > > 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:63
static const word null
An empty word.
Definition: word.H:78
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define WarningInFunction
Report a warning using Foam::Warning.
defineTypeNameAndDebug(fvMeshFunctionObject, 0)
addToRunTimeSelectionTable(functionObject, fvModel, dictionary)
Namespace for OpenFOAM.
Type gMin(const UList< Type > &f, const label comm)
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
const dimensionSet & dimTime
Definition: dimensions.C:142
dimensioned< Type > min(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
word typedName(Name name)
Return the name of the object within the given type.
Definition: typeInfo.H:188
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
error FatalError
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
dictionary dict