FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

trackedParticle.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 \*----------------------------------------------------------------------------*/
00025 
00026 #include <autoMesh/trackedParticle.H>
00027 
00028 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00029 
00030 //- Construct from components
00031 Foam::trackedParticle::trackedParticle
00032 (
00033     const Cloud<trackedParticle>& c,
00034     const vector& position,
00035     const label celli,
00036     const point& end,
00037     const label level,
00038     const label i,
00039     const label j
00040 )
00041 :
00042     ExactParticle<trackedParticle>(c, position, celli),
00043     end_(end),
00044     level_(level),
00045     i_(i),
00046     j_(j)
00047 {}
00048 
00049 
00050 //- Construct from Istream
00051 Foam::trackedParticle::trackedParticle
00052 (
00053     const Cloud<trackedParticle>& c,
00054     Istream& is,
00055     bool readFields
00056 )
00057 :
00058     ExactParticle<trackedParticle>(c, is, readFields)
00059 {
00060     if (readFields)
00061     {
00062         if (is.format() == IOstream::ASCII)
00063         {
00064             is >> end_;
00065             level_ = readLabel(is);
00066             i_ = readLabel(is);
00067             j_ = readLabel(is);
00068         }
00069         else
00070         {
00071             is.read
00072             (
00073                 reinterpret_cast<char*>(&end_),
00074                 sizeof(end_) + sizeof(level_) + sizeof(i_) + sizeof(j_)
00075             );
00076         }
00077     }
00078 
00079     // Check state of Istream
00080     is.check
00081     (
00082         "trackedParticle::trackedParticle"
00083         "(const Cloud<trackedParticle>&, Istream&, bool)"
00084     );
00085 }
00086 
00087 
00088 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00089 
00090 bool Foam::trackedParticle::move(trackedParticle::trackData& td)
00091 {
00092     td.switchProcessor = false;
00093     td.keepParticle = true;
00094 
00095     scalar deltaT = cloud().pMesh().time().deltaT().value();
00096     scalar tEnd = (1.0 - stepFraction())*deltaT;
00097     scalar dtMax = tEnd;
00098 
00099     while (td.keepParticle && !td.switchProcessor && tEnd > SMALL)
00100     {
00101         // set the lagrangian time-step
00102         scalar dt = min(dtMax, tEnd);
00103 
00104         // mark visited cell with max level.
00105         td.maxLevel()[cell()] = max(td.maxLevel()[cell()], level_);
00106 
00107         dt *= trackToFace(end_, td);
00108 
00109         tEnd -= dt;
00110         stepFraction() = 1.0 - tEnd/deltaT;
00111     }
00112 
00113     return td.keepParticle;
00114 }
00115 
00116 
00117 bool Foam::trackedParticle::hitPatch
00118 (
00119     const polyPatch&,
00120     trackedParticle::trackData& td,
00121     const label patchI
00122 )
00123 {
00124     return false;
00125 }
00126 
00127 
00128 bool Foam::trackedParticle::hitPatch
00129 (
00130     const polyPatch&,
00131     int&,
00132     const label
00133 )
00134 {
00135     return false;
00136 }
00137 
00138 
00139 void Foam::trackedParticle::hitWedgePatch
00140 (
00141     const wedgePolyPatch&,
00142     trackedParticle::trackData& td
00143 )
00144 {
00145     // Remove particle
00146     td.keepParticle = false;
00147 }
00148 
00149 
00150 void Foam::trackedParticle::hitWedgePatch
00151 (
00152     const wedgePolyPatch&,
00153     int&
00154 )
00155 {}
00156 
00157 
00158 void Foam::trackedParticle::hitSymmetryPatch
00159 (
00160     const symmetryPolyPatch&,
00161     trackedParticle::trackData& td
00162 )
00163 {
00164     // Remove particle
00165     td.keepParticle = false;
00166 }
00167 
00168 
00169 void Foam::trackedParticle::hitSymmetryPatch
00170 (
00171     const symmetryPolyPatch&,
00172     int&
00173 )
00174 {}
00175 
00176 
00177 void Foam::trackedParticle::hitCyclicPatch
00178 (
00179     const cyclicPolyPatch&,
00180     trackedParticle::trackData& td
00181 )
00182 {
00183     // Remove particle
00184     td.keepParticle = false;
00185 }
00186 
00187 
00188 void Foam::trackedParticle::hitCyclicPatch
00189 (
00190     const cyclicPolyPatch&,
00191     int&
00192 )
00193 {}
00194 
00195 
00196 void Foam::trackedParticle::hitProcessorPatch
00197 (
00198     const processorPolyPatch&,
00199     trackedParticle::trackData& td
00200 )
00201 {
00202     // Remove particle
00203     td.switchProcessor = true;
00204 }
00205 
00206 
00207 void Foam::trackedParticle::hitProcessorPatch
00208 (
00209     const processorPolyPatch&,
00210     int&
00211 )
00212 {}
00213 
00214 
00215 void Foam::trackedParticle::hitWallPatch
00216 (
00217     const wallPolyPatch& wpp,
00218     trackedParticle::trackData& td
00219 )
00220 {
00221     // Remove particle
00222     td.keepParticle = false;
00223 }
00224 
00225 
00226 void Foam::trackedParticle::hitWallPatch
00227 (
00228     const wallPolyPatch& wpp,
00229     int&
00230 )
00231 {}
00232 
00233 
00234 void Foam::trackedParticle::hitPatch
00235 (
00236     const polyPatch& wpp,
00237     trackedParticle::trackData& td
00238 )
00239 {
00240     // Remove particle
00241     td.keepParticle = false;
00242 }
00243 
00244 
00245 void Foam::trackedParticle::hitPatch
00246 (
00247     const polyPatch& wpp,
00248     int&
00249 )
00250 {}
00251 
00252 
00253 // * * * * * * * * * * * * * * * IOstream Operators  * * * * * * * * * * * * //
00254 
00255 Foam::Ostream& Foam::operator<<(Ostream& os, const trackedParticle& p)
00256 {
00257     if (os.format() == IOstream::ASCII)
00258     {
00259         os  << static_cast<const ExactParticle<trackedParticle>&>(p)
00260             << token::SPACE << p.end_
00261             << token::SPACE << p.level_
00262             << token::SPACE << p.i_
00263             << token::SPACE << p.j_;
00264     }
00265     else
00266     {
00267         os  << static_cast<const ExactParticle<trackedParticle>&>(p);
00268         os.write
00269         (
00270             reinterpret_cast<const char*>(&p.end_),
00271             sizeof(p.end_) + sizeof(p.level_) + sizeof(p.i_) + sizeof(p.j_)
00272         );
00273     }
00274 
00275     // Check state of Ostream
00276     os.check("Ostream& operator<<(Ostream&, const trackedParticle&)");
00277 
00278     return os;
00279 }
00280 
00281 
00282 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines