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

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-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 "DsmcParcel_.H"
00027 #include <meshTools/meshTools.H>
00028 
00029 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00030 
00031 template<class ParcelType>
00032 template<class TrackData>
00033 bool Foam::DsmcParcel<ParcelType>::move
00034 (
00035     TrackData& td
00036 )
00037 {
00038     ParcelType& p = static_cast<ParcelType&>(*this);
00039 
00040     td.switchProcessor = false;
00041     td.keepParticle = true;
00042 
00043     const polyMesh& mesh = td.cloud().pMesh();
00044     const polyBoundaryMesh& pbMesh = mesh.boundaryMesh();
00045 
00046     const scalar deltaT = mesh.time().deltaTValue();
00047     scalar tEnd = (1.0 - p.stepFraction())*deltaT;
00048     const scalar dtMax = tEnd;
00049 
00050     // For reduced-D cases, the velocity used to track needs to be
00051     // constrained, but the actual U_ of the parcel must not be
00052     // altered or used, as it is altered by patch interactions an
00053     // needs to retain its 3D value for collision purposes.
00054     vector Utracking = U_;
00055 
00056     while (td.keepParticle && !td.switchProcessor && tEnd > ROOTVSMALL)
00057     {
00058         // Apply correction to position for reduced-D cases
00059         meshTools::constrainToMeshCentre(mesh, p.position());
00060 
00061         Utracking = U_;
00062 
00063         // Apply correction to velocity to constrain tracking for
00064         // reduced-D cases
00065         meshTools::constrainDirection(mesh, mesh.solutionD(), Utracking);
00066 
00067         // Set the Lagrangian time-step
00068         scalar dt = min(dtMax, tEnd);
00069 
00070         dt *= p.trackToFace(p.position() + dt*Utracking, td);
00071 
00072         tEnd -= dt;
00073 
00074         p.stepFraction() = 1.0 - tEnd/deltaT;
00075 
00076         if (p.onBoundary() && td.keepParticle)
00077         {
00078             if (isA<processorPolyPatch>(pbMesh[p.patch(p.face())]))
00079             {
00080                 td.switchProcessor = true;
00081             }
00082         }
00083     }
00084 
00085     return td.keepParticle;
00086 }
00087 
00088 
00089 template<class ParcelType>
00090 template<class TrackData>
00091 bool Foam::DsmcParcel<ParcelType>::hitPatch
00092 (
00093     const polyPatch&,
00094     TrackData& td,
00095     const label patchI
00096 )
00097 {
00098     return false;
00099 }
00100 
00101 
00102 template<class ParcelType>
00103 template<class TrackData>
00104 void Foam::DsmcParcel<ParcelType>::hitProcessorPatch
00105 (
00106     const processorPolyPatch&,
00107     TrackData& td
00108 )
00109 {
00110     td.switchProcessor = true;
00111 }
00112 
00113 
00114 template<class ParcelType>
00115 void Foam::DsmcParcel<ParcelType>::hitProcessorPatch
00116 (
00117     const processorPolyPatch&,
00118     int&
00119 )
00120 {}
00121 
00122 
00123 template<class ParcelType>
00124 template<class TrackData>
00125 void Foam::DsmcParcel<ParcelType>::hitWallPatch
00126 (
00127     const wallPolyPatch& wpp,
00128     TrackData& td
00129 )
00130 {
00131     label wppIndex = wpp.index();
00132 
00133     label wppLocalFace = wpp.whichFace(this->face());
00134 
00135     const scalar fA = mag(wpp.faceAreas()[wppLocalFace]);
00136 
00137     const scalar deltaT = td.cloud().pMesh().time().deltaTValue();
00138 
00139     const constantProperties& constProps(td.cloud().constProps(typeId_));
00140 
00141     scalar m = constProps.mass();
00142 
00143     vector nw = wpp.faceAreas()[wppLocalFace];
00144     nw /= mag(nw);
00145 
00146     scalar U_dot_nw = U_ & nw;
00147 
00148     vector Ut = U_ - U_dot_nw*nw;
00149 
00150     scalar invMagUnfA = 1/max(mag(U_dot_nw)*fA, VSMALL);
00151 
00152     td.cloud().rhoNBF()[wppIndex][wppLocalFace] += invMagUnfA;
00153 
00154     td.cloud().rhoMBF()[wppIndex][wppLocalFace] += m*invMagUnfA;
00155 
00156     td.cloud().linearKEBF()[wppIndex][wppLocalFace] +=
00157         0.5*m*(U_ & U_)*invMagUnfA;
00158 
00159     td.cloud().internalEBF()[wppIndex][wppLocalFace] += Ei_*invMagUnfA;
00160 
00161     td.cloud().iDofBF()[wppIndex][wppLocalFace] +=
00162         constProps.internalDegreesOfFreedom()*invMagUnfA;
00163 
00164     td.cloud().momentumBF()[wppIndex][wppLocalFace] += m*Ut*invMagUnfA;
00165 
00166     // pre-interaction energy
00167     scalar preIE = 0.5*m*(U_ & U_) + Ei_;
00168 
00169     // pre-interaction momentum
00170     vector preIMom = m*U_;
00171 
00172     td.cloud().wallInteraction().correct
00173     (
00174         wpp,
00175         this->face(),
00176         U_,
00177         Ei_,
00178         typeId_
00179     );
00180 
00181     U_dot_nw = U_ & nw;
00182 
00183     Ut = U_ - U_dot_nw*nw;
00184 
00185     invMagUnfA = 1/max(mag(U_dot_nw)*fA, VSMALL);
00186 
00187     td.cloud().rhoNBF()[wppIndex][wppLocalFace] += invMagUnfA;
00188 
00189     td.cloud().rhoMBF()[wppIndex][wppLocalFace] += m*invMagUnfA;
00190 
00191     td.cloud().linearKEBF()[wppIndex][wppLocalFace] +=
00192         0.5*m*(U_ & U_)*invMagUnfA;
00193 
00194     td.cloud().internalEBF()[wppIndex][wppLocalFace] += Ei_*invMagUnfA;
00195 
00196     td.cloud().iDofBF()[wppIndex][wppLocalFace] +=
00197         constProps.internalDegreesOfFreedom()*invMagUnfA;
00198 
00199     td.cloud().momentumBF()[wppIndex][wppLocalFace] += m*Ut*invMagUnfA;
00200 
00201     // post-interaction energy
00202     scalar postIE = 0.5*m*(U_ & U_) + Ei_;
00203 
00204     // post-interaction momentum
00205     vector postIMom = m*U_;
00206 
00207     scalar deltaQ = td.cloud().nParticle()*(preIE - postIE)/(deltaT*fA);
00208 
00209     vector deltaFD = td.cloud().nParticle()*(preIMom - postIMom)/(deltaT*fA);
00210 
00211     td.cloud().qBF()[wppIndex][wppLocalFace] += deltaQ;
00212 
00213     td.cloud().fDBF()[wppIndex][wppLocalFace] += deltaFD;
00214 
00215 }
00216 
00217 
00218 template<class ParcelType>
00219 void Foam::DsmcParcel<ParcelType>::hitWallPatch
00220 (
00221     const wallPolyPatch&,
00222     int&
00223 )
00224 {}
00225 
00226 
00227 template<class ParcelType>
00228 template<class TrackData>
00229 void Foam::DsmcParcel<ParcelType>::hitPatch
00230 (
00231     const polyPatch&,
00232     TrackData& td
00233 )
00234 {
00235     td.keepParticle = false;
00236 }
00237 
00238 
00239 template<class ParcelType>
00240 void Foam::DsmcParcel<ParcelType>::hitPatch
00241 (
00242     const polyPatch&,
00243     int&
00244 )
00245 {}
00246 
00247 
00248 template<class ParcelType>
00249 void Foam::DsmcParcel<ParcelType>::transformProperties
00250 (
00251     const tensor& T
00252 )
00253 {
00254     Particle<ParcelType>::transformProperties(T);
00255     U_ = transform(T, U_);
00256 }
00257 
00258 
00259 template<class ParcelType>
00260 void Foam::DsmcParcel<ParcelType>::transformProperties
00261 (
00262     const vector& separation
00263 )
00264 {
00265     Particle<ParcelType>::transformProperties(separation);
00266 }
00267 
00268 
00269 // * * * * * * * * * * * * * * * *  IOStream operators * * * * * * * * * * * //
00270 
00271 #include "DsmcParcelIO.C"
00272 
00273 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines