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

LocalInteraction.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-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 "LocalInteraction.H"
00028 
00029 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00030 
00031 template <class CloudType>
00032 Foam::label Foam::LocalInteraction<CloudType>::applyToPatch
00033 (
00034     const label globalPatchI
00035 ) const
00036 {
00037     forAll(patchIds_, patchI)
00038     {
00039         if (patchIds_[patchI] == globalPatchI)
00040         {
00041             return patchI;
00042         }
00043     }
00044 
00045     return -1;
00046 }
00047 
00048 
00049 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00050 
00051 template <class CloudType>
00052 Foam::LocalInteraction<CloudType>::LocalInteraction
00053 (
00054     const dictionary& dict,
00055     CloudType& cloud
00056 )
00057 :
00058     PatchInteractionModel<CloudType>(dict, cloud, typeName),
00059     patchData_(this->coeffDict().lookup("patches")),
00060     patchIds_(patchData_.size())
00061 {
00062     const polyMesh& mesh = cloud.mesh();
00063     const polyBoundaryMesh& bMesh = mesh.boundaryMesh();
00064 
00065     forAll(patchData_, patchI)
00066     {
00067         const word& patchName = patchData_[patchI].patchName();
00068         patchIds_[patchI] = bMesh.findPatchID(patchName);
00069         if (patchIds_[patchI] < 0)
00070         {
00071             FatalErrorIn("LocalInteraction(const dictionary&, CloudType&)")
00072                 << "Patch " << patchName << " not found. Available patches "
00073                 << "are: " << bMesh.names() << exit(FatalError);
00074         }
00075     }
00076 
00077     // check that all walls are specified
00078     DynamicList<word> badWalls;
00079     forAll(bMesh, patchI)
00080     {
00081         if
00082         (
00083             isA<wallPolyPatch>(bMesh[patchI])
00084          && applyToPatch(bMesh[patchI].index()) < 0
00085         )
00086         {
00087             badWalls.append(bMesh[patchI].name());
00088         }
00089     }
00090 
00091     if (badWalls.size() > 0)
00092     {
00093         FatalErrorIn("LocalInteraction(const dictionary&, CloudType&)")
00094             << "All wall patches must be specified when employing local patch "
00095             << "interaction. Please specify data for patches:" << nl
00096             << badWalls << nl << exit(FatalError);
00097     }
00098 }
00099 
00100 
00101 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00102 
00103 template <class CloudType>
00104 Foam::LocalInteraction<CloudType>::~LocalInteraction()
00105 {}
00106 
00107 
00108 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00109 
00110 template<class CloudType>
00111 bool Foam::LocalInteraction<CloudType>::active() const
00112 {
00113     return true;
00114 }
00115 
00116 
00117 template <class CloudType>
00118 bool Foam::LocalInteraction<CloudType>::correct
00119 (
00120     const polyPatch& pp,
00121     const label faceId,
00122     vector& U
00123 ) const
00124 {
00125     label patchI = applyToPatch(pp.index());
00126 
00127     if (patchI >= 0)
00128     {
00129         vector nw = pp.faceAreas()[pp.whichFace(faceId)];
00130         nw /= mag(nw);
00131 
00132         scalar Un = U & nw;
00133         vector Ut = U - Un*nw;
00134 
00135         if (Un > 0)
00136         {
00137             U -= (1.0 + patchData_[patchI].e())*Un*nw;
00138         }
00139 
00140         U -= patchData_[patchI].mu()*Ut;
00141 
00142         return true;
00143     }
00144 
00145     return false;
00146 }
00147 
00148 
00149 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd