distributionGroupFractionFvScalarFieldSource.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-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 "populationBalanceModel.H"
29 
30 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
31 
32 Foam::scalar Foam::distributionGroupFractionFvScalarFieldSource::eta
33 (
34  const fvSource& model
35 ) const
36 {
37  if (!etaPtr_.valid())
38  {
39  etaPtr_.set
40  (
41  new scalar
42  (
43  popBal().etaV(i(), distribution_()).value()
44  )
45  );
46 
47  if (debug)
48  {
49  Info<< typeName << ": Group #" << i() << " is receiving "
50  << 100*etaPtr_() << "\% of source " << model.name() << endl;
51  }
52  }
53 
54  return etaPtr_();
55 }
56 
57 
58 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
59 
62 (
64  const dictionary& dict
65 )
66 :
67  fvScalarFieldSource(iF, dict),
69  distribution_
70  (
71  distribution::New(dimLength, dict.subDict("distribution"), 3, -1)
72  ),
73  etaPtr_(nullptr)
74 {}
75 
76 
79 (
82 )
83 :
84  fvScalarFieldSource(field, iF),
86  distribution_(field.distribution_, false),
87  etaPtr_(nullptr)
88 {}
89 
90 
91 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
92 
95 {}
96 
97 
98 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
99 
102 (
103  const fvSource& model,
105 ) const
106 {
107  return
109  (
110  model.name() + ":" + this->internalField().name() + "SourceValue",
111  this->internalField().mesh(),
112  dimensionedScalar(dimless, eta(model))
113  );
114 }
115 
116 
119 (
120  const fvSource& model,
121  const scalarField& source,
122  const labelUList& cells
123 ) const
124 {
125  return tmp<scalarField>(new scalarField(source.size(), eta(model)));
126 }
127 
128 
131 (
132  const fvSource& model,
134 ) const
135 {
136  return
138  (
139  model.name() + ":" + this->internalField().name() + "InternalCoeff",
140  this->internalField().mesh(),
141  dimensionedScalar(dimless, scalar(0))
142  );
143 }
144 
145 
148 (
149  const fvSource& model,
150  const scalarField& source,
151  const labelUList& cells
152 ) const
153 {
154  return tmp<scalarField>(new scalarField(source.size(), scalar(0)));
155 }
156 
157 
159 (
160  Ostream& os
161 ) const
162 {
164  writeEntry(os, "distribution", dimLength, distribution_(), true, false);
165 }
166 
167 
168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 
170 namespace Foam
171 {
173  (
174  fvScalarFieldSource,
176  );
177 
178  // Backwards compatible lookup as "distributionSizeGroup"
180  (
181  fvScalarFieldSource,
183  dictionary,
184  distributionSizeGroup
185  );
186 }
187 
188 // ************************************************************************* //
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 GeoMesh &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 group fractions of a population balance model that sets values corresponding to ...
virtual tmp< DimensionedField< scalar, fvMesh > > sourceValue(const fvSource &model, const DimensionedField< scalar, fvMesh > &source) const
Return the source value.
virtual tmp< DimensionedField< scalar, fvMesh > > internalCoeff(const fvSource &model, const DimensionedField< scalar, fvMesh > &source) const
Return the internal coefficient.
distributionGroupFractionFvScalarFieldSource(const DimensionedField< scalar, fvMesh > &, const dictionary &dict)
Construct from internal field and dictionary.
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:53
Base class for source conditions of properties of the groups in a population balance model.
const populationBalanceModel & popBal() const
Return the population balance.
label i() const
Return the index of this group.
A class for managing temporary objects.
Definition: tmp.H:55
Template function which returns the un-mangled name of a given type. Useful for types which do not ha...
const cellShapeList & cells
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
Namespace for OpenFOAM.
const dimensionSet & dimless
Definition: dimensions.C:138
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:288
const dimensionSet & dimLength
Definition: dimensions.C:141
addNamedToRunTimeSelectionTable(fvPatchScalarField, turbulentKineticEnergyFvPatchScalarField, dictionary, turbulentIntensityKineticEnergyInlet)
messageStream Info
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
makeTypeFieldSource(fvScalarFieldSource, turbulentKineticEnergyFvScalarFieldSource)
tmp< DimensionedField< TypeR, GeoMesh, Field > > New(const tmp< DimensionedField< TypeR, GeoMesh, Field >> &tdf1, const word &name, const dimensionSet &dimensions)
void writeEntry(Ostream &os, const word &key, const DimensionedFieldFunction< DimensionedFieldType > &f)
dictionary dict