diff --git a/src/meshTools/topoSet/cellSources/boxToCell/boxToCell.H b/src/meshTools/topoSet/cellSources/boxToCell/boxToCell.H index 1da35b00b0..0775939338 100644 --- a/src/meshTools/topoSet/cellSources/boxToCell/boxToCell.H +++ b/src/meshTools/topoSet/cellSources/boxToCell/boxToCell.H @@ -50,7 +50,7 @@ Usage source boxToCell; // Conditional mandatory entries - // Select either of the below + // Select one of the below // Option-1 boxes diff --git a/src/meshTools/topoSet/cellSources/cellToCell/cellToCell.C b/src/meshTools/topoSet/cellSources/cellToCell/cellToCell.C index e43ab9ee64..667ccd02c3 100644 --- a/src/meshTools/topoSet/cellSources/cellToCell/cellToCell.C +++ b/src/meshTools/topoSet/cellSources/cellToCell/cellToCell.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2018-2020 OpenCFD Ltd. + Copyright (C) 2018-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -60,7 +60,8 @@ Foam::cellToCell::cellToCell ) : topoSetCellSource(mesh), - names_(one{}, setName) + names_(Foam::one{}, setName), + isZone_(false) {} @@ -71,15 +72,9 @@ Foam::cellToCell::cellToCell ) : topoSetCellSource(mesh, dict), - names_() -{ - // Look for 'sets' or 'set' - if (!dict.readIfPresent("sets", names_)) - { - names_.resize(1); - dict.readEntry("set", names_.front()); - } -} + names_(), + isZone_(topoSetSource::readNames(dict, names_)) +{} Foam::cellToCell::cellToCell @@ -89,7 +84,8 @@ Foam::cellToCell::cellToCell ) : topoSetCellSource(mesh), - names_(one{}, word(checkIs(is))) + names_(Foam::one{}, word(checkIs(is))), + isZone_(false) {} @@ -105,30 +101,44 @@ void Foam::cellToCell::applyToSet { if (verbose_) { - Info<< " Adding all elements of cell sets: " + Info<< " Adding all elements of cell " + << (isZone_ ? "zones: " : "sets: ") << flatOutput(names_) << nl; } for (const word& setName : names_) { - cellSet loadedSet(mesh_, setName); - - set.addSet(loadedSet); + if (isZone_) + { + set.addSet(mesh_.cellZones()[setName]); + } + else + { + cellSet loadedSet(mesh_, setName); + set.addSet(loadedSet); + } } } else if (action == topoSetSource::SUBTRACT) { if (verbose_) { - Info<< " Removing all elements of cell sets: " + Info<< " Removing all elements of cell " + << (isZone_ ? "zones: " : "sets: ") << flatOutput(names_) << nl; } for (const word& setName : names_) { - cellSet loadedSet(mesh_, setName); - - set.subtractSet(loadedSet); + if (isZone_) + { + set.subtractSet(mesh_.cellZones()[setName]); + } + else + { + cellSet loadedSet(mesh_, setName); + set.subtractSet(loadedSet); + } } } } diff --git a/src/meshTools/topoSet/cellSources/cellToCell/cellToCell.H b/src/meshTools/topoSet/cellSources/cellToCell/cellToCell.H index 1a42aa8b00..fb595cb787 100644 --- a/src/meshTools/topoSet/cellSources/cellToCell/cellToCell.H +++ b/src/meshTools/topoSet/cellSources/cellToCell/cellToCell.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011 OpenFOAM Foundation - Copyright (C) 2018-2020 OpenCFD Ltd. + Copyright (C) 2018-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -28,7 +28,8 @@ Class Foam::cellToCell Description - A \c topoSetCellSource to select all the cells from given \c cellSet(s). + A \c topoSetCellSource to select all the cells from given \c cellSet(s) + or \c cellZone(s). Operands: \table @@ -50,7 +51,7 @@ Usage source cellToCell; // Conditional mandatory entries - // Select either of the below + // Select one of the below // Option-1 sets @@ -61,7 +62,18 @@ Usage ); // Option-2 - set ; + zones + ( + + + ... + ); + + // Option-3 + set ; + + // Option-4 + zone ; } \endverbatim @@ -81,17 +93,15 @@ Usage subtract | Remove selected cells from this cellSet \endverbatim - Options for the conditional mandatory entries: + Options for the conditional mandatory entries (in order of precedence): \verbatim Entry | Description | Type | Req'd | Dflt sets | Names of input cellSets | wordList | cond'l | - + zones | Names of input cellZones | wordList | cond'l | - set | Name of input cellSet | word | cond'l | - + zone | Name of input cellZone | word | cond'l | - \endverbatim -Note - The order of precedence among the conditional mandatory entries from the - highest to the lowest is \c sets, and \c set. - See also - Foam::topoSetSource - Foam::topoSetCellSource @@ -101,8 +111,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef cellToCell_H -#define cellToCell_H +#ifndef Foam_cellToCell_H +#define Foam_cellToCell_H #include "topoSetCellSource.H" @@ -124,9 +134,12 @@ class cellToCell //- Add usage string static addToUsageTable usage_; - //- Names of sets to use + //- Names of sets or zones to use wordList names_; + //- Is name a set or a zone + const bool isZone_; + public: diff --git a/src/meshTools/topoSet/cellSources/faceToCell/faceToCell.C b/src/meshTools/topoSet/cellSources/faceToCell/faceToCell.C index ec52df9e2d..a71a70760b 100644 --- a/src/meshTools/topoSet/cellSources/faceToCell/faceToCell.C +++ b/src/meshTools/topoSet/cellSources/faceToCell/faceToCell.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2018-2020 OpenCFD Ltd. + Copyright (C) 2018-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -66,18 +66,14 @@ Foam::faceToCell::faceActionNames_ // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -void Foam::faceToCell::combine +template +void Foam::faceToCell::combineImpl ( topoSet& set, const bool add, - const word& setName + const Selector& faceLabels ) const { - // Load the set - faceSet loadedSet(mesh_, setName); - - const labelHashSet& faceLabels = loadedSet; - // Handle owner/neighbour/any selection for (const label facei : faceLabels) { @@ -104,7 +100,7 @@ void Foam::faceToCell::combine { // Count number of selected faces per cell. - Map