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

StandardWallInteraction.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) 2008-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 "StandardWallInteraction.H"
00027 
00028 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00029 
00030 template <class CloudType>
00031 Foam::StandardWallInteraction<CloudType>::StandardWallInteraction
00032 (
00033     const dictionary& dict,
00034     CloudType& cloud
00035 )
00036 :
00037     PatchInteractionModel<CloudType>(dict, cloud, typeName),
00038     interactionType_
00039     (
00040         this->wordToInteractionType(this->coeffDict().lookup("type"))
00041     ),
00042     e_(0.0),
00043     mu_(0.0)
00044 {
00045     switch (interactionType_)
00046     {
00047         case PatchInteractionModel<CloudType>::itOther:
00048         {
00049             word interactionTypeName(this->coeffDict().lookup("type"));
00050 
00051             FatalErrorIn
00052             (
00053                 "StandardWallInteraction<CloudType>::StandardWallInteraction"
00054                 "("
00055                     "const dictionary&, "
00056                     "CloudType& cloud"
00057                 ")"
00058             )   << "Unknown interaction result type "
00059                 << interactionTypeName
00060                 << ". Valid selections are:" << this->interactionTypeNames_
00061                 << endl << exit(FatalError);
00062 
00063             break;
00064         }
00065         case PatchInteractionModel<CloudType>::itRebound:
00066         {
00067             e_ = this->coeffDict().lookupOrDefault("e", 1.0);
00068             mu_ = this->coeffDict().lookupOrDefault("mu", 0.0);
00069             break;
00070         }
00071         default:
00072         {
00073             // do nothing
00074         }
00075     }
00076 }
00077 
00078 
00079 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00080 
00081 template <class CloudType>
00082 Foam::StandardWallInteraction<CloudType>::~StandardWallInteraction()
00083 {}
00084 
00085 
00086 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00087 
00088 template<class CloudType>
00089 bool Foam::StandardWallInteraction<CloudType>::active() const
00090 {
00091     return true;
00092 }
00093 
00094 
00095 template <class CloudType>
00096 bool Foam::StandardWallInteraction<CloudType>::correct
00097 (
00098     const polyPatch& pp,
00099     const label faceId,
00100     bool& keepParticle,
00101     bool& active,
00102     vector& U
00103 ) const
00104 {
00105     if (isA<wallPolyPatch>(pp))
00106     {
00107         switch (interactionType_)
00108         {
00109             case PatchInteractionModel<CloudType>::itEscape:
00110             {
00111                 keepParticle = false;
00112                 active = false;
00113                 U = vector::zero;
00114                 break;
00115             }
00116             case PatchInteractionModel<CloudType>::itStick:
00117             {
00118                 keepParticle = true;
00119                 active = false;
00120                 U = vector::zero;
00121                 break;
00122             }
00123             case PatchInteractionModel<CloudType>::itRebound:
00124             {
00125                 keepParticle = true;
00126                 active = true;
00127 
00128                 vector nw = pp.faceAreas()[pp.whichFace(faceId)];
00129                 nw /= mag(nw);
00130 
00131                 scalar Un = U & nw;
00132                 vector Ut = U - Un*nw;
00133 
00134                 if (Un > 0)
00135                 {
00136                     U -= (1.0 + e_)*Un*nw;
00137                 }
00138 
00139                 U -= mu_*Ut;
00140 
00141                 break;
00142             }
00143             default:
00144             {
00145                 FatalErrorIn
00146                 (
00147                     "bool StandardWallInteraction<CloudType>::correct"
00148                     "("
00149                         "const polyPatch&, "
00150                         "const label, "
00151                         "bool&, "
00152                         "vector&"
00153                     ") const"
00154                 )   << "Unknown interaction type "
00155                     << this->interactionTypeToWord(interactionType_)
00156                     << "(" << interactionType_ << ")" << endl
00157                     << abort(FatalError);
00158             }
00159         }
00160 
00161         return true;
00162     }
00163 
00164     return false;
00165 }
00166 
00167 
00168 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines