fixed writing out entries in advective bc
[OpenFOAM-1.6-ext.git] / src / autoMesh / autoHexMesh / trackedParticle / trackedParticle.C
blob04ba7d0edba5a2f69b4560ae5d30ec2c15965326
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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,
36     const label celli,
37     const point& end,
38     const label level,
39     const label i,
40     const label j
43     ExactParticle<trackedParticle>(c, position, celli),
44     end_(end),
45     level_(level),
46     i_(i),
47     j_(j)
51 //- Construct from Istream
52 Foam::trackedParticle::trackedParticle
54     const Cloud<trackedParticle>& c,
55     Istream& is,
56     bool readFields
59     ExactParticle<trackedParticle>(c, is, readFields)
61     if (readFields)
62     {
63         if (is.format() == IOstream::ASCII)
64         {
65             is >> end_;
66             level_ = readLabel(is);
67             i_ = readLabel(is);
68             j_ = readLabel(is);
69         }
70         else
71         {
72             is.read
73             (
74                 reinterpret_cast<char*>(&end_),
75                 sizeof(end_) + sizeof(level_) + sizeof(i_) + sizeof(j_)
76             );
77         }
78     }
80     // Check state of Istream
81     is.check
82     (
83         "trackedParticle::trackedParticle"
84         "(const Cloud<trackedParticle>&, Istream&, bool)"
85     );
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;
98     scalar dtMax = tEnd;
100     while (td.keepParticle && !td.switchProcessor && tEnd > SMALL)
101     {
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);
110         tEnd -= dt;
111         stepFraction() = 1.0 - tEnd/deltaT;
112     }
114     return td.keepParticle;
118 bool Foam::trackedParticle::hitPatch
120     const polyPatch&,
121     trackedParticle::trackData& td,
122     const label patchI
125     return false;
129 bool Foam::trackedParticle::hitPatch
131     const polyPatch&,
132     int&,
133     const label
136     return false;
140 void Foam::trackedParticle::hitWedgePatch
142     const wedgePolyPatch&,
143     trackedParticle::trackData& td
146     // Remove particle
147     td.keepParticle = false;
151 void Foam::trackedParticle::hitWedgePatch
153     const wedgePolyPatch&,
154     int&
159 void Foam::trackedParticle::hitSymmetryPatch
161     const symmetryPolyPatch&,
162     trackedParticle::trackData& td
165     // Remove particle
166     td.keepParticle = false;
170 void Foam::trackedParticle::hitSymmetryPatch
172     const symmetryPolyPatch&,
173     int&
178 void Foam::trackedParticle::hitCyclicPatch
180     const cyclicPolyPatch&,
181     trackedParticle::trackData& td
184     // Remove particle
185     td.keepParticle = false;
189 void Foam::trackedParticle::hitCyclicPatch
191     const cyclicPolyPatch&,
192     int&
197 void Foam::trackedParticle::hitProcessorPatch
199     const processorPolyPatch&,
200     trackedParticle::trackData& td
203     // Remove particle
204     td.switchProcessor = true;
208 void Foam::trackedParticle::hitProcessorPatch
210     const processorPolyPatch&,
211     int&
216 void Foam::trackedParticle::hitWallPatch
218     const wallPolyPatch& wpp,
219     trackedParticle::trackData& td
222     // Remove particle
223     td.keepParticle = false;
227 void Foam::trackedParticle::hitWallPatch
229     const wallPolyPatch& wpp,
230     int&
235 void Foam::trackedParticle::hitPatch
237     const polyPatch& wpp,
238     trackedParticle::trackData& td
241     // Remove particle
242     td.keepParticle = false;
246 void Foam::trackedParticle::hitPatch
248     const polyPatch& wpp,
249     int&
254 // * * * * * * * * * * * * * * * IOstream Operators  * * * * * * * * * * * * //
256 Foam::Ostream& Foam::operator<<(Ostream& os, const trackedParticle& p)
258     if (os.format() == IOstream::ASCII)
259     {
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_;
265     }
266     else
267     {
268         os  << static_cast<const ExactParticle<trackedParticle>&>(p);
269         os.write
270         (
271             reinterpret_cast<const char*>(&p.end_),
272             sizeof(p.end_) + sizeof(p.level_) + sizeof(p.i_) + sizeof(p.j_)
273         );
274     }
276     // Check state of Ostream
277     os.check("Ostream& operator<<(Ostream&, const trackedParticle&)");
279     return os;
283 // ************************************************************************* //