1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*----------------------------------------------------------------------------*/
27 #include "trackedParticle.H"
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 //- Construct from components
32 Foam::trackedParticle::trackedParticle
34 const Cloud<trackedParticle>& c,
35 const vector& position,
43 ExactParticle<trackedParticle>(c, position, celli),
51 //- Construct from Istream
52 Foam::trackedParticle::trackedParticle
54 const Cloud<trackedParticle>& c,
59 ExactParticle<trackedParticle>(c, is, readFields)
63 if (is.format() == IOstream::ASCII)
66 level_ = readLabel(is);
74 reinterpret_cast<char*>(&end_),
75 sizeof(end_) + sizeof(level_) + sizeof(i_) + sizeof(j_)
80 // Check state of Istream
83 "trackedParticle::trackedParticle"
84 "(const Cloud<trackedParticle>&, Istream&, bool)"
89 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
91 bool Foam::trackedParticle::move(trackedParticle::trackData& td)
93 td.switchProcessor = false;
94 td.keepParticle = true;
96 scalar deltaT = cloud().pMesh().time().deltaT().value();
97 scalar tEnd = (1.0 - stepFraction())*deltaT;
100 while (td.keepParticle && !td.switchProcessor && tEnd > SMALL)
102 // set the lagrangian time-step
103 scalar dt = min(dtMax, tEnd);
105 // mark visited cell with max level.
106 td.maxLevel()[cell()] = max(td.maxLevel()[cell()], level_);
108 dt *= trackToFace(end_, td);
111 stepFraction() = 1.0 - tEnd/deltaT;
114 return td.keepParticle;
118 bool Foam::trackedParticle::hitPatch
121 trackedParticle::trackData& td,
129 bool Foam::trackedParticle::hitPatch
140 void Foam::trackedParticle::hitWedgePatch
142 const wedgePolyPatch&,
143 trackedParticle::trackData& td
147 td.keepParticle = false;
151 void Foam::trackedParticle::hitWedgePatch
153 const wedgePolyPatch&,
159 void Foam::trackedParticle::hitSymmetryPatch
161 const symmetryPolyPatch&,
162 trackedParticle::trackData& td
166 td.keepParticle = false;
170 void Foam::trackedParticle::hitSymmetryPatch
172 const symmetryPolyPatch&,
178 void Foam::trackedParticle::hitCyclicPatch
180 const cyclicPolyPatch&,
181 trackedParticle::trackData& td
185 td.keepParticle = false;
189 void Foam::trackedParticle::hitCyclicPatch
191 const cyclicPolyPatch&,
197 void Foam::trackedParticle::hitProcessorPatch
199 const processorPolyPatch&,
200 trackedParticle::trackData& td
204 td.switchProcessor = true;
208 void Foam::trackedParticle::hitProcessorPatch
210 const processorPolyPatch&,
216 void Foam::trackedParticle::hitWallPatch
218 const wallPolyPatch& wpp,
219 trackedParticle::trackData& td
223 td.keepParticle = false;
227 void Foam::trackedParticle::hitWallPatch
229 const wallPolyPatch& wpp,
235 void Foam::trackedParticle::hitPatch
237 const polyPatch& wpp,
238 trackedParticle::trackData& td
242 td.keepParticle = false;
246 void Foam::trackedParticle::hitPatch
248 const polyPatch& wpp,
254 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
256 Foam::Ostream& Foam::operator<<(Ostream& os, const trackedParticle& p)
258 if (os.format() == IOstream::ASCII)
260 os << static_cast<const ExactParticle<trackedParticle>&>(p)
261 << token::SPACE << p.end_
262 << token::SPACE << p.level_
263 << token::SPACE << p.i_
264 << token::SPACE << p.j_;
268 os << static_cast<const ExactParticle<trackedParticle>&>(p);
271 reinterpret_cast<const char*>(&p.end_),
272 sizeof(p.end_) + sizeof(p.level_) + sizeof(p.i_) + sizeof(p.j_)
276 // Check state of Ostream
277 os.check("Ostream& operator<<(Ostream&, const trackedParticle&)");
283 // ************************************************************************* //