PatchCollisionDensity.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) 2018-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 \*---------------------------------------------------------------------------*/
25 
26 #include "PatchCollisionDensity.H"
27 #include "Pstream.H"
28 #include "stringListOps.H"
29 #include "ListOps.H"
30 #include "ListListOps.H"
31 
32 // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
33 
34 template<class CloudType>
36 {
37  const scalarField z(this->owner().mesh().nCells(), 0);
38 
40  (
41  IOobject
42  (
43  this->owner().name() + ":numberCollisionDensity",
44  this->owner().mesh().time().timeName(),
45  this->owner().mesh()
46  ),
47  this->owner().mesh(),
49  z,
50  numberCollisionDensity_
51  )
52  .write();
53 
55  (
56  IOobject
57  (
58  this->owner().name() + ":numberCollisionDensityRate",
59  this->owner().mesh().time().timeName(),
60  this->owner().mesh()
61  ),
62  this->owner().mesh(),
64  z,
65  (numberCollisionDensity_ - numberCollisionDensity0_)
66  /(this->owner().mesh().time().value() - time0_)
67  )
68  .write();
69 
71  (
72  IOobject
73  (
74  this->owner().name() + ":massCollisionDensity",
75  this->owner().mesh().time().timeName(),
76  this->owner().mesh()
77  ),
78  this->owner().mesh(),
80  z,
81  massCollisionDensity_
82  )
83  .write();
84 
86  (
87  IOobject
88  (
89  this->owner().name() + ":massCollisionDensityRate",
90  this->owner().mesh().time().timeName(),
91  this->owner().mesh()
92  ),
93  this->owner().mesh(),
95  z,
96  (massCollisionDensity_ - massCollisionDensity0_)
97  /(this->owner().mesh().time().value() - time0_)
98  )
99  .write();
100 
101  numberCollisionDensity0_ == numberCollisionDensity_;
102  massCollisionDensity0_ == massCollisionDensity_;
103  time0_ = this->owner().mesh().time().value();
104 }
105 
106 
107 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
108 
109 template<class CloudType>
111 (
112  const dictionary& dict,
113  CloudType& owner,
114  const word& modelName
115 )
116 :
117  CloudFunctionObject<CloudType>(dict, owner, modelName, typeName),
118  minSpeed_(dict.lookupOrDefault<scalar>("minSpeed", -1)),
119  numberCollisionDensity_
120  (
121  this->owner().mesh().boundary(),
122  volScalarField::Internal::null(),
124  ),
125  numberCollisionDensity0_
126  (
127  this->owner().mesh().boundary(),
128  volScalarField::Internal::null(),
130  ),
131  massCollisionDensity_
132  (
133  this->owner().mesh().boundary(),
134  volScalarField::Internal::null(),
136  ),
137  massCollisionDensity0_
138  (
139  this->owner().mesh().boundary(),
140  volScalarField::Internal::null(),
142  ),
143  time0_(this->owner().mesh().time().value())
144 {
145  numberCollisionDensity_ == 0;
146  numberCollisionDensity0_ == 0;
147  massCollisionDensity_ == 0;
148  massCollisionDensity0_ == 0;
149 
151  (
152  this->owner().name() + ":numberCollisionDensity",
153  this->owner().mesh().time().timeName(),
154  this->owner().mesh(),
155  IOobject::MUST_READ,
156  IOobject::NO_WRITE
157  );
158 
159  if (numberIo.headerOk())
160  {
161  const volScalarField numberCollisionDensity
162  (
163  numberIo,
164  this->owner().mesh()
165  );
166  numberCollisionDensity_ == numberCollisionDensity.boundaryField();
167  numberCollisionDensity0_ == numberCollisionDensity.boundaryField();
168  }
169 
171  (
172  this->owner().name() + ":massCollisionDensity",
173  this->owner().mesh().time().timeName(),
174  this->owner().mesh(),
175  IOobject::MUST_READ,
176  IOobject::NO_WRITE
177  );
178 
179  if (massIo.headerOk())
180  {
181  const volScalarField massCollisionDensity
182  (
183  massIo,
184  this->owner().mesh()
185  );
186  massCollisionDensity_ == massCollisionDensity.boundaryField();
187  massCollisionDensity0_ == massCollisionDensity.boundaryField();
188  }
189 }
190 
191 
192 template<class CloudType>
194 (
196 )
197 :
199  minSpeed_(ppm.minSpeed_),
200  numberCollisionDensity_
201  (
202  volScalarField::Internal::null(),
203  ppm.numberCollisionDensity_
204  ),
205  numberCollisionDensity0_
206  (
207  volScalarField::Internal::null(),
208  ppm.numberCollisionDensity0_
209  ),
210  massCollisionDensity_
211  (
212  volScalarField::Internal::null(),
213  ppm.massCollisionDensity_
214  ),
215  massCollisionDensity0_
216  (
217  volScalarField::Internal::null(),
218  ppm.massCollisionDensity0_
219  ),
220  time0_(ppm.time0_)
221 {}
222 
223 
224 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
225 
226 template<class CloudType>
228 {}
229 
230 
231 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
232 
233 template<class CloudType>
235 (
236  const parcelType& p,
237  const polyPatch& pp,
238  bool&
239 )
240 {
241  const label patchi = pp.index();
242  const label patchFacei = p.face() - pp.start();
243 
244  vector nw, Up;
245  this->owner().patchData(p, pp, nw, Up);
246 
247  const scalar speed = (p.U() - Up) & nw;
248  if (speed > minSpeed_)
249  {
250  const scalar magSf =
251  this->owner().mesh().magSf().boundaryField()[patchi][patchFacei];
252  numberCollisionDensity_[patchi][patchFacei] += 1/magSf;
253  massCollisionDensity_[patchi][patchFacei] +=
254  p.mass()*p.nParticle()/magSf;
255  }
256 }
257 
258 
259 // ************************************************************************* //
dictionary dict
const dimensionSet dimArea
bool headerOk()
Read header (uses typeGlobalFile to find file) and check.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
const Boundary & boundaryField() const
Return const-reference to the boundary field.
Templated form of IOobject providing type information for file reading and header type checking...
Definition: IOobject.H:537
const dimensionSet dimless
Operations on lists of strings.
fvMesh & mesh
void write()
Write post-processing info.
Various functions to operate on Lists.
virtual ~PatchCollisionDensity()
Destructor.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:58
const dimensionSet dimTime
A class for handling words, derived from string.
Definition: word.H:59
This boundary condition is not designed to be evaluated; it is assumed that the value is assigned via...
word timeName
Definition: getTimeIndex.H:3
virtual void postPatch(const parcelType &p, const polyPatch &pp, bool &keepParticle)
Post-patch hook.
const dimensionSet dimMass
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
label patchi
Function object which generates fields of the number and mass and rates thereof of collisions per uni...
label index() const
Return the index of this patch in the boundaryMesh.
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:306
virtual bool write(const bool write=true) const
Write using setting from DB.
PatchCollisionDensity(const dictionary &dict, CloudType &owner, const word &modelName)
Construct from dictionary.
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:98
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:75
Templated cloud function object base class.
label nw
Definition: createFields.H:12