FreeFOAM The Cross-Platform CFD Toolkit
trackedParticle.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 
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
30 //- Construct from components
32 (
33  const Cloud<trackedParticle>& c,
34  const vector& position,
35  const label celli,
36  const point& end,
37  const label level,
38  const label i,
39  const label j
40 )
41 :
42  ExactParticle<trackedParticle>(c, position, celli),
43  end_(end),
44  level_(level),
45  i_(i),
46  j_(j)
47 {}
48 
49 
50 //- Construct from Istream
52 (
53  const Cloud<trackedParticle>& c,
54  Istream& is,
55  bool readFields
56 )
57 :
59 {
60  if (readFields)
61  {
62  if (is.format() == IOstream::ASCII)
63  {
64  is >> end_;
65  level_ = readLabel(is);
66  i_ = readLabel(is);
67  j_ = readLabel(is);
68  }
69  else
70  {
71  is.read
72  (
73  reinterpret_cast<char*>(&end_),
74  sizeof(end_) + sizeof(level_) + sizeof(i_) + sizeof(j_)
75  );
76  }
77  }
78 
79  // Check state of Istream
80  is.check
81  (
82  "trackedParticle::trackedParticle"
83  "(const Cloud<trackedParticle>&, Istream&, bool)"
84  );
85 }
86 
87 
88 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
89 
91 {
92  td.switchProcessor = false;
93  td.keepParticle = true;
94 
95  scalar deltaT = cloud().pMesh().time().deltaT().value();
96  scalar tEnd = (1.0 - stepFraction())*deltaT;
97  scalar dtMax = tEnd;
98 
99  while (td.keepParticle && !td.switchProcessor && tEnd > SMALL)
100  {
101  // set the lagrangian time-step
102  scalar dt = min(dtMax, tEnd);
103 
104  // mark visited cell with max level.
105  td.maxLevel()[cell()] = max(td.maxLevel()[cell()], level_);
106 
107  dt *= trackToFace(end_, td);
108 
109  tEnd -= dt;
110  stepFraction() = 1.0 - tEnd/deltaT;
111  }
112 
113  return td.keepParticle;
114 }
115 
116 
118 (
119  const polyPatch&,
121  const label patchI
122 )
123 {
124  return false;
125 }
126 
127 
129 (
130  const polyPatch&,
131  int&,
132  const label
133 )
134 {
135  return false;
136 }
137 
138 
140 (
141  const wedgePolyPatch&,
143 )
144 {
145  // Remove particle
146  td.keepParticle = false;
147 }
148 
149 
151 (
152  const wedgePolyPatch&,
153  int&
154 )
155 {}
156 
157 
159 (
160  const symmetryPolyPatch&,
162 )
163 {
164  // Remove particle
165  td.keepParticle = false;
166 }
167 
168 
170 (
171  const symmetryPolyPatch&,
172  int&
173 )
174 {}
175 
176 
178 (
179  const cyclicPolyPatch&,
181 )
182 {
183  // Remove particle
184  td.keepParticle = false;
185 }
186 
187 
189 (
190  const cyclicPolyPatch&,
191  int&
192 )
193 {}
194 
195 
197 (
198  const processorPolyPatch&,
200 )
201 {
202  // Remove particle
203  td.switchProcessor = true;
204 }
205 
206 
208 (
209  const processorPolyPatch&,
210  int&
211 )
212 {}
213 
214 
216 (
217  const wallPolyPatch& wpp,
219 )
220 {
221  // Remove particle
222  td.keepParticle = false;
223 }
224 
225 
227 (
228  const wallPolyPatch& wpp,
229  int&
230 )
231 {}
232 
233 
235 (
236  const polyPatch& wpp,
238 )
239 {
240  // Remove particle
241  td.keepParticle = false;
242 }
243 
244 
246 (
247  const polyPatch& wpp,
248  int&
249 )
250 {}
251 
252 
253 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
254 
256 {
257  if (os.format() == IOstream::ASCII)
258  {
259  os << static_cast<const ExactParticle<trackedParticle>&>(p)
260  << token::SPACE << p.end_
261  << token::SPACE << p.level_
262  << token::SPACE << p.i_
263  << token::SPACE << p.j_;
264  }
265  else
266  {
267  os << static_cast<const ExactParticle<trackedParticle>&>(p);
268  os.write
269  (
270  reinterpret_cast<const char*>(&p.end_),
271  sizeof(p.end_) + sizeof(p.level_) + sizeof(p.i_) + sizeof(p.j_)
272  );
273  }
274 
275  // Check state of Ostream
276  os.check("Ostream& operator<<(Ostream&, const trackedParticle&)");
277 
278  return os;
279 }
280 
281 
282 // ************************ vim: set sw=4 sts=4 et: ************************ //