distributionSizeGroupFvScalarFieldSource.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-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 "populationBalanceModel.H"
29 
30 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
31 
32 Foam::scalar Foam::distributionSizeGroupFvScalarFieldSource::eta
33 (
34  const fvSource& model
35 ) const
36 {
37  if (!etaPtr_.valid())
38  {
39  const diameterModels::sizeGroup& fi =
40  refCast<const diameterModels::sizeGroup>(internalField());
41 
42  etaPtr_.set
43  (
44  new scalar
45  (
46  fi.group().popBal().etaV(fi.i(), distribution_()).value()
47  )
48  );
49 
50  if (debug)
51  {
52  Info<< typeName << ": Size group #" << fi.i() << " is receiving "
53  << 100*etaPtr_() << "\% of source " << model.name() << endl;
54  }
55  }
56 
57  return etaPtr_();
58 }
59 
60 
61 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
62 
65 (
67  const dictionary& dict
68 )
69 :
70  fvScalarFieldSource(iF, dict),
71  distribution_
72  (
73  distribution::New(dimLength, dict.subDict("distribution"), 3, -1)
74  ),
75  etaPtr_(nullptr)
76 {}
77 
78 
81 (
84 )
85 :
86  fvScalarFieldSource(field, iF),
87  distribution_(field.distribution_, false),
88  etaPtr_(nullptr)
89 {}
90 
91 
92 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
93 
96 {}
97 
98 
99 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
100 
103 (
104  const fvSource& model,
106 ) const
107 {
108  return
110  (
111  model.name() + ":" + this->internalField().name() + "SourceValue",
112  this->internalField().mesh(),
113  dimensionedScalar(dimless, eta(model))
114  );
115 }
116 
117 
120 (
121  const fvSource& model,
122  const scalarField& source,
123  const labelUList& cells
124 ) const
125 {
126  return tmp<scalarField>(new scalarField(source.size(), eta(model)));
127 }
128 
129 
132 (
133  const fvSource& model,
135 ) const
136 {
137  return
139  (
140  model.name() + ":" + this->internalField().name() + "InternalCoeff",
141  this->internalField().mesh(),
142  dimensionedScalar(dimless, scalar(0))
143  );
144 }
145 
146 
149 (
150  const fvSource& model,
151  const scalarField& source,
152  const labelUList& cells
153 ) const
154 {
155  return tmp<scalarField>(new scalarField(source.size(), scalar(0)));
156 }
157 
158 
160 {
162  writeEntry(os, "distribution", dimLength, distribution_(), true, false);
163 }
164 
165 
166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
167 
168 namespace Foam
169 {
171  (
172  fvScalarFieldSource,
174  );
175 }
176 
177 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
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,.
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set)
Definition: autoPtrI.H:83
void set(T *)
Set pointer to that given.
Definition: autoPtrI.H:99
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Source condition for size-group fractions that sets values corresponding to a given distribution.
virtual tmp< DimensionedField< scalar, volMesh > > sourceValue(const fvSource &model, const DimensionedField< scalar, volMesh > &source) const
Return the source value.
distributionSizeGroupFvScalarFieldSource(const DimensionedField< scalar, volMesh > &, const dictionary &dict)
Construct from internal field and dictionary.
virtual tmp< DimensionedField< scalar, volMesh > > internalCoeff(const fvSource &model, const DimensionedField< scalar, volMesh > &source) const
Return the internal coefficient.
Base class for statistical distributions.
Definition: distribution.H:76
const word & name() const
Return const access to the source name.
Definition: fvModelI.H:57
Base class for finite volume sources.
Definition: fvSource.H:52
A class for managing temporary objects.
Definition: tmp.H:55
const cellShapeList & cells
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
Namespace for OpenFOAM.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:258
const dimensionSet dimless
messageStream Info
makeTypeFieldSource(fvScalarFieldSource, turbulentIntensityKineticEnergyFvScalarFieldSource)
const dimensionSet dimLength
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
tmp< DimensionedField< TypeR, GeoMesh, Field > > New(const tmp< DimensionedField< TypeR, GeoMesh, Field >> &tdf1, const word &name, const dimensionSet &dimensions)
dictionary dict