1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "nearWallDist.H"
28 #include "cellDistFuncs.H"
29 #include "wallFvPatch.H"
30 #include "surfaceFields.H"
32 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
34 void Foam::nearWallDist::doAll()
36 cellDistFuncs wallUtils(mesh_);
38 // Get patch ids of walls
39 labelHashSet wallPatchIDs(wallUtils.getPatchIDs<wallPolyPatch>());
41 // Size neighbours array for maximum possible
43 labelList neighbours(wallUtils.maxPatchSize(wallPatchIDs));
46 // Correct all cells with face on wall
48 const volVectorField& cellCentres = mesh_.C();
50 forAll(mesh_.boundary(), patchI)
52 fvPatchScalarField& ypatch = operator[](patchI);
54 const fvPatch& patch = mesh_.boundary()[patchI];
56 if (isA<wallFvPatch>(patch))
58 const polyPatch& pPatch = patch.patch();
60 const labelUList& faceCells = patch.faceCells();
62 // Check cells with face on wall
63 forAll(patch, patchFaceI)
65 label nNeighbours = wallUtils.getPointNeighbours
74 ypatch[patchFaceI] = wallUtils.smallestDist
76 cellCentres[faceCells[patchFaceI]],
92 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
94 Foam::nearWallDist::nearWallDist(const Foam::fvMesh& mesh)
96 volScalarField::GeometricBoundaryField
99 mesh.V(), // Dummy internal field,
100 calculatedFvPatchScalarField::typeName
108 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
110 Foam::nearWallDist::~nearWallDist()
114 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
116 void Foam::nearWallDist::correct()
118 if (mesh_.changing())
120 // Update size of GeometricBoundaryField
121 forAll(mesh_.boundary(), patchI)
123 operator[](patchI).setSize(mesh_.boundary()[patchI].size());
131 // ************************************************************************* //