1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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/>.
28 Test app for determining extended stencil.
30 \*---------------------------------------------------------------------------*/
34 #include "volFields.H"
36 //#include "mapDistribute.H"
38 #include "meshTools.H"
39 //#include "FECCellToFaceStencil.H"
40 //#include "CFCCellToFaceStencil.H"
41 //#include "CPCCellToFaceStencil.H"
42 //#include "CECCellToFaceStencil.H"
43 //#include "extendedCentredCellToFaceStencil.H"
44 //#include "extendedUpwindCellToFaceStencil.H"
46 //#include "centredCFCCellToFaceStencilObject.H"
47 //#include "centredFECCellToFaceStencilObject.H"
48 //#include "centredCPCCellToFaceStencilObject.H"
49 //#include "centredCECCellToFaceStencilObject.H"
51 //#include "upwindFECCellToFaceStencilObject.H"
52 //#include "upwindCPCCellToFaceStencilObject.H"
53 //#include "upwindCECCellToFaceStencilObject.H"
55 //#include "upwindCFCCellToFaceStencilObject.H"
56 #include "centredCFCFaceToCellStencilObject.H"
60 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
64 const fileName& fName,
66 const List<point>& stencilCc
72 meshTools::writeOBJ(str, fc);
77 meshTools::writeOBJ(str, stencilCc[i]);
79 str << "l 1 " << vertI << nl;
85 void writeStencilStats(const labelListList& stencil)
89 label minSize = labelMax;
90 label maxSize = labelMin;
94 const labelList& sCells = stencil[i];
96 if (sCells.size() > 0)
98 sumSize += sCells.size();
100 minSize = min(minSize, sCells.size());
101 maxSize = max(maxSize, sCells.size());
104 reduce(sumSize, sumOp<label>());
105 reduce(nSum, sumOp<label>());
108 reduce(minSize, minOp<label>());
109 reduce(maxSize, maxOp<label>());
111 Info<< "Stencil size :" << nl
112 << " average : " << sumSize << nl
113 << " min : " << minSize << nl
114 << " max : " << maxSize << nl
121 int main(int argc, char *argv[])
123 # include "addTimeOptions.H"
124 # include "setRootCase.H"
125 # include "createTime.H"
128 instantList Times = runTime.times();
129 # include "checkTimeOptions.H"
130 runTime.setTime(Times[startTime], startTime);
131 # include "createMesh.H"
133 // Force calculation of extended edge addressing
134 const labelListList& edgeFaces = mesh.edgeFaces();
135 const labelListList& edgeCells = mesh.edgeCells();
136 const labelListList& pointCells = mesh.pointCells();
137 Info<< "dummy:" << edgeFaces.size() + edgeCells.size() + pointCells.size()
141 // Centred, semi-extended stencil (edge cells only)
142 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
145 // //const FECCellToFaceStencil cfcStencil(mesh);
146 // //const extendedCentredCellToFaceStencil addressing
150 // const extendedCentredStencil& addressing =
151 // centredFECCellToFaceStencilObject::New
156 // Info<< "faceEdgeCell:" << endl;
157 // writeStencilStats(addressing.stencil());
159 // // Collect stencil cell centres
160 // List<List<point> > stencilPoints(mesh.nFaces());
161 // addressing.collectData
167 // forAll(stencilPoints, faceI)
171 // runTime.path()/"faceEdgeCell" + Foam::name(faceI) + ".obj",
172 // mesh.faceCentres()[faceI],
173 // stencilPoints[faceI]
181 // // Centred, face stencil
182 // // ~~~~~~~~~~~~~~~~~~~~~
185 // const extendedCentredCellToFaceStencil& addressing =
186 // centredCFCCellToFaceStencilObject::New
191 // Info<< "cellFaceCell:" << endl;
192 // writeStencilStats(addressing.stencil());
195 // //// Do some interpolation.
197 // // const labelListList& stencil = addressing.stencil();
198 // // List<List<scalar> > stencilWeights(stencil.size());
199 // // forAll(stencil, faceI)
201 // // const labelList& fStencil = stencil[faceI];
203 // // if (fStencil.size() > 0)
205 // // // Uniform weights
206 // // stencilWeights[faceI] = scalarList
208 // // fStencil.size(),
209 // // 1.0/fStencil.size()
214 // // tmp<surfaceVectorField> tfc
216 // // addressing.weightedSum(mesh.C(), stencilWeights)
221 // // Collect stencil cell centres
222 // List<List<point> > stencilPoints(mesh.nFaces());
223 // addressing.collectData
229 // forAll(stencilPoints, faceI)
231 // if (stencilPoints[faceI].size() >= 15)
235 // runTime.path()/"centredFace" + Foam::name(faceI) + ".obj",
236 // mesh.faceCentres()[faceI],
237 // stencilPoints[faceI]
244 // // Centred, point stencil
245 // // ~~~~~~~~~~~~~~~~~~~~~~
248 // //const extendedCentredCellToFaceStencil& addressing =
249 // //centredCPCStencilObject::New
254 // //Info<< "cellPointCell:" << endl;
255 // //writeStencilStats(addressing.stencil());
258 // //// Collect stencil cell centres
259 // //List<List<point> > stencilPoints(mesh.nFaces());
260 // //addressing.collectData
266 // //forAll(stencilPoints, faceI)
268 // // writeStencilOBJ
270 // // runTime.path()/"centredPoint" + Foam::name(faceI) + ".obj",
271 // // mesh.faceCentres()[faceI],
272 // // stencilPoints[faceI]
279 // // Centred, edge stencil
280 // // ~~~~~~~~~~~~~~~~~~~~~~
283 // //const extendedCentredCellToFaceStencil& addressing =
284 // //centredCECStencilObject::New
289 // //Info<< "cellEdgeCell:" << endl;
290 // //writeStencilStats(addressing.stencil());
293 // //// Collect stencil cell centres
294 // //List<List<point> > stencilPoints(mesh.nFaces());
295 // //addressing.collectData
301 // //forAll(stencilPoints, faceI)
303 // // writeStencilOBJ
305 // // runTime.path()/"centredEdge" + Foam::name(faceI) + ".obj",
306 // // mesh.faceCentres()[faceI],
307 // // stencilPoints[faceI]
314 // Upwind, semi-extended stencil
315 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
318 // const extendedUpwindCellToFaceStencil& addressing =
319 // upwindFECCellToFaceStencilObject::New
325 // Info<< "upwind-faceEdgeCell:" << endl;
326 // writeStencilStats(addressing.ownStencil());
329 // // Collect stencil cell centres
330 // List<List<point> > ownPoints(mesh.nFaces());
331 // addressing.collectData
333 // addressing.ownMap(),
334 // addressing.ownStencil(),
339 // forAll(ownPoints, faceI)
343 // runTime.path()/"ownFEC" + Foam::name(faceI) + ".obj",
344 // mesh.faceCentres()[faceI],
350 // // Collect stencil cell centres
351 // List<List<point> > neiPoints(mesh.nFaces());
352 // addressing.collectData
354 // addressing.neiMap(),
355 // addressing.neiStencil(),
360 // forAll(neiPoints, faceI)
364 // runTime.path()/"neiFEC" + Foam::name(faceI) + ".obj",
365 // mesh.faceCentres()[faceI],
374 // Upwind, extended stencil
375 // ~~~~~~~~~~~~~~~~~~~~~~~~
378 // const extendedUpwindCellToFaceStencil& addressing =
379 // upwindCFCCellToFaceStencilObject::New
385 // Info<< "upwind-cellFaceCell:" << endl;
386 // writeStencilStats(addressing.ownStencil());
389 // // Collect stencil cell centres
390 // List<List<point> > ownPoints(mesh.nFaces());
391 // addressing.collectData
393 // addressing.ownMap(),
394 // addressing.ownStencil(),
399 // forAll(ownPoints, faceI)
403 // runTime.path()/"ownCFC" + Foam::name(faceI) + ".obj",
404 // mesh.faceCentres()[faceI],
410 // // Collect stencil cell centres
411 // List<List<point> > neiPoints(mesh.nFaces());
412 // addressing.collectData
414 // addressing.neiMap(),
415 // addressing.neiStencil(),
420 // forAll(neiPoints, faceI)
424 // runTime.path()/"neiCFC" + Foam::name(faceI) + ".obj",
425 // mesh.faceCentres()[faceI],
434 //---- CELL CENTRED STENCIL -----
436 // Centred, cell stencil
437 // ~~~~~~~~~~~~~~~~~~~~~
440 const extendedCentredFaceToCellStencil& addressing =
441 centredCFCFaceToCellStencilObject::New
446 Info<< "cellFaceCell:" << endl;
447 writeStencilStats(addressing.stencil());
449 // Collect stencil face centres
450 List<List<point> > stencilPoints(mesh.nCells());
451 addressing.collectData
457 forAll(stencilPoints, cellI)
461 runTime.path()/"centredCell" + Foam::name(cellI) + ".obj",
462 mesh.cellCentres()[cellI],
471 // List<List<scalar> > stencilData(faceStencils.size());
472 // collectStencilData
479 // for (label faci = 0; faci < mesh.nInternalFaces(); faci++)
481 // const scalarList& stData = stencilData[faceI];
482 // const scalarList& stWeight = fit[faceI];
486 // sf[faceI] += stWeight[i]*stData[i];
489 // See finiteVolume/lnInclude/leastSquaresGrad.C
492 Pout<< "End\n" << endl;
498 // ************************************************************************* //