1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
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
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
26 Wave propagation of nearwall distance through grid. Every iteration
27 information goes through one layer of cells.
29 \*---------------------------------------------------------------------------*/
32 #include "wallFvPatch.H"
34 #include "wallPoint.H"
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 int main(int argc, char *argv[])
42 # include "setRootCase.H"
43 # include "createTime.H"
44 # include "createMesh.H"
46 Info<< "Mesh read in = "
47 << runTime.cpuTimeIncrement()
48 << " s\n" << endl << endl;
50 Info<< "Creating field wDistNC\n" << endl;
51 volScalarField wallDistUncorrected
65 dimensionSet(0, 1, 0, 0, 0),
71 // Set initial changed faces: set wallPoint for wall faces to wall centre
76 forAll (mesh.boundary(), patchI)
78 const fvPatch& patch = mesh.boundary()[patchI];
80 if (typeid(patch) == typeid(wallFvPatch))
82 nWalls += patch.size();
86 List<wallPoint> faceDist(nWalls);
87 labelList changedFaces(nWalls);
89 label nChangedFaces = 0;
90 forAll (mesh.boundary(), patchI)
92 const fvPatch& patch = mesh.boundary()[patchI];
94 if (typeid(patch) == typeid(wallFvPatch))
96 forAll (patch.Cf(), patchFaceI)
98 const polyPatch& polyPatch = mesh.boundaryMesh()[patchI];
100 label meshFaceI = polyPatch.start() + patchFaceI;
102 changedFaces[nChangedFaces] = meshFaceI;
104 faceDist[nChangedFaces] =
105 wallPoint(patch.Cf()[patchFaceI], 0.0);
113 MeshWave<wallPoint> wallDistCalc
121 Info<< "\nStarting time loop\n" << endl;
123 for (runTime++; !runTime.end(); runTime++)
125 Info<< "Time = " << runTime.timeName() << endl;
128 label nCells = wallDistCalc.faceToCell();
130 Info<< " Total changed cells : " << nCells << endl;
138 label nFaces = wallDistCalc.cellToFace();
140 Info<< " Total changed faces : " << nFaces << endl;
149 // Copy face and cell values into field
152 const List<wallPoint>& cellInfo = wallDistCalc.allCellInfo();
153 const List<wallPoint>& faceInfo = wallDistCalc.allFaceInfo();
158 forAll(cellInfo, cellI)
160 scalar dist = cellInfo[cellI].distSqr();
161 if (cellInfo[cellI].valid())
163 wallDistUncorrected[cellI] = Foam::sqrt(dist);
167 wallDistUncorrected[cellI] = -1;
172 // Copy boundary values
173 forAll (wallDistUncorrected.boundaryField(), patchI)
175 fvPatchScalarField& patchField =
176 wallDistUncorrected.boundaryField()[patchI];
178 forAll(patchField, patchFaceI)
181 patchField.patch().patch().start() + patchFaceI;
183 scalar dist = faceInfo[meshFaceI].distSqr();
184 if (faceInfo[meshFaceI].valid())
186 patchField[patchFaceI] = Foam::sqrt(dist);
190 patchField[patchFaceI] = dist;
196 Info<< "nIllegal:" << nIllegal << endl;
203 wallDistUncorrected.write();
205 Info<< "ExecutionTime = "
206 << runTime.elapsedCpuTime()
207 << " s\n" << endl << endl;
210 Info<< "End\n" << endl;
216 // ************************************************************************* //