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

nearWallDistNoSearch.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 "nearWallDistNoSearch.H"
00028 #include "fvMesh.H"
00029 #include "wallPoint.H"
00030 #include "wallFvPatch.H"
00031 #include "surfaceFields.H"
00032 
00033 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00034 
00035 void Foam::nearWallDistNoSearch::doAll()
00036 {
00037     const volVectorField& cellCentres = mesh_.C();
00038     const fvPatchList& patches = mesh_.boundary();
00039 
00040     forAll(patches, patchI)
00041     {
00042         fvPatchScalarField& ypatch = operator[](patchI);
00043 
00044         if (patches[patchI].type() == wallFvPatch::typeName)
00045         {
00046             const unallocLabelList& faceCells = patches[patchI].faceCells();
00047 
00048             const fvPatchVectorField& patchCentres
00049                 = cellCentres.boundaryField()[patchI];
00050 
00051             const fvsPatchVectorField& Apatch
00052                 = mesh_.Sf().boundaryField()[patchI];
00053 
00054             const fvsPatchScalarField& magApatch
00055                 = mesh_.magSf().boundaryField()[patchI];
00056 
00057             forAll(patchCentres, facei)
00058             {
00059                 ypatch[facei] =
00060                 (
00061                     Apatch[facei] &
00062                     (
00063                         patchCentres[facei]
00064                       - cellCentres[faceCells[facei]]
00065                     )
00066                 )/magApatch[facei];
00067             }
00068         }
00069         else
00070         {
00071             ypatch = 0.0;
00072         }
00073     }
00074 }
00075 
00076 
00077 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00078 
00079 Foam::nearWallDistNoSearch::nearWallDistNoSearch(const Foam::fvMesh& mesh)
00080 :
00081     volScalarField::GeometricBoundaryField
00082     (
00083         mesh.boundary(),
00084         mesh.V(),           // Dummy internal field
00085         calculatedFvPatchScalarField::typeName
00086     ),
00087     mesh_(mesh)
00088 {
00089     doAll();
00090 }
00091 
00092 
00093 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00094 
00095 Foam::nearWallDistNoSearch::~nearWallDistNoSearch()
00096 {}
00097 
00098 
00099 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00100 
00101 void Foam::nearWallDistNoSearch::correct()
00102 {
00103     if (mesh_.changing())
00104     {
00105         // Update size of GeometricBoundaryField
00106         forAll(mesh_.boundary(), patchI)
00107         {
00108             operator[](patchI).setSize(mesh_.boundary()[patchI].size());
00109         }
00110     }
00111 
00112     doAll();
00113 }
00114 
00115 
00116 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd