ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / applications / test / PointEdgeWave / Test-PointEdgeWave.C
blob229268d518b0e81d44c7449dd5d0e1ed88513d23
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 Description
25     Test pointEdgeWave.
27 \*---------------------------------------------------------------------------*/
29 #include "argList.H"
30 #include "Time.H"
31 #include "polyMesh.H"
32 #include "pointMesh.H"
33 #include "OSspecific.H"
34 #include "IFstream.H"
35 #include "pointEdgePoint.H"
36 #include "PointEdgeWave.H"
38 using namespace Foam;
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 int main(int argc, char *argv[])
44     argList::validArgs.append("patch");
46 #   include "setRootCase.H"
47 #   include "createTime.H"
48 #   include "createPolyMesh.H"
50     const polyBoundaryMesh& patches = mesh.boundaryMesh();
52     // Get name of patch
53     const word patchName = args[1];
55     // Find the label in patches by name.
56     label patchI = patches.findPatchID(patchName);
58     {
59         // Test whether any processor has patch
60         label maxPatchI = patchI;
62         reduce(maxPatchI, maxOp<label>());
64         if (maxPatchI == -1)
65         {
66             FatalErrorIn(args.executable())
67                 << "Cannot find patch named " << patchName << exit(FatalError);
68         }
69     }
72     // Set initial changed points to all the patch points(if patch present)
73     List<pointEdgePoint> wallInfo;
74     labelList wallPoints;
76     if (patchI != -1)
77     {
78         // Retrieve the patch now we have its index in patches.
79         const polyPatch& pp = mesh.boundaryMesh()[patchI];
81         wallPoints = pp.meshPoints();
83         wallInfo.setSize(pp.nPoints());
85         forAll(pp.localPoints(), ppI)
86         {
87             wallInfo[ppI] = pointEdgePoint(pp.localPoints()[ppI], 0.0);
88         }
89     }
91     // Current info on points
92     List<pointEdgePoint> allPointInfo(mesh.nPoints());
94     // Current info on edges
95     List<pointEdgePoint> allEdgeInfo(mesh.nEdges());
97     PointEdgeWave<pointEdgePoint> wallCalc
98     (
99         mesh,
100         wallPoints,
101         wallInfo,
103         allPointInfo,
104         allEdgeInfo,
105         mesh.nPoints()  // max iterations
106     );
109     pointScalarField psf
110     (
111         IOobject
112         (
113             "wallDist",
114             runTime.timeName(),
115             mesh,
116             IOobject::NO_READ,
117             IOobject::AUTO_WRITE
118         ),
119         pointMesh::New(mesh),
120         dimensionedScalar("wallDist", dimLength, 0.0)
121     );
123     forAll(allPointInfo, pointI)
124     {
125         psf[pointI] = Foam::sqrt(allPointInfo[pointI].distSqr());
126     }
128     Info<< "Writing wallDist pointScalarField to " << runTime.value()
129         << endl;
131     psf.write();
133     Info<< "\nEnd\n" << endl;
134     return 0;
138 // ************************************************************************* //