FreeFOAM The Cross-Platform CFD Toolkit
wallDist.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "wallDist.H"
27 #include <meshTools/patchWave.H>
28 #include <finiteVolume/fvMesh.H>
29 #include <OpenFOAM/wallPolyPatch.H>
31 #include <OpenFOAM/Field.H>
33 
34 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
35 
36 Foam::wallDist::wallDist(const fvMesh& mesh, const bool correctWalls)
37 :
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)
52 {
54 }
55 
56 
57 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
58 
60 {}
61 
62 
63 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
64 
65 // Correct for mesh geom/topo changes. Might be more intelligent in the
66 // future (if only small topology change)
68 {
69  // Get patchids of walls
70  labelHashSet wallPatchIDs(getPatchIDs<wallPolyPatch>());
71 
72  // Calculate distance starting from wallPatch faces.
73  patchWave wave(cellDistFuncs::mesh(), wallPatchIDs, correctWalls_);
74 
75  // Transfer cell values from wave into *this
76  transfer(wave.distance());
77 
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];
84 
85  boundaryField()[patchI].transfer(waveFld);
86  }
87  }
88 
89  // Transfer number of unset values
90  nUnset_ = wave.nUnset();
91 }
92 
93 
94 // ************************ vim: set sw=4 sts=4 et: ************************ //