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

nearWallDist.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 "nearWallDist.H"
00027 #include <finiteVolume/fvMesh.H>
00028 #include <meshTools/cellDistFuncs.H>
00029 #include <finiteVolume/wallFvPatch.H>
00030 #include <finiteVolume/surfaceFields.H>
00031 
00032 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00033 
00034 void Foam::nearWallDist::doAll()
00035 {
00036     cellDistFuncs wallUtils(mesh_);
00037 
00038     // Get patch ids of walls
00039     labelHashSet wallPatchIDs(wallUtils.getPatchIDs<wallPolyPatch>());
00040 
00041     // Size neighbours array for maximum possible
00042 
00043     labelList neighbours(wallUtils.maxPatchSize(wallPatchIDs));
00044 
00045 
00046     // Correct all cells with face on wall
00047 
00048     const volVectorField& cellCentres = mesh_.C();
00049 
00050     forAll(mesh_.boundary(), patchI)
00051     {
00052         fvPatchScalarField& ypatch = operator[](patchI);
00053 
00054         const fvPatch& patch = mesh_.boundary()[patchI];
00055 
00056         if (isA<wallFvPatch>(patch))
00057         {
00058             const polyPatch& pPatch = patch.patch();
00059 
00060             const unallocLabelList& faceCells = patch.faceCells();
00061 
00062             // Check cells with face on wall
00063             forAll(patch, patchFaceI)
00064             {
00065                 label nNeighbours = wallUtils.getPointNeighbours
00066                 (
00067                     pPatch,
00068                     patchFaceI,
00069                     neighbours
00070                 );
00071 
00072                 label minFaceI = -1;
00073 
00074                 ypatch[patchFaceI] = wallUtils.smallestDist
00075                 (
00076                     cellCentres[faceCells[patchFaceI]],
00077                     pPatch,
00078                     nNeighbours,
00079                     neighbours,
00080                     minFaceI
00081                 );
00082             }
00083         }
00084         else
00085         {
00086             ypatch = 0.0;
00087         }
00088     }
00089 }
00090 
00091 
00092 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00093 
00094 Foam::nearWallDist::nearWallDist(const Foam::fvMesh& mesh)
00095 :
00096     volScalarField::GeometricBoundaryField
00097     (
00098         mesh.boundary(),
00099         mesh.V(),           // Dummy internal field,
00100         calculatedFvPatchScalarField::typeName
00101     ),
00102     mesh_(mesh)
00103 {
00104     doAll();
00105 }
00106 
00107 
00108 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00109 
00110 Foam::nearWallDist::~nearWallDist()
00111 {}
00112 
00113 
00114 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00115 
00116 void Foam::nearWallDist::correct()
00117 {
00118     if (mesh_.changing())
00119     {
00120         // Update size of GeometricBoundaryField
00121         forAll(mesh_.boundary(), patchI)
00122         {
00123             operator[](patchI).setSize(mesh_.boundary()[patchI].size());
00124         }
00125     }
00126 
00127     doAll();
00128 }
00129 
00130 
00131 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines