ENH: patchCloud: return pTraits<Type>::max for unfound points
[OpenFOAM-1.7.x.git] / applications / test / nearWallDist-wave / testWallDistData.C
blob0811bc0b85f679645448ad78ea0a7f0a796db997
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.
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 Description
25     Calculate distance to wall.
27 \*---------------------------------------------------------------------------*/
29 #include "fvCFD.H"
30 #include "wallDistData.H"
31 #include "wallPointData.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 // Main program:
36 int main(int argc, char *argv[])
38 #   include "setRootCase.H"
39 #   include "createTime.H"
40 #   include "createMesh.H"
42     Info<< "Mesh read in = "
43         << runTime.cpuTimeIncrement()
44         << " s\n" << endl << endl;
47     Info<< "Time now = " << runTime.timeName() << endl;
49     // wall distance and reflection vectors
51     volVectorField n
52     (
53         IOobject
54         (
55             "n",
56             mesh.time().timeName(),
57             mesh
58         ),
59         mesh,
60         dimensionedVector("n", dimLength, wallPoint::greatPoint)
61     );
63     // Fill wall patches with unit normal
64     forAll(mesh.boundary(), patchI)
65     {
66         const fvPatch& patch = mesh.boundary()[patchI];
68         if (isA<wallFvPatch>(patch))
69         {
70             fvPatchVectorField& wallData = n.boundaryField()[patchI];
72             forAll(patch.Cf(), patchFaceI)
73             {
74                 wallData[patchFaceI] = patch.Cf()[patchFaceI];
75                 wallData[patchFaceI] /= Foam::mag(wallData[patchFaceI]);
76             }
77         }
78     }
81     // Do distance calculation, transporting values of n.
82     wallDistData<wallPointData<vector> > y(mesh, n, true);
84     if (y.nUnset() != 0)
85     {
86         WarningIn(args.executable())
87             << "There are " << y.nUnset()
88             << " remaining unset cells and/or boundary values" << endl;
89     }
92     y.write();
93     y.data().write();
95     runTime++;
97     Info<< "Time now = " << runTime.timeName() << endl;
100     // Move points
102     boundBox meshBb(mesh.points());
104     pointField newPoints(mesh.points());
106     const point half(0.5*(meshBb.min() + meshBb.max()));
108     forAll(newPoints, pointI)
109     {
110         point& pt = newPoints[pointI];
112         // expand around half
113         pt.y() +=  pt.y() - half.y();
114     }
116     mesh.movePoints(newPoints);
118     mesh.write();
120     y.correct();
122     y.write();
123     y.data().write();
124     
126     Info<< "End\n" << endl;
128     return 0;
135 // ************************************************************************* //