OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

DsmcParcel.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) 2009-2009 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 the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     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, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "DsmcParcel.H"
00028 #include "dimensionedConstants.H"
00029 
00030 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00031 
00032 template<class ParcelType>
00033 template<class TrackData>
00034 bool Foam::DsmcParcel<ParcelType>::move
00035 (
00036     TrackData& td
00037 )
00038 {
00039     ParcelType& p = static_cast<ParcelType&>(*this);
00040 
00041     td.switchProcessor = false;
00042     td.keepParticle = true;
00043 
00044     const polyMesh& mesh = td.cloud().pMesh();
00045     const polyBoundaryMesh& pbMesh = mesh.boundaryMesh();
00046 
00047     const scalar deltaT = td.cloud().cachedDeltaT();
00048     scalar tEnd = (1.0 - p.stepFraction())*deltaT;
00049     const scalar dtMax = tEnd;
00050 
00051     while (td.keepParticle && !td.switchProcessor && tEnd > ROOTVSMALL)
00052     {
00053         // Set the Lagrangian time-step
00054         scalar dt = min(dtMax, tEnd);
00055 
00056         dt *= p.trackToFace(p.position() + dt*U_, td);
00057 
00058         tEnd -= dt;
00059 
00060         p.stepFraction() = 1.0 - tEnd/deltaT;
00061 
00062         if (p.onBoundary() && td.keepParticle)
00063         {
00064             if (isType<processorPolyPatch>(pbMesh[p.patch(p.face())]))
00065             {
00066                 td.switchProcessor = true;
00067             }
00068         }
00069     }
00070 
00071     return td.keepParticle;
00072 }
00073 
00074 
00075 template<class ParcelType>
00076 template<class TrackData>
00077 bool Foam::DsmcParcel<ParcelType>::hitPatch
00078 (
00079     const polyPatch&,
00080     TrackData& td,
00081     const label patchI
00082 )
00083 {
00084     return false;
00085 }
00086 
00087 
00088 template<class ParcelType>
00089 template<class TrackData>
00090 void Foam::DsmcParcel<ParcelType>::hitProcessorPatch
00091 (
00092     const processorPolyPatch&,
00093     TrackData& td
00094 )
00095 {
00096     td.switchProcessor = true;
00097 }
00098 
00099 
00100 template<class ParcelType>
00101 void Foam::DsmcParcel<ParcelType>::hitProcessorPatch
00102 (
00103     const processorPolyPatch&,
00104     int&
00105 )
00106 {}
00107 
00108 
00109 template<class ParcelType>
00110 template<class TrackData>
00111 void Foam::DsmcParcel<ParcelType>::hitWallPatch
00112 (
00113     const wallPolyPatch& wpp,
00114     TrackData& td
00115 )
00116 {
00117     const constantProperties& constProps(td.cloud().constProps(typeId_));
00118 
00119     scalar m = constProps.mass();
00120 
00121     // pre-interaction energy
00122     scalar preIE = 0.5*m*(U_ & U_) + Ei_;
00123 
00124     // pre-interaction momentum
00125     vector preIMom = m*U_;
00126 
00127     td.cloud().wallInteraction().correct
00128     (
00129         wpp,
00130         this->face(),
00131         U_,
00132         Ei_,
00133         typeId_
00134     );
00135 
00136     // post-interaction energy
00137     scalar postIE = 0.5*m*(U_ & U_) + Ei_;
00138 
00139     // post-interaction momentum
00140     vector postIMom = m*U_;
00141 
00142     label wppIndex = wpp.index();
00143 
00144     label wppLocalFace = wpp.whichFace(this->face());
00145 
00146     const scalar fA = mag(wpp.faceAreas()[wppLocalFace]);
00147 
00148     const scalar deltaT = td.cloud().cachedDeltaT();
00149 
00150     scalar deltaQ = td.cloud().nParticle()*(preIE - postIE)/(deltaT*fA);
00151 
00152     vector deltaFD = td.cloud().nParticle()*(preIMom - postIMom)/(deltaT*fA);
00153 
00154     td.cloud().q().boundaryField()[wppIndex][wppLocalFace] += deltaQ;
00155 
00156     td.cloud().fD().boundaryField()[wppIndex][wppLocalFace] += deltaFD;
00157 }
00158 
00159 
00160 template<class ParcelType>
00161 void Foam::DsmcParcel<ParcelType>::hitWallPatch
00162 (
00163     const wallPolyPatch&,
00164     int&
00165 )
00166 {}
00167 
00168 
00169 template<class ParcelType>
00170 template<class TrackData>
00171 void Foam::DsmcParcel<ParcelType>::hitPatch
00172 (
00173     const polyPatch&,
00174     TrackData& td
00175 )
00176 {
00177     td.keepParticle = false;
00178 }
00179 
00180 
00181 template<class ParcelType>
00182 void Foam::DsmcParcel<ParcelType>::hitPatch
00183 (
00184     const polyPatch&,
00185     int&
00186 )
00187 {}
00188 
00189 
00190 template<class ParcelType>
00191 void Foam::DsmcParcel<ParcelType>::transformProperties
00192 (
00193     const tensor& T
00194 )
00195 {
00196     Particle<ParcelType>::transformProperties(T);
00197     U_ = transform(T, U_);
00198 }
00199 
00200 
00201 template<class ParcelType>
00202 void Foam::DsmcParcel<ParcelType>::transformProperties
00203 (
00204     const vector& separation
00205 )
00206 {
00207     Particle<ParcelType>::transformProperties(separation);
00208 }
00209 
00210 
00211 // * * * * * * * * * * * * * * * *  IOStream operators * * * * * * * * * * * //
00212 
00213 #include "DsmcParcelIO.C"
00214 
00215 // ************************************************************************* //
00216 
Copyright © 2000-2009 OpenCFD Ltd