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-2024 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 "CloudFunctionObject.H"
51 
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 
54 namespace Foam
55 {
56 
57 /*---------------------------------------------------------------------------*\
58  Class Flux Declaration
59 \*---------------------------------------------------------------------------*/
60 
61 template<class CloudType, class Derived>
62 class Flux
63 :
64  public CloudFunctionObject<CloudType>
65 {
66  // Private Typedefs
67 
68  //- The parcel type
69  typedef typename CloudType::particleType parcelType;
70 
71 
72  // Private Data
73 
74  //- Whether or not to write the flux field
75  const bool write_;
76 
77  //- The flux field
78  surfaceScalarField phi_;
79 
80 
81 protected:
82 
83  // Protected Member Functions
84 
85  //- Write post-processing info
86  void write();
87 
88  //- Accumulate the particle into the flux
89  void accumulate(const parcelType& p, const bool isPre);
90 
91 
92 public:
93 
94  // Constructors
95 
96  //- Construct from dictionary
97  Flux
98  (
99  const dictionary& dict,
100  CloudType& owner,
101  const word& modelName
102  );
103 
104  //- Construct copy
105  Flux(const Flux<CloudType, Derived>& ppm);
106 
107  //- Construct and return a clone
109  {
111  (
112  new Derived(static_cast<const Derived&>(*this))
113  );
114  }
115 
116 
117  //- Destructor
118  virtual ~Flux();
119 
120 
121  // Member Functions
122 
123  // Evaluation
124 
125  //- Pre-evolve hook
126  virtual void preEvolve();
127 
128  //- Pre-face hook
129  virtual void preFace(const parcelType& p);
130 
131  //- Post-face hook
132  virtual void postFace(const parcelType& p);
133 };
134 
135 
136 /*---------------------------------------------------------------------------*\
137  Class NumberFlux Declaration
138 \*---------------------------------------------------------------------------*/
139 
140 template<class CloudType>
141 class NumberFlux
142 :
143  public Flux<CloudType, NumberFlux<CloudType>>
144 {
145 public:
146 
147  //- Runtime type information
148  TypeName("numberFlux");
149 
150 
151  // Constructors
152 
153  //- Inherit constructors
155 
156 
157  // Static Member Data
158 
159  //- Dimensions of the flux field
160  static const dimensionSet dimensions;
161 
162 
163  // Member Functions
164 
165  //- Return the flux contribution for a single particle
166  static scalar dPhiDeltaT(const typename CloudType::particleType& p)
167  {
168  return p.nParticle();
169  }
170 };
171 
172 
173 /*---------------------------------------------------------------------------*\
174  Class VolumeFlux Declaration
175 \*---------------------------------------------------------------------------*/
176 
177 template<class CloudType>
178 class VolumeFlux
179 :
180  public Flux<CloudType, VolumeFlux<CloudType>>
181 {
182 public:
183 
184  //- Runtime type information
185  TypeName("volumeFlux");
186 
187 
188  // Constructors
189 
190  //- Inherit constructors
192 
193 
194  // Static Member Data
195 
196  //- Dimensions of the flux field
197  static const dimensionSet dimensions;
198 
199 
200  // Member Functions
201 
202  //- Return the flux contribution for a single particle
203  static scalar dPhiDeltaT(const typename CloudType::particleType& p)
204  {
205  return p.nParticle()*p.volume();
206  }
207 };
208 
209 
210 /*---------------------------------------------------------------------------*\
211  Class MassFlux Declaration
212 \*---------------------------------------------------------------------------*/
213 
214 template<class CloudType>
215 class MassFlux
216 :
217  public Flux<CloudType, MassFlux<CloudType>>
218 {
219 public:
220 
221  //- Runtime type information
222  TypeName("massFlux");
223 
224 
225  // Constructors
226 
227  //- Inherit constructors
229 
230 
231  // Static Member Data
232 
233  //- Dimensions of the flux field
234  static const dimensionSet dimensions;
235 
236 
237  // Member Functions
238 
239  //- Return the flux contribution for a single particle
240  static scalar dPhiDeltaT(const typename CloudType::particleType& p)
241  {
242  return p.nParticle()*p.mass();
243  }
244 };
245 
246 
247 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
248 
249 } // End namespace Foam
250 
251 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
252 
253 #ifdef NoRepository
254  #include "Flux.C"
255 #endif
256 
257 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
258 
259 #endif
260 
261 // ************************************************************************* //
Templated cloud function object base class.
const CloudType & owner() const
Return const access to the owner cloud.
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:64
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:107
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:233
TypeName("massFlux")
Runtime type information.
static scalar dPhiDeltaT(const typename CloudType::particleType &p)
Return the flux contribution for a single particle.
Definition: Flux.H:239
static const dimensionSet dimensions
Dimensions of the flux field.
Definition: Flux.H:159
static scalar dPhiDeltaT(const typename CloudType::particleType &p)
Return the flux contribution for a single particle.
Definition: Flux.H:165
TypeName("numberFlux")
Runtime type information.
static const dimensionSet dimensions
Dimensions of the flux field.
Definition: Flux.H:196
TypeName("volumeFlux")
Runtime type information.
static scalar dPhiDeltaT(const typename CloudType::particleType &p)
Return the flux contribution for a single particle.
Definition: Flux.H:202
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 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
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.