Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / src / finiteVolume / fvMesh / wallDist / nearWallDistNoSearch.C
blobd0acc85b268a1eb7829786fea974ce3d67b1fc5a
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2004-2010 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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 "nearWallDistNoSearch.H"
27 #include "fvMesh.H"
28 #include "wallFvPatch.H"
29 #include "surfaceFields.H"
31 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
33 void Foam::nearWallDistNoSearch::doAll()
35     const volVectorField& cellCentres = mesh_.C();
36     const fvPatchList& patches = mesh_.boundary();
38     forAll(patches, patchI)
39     {
40         fvPatchScalarField& ypatch = operator[](patchI);
42         if (isA<wallFvPatch>(patches[patchI]))
43         {
44             const labelUList& faceCells = patches[patchI].faceCells();
46             const fvPatchVectorField& patchCentres
47                 = cellCentres.boundaryField()[patchI];
49             const fvsPatchVectorField& Apatch
50                 = mesh_.Sf().boundaryField()[patchI];
52             const fvsPatchScalarField& magApatch
53                 = mesh_.magSf().boundaryField()[patchI];
55             forAll(patchCentres, facei)
56             {
57                 ypatch[facei] =
58                 (
59                     Apatch[facei] &
60                     (
61                         patchCentres[facei]
62                       - cellCentres[faceCells[facei]]
63                     )
64                 )/magApatch[facei];
65             }
66         }
67         else
68         {
69             ypatch = 0.0;
70         }
71     }
75 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
77 Foam::nearWallDistNoSearch::nearWallDistNoSearch(const Foam::fvMesh& mesh)
79     volScalarField::GeometricBoundaryField
80     (
81         mesh.boundary(),
82         mesh.V(),           // Dummy internal field
83         calculatedFvPatchScalarField::typeName
84     ),
85     mesh_(mesh)
87     doAll();
91 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
93 Foam::nearWallDistNoSearch::~nearWallDistNoSearch()
97 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
99 void Foam::nearWallDistNoSearch::correct()
101     if (mesh_.changing())
102     {
103         // Update size of GeometricBoundaryField
104         forAll(mesh_.boundary(), patchI)
105         {
106             operator[](patchI).setSize(mesh_.boundary()[patchI].size());
107         }
108     }
110     doAll();
114 // ************************************************************************* //