/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Copyright (C) 2011-2025 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- 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 "pointToCell.H" #include "polyMesh.H" #include "pointSet.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { defineTypeNameAndDebug(pointToCell, 0); addToRunTimeSelectionTable(topoSetSource, pointToCell, word); } const Foam::NamedEnum Foam::pointToCell::pointActionNames_ { "any", "edge" }; // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // void Foam::pointToCell::combine(topoSet& set, const bool add) const { // Load the set pointSet loadedSet(mesh_, setName_); // Handle any selection if (option_ == ANY) { forAllConstIter(pointSet, loadedSet, iter) { const label pointi = iter.key(); const labelList& pCells = mesh_.pointCells()[pointi]; forAll(pCells, pCelli) { addOrDelete(set, pCells[pCelli], add); } } } else if (option_ == EDGE) { const faceList& faces = mesh_.faces(); forAll(faces, facei) { const face& f = faces[facei]; forAll(f, fp) { if (loadedSet.found(f[fp]) && loadedSet.found(f.nextLabel(fp))) { addOrDelete(set, mesh_.faceOwner()[facei], add); if (mesh_.isInternalFace(facei)) { addOrDelete(set, mesh_.faceNeighbour()[facei], add); } } } } } } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::pointToCell::pointToCell ( const polyMesh& mesh, const word& setName, const pointAction option ) : topoSetSource(mesh), setName_(setName), option_(option) {} Foam::pointToCell::pointToCell ( const polyMesh& mesh, const dictionary& dict ) : topoSetSource(mesh), setName_(dict.lookup("set")), option_(pointActionNames_.read(dict.lookup("option"))) {} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Foam::pointToCell::~pointToCell() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::pointToCell::applyToSet ( const topoSetSource::setAction action, topoSet& set ) const { if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) { Info<< " Adding cells according to pointSet " << setName_ << " ..." << endl; combine(set, true); } else if (action == topoSetSource::DELETE) { Info<< " Removing cells according to pointSet " << setName_ << " ..." << endl; combine(set, false); } } // ************************************************************************* //