FreeFOAM The Cross-Platform CFD Toolkit
KinematicCloud_.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
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 "KinematicCloud_.H"
29 
35 
36 // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
37 
38 template<class ParcelType>
40 {
41  this->dispersion().cacheFields(true);
42  forces_.cacheFields(true);
43 }
44 
45 
46 template<class ParcelType>
48 {
49  autoPtr<interpolation<scalar> > rhoInterpolator =
51  (
52  interpolationSchemes_,
53  rho_
54  );
55 
56  autoPtr<interpolation<vector> > UInterpolator =
58  (
59  interpolationSchemes_,
60  U_
61  );
62 
63  autoPtr<interpolation<scalar> > muInterpolator =
65  (
66  interpolationSchemes_,
67  mu_
68  );
69 
70  typename ParcelType::trackData td
71  (
72  *this,
73  constProps_,
74  rhoInterpolator(),
75  UInterpolator(),
76  muInterpolator(),
77  g_.value()
78  );
79 
80  this->injection().inject(td);
81 
82  if (coupled_)
83  {
84  resetSourceTerms();
85  }
86 
88 }
89 
90 
91 template<class ParcelType>
93 {
94  if (debug)
95  {
96  this->writePositions();
97  }
98 
99  this->dispersion().cacheFields(false);
100  forces_.cacheFields(false);
101 
102  this->postProcessing().post();
103 }
104 
105 
106 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
107 
108 template<class ParcelType>
110 (
111  const word& cloudName,
112  const volScalarField& rho,
113  const volVectorField& U,
114  const volScalarField& mu,
115  const dimensionedVector& g,
116  bool readFields
117 )
118 :
119  Cloud<ParcelType>(rho.mesh(), cloudName, false),
120  kinematicCloud(),
121  mesh_(rho.mesh()),
122  particleProperties_
123  (
124  IOobject
125  (
126  cloudName + "Properties",
127  rho.mesh().time().constant(),
128  rho.mesh(),
129  IOobject::MUST_READ,
130  IOobject::NO_WRITE
131  )
132  ),
133  constProps_(particleProperties_),
134  active_(particleProperties_.lookup("active")),
135  parcelTypeId_(readLabel(particleProperties_.lookup("parcelTypeId"))),
136  coupled_(particleProperties_.lookup("coupled")),
137  cellValueSourceCorrection_
138  (
139  particleProperties_.lookup("cellValueSourceCorrection")
140  ),
141  rndGen_(label(0)),
142  rho_(rho),
143  U_(U),
144  mu_(mu),
145  g_(g),
146  forces_(mesh_, particleProperties_, g_.value()),
147  interpolationSchemes_(particleProperties_.subDict("interpolationSchemes")),
148  dispersionModel_
149  (
150  DispersionModel<KinematicCloud<ParcelType> >::New
151  (
152  particleProperties_,
153  *this
154  )
155  ),
156  dragModel_
157  (
158  DragModel<KinematicCloud<ParcelType> >::New
159  (
160  particleProperties_,
161  *this
162  )
163  ),
164  injectionModel_
165  (
166  InjectionModel<KinematicCloud<ParcelType> >::New
167  (
168  particleProperties_,
169  *this
170  )
171  ),
172  patchInteractionModel_
173  (
174  PatchInteractionModel<KinematicCloud<ParcelType> >::New
175  (
176  particleProperties_,
177  *this
178  )
179  ),
180  postProcessingModel_
181  (
182  PostProcessingModel<KinematicCloud<ParcelType> >::New
183  (
184  this->particleProperties_,
185  *this
186  )
187  ),
188  UIntegrator_
189  (
191  (
192  "U",
193  particleProperties_.subDict("integrationSchemes")
194  )
195  ),
196  UTrans_
197  (
198  IOobject
199  (
200  this->name() + "UTrans",
201  this->db().time().timeName(),
202  this->db(),
203  IOobject::NO_READ,
204  IOobject::NO_WRITE,
205  false
206  ),
207  mesh_,
209  )
210 {
211  if (readFields)
212  {
213  ParcelType::readFields(*this);
214  }
215 }
216 
217 
218 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
219 
220 template<class ParcelType>
222 {}
223 
224 
225 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
226 
227 template<class ParcelType>
229 (
230  ParcelType& parcel,
231  const scalar lagrangianDt,
232  const bool fullyDescribed
233 )
234 {
235  if (!fullyDescribed)
236  {
237  parcel.rho() = constProps_.rho0();
238  }
239 
240  scalar carrierDt = this->db().time().deltaTValue();
241  parcel.stepFraction() = (carrierDt - lagrangianDt)/carrierDt;
242 }
243 
244 
245 template<class ParcelType>
247 {
248  UTrans_.field() = vector::zero;
249 }
250 
251 
252 template<class ParcelType>
254 {
255  if (active_)
256  {
257  preEvolve();
258 
259  evolveCloud();
260 
261  postEvolve();
262 
263  info();
264  Info<< endl;
265  }
266 }
267 
268 
269 template<class ParcelType>
271 {
272  Info<< "Cloud: " << this->name() << nl
273  << " Total number of parcels added = "
274  << this->injection().parcelsAddedTotal() << nl
275  << " Total mass introduced = "
276  << this->injection().massInjected() << nl
277  << " Current number of parcels = "
278  << returnReduce(this->size(), sumOp<label>()) << nl
279  << " Current mass in system = "
280  << returnReduce(massInSystem(), sumOp<scalar>()) << nl;
281 }
282 
283 
284 // ************************ vim: set sw=4 sts=4 et: ************************ //