1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*----------------------------------------------------------------------------*/
26 #include "trackedParticle.H"
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 Foam::trackedParticle::trackedParticle
33 const vector& position,
43 particle(mesh, position, cellI, tetFaceI, tetPtI),
51 Foam::trackedParticle::trackedParticle
58 particle(mesh, is, readFields)
62 if (is.format() == IOstream::ASCII)
65 level_ = readLabel(is);
73 reinterpret_cast<char*>(&end_),
74 sizeof(end_) + sizeof(level_) + sizeof(i_) + sizeof(j_)
79 // Check state of Istream
82 "trackedParticle::trackedParticle"
83 "(const Cloud<trackedParticle>&, Istream&, bool)"
88 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
90 bool Foam::trackedParticle::move
93 const scalar trackedParticle
96 td.switchProcessor = false;
97 td.keepParticle = true;
99 scalar tEnd = (1.0 - stepFraction())*trackedParticle;
102 while (td.keepParticle && !td.switchProcessor && tEnd > SMALL)
104 // set the lagrangian time-step
105 scalar dt = min(dtMax, tEnd);
107 // mark visited cell with max level.
108 td.maxLevel()[cell()] = max(td.maxLevel()[cell()], level_);
110 dt *= trackToFace(end_, td);
113 stepFraction() = 1.0 - tEnd/trackedParticle;
116 return td.keepParticle;
120 bool Foam::trackedParticle::hitPatch
125 const scalar trackFraction,
126 const tetIndices& tetIs
133 void Foam::trackedParticle::hitWedgePatch
135 const wedgePolyPatch&,
140 td.keepParticle = false;
144 void Foam::trackedParticle::hitSymmetryPatch
146 const symmetryPolyPatch&,
151 td.keepParticle = false;
155 void Foam::trackedParticle::hitCyclicPatch
157 const cyclicPolyPatch&,
162 td.keepParticle = false;
166 void Foam::trackedParticle::hitProcessorPatch
168 const processorPolyPatch&,
173 td.switchProcessor = true;
177 void Foam::trackedParticle::hitWallPatch
179 const wallPolyPatch& wpp,
185 td.keepParticle = false;
189 void Foam::trackedParticle::hitPatch
191 const polyPatch& wpp,
196 td.keepParticle = false;
200 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
202 Foam::Ostream& Foam::operator<<(Ostream& os, const trackedParticle& p)
204 if (os.format() == IOstream::ASCII)
206 os << static_cast<const particle&>(p)
207 << token::SPACE << p.end_
208 << token::SPACE << p.level_
209 << token::SPACE << p.i_
210 << token::SPACE << p.j_;
214 os << static_cast<const particle&>(p);
217 reinterpret_cast<const char*>(&p.end_),
218 sizeof(p.end_) + sizeof(p.level_) + sizeof(p.i_) + sizeof(p.j_)
222 // Check state of Ostream
223 os.check("Ostream& operator<<(Ostream&, const trackedParticle&)");
229 // ************************************************************************* //