LagrangianModelsTemplates.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 
26 #include "LagrangianModels.H"
27 
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
29 
30 template
31 <
32  class Type,
33  template<class> class PrimitiveField,
34  class ... AlphaRhoFieldTypes
35 >
36 Foam::tmp<Foam::LagrangianEqn<Type>> Foam::LagrangianModels::sourceTerm
37 (
39  const LagrangianSubScalarField& deltaT,
40  const AlphaRhoFieldTypes& ... alphaRhoFields
41 ) const
42 {
43  checkApplied();
44 
46  (
48  (
49  "S(" + LagrangianModel::fieldsName(alphaRhoFields ...) + ")",
50  eqnField
51  )
52  );
53  LagrangianEqn<Type>& eqn = tEqn.ref();
54 
55  const PtrListDictionary<LagrangianModel>& modelList(*this);
56 
57  const word fieldName = LagrangianModel::fieldName(alphaRhoFields ...);
58  const word eqnFieldName = LagrangianModel::fieldName(eqnField);
59 
60  forAll(modelList, i)
61  {
62  const LagrangianModel& model = modelList[i];
63 
64  if (model.addsSupToField(fieldName, eqnFieldName))
65  {
66  addSupFields_[i].insert(fieldName);
67 
68  model.addSup(deltaT, toSubField(alphaRhoFields)() ..., eqn);
69  }
70  }
71 
72  return tEqn;
73 }
74 
75 
76 template
77 <
78  class ModelType,
79  class FieldSourceType,
80  class ... ModelAndFieldSourceTypes
81 >
82 struct Foam::LagrangianModels::modelTypeFieldSourceType
83 <
84  ModelType,
85  FieldSourceType,
86  ModelAndFieldSourceTypes ...
87 >
88 {
89  static void insert(const LagrangianModel& model, HashTable<word>& result)
90  {
91  if (isA<ModelType>(model))
92  {
93  result.insert(model.name(), FieldSourceType::typeName);
94  }
95  else
96  {
98  (
99  model,
100  result
101  );
102  }
103  }
104 };
105 
106 
107 template<>
108 struct Foam::LagrangianModels::modelTypeFieldSourceType<>
109 {
110  static void insert(const LagrangianModel& model, HashTable<word>& result)
111  {}
112 };
113 
114 
115 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
116 
117 template<class Type, template<class> class PrimitiveField>
119 (
121 ) const
122 {
123  return addsSupToField(LagrangianModel::fieldName(field));
124 }
125 
126 
127 template
128 <
129  class Type,
130  template<class> class PrimitiveField,
131  template<class> class PrimitiveEqnField
132 >
134 (
137 ) const
138 {
139  return
140  addsSupToField
141  (
144  );
145 }
146 
147 
148 template<class ... ModelAndFieldSourceTypes>
151 {
152  const PtrListDictionary<LagrangianModel>& modelList(*this);
153 
154  HashTable<word> result;
155  forAll(modelList, i)
156  {
158  (
159  modelList[i],
160  result
161  );
162  }
163 
164  return result;
165 }
166 
167 
168 template<class Type, template<class> class PrimitiveField>
170 (
171  const LagrangianSubScalarField& deltaT,
173 ) const
174 {
175  return sourceTerm(field, deltaT, field);
176 }
177 
178 
179 template
180 <
181  class Type,
182  template<class> class PrimitiveField,
183  template<class> class PrimitiveEqnField
184 >
186 (
187  const LagrangianSubScalarField& deltaT,
190 ) const
191 {
192  return sourceTerm(eqnField, deltaT, field);
193 }
194 
195 
196 template<class Type, template<class> class PrimitiveField>
198 (
199  const LagrangianSubScalarField& deltaT,
202 ) const
203 {
204  return sourceTerm(field, deltaT, vOrM, field);
205 }
206 
207 
208 template
209 <
210  class Type,
211  template<class> class PrimitiveField,
212  template<class> class PrimitiveEqnField
213 >
215 (
216  const LagrangianSubScalarField& deltaT,
220 ) const
221 {
222  return sourceTerm(eqnField, deltaT, vOrM, field);
223 }
224 
225 
226 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
An STL-conforming hash table.
Definition: HashTable.H:127
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
Definition: HashTableI.H:80
This class stores the coefficients of a Lagrangian equation, and facilitates solving that equation an...
Definition: LagrangianEqn.H:56
Base class for Lagrangian models.
virtual void addSup(const LagrangianSubScalarField &deltaT, LagrangianEqn< scalar > &eqn) const
Add a fractional source term.
virtual bool addsSupToField(const word &fieldName, const word &eqnFieldName) const =0
Return true if the LagrangianModel adds a source term to the.
static word fieldsName(const AlphaRhoFieldType &alphaRhoField, const AlphaRhoFieldTypes &... alphaRhoFields)
Return the name of the product of the fields associated with a.
static word fieldName(const AlphaRhoFieldType &alphaRhoField, const AlphaRhoFieldTypes &... alphaRhoFields)
Return the name of the field associated with a source term.
const word & name() const
The source name.
tmp< LagrangianEqn< scalar > > source(const LagrangianSubScalarField &deltaT) const
Return the fractional source.
HashTable< word > modelTypeFieldSourceTypes() const
Return a table of field source types that are chosen to match given.
tmp< LagrangianEqn< Type > > sourceProxy(const LagrangianSubScalarField &deltaT, const LagrangianSubField< Type, PrimitiveField > &field, const LagrangianSubField< Type, PrimitiveEqnField > &eqnField) const
Return source for an equation.
bool addsSupToField(const word &fieldName) const
Return true if the LagrangianModels adds a source term to the.
A class for managing temporary objects.
Definition: tmp.H:55
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:197
A class for handling words, derived from string.
Definition: word.H:63
void insert(const scalar, DynamicList< floatScalar > &)
Append scalar to given DynamicList.
String typeName(const std::type_info &info)
Return the un-mangled name given the standard type info.
tmp< DimensionedField< Type, GeoMesh, SubField > > toSubField(const DimensionedField< Type, GeoMesh, Field > &)
Return a temporary sub-field from a reference to a field.
static void insert(const LagrangianModel &model, HashTable< word > &result)