/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2017 OpenFOAM Foundation Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM 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. OpenFOAM 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 OpenFOAM. If not, see . \*---------------------------------------------------------------------------*/ #include "targetVolumeToCell.H" #include "polyMesh.H" #include "globalMeshData.H" #include "plane.H" #include "bitSet.H" #include "cellSet.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { defineTypeNameAndDebug(targetVolumeToCell, 0); addToRunTimeSelectionTable(topoSetSource, targetVolumeToCell, word); addToRunTimeSelectionTable(topoSetSource, targetVolumeToCell, istream); addToRunTimeSelectionTable(topoSetCellSource, targetVolumeToCell, word); addToRunTimeSelectionTable(topoSetCellSource, targetVolumeToCell, istream); addNamedToRunTimeSelectionTable ( topoSetCellSource, targetVolumeToCell, word, targetVolume ); addNamedToRunTimeSelectionTable ( topoSetCellSource, targetVolumeToCell, istream, targetVolume ); } Foam::topoSetSource::addToUsageTable Foam::targetVolumeToCell::usage_ ( targetVolumeToCell::typeName, "\n Usage: targetVolumeToCell (nx ny nz)\n\n" " Adjust plane until obtained selected volume\n\n" ); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // Foam::scalar Foam::targetVolumeToCell::volumeOfSet ( const bitSet& selected ) const { scalar sumVol = 0.0; // Loop over selected cells only for (const label celli : selected) { sumVol += mesh_.cellVolumes()[celli]; } return returnReduce(sumVol, sumOp()); } Foam::label Foam::targetVolumeToCell::selectCells ( const scalar normalComp, const bitSet& maskSet, bitSet& selected ) const { selected.resize(mesh_.nCells()); selected = false; label nSelected = 0; forAll(mesh_.cellCentres(), celli) { const point& cc = mesh_.cellCentres()[celli]; if (maskSet.test(celli) && ((cc & normal_) < normalComp)) { selected.set(celli); ++nSelected; } } return returnReduce(nSelected, sumOp