1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2010 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
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
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/>.
25 Wave propagation of nearwall distance through grid. Every iteration
26 information goes through one layer of cells.
28 \*---------------------------------------------------------------------------*/
31 #include "wallFvPatch.H"
33 #include "wallPoint.H"
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 int main(int argc, char *argv[])
41 # include "setRootCase.H"
42 # include "createTime.H"
43 # include "createMesh.H"
45 Info<< "Mesh read in = "
46 << runTime.cpuTimeIncrement()
47 << " s\n" << endl << endl;
49 Info<< "Creating field wDistNC\n" << endl;
50 volScalarField wallDistUncorrected
64 dimensionSet(0, 1, 0, 0, 0),
70 // Set initial changed faces: set wallPoint for wall faces to wall centre
75 forAll (mesh.boundary(), patchI)
77 const fvPatch& patch = mesh.boundary()[patchI];
79 if (isA<wallFvPatch>(patch))
81 nWalls += patch.size();
85 List<wallPoint> faceDist(nWalls);
86 labelList changedFaces(nWalls);
88 label nChangedFaces = 0;
89 forAll (mesh.boundary(), patchI)
91 const fvPatch& patch = mesh.boundary()[patchI];
93 if (isA<wallFvPatch>(patch))
95 forAll (patch.Cf(), patchFaceI)
97 const polyPatch& polyPatch = mesh.boundaryMesh()[patchI];
99 label meshFaceI = polyPatch.start() + patchFaceI;
101 changedFaces[nChangedFaces] = meshFaceI;
103 faceDist[nChangedFaces] =
104 wallPoint(patch.Cf()[patchFaceI], 0.0);
112 MeshWave<wallPoint> wallDistCalc
120 Info<< "\nStarting time loop\n" << endl;
122 while (runTime.loop())
124 Info<< "Time = " << runTime.timeName() << endl;
127 label nCells = wallDistCalc.faceToCell();
129 Info<< " Total changed cells : " << nCells << endl;
137 label nFaces = wallDistCalc.cellToFace();
139 Info<< " Total changed faces : " << nFaces << endl;
148 // Copy face and cell values into field
151 const List<wallPoint>& cellInfo = wallDistCalc.allCellInfo();
152 const List<wallPoint>& faceInfo = wallDistCalc.allFaceInfo();
157 forAll(cellInfo, cellI)
159 scalar dist = cellInfo[cellI].distSqr();
160 if (cellInfo[cellI].valid())
162 wallDistUncorrected[cellI] = Foam::sqrt(dist);
166 wallDistUncorrected[cellI] = -1;
171 // Copy boundary values
172 forAll (wallDistUncorrected.boundaryField(), patchI)
174 fvPatchScalarField& patchField =
175 wallDistUncorrected.boundaryField()[patchI];
177 forAll(patchField, patchFaceI)
180 patchField.patch().patch().start() + patchFaceI;
182 scalar dist = faceInfo[meshFaceI].distSqr();
183 if (faceInfo[meshFaceI].valid())
185 patchField[patchFaceI] = Foam::sqrt(dist);
189 patchField[patchFaceI] = dist;
195 Info<< "nIllegal:" << nIllegal << endl;
202 wallDistUncorrected.write();
204 Info<< "ExecutionTime = "
205 << runTime.elapsedCpuTime()
206 << " s\n" << endl << endl;
209 Info<< "End\n" << endl;
215 // ************************************************************************* //