uniformSizeNumberLagrangianScalarFieldSource.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 "massive.H"
28 
29 // * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
34 }
35 
36 const Foam::NamedEnum
37 <
39  4
40 >
42 {
43  "number",
44  "surfaceArea",
45  "volume",
46  "mass"
47 };
48 
49 
50 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
51 
53 (
54  const LagrangianInjection& injection,
55  const LagrangianSubMesh& subMesh,
57  const bool needv,
59  const bool needm,
61 ) const
62 {
63  const bool actuallyNeedv = needv || uniformSize_ == uniformSize::volume;
64  const bool actuallyNeedm = needm || uniformSize_ == uniformSize::mass;
65 
66  const Foam::clouds::shaped& shapedCloud =
67  this->cloud<Foam::clouds::shaped>(injection, subMesh);
68 
69  // Evaluate the volume and mass (as necessary) of the created particles
70  if (actuallyNeedv)
71  {
72  v = shapedCloud.v(injection, subMesh);
73  }
74  if (actuallyNeedm)
75  {
76  const clouds::massive& massiveCloud =
77  this->cloud<clouds::massive>(injection, subMesh);
78 
79  m = massiveCloud.m(injection, subMesh);
80  }
81 
82  // Create a field proportional to the desired uniform size
83  switch (uniformSize_)
84  {
86  {
87  size =
89  (
90  "1",
91  subMesh,
93  );
94  break;
95  }
97  {
98  size = shapedCloud.a(injection, subMesh);
99  break;
100  }
101  case uniformSize::volume:
102  {
103  size = v();
104  break;
105  }
106  case uniformSize::mass:
107  {
108  size = m();
109  break;
110  }
111  }
112 }
113 
114 
115 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
116 
119 (
120  const regIOobject& iIo,
121  const dictionary& dict
122 )
123 :
124  LagrangianScalarFieldSource(iIo, dict),
125  CloudLagrangianFieldSource<scalar>(*this),
126  uniformSize_(uniformSizeNames_[dict.lookup<word>("uniformSize")])
127 {}
128 
129 
132 (
134  const regIOobject& iIo
135 )
136 :
137  LagrangianScalarFieldSource(field, iIo),
138  CloudLagrangianFieldSource<scalar>(*this),
139  uniformSize_(field.uniformSize_)
140 {}
141 
142 
143 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
144 
147 {}
148 
149 
150 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
151 
153 {
154  switch (uniformSize_)
155  {
156  case uniformSize::number:
157  return 0;
158  case uniformSize::surfaceArea:
159  return 2;
160  case uniformSize::volume:
161  return 3;
162  case uniformSize::mass:
163  return 3;
164  }
165 
166  return -labelMax;
167 }
168 
169 
171 (
172  Ostream& os
173 ) const
174 {
176 
177  writeEntry(os, "uniformSize", uniformSizeNames_[uniformSize_]);
178 }
179 
180 
181 // ************************************************************************* //
Templated base class for source conditions that refer to a cloud. Not a source condition in itself....
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,.
Base class for Lagrangian injections. Minimal wrapper over LagrangianSource. Implements some utility ...
Mesh that relates to a sub-section of a Lagrangian mesh. This is used to construct fields that relate...
Initialise the NamedEnum HashTable from the static list of names.
Definition: NamedEnum.H:55
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Base class for clouds. Provides a basic evolution algorithm, models, and a database for caching deriv...
Definition: cloud.H:63
Base class for clouds with particles with mass.
Definition: massive.H:51
const CloudDerivedField< scalar > & m
Mass.
Definition: massive.H:69
Base class for clouds with particles with mass.
Definition: shaped.H:51
const CloudDerivedField< scalar > & v
Volume.
Definition: shaped.H:83
const CloudDerivedField< scalar > & a
Surface area.
Definition: shaped.H:86
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:55
A class for managing temporary objects.
Definition: tmp.H:55
Base class for Lagrangian source conditions that calculate the number field from a total (e....
void calcSizes(const LagrangianInjection &injection, const LagrangianSubMesh &subMesh, tmp< LagrangianSubScalarField > &size, const bool needv, tmp< LagrangianSubScalarField > &v, const bool needm, tmp< LagrangianSubScalarField > &m) const
Calculate the necessary sizes.
uniformSizeNumberLagrangianScalarFieldSource(const regIOobject &, const dictionary &dict)
Construct from internal field and dictionary.
static const NamedEnum< uniformSize, 4 > uniformSizeNames_
Names of the uniform size.
A class for handling words, derived from string.
Definition: word.H:62
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
const dimensionSet dimless
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
defineTypeNameAndDebug(combustionModel, 0)
static const label labelMax
Definition: label.H:62
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
dictionary dict