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

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