secondaryPropertyFvScalarFieldSource.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"
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
33 (
35 )
36 :
37  internalField_(iF),
38  i_(-1)
39 {}
40 
41 
42 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
43 
46 {
47  return
48  refCast<const diameterModels::velocityGroup>
49  (
50  internalField_
51  .db()
52  .lookupObject<phaseSystem>(phaseSystem::propertiesName)
53  .phases()[internalField_.group()]
54  .diameter()
55  ).popBal().sizeGroups();
56 }
57 
58 
60 {
61  // Use the cached index if we have it
62  if (i_ != -1) return i_;
63 
64  // Remove the phase suffix
65  const word member = internalField_.member();
66 
67  // Determine the number of trailing digits
68  string::size_type memberChari = member.size();
69  while (memberChari && isdigit(member[memberChari - 1]))
70  {
71  memberChari --;
72  }
73 
74  // Check that we have something
75  if (memberChari == member.size())
76  {
78  << "Could not determine the size-group index for "
79  << "secondary property field " << internalField_.name()
80  << exit(FatalError);
81  }
82 
83  // Convert the trailing digits to an integer
84  i_ = atoi(member(memberChari, member.size()).c_str());
85 
86  // Check that the index is in bounds
87  if (i_ < 0 || i_ >= fis().size())
88  {
90  << "Size-group index for secondary property field "
91  << internalField_.name() << " is out of range"
92  << exit(FatalError);
93  }
94 
95  return i_;
96 }
97 
98 
101 {
102  const UPtrList<diameterModels::sizeGroup>& fis = this->fis();
103 
104  const label i = this->i() + deltai;
105 
106  return
107  i < 0 || i > fis.size() - 1
108  ? NullObjectRef<diameterModels::sizeGroup>()
109  : fis[i];
110 }
111 
112 
113 // ************************************************************************* //
graph_traits< Graph >::vertices_size_type size_type
Definition: SloanRenumber.C:73
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
label size() const
Return the number of elements in the UPtrList.
Definition: UPtrListI.H:29
Single size class fraction field representing a fixed particle volume as defined by the user through ...
Definition: sizeGroup.H:96
static const word propertiesName
Default name of the phase properties dictionary.
Definition: phaseSystem.H:252
const UPtrList< diameterModels::sizeGroup > & fis() const
Return the list of size-groups.
label i() const
Return the index of this group.
secondaryPropertyFvScalarFieldSource(const DimensionedField< scalar, volMesh > &)
Construct from internal field.
const diameterModels::sizeGroup & fi(const label deltai=0) const
Return a size-group.
A class for handling words, derived from string.
Definition: word.H:62
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
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
error FatalError