initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / applications / test / nearWallDist-wave / testWallDistData.C
blob749c810a55e86b4a87942ebefdb81911e530c757
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     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, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Description
26     Calculate distance to wall.
28 \*---------------------------------------------------------------------------*/
30 #include "fvCFD.H"
31 #include "wallDistData.H"
32 #include "wallPointData.H"
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 // Main program:
37 int main(int argc, char *argv[])
39 #   include "setRootCase.H"
40 #   include "createTime.H"
41 #   include "createMesh.H"
43     Info<< "Mesh read in = "
44         << runTime.cpuTimeIncrement()
45         << " s\n" << endl << endl;
48     Info<< "Time now = " << runTime.timeName() << endl;
50     // wall distance and reflection vectors
52     volVectorField n
53     (
54         IOobject
55         (
56             "n",
57             mesh.time().timeName(),
58             mesh
59         ),
60         mesh,
61         dimensionedVector("n", dimLength, wallPoint::greatPoint)
62     );
64     // Fill wall patches with unit normal
65     forAll(mesh.boundary(), patchI)
66     {
67         const fvPatch& patch = mesh.boundary()[patchI];
69         if (typeid(patch) == typeid(wallFvPatch))
70         {
71             fvPatchVectorField& wallData = n.boundaryField()[patchI];
73             forAll(patch.Cf(), patchFaceI)
74             {
75                 wallData[patchFaceI] = patch.Cf()[patchFaceI];
76                 wallData[patchFaceI] /= Foam::mag(wallData[patchFaceI]);
77             }
78         }
79     }
82     // Do distance calculation, transporting values of n.
83     wallDistData<wallPointData<vector> > y(mesh, n, true);
85     if (y.nUnset() != 0)
86     {
87         WarningIn(args.executable())
88             << "There are " << y.nUnset()
89             << " remaining unset cells and/or boundary values" << endl;
90     }
93     y.write();
94     y.data().write();
96     runTime++;
98     Info<< "Time now = " << runTime.timeName() << endl;
101     // Move points
103     boundBox meshBb(mesh.points());
105     pointField newPoints(mesh.points());
107     const point half(0.5*(meshBb.min() + meshBb.max()));
109     forAll(newPoints, pointI)
110     {
111         point& pt = newPoints[pointI];
113         // expand around half
114         pt.y() +=  pt.y() - half.y();
115     }
117     mesh.movePoints(newPoints);
119     mesh.write();
121     y.correct();
123     y.write();
124     y.data().write();
125     
127     Info<< "End\n" << endl;
129     return 0;
136 // ************************************************************************* //