singleSizeGroupFvScalarFieldSource.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::singleSizeGroupFvScalarFieldSource::eta() const
33 {
34  const diameterModels::sizeGroup& fi =
35  refCast<const diameterModels::sizeGroup>(internalField());
36 
37  // Check the index
38  const label firstIndex = fi.group().sizeGroups().first().i();
39  const label lastIndex = fi.group().sizeGroups().last().i();
40  if (index_ < firstIndex || index_ > lastIndex)
41  {
43  << "Size-group index " << index_ << " is out of range of the "
44  << "indices associated with phase " << internalField().group()
45  << " (" << firstIndex << " -> " << lastIndex << ")"
46  << exit(FatalError);
47  }
48 
49  return fi.i() == index_ ? scalar(1) : scalar(0);
50 }
51 
52 
53 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
54 
56 (
58  const dictionary& dict
59 )
60 :
61  fvScalarFieldSource(iF, dict),
62  index_(dict.lookup<label>("index"))
63 {}
64 
65 
67 (
70 )
71 :
72  fvScalarFieldSource(field, iF),
73  index_(field.index_)
74 {}
75 
76 
77 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
78 
80 {}
81 
82 
83 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
84 
87 (
88  const fvSource& model,
90 ) const
91 {
92  return
94  (
95  model.name() + ":" + this->internalField().name() + "SourceValue",
96  this->internalField().mesh(),
98  );
99 }
100 
101 
104 (
105  const fvSource& model,
106  const scalarField& source,
107  const labelUList& cells
108 ) const
109 {
110  return tmp<scalarField>(new scalarField(source.size(), eta()));
111 }
112 
113 
116 (
117  const fvSource& model,
119 ) const
120 {
121  return
123  (
124  model.name() + ":" + this->internalField().name() + "InternalCoeff",
125  this->internalField().mesh(),
126  dimensionedScalar(dimless, scalar(0))
127  );
128 }
129 
130 
133 (
134  const fvSource& model,
135  const scalarField& source,
136  const labelUList& cells
137 ) const
138 {
139  return tmp<scalarField>(new scalarField(source.size(), scalar(0)));
140 }
141 
142 
144 {
146  writeEntry(os, "index", index_);
147 }
148 
149 
150 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
151 
152 namespace Foam
153 {
155  (
156  fvScalarFieldSource,
158  );
159 }
160 
161 // ************************************************************************* //
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
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
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
Source condition for size-group fractions that sets a value of one in a single group,...
singleSizeGroupFvScalarFieldSource(const DimensionedField< scalar, volMesh > &, const dictionary &dict)
Construct from internal field and dictionary.
virtual tmp< DimensionedField< scalar, volMesh > > sourceValue(const fvSource &model, const DimensionedField< scalar, volMesh > &source) const
Return the source value.
virtual tmp< DimensionedField< scalar, volMesh > > internalCoeff(const fvSource &model, const DimensionedField< scalar, volMesh > &source) const
Return the internal coefficient.
A class for managing temporary objects.
Definition: tmp.H:55
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
const cellShapeList & cells
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
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
makeTypeFieldSource(fvScalarFieldSource, turbulentIntensityKineticEnergyFvScalarFieldSource)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
error FatalError
dictionary dict