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

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