cloud_fvModel.H
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-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 Class
25  Foam::fv::cloud
26 
27 Description
28  Finite volume model that solves for the evolution of a cloud. Provides
29  two-way coupling with a finite-volume carrier phase.
30 
31 SourceFiles
32  cloud_fvModel.C
33  cloud_fvModelTemplates.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef cloud_fvModel_H
38 #define cloud_fvModel_H
39 
40 #include "fvSource.H"
41 #include "coupled.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 namespace fv
48 {
49 
50 /*---------------------------------------------------------------------------*\
51  Class cloud Declaration
52 \*---------------------------------------------------------------------------*/
53 
54 class cloud
55 :
56  public fvSource
57 {
58  // Private Data
59 
60  //- The cloud
61  autoPtr<Foam::cloud> cloudPtr_;
62 
63  //- Cloud reference (for convenience)
64  const Foam::cloud& cloud_;
65 
66  //- Carried cloud reference (for convenience)
67  const clouds::carried& carriedCloud_;
68 
69  //- Coupled cloud reference (for convenience)
70  const clouds::coupled& coupledCloud_;
71 
72 
73  // Private Member Functions
74 
75  //- Fail with a message indicating that a source could not be added
76  template<class Type>
77  void fail(const fvMatrix<Type>& eqn) const;
78 
79  //- Fail with a message indicating that a source could not be added
80  template<class Type, class ... AlphaRhoFieldTypes>
81  void fail
82  (
83  const fvMatrix<Type>& eqn,
84  const AlphaRhoFieldTypes& ... alphaRhoFields
85  ) const;
86 
87 
88  // Sources
89 
90  //- Return the material source for the given phase
92  (
93  const word& phaseName,
94  const dimensionSet& dims
95  ) const;
96 
97  //- Return the material source for the given phase
98  template<class Type>
99  tmp<fvMatrix<Type>> Sfield
100  (
101  const VolField<Type>& field,
102  const dimensionSet& dims
103  ) const;
104 
105  //- Add a source term to an equation
106  template<class Type>
107  void addSupType
108  (
109  const VolField<Type>& field,
110  fvMatrix<Type>& eqn
111  ) const;
112 
113  //- Add a source term to a phase continuity equation or a scalar
114  // equation
115  void addSupType
116  (
117  const volScalarField& alphaOrField,
118  fvMatrix<scalar>& eqn
119  ) const;
120 
121  //- Add a source term to a compressible equation
122  template<class Type>
123  void addSupType
124  (
125  const volScalarField& rho,
126  const VolField<Type>& field,
127  fvMatrix<Type>& eqn
128  ) const;
129 
130  //- Add a source term to a compressible phase continuity equation
131  // or a compressible scalar equation
132  void addSupType
133  (
134  const volScalarField& alphaOrRho,
135  const volScalarField& rhoOrField,
136  fvMatrix<scalar>& eqn
137  ) const;
138 
139  //- Add a source term to a phase equation
140  template<class Type>
141  void addSupType
142  (
143  const volScalarField& alpha,
144  const volScalarField& rho,
145  const VolField<Type>& field,
146  fvMatrix<Type>& eqn
147  ) const;
148 
149 
150 protected:
151 
152  // Protected Classes
153 
154  //- Empty template class used to template the constructor on the type
155  // of the cloud
156  template<class Type>
157  class Cloud
158  {};
159 
160 
161  // Protected Constructors
162 
163  //- Construct from components
164  template<class Type>
165  cloud
166  (
167  const word& name,
168  const word& modelType,
169  const fvMesh& mesh,
170  const dictionary& dict,
171  const Cloud<Type>&
172  );
173 
174 
175 public:
176 
177  // Public Static Data
178 
179  //- Run-time type information
180  TypeName("cloud");
181 
182 
183  //- Destructor
184  virtual ~cloud();
185 
186 
187  // Member Functions
188 
189  // Checks
190 
191  //- Return true if the fvModel adds a source term to the given
192  // field's transport equation
193  virtual bool addsSupToField(const word& fieldName) const;
194 
195 
196  // Sources
197 
198  //- Add a source term to a field-less proxy equation
199  virtual void addSup(fvMatrix<scalar>& eqn) const;
200 
201  //- Add a source term to an equation
203 
204  //- Add a source term to a compressible equation
206 
207  //- Add a source term to a phase equation
209 
210 
211  //- Solve the evolution of the cloud over the current time-step
212  virtual void correct();
213 
214 
215  // Mesh changes
216 
217  //- Prepare for mesh update
218  virtual void preUpdateMesh();
219 
220  //- Update for mesh motion
221  virtual bool movePoints();
222 
223  //- Update topology using the given map
224  virtual void topoChange(const polyTopoChangeMap&);
225 
226  //- Update from another mesh using the given map
227  virtual void mapMesh(const polyMeshMap&);
228 
229  //- Redistribute or update using the given distribution map
230  virtual void distribute(const polyDistributionMap&);
231 };
232 
233 
234 /*---------------------------------------------------------------------------*\
235  Class Cloud Declaration
236 \*---------------------------------------------------------------------------*/
237 
238 template<class Type>
239 class Cloud
240 :
241  public cloud
242 {
243 public:
244 
245  // Public Static Data
246 
247  //- Run-time type information
248  TypeName("Cloud");
249 
250 
251  // Constructors
252 
253  //- Construct from components
254  Cloud
255  (
256  const word& name,
257  const word& modelType,
258  const fvMesh& mesh,
259  const dictionary& dict
260  );
261 };
262 
263 
264 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
265 
266 } // End namespace fv
267 } // End namespace Foam
268 
269 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
270 
271 #ifdef NoRepository
272  #include "cloud_fvModelTemplates.C"
273 #endif
274 
275 
276 #define makeCloudFvModel(Type) \
277  \
278  typedef Cloud<clouds::Type> Type##CloudFvModel; \
279  \
280  defineTemplateTypeNameAndDebugWithName \
281  ( \
282  Type##CloudFvModel, \
283  (clouds::Type::typeName + "Cloud").c_str(), \
284  0 \
285  ); \
286  \
287  addToRunTimeSelectionTable \
288  ( \
289  fvModel, \
290  Type##CloudFvModel, \
291  dictionary \
292  );
293 
294 
295 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
296 
297 #endif
298 
299 // ************************************************************************* //
Generic GeometricField class.
Base class for clouds. Provides a basic evolution algorithm, models, and a database for caching deriv...
Definition: cloud.H:61
Base class for clouds which are carried by a fluid.
Definition: carried.H:57
Base class for clouds which are coupled to a carrier.
Definition: coupled.H:55
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Dimension set for the base types.
Definition: dimensionSet.H:125
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvMatrix.H:118
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:98
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvModelI.H:69
const word & name() const
Return const access to the source name.
Definition: fvModelI.H:57
static const word & fieldName()
Return the name of the field associated with a source term. Special.
Definition: fvModelI.H:49
Base class for finite volume sources.
Definition: fvSource.H:53
Cloud(const word &name, const word &modelType, const fvMesh &mesh, const dictionary &dict)
Construct from components.
TypeName("Cloud")
Run-time type information.
Empty template class used to template the constructor on the type.
Finite volume model that solves for the evolution of a cloud. Provides two-way coupling with a finite...
Definition: cloud_fvModel.H:56
virtual bool movePoints()
Update for mesh motion.
virtual void correct()
Add a source term to an equation.
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
TypeName("cloud")
Run-time type information.
virtual void preUpdateMesh()
Prepare for mesh update.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
virtual ~cloud()
Destructor.
virtual void addSup(fvMatrix< scalar > &eqn) const
Add a source term to a field-less proxy equation.
cloud(const word &name, const word &modelType, const fvMesh &mesh, const dictionary &dict, const Cloud< Type > &)
Construct from components.
virtual bool addsSupToField(const word &fieldName) const
Return true if the fvModel adds a source term to the given.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:63
#define DEFINE_FV_MODEL_ADD_ALPHA_RHO_FIELD_SUP(Type, nullArg)
Definition: fvModelM.H:62
#define DEFINE_FV_MODEL_ADD_RHO_FIELD_SUP(Type, nullArg)
Definition: fvModelM.H:43
#define DEFINE_FV_MODEL_ADD_FIELD_SUP(Type, nullArg)
Definition: fvModelM.H:26
rho
Definition: pEqn.H:1
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
Namespace for OpenFOAM.
FOR_ALL_FIELD_TYPES(makeDimensionedPointFieldFunctions)
labelList fv(nPoints)
dictionary dict