.. _program_listing_file_samplers_MultiCellSampler_MultiCellSampler.C: Program Listing for File MultiCellSampler.C =========================================== |exhale_lsh| :ref:`Return to documentation for file ` (``samplers/MultiCellSampler/MultiCellSampler.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 "MultiCellSampler.H" #include "meshSearch.H" #include "fvPatchFieldMapper.H" #include "volFields.H" #include "wallFvPatch.H" #include "objectRegistry.H" #include "IOField.H" #include "SampledField.H" #include "SampledVelocityField.H" #include "SampledPGradField.H" #include "SampledWallGradUField.H" #include "codeRules.H" #include "patchDistMethod.H" #include "scalarListIOList.H" #include "scalarListListIOList.H" #include "TreeCellFinder.H" #include "CrawlingCellFinder.H" #include "Sampler.H" #include "surfaceMesh.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #if !defined(DOXYGEN_SHOULD_SKIP_THIS) namespace Foam { defineTypeNameAndDebug(MultiCellSampler, 0); addToRunTimeSelectionTable(Sampler, MultiCellSampler, SamplerRTSTable); } #endif // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // void Foam::MultiCellSampler::createIndexList() { const label patchIndex = patch().index(); word hName; // Grab h for the current patch if (mesh_.foundObject("hSampler")) { hName = "hSampler"; } else { hName = "h"; } volScalarField & hField = const_cast(mesh_.lookupObject (hName)); scalarField hPatch = hField.boundaryField()[patchIndex]; if (cellFinderType() == "Crawling") { CrawlingCellFinder cellFinder(patch()); cellFinder.findCellIndices(indexList_, hPatch, hIsIndex_, excludeWallAdjacent_); } else if (cellFinderType() == "Tree") { if (hIsIndex_) { FatalErrorInFunction << "MultiCellSampler: hIsIndex is not supported by the Tree " << "sampler. Please use the Crawling sampler or provide h as " << "distances." << abort(FatalError); } TreeCellFinder cellFinder(patch()); cellFinder.findCellIndices(indexList_, hPatch, excludeWallAdjacent_); } else { FatalErrorInFunction << "MultiCellSampler: invalid sampler finder name, choose " << "Tree or Crawling. Current choice is " << cellFinderType() << abort(FatalError); } const vectorField & patchFaceCentres = patch().Cf(); const volVectorField & C = mesh_.C(); forAll(patch(), faceI) { h_[faceI].setSize(indexList_[faceI].size()); forAll(indexList_[faceI], i) { h_[faceI][i] = mag(C[indexList_[faceI][i]] - patchFaceCentres[faceI]); } } scalarField hTop(indexList_.size()); forAll(patch(), faceI) { const label n = h_[faceI].size() - 1; hTop[faceI] = h_[faceI][n]; } // If the h field holds the distance, reassign the real distance used if (!hIsIndex()) { hField.boundaryFieldRef()[patch().index()] == hTop; } // Grab samplingCells field volScalarField & samplingCells = const_cast ( mesh_.lookupObject ("samplingCells") ); label totalSize = 0; forAll(indexList_, i) { totalSize += indexList_[i].size(); forAll(indexList_[i], j) { samplingCells[indexList_[i][j]] = patchIndex; } } label totalPatchSize = patch().size(); reduce(totalPatchSize, sumOp