.. _program_listing_file_cellFinders_TreeCellFinder_TreeCellFinder.C: Program Listing for File TreeCellFinder.C ========================================= |exhale_lsh| :ref:`Return to documentation for file ` (``cellFinders/TreeCellFinder/TreeCellFinder.C``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp /*---------------------------------------------------------------------------* \ License This file is part of libWallModelledLES. libWallModelledLES is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. libWallModelledLES is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with libWallModelledLES. If not, see . \*---------------------------------------------------------------------------*/ #include "TreeCellFinder.H" #include "volFields.H" #include "surfaceFields.H" #include "codeRules.H" #include "treeDataCell.H" #include "treeDataFace.H" #include "treeBoundBox.H" #include "indexedOctree.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #if !defined(DOXYGEN_SHOULD_SKIP_THIS) namespace Foam { defineTypeNameAndDebug(TreeCellFinder, 0); addToRunTimeSelectionTable(CellFinder, TreeCellFinder, Patch); } #endif // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::TreeCellFinder::TreeCellFinder ( const fvPatch & p ) : CellFinder(p) { if (debug) { Info << "TreeCellFinder: Constructing from patch" << nl; } createFields(); } Foam::TreeCellFinder::TreeCellFinder ( const word & cellFinderName, const fvPatch & p ) : CellFinder(p) { } // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::TreeCellFinder::findCellIndices ( labelList & indexList, const scalarField & h ) const { scalar maxH = max(h); if (debug) { Info<< "TreeCellFinder: Constructing mesh bounding box" << nl; } treeBoundBox boundBox(mesh().bounds()); Random rndGen(261782); #ifdef FOAM_TREEBOUNDBOX_DOES_NOT_ACCEPT_RNG boundBox.extend(1e-4); #else boundBox.extend(rndGen, 1e-4); #endif boundBox.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); boundBox.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); tmp distField(distanceField()); const scalarField & dist = distField().primitiveField(); tmp tSearchCellLabels = findCandidateCellLabels(dist, h); const labelField & searchCellLabels = tSearchCellLabels(); autoPtr > treePtr ( new indexedOctree ( treeDataCell ( false, mesh_, searchCellLabels, polyMesh::CELL_TETS ), boundBox, 8, 10, 3.0 ) ); if (treePtr->nodes().empty() && (maxH != 0) && (patch().size())) { Warning << "TreeCellFinder: max(h) is " << maxH << " but no cell centres within " << "distance 2*max(h) were found. " << "Will sample from wall-adjacent cells." << nl; } if (debug) { Info<< "TreeCellFinder: Constructing face octree" << nl; } labelList bndFaces(mesh().nFaces() - mesh().nInternalFaces()); forAll(bndFaces, i) { bndFaces[i] = mesh().nInternalFaces() + i; } autoPtr > boundaryTreePtr ( new indexedOctree ( treeDataFace ( false, mesh(), bndFaces ), boundBox, 8, 10, 3.0 ) ); // Grab face centres and normals for each patch face const vectorField & faceCentres = patch().Cf(); const tmp tfaceNormals = patch().nf(); const vectorField faceNormals = tfaceNormals(); // Grab the global indices of adjacent cells const UList