Flux.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) 2022 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::Flux
26 
27 Description
28  Function objects which generate the number, volume or mass flux of
29  particles in a cloud.
30 
31  Example usage:
32  \verbatim
33  massFlux1
34  {
35  type numberFlux; // numberFlux, volumeFlux, or massFlux
36  }
37  \endverbatim
38 
39 SourceFiles
40  Flux.C
41 
42 \*---------------------------------------------------------------------------*/
43 
44 #ifndef Flux_H
45 #define Flux_H
46 
47 #include "NamedEnum.H"
48 #include "volFields.H"
49 #include "surfaceFields.H"
50 #include "cloud.H"
51 #include "CloudFunctionObject.H"
52 
53 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 
55 namespace Foam
56 {
57 
58 /*---------------------------------------------------------------------------*\
59  Class Flux Declaration
60 \*---------------------------------------------------------------------------*/
61 
62 template<class CloudType, class Derived>
63 class Flux
64 :
65  public CloudFunctionObject<CloudType>
66 {
67  // Private Typedefs
68 
69  //- The parcel type
70  typedef typename CloudType::particleType parcelType;
71 
72 
73  // Private Data
74 
75  //- Whether or not to write the flux field
76  const bool write_;
77 
78  //- The flux field
79  surfaceScalarField phi_;
80 
81 
82 protected:
83 
84  // Protected Member Functions
85 
86  //- Write post-processing info
87  void write();
88 
89  //- Accumulate the particle into the flux
90  void accumulate(const parcelType& p, const bool isPre);
91 
92 
93 public:
94 
95  // Constructors
96 
97  //- Construct from dictionary
98  Flux
99  (
100  const dictionary& dict,
101  CloudType& owner,
102  const word& modelName
103  );
104 
105  //- Construct copy
106  Flux(const Flux<CloudType, Derived>& ppm);
107 
108  //- Construct and return a clone
110  {
112  (
113  new Derived(static_cast<const Derived&>(*this))
114  );
115  }
116 
117 
118  //- Destructor
119  virtual ~Flux();
120 
121 
122  // Member Functions
123 
124  // Evaluation
125 
126  //- Pre-evolve hook
127  virtual void preEvolve();
128 
129  //- Pre-face hook
130  virtual void preFace(const parcelType& p);
131 
132  //- Post-face hook
133  virtual void postFace(const parcelType& p);
134 };
135 
136 
137 /*---------------------------------------------------------------------------*\
138  Class NumberFlux Declaration
139 \*---------------------------------------------------------------------------*/
140 
141 template<class CloudType>
142 class NumberFlux
143 :
144  public Flux<CloudType, NumberFlux<CloudType>>
145 {
146 public:
147 
148  //- Runtime type information
149  TypeName("numberFlux");
150 
151 
152  // Constructors
153 
154  //- Inherit constructors
156 
157 
158  // Static Member Data
159 
160  //- Dimensions of the flux field
161  static const dimensionSet dimensions;
162 
163 
164  // Member Functions
165 
166  //- Return the flux contribution for a single particle
167  static scalar dPhiDeltaT(const typename CloudType::particleType& p)
168  {
169  return p.nParticle();
170  }
171 };
172 
173 
174 /*---------------------------------------------------------------------------*\
175  Class VolumeFlux Declaration
176 \*---------------------------------------------------------------------------*/
177 
178 template<class CloudType>
179 class VolumeFlux
180 :
181  public Flux<CloudType, VolumeFlux<CloudType>>
182 {
183 public:
184 
185  //- Runtime type information
186  TypeName("volumeFlux");
187 
188 
189  // Constructors
190 
191  //- Inherit constructors
193 
194 
195  // Static Member Data
196 
197  //- Dimensions of the flux field
198  static const dimensionSet dimensions;
199 
200 
201  // Member Functions
202 
203  //- Return the flux contribution for a single particle
204  static scalar dPhiDeltaT(const typename CloudType::particleType& p)
205  {
206  return p.nParticle()*p.volume();
207  }
208 };
209 
210 
211 /*---------------------------------------------------------------------------*\
212  Class MassFlux Declaration
213 \*---------------------------------------------------------------------------*/
214 
215 template<class CloudType>
216 class MassFlux
217 :
218  public Flux<CloudType, MassFlux<CloudType>>
219 {
220 public:
221 
222  //- Runtime type information
223  TypeName("massFlux");
224 
225 
226  // Constructors
227 
228  //- Inherit constructors
230 
231 
232  // Static Member Data
233 
234  //- Dimensions of the flux field
235  static const dimensionSet dimensions;
236 
237 
238  // Member Functions
239 
240  //- Return the flux contribution for a single particle
241  static scalar dPhiDeltaT(const typename CloudType::particleType& p)
242  {
243  return p.nParticle()*p.mass();
244  }
245 };
246 
247 
248 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
249 
250 } // End namespace Foam
251 
252 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
253 
254 #ifdef NoRepository
255  #include "Flux.C"
256 #endif
257 
258 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
259 
260 #endif
261 
262 // ************************************************************************* //
Templated cloud function object base class.
const CloudType & owner() const
Return const access to the owner cloud.
ParcelType particleType
Definition: Cloud.H:128
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:80
Function objects which generate the number, volume or mass flux of particles in a cloud.
Definition: Flux.H:65
virtual void preFace(const parcelType &p)
Pre-face hook.
Definition: Flux.C:140
Flux(const dictionary &dict, CloudType &owner, const word &modelName)
Construct from dictionary.
Definition: Flux.C:89
void write()
Write post-processing info.
Definition: Flux.C:46
virtual void postFace(const parcelType &p)
Post-face hook.
Definition: Flux.C:147
virtual autoPtr< CloudFunctionObject< CloudType > > clone() const
Construct and return a clone.
Definition: Flux.H:108
virtual ~Flux()
Destructor.
Definition: Flux.C:126
void accumulate(const parcelType &p, const bool isPre)
Accumulate the particle into the flux.
Definition: Flux.C:57
virtual void preEvolve()
Pre-evolve hook.
Definition: Flux.C:133
Generic GeometricField class.
static const dimensionSet dimensions
Dimensions of the flux field.
Definition: Flux.H:234
TypeName("massFlux")
Runtime type information.
static scalar dPhiDeltaT(const typename CloudType::particleType &p)
Return the flux contribution for a single particle.
Definition: Flux.H:240
static const dimensionSet dimensions
Dimensions of the flux field.
Definition: Flux.H:160
static scalar dPhiDeltaT(const typename CloudType::particleType &p)
Return the flux contribution for a single particle.
Definition: Flux.H:166
TypeName("numberFlux")
Runtime type information.
static const dimensionSet dimensions
Dimensions of the flux field.
Definition: Flux.H:197
TypeName("volumeFlux")
Runtime type information.
static scalar dPhiDeltaT(const typename CloudType::particleType &p)
Return the flux contribution for a single particle.
Definition: Flux.H:203
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Dimension set for the base types.
Definition: dimensionSet.H:125
const dictionary & dict() const
Return const access to the cloud dictionary.
Definition: subModelBase.C:110
const word & modelName() const
Return const access to the name of the sub-model.
Definition: subModelBase.C:104
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.
volScalarField & p
Foam::surfaceFields.