Transferred copyright to the OpenFOAM Foundation
[OpenFOAM-2.0.x.git] / src / finiteVolume / fvMesh / wallDist / wallDist.C
blob1cfd67f1898030da0c4792deb85ade8a7eb86e72
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
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 "wallDist.H"
27 #include "patchWave.H"
28 #include "fvMesh.H"
29 #include "wallPolyPatch.H"
30 #include "fvPatchField.H"
31 #include "Field.H"
32 #include "emptyFvPatchFields.H"
34 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
36 Foam::wallDist::wallDist(const fvMesh& mesh, const bool correctWalls)
38     volScalarField
39     (
40         IOobject
41         (
42             "y",
43             mesh.time().timeName(),
44             mesh
45         ),
46         mesh,
47         dimensionedScalar("y", dimLength, GREAT)
48     ),
49     cellDistFuncs(mesh),
50     correctWalls_(correctWalls),
51     nUnset_(0)
53     wallDist::correct();
57 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
59 Foam::wallDist::~wallDist()
63 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
65 // Correct for mesh geom/topo changes. Might be more intelligent in the
66 // future (if only small topology change)
67 void Foam::wallDist::correct()
69     // Get patchids of walls
70     labelHashSet wallPatchIDs(getPatchIDs<wallPolyPatch>());
72     // Calculate distance starting from wallPatch faces.
73     patchWave wave(cellDistFuncs::mesh(), wallPatchIDs, correctWalls_);
75     // Transfer cell values from wave into *this
76     transfer(wave.distance());
78     // Transfer values on patches into boundaryField of *this
79     forAll(boundaryField(), patchI)
80     {
81         if (!isA<emptyFvPatchScalarField>(boundaryField()[patchI]))
82         {
83             scalarField& waveFld = wave.patchDistance()[patchI];
85             boundaryField()[patchI].transfer(waveFld);
86         }
87     }
89     // Transfer number of unset values
90     nUnset_ = wave.nUnset();
94 // ************************************************************************* //