multiCycleConstantbXiIgnition.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) 2024 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 
28 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
29 
30 namespace Foam
31 {
32  namespace fv
33  {
35 
37  (
38  fvModel,
41  );
42  }
43 }
44 
45 
46 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
47 
48 void Foam::fv::multiCycleConstantbXiIgnition::readCoeffs(const dictionary& dict)
49 {
50  period_.read(dict, mesh().time().userUnits());
51  combustionDuration_.read(dict, mesh().time().userUnits());
52 }
53 
54 
55 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
56 
58 (
59  const word& name,
60  const word& modelType,
61  const fvMesh& mesh,
62  const dictionary& dict
63 )
64 :
65  constantbXiIgnition(name, modelType, mesh, dict),
66  period_("period", mesh().time().userUnits(), dict),
67  combustionDuration_("combustionDuration", mesh().time().userUnits(), dict),
68  reset_(!ignited())
69 {}
70 
71 
72 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
73 
74 Foam::scalar Foam::fv::multiCycleConstantbXiIgnition::ignRelTime
75 (
76  const scalar t
77 ) const
78 {
79  return std::fmod(t - start_.value(), period_.value());
80 }
81 
82 
84 {
85  const scalar curTime = mesh().time().value();
86  const scalar deltaT = mesh().time().deltaTValue();
87 
88  const bool igniting
89  (
90  ignRelTime(curTime) > -0.5*deltaT
91  && ignRelTime(curTime) < max(duration_.value(), 0.5*deltaT)
92  );
93 
94  if (igniting)
95  {
96  reset_ = false;
97  }
98 
99  return igniting;
100 }
101 
102 
104 {
105  const scalar curTime = mesh().time().value();
106  const scalar deltaT = mesh().time().deltaTValue();
107 
108  const bool ignited
109  (
110  ignRelTime(curTime) > -0.5*deltaT
111  && ignRelTime(curTime) < combustionDuration_.value() + 0.5*deltaT
112  );
113 
114  if
115  (
116  !reset_
117  && ignRelTime(curTime) > combustionDuration_.value() - 0.5*deltaT
118  )
119  {
120  reset_ = true;
121 
122  mesh().lookupObjectRef<solvers::XiFluid>(solver::typeName).reset();
123  }
124 
125  return ignited;
126 }
127 
128 
130 {
132  {
133  readCoeffs(coeffs(dict));
134  return true;
135  }
136  else
137  {
138  return false;
139  }
140 
141  return false;
142 }
143 
144 
145 // ************************************************************************* //
scalar deltaTValue() const
Return time step value.
Definition: TimeStateI.H:34
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
void read(const dictionary &, const unitConversion &defaultUnits=NullObjectRef< unitConversion >())
Update the value of dimensioned<Type>
const Type & value() const
Return const reference to value.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:96
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:420
Finite volume model abstract base class.
Definition: fvModel.H:60
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvModelI.H:69
Simple constant rate ignition model for the Weller b-Xi combustion models.
virtual bool read(const dictionary &dict)
Read source dictionary.
Simple constant rate ignition model for the Weller b-Xi combustion models.
multiCycleConstantbXiIgnition(const word &name, const word &modelType, const fvMesh &mesh, const dictionary &dict)
Construct from explicit source name and mesh.
virtual bool read(const dictionary &dict)
Read source dictionary.
virtual bool ignited() const
Return true during the combustion duration.
virtual bool igniting() const
Return true during the ignition duration.
Type & lookupObjectRef(const word &name) const
Lookup and return the object reference of the given Type.
Solver module for compressible premixed/partially-premixed combustion with turbulence modelling.
Definition: XiFluid.H:143
A class for handling words, derived from string.
Definition: word.H:62
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
addToRunTimeSelectionTable(fvConstraint, bound, dictionary)
defineTypeNameAndDebug(bound, 0)
Namespace for OpenFOAM.
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
labelList fv(nPoints)
dictionary dict