Loading...
Searching...
No Matches
cellToCell.C
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2017 OpenFOAM Foundation
9 Copyright (C) 2018-2024 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29#include "cellToCell.H"
30#include "polyMesh.H"
31#include "cellSet.H"
34// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36namespace Foam
37{
43}
44
45
46Foam::topoSetSource::addToUsageTable Foam::cellToCell::usage_
47(
48 cellToCell::typeName,
49 "\n Usage: cellToCell <cellSet>\n\n"
50 " Select all cells in the cellSet\n\n"
51);
52
53
54// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
55
57(
58 const polyMesh& mesh,
59 const word& setName
60)
63 names_(Foam::one{}, setName),
64 isZone_(false)
65{}
66
67
69(
70 const polyMesh& mesh,
71 const dictionary& dict
72)
75 names_(),
76 isZone_(topoSetSource::readNames(dict, names_))
77{}
78
79
81(
82 const polyMesh& mesh,
83 Istream& is
84)
85:
87 names_(Foam::one{}, word(checkIs(is))),
88 isZone_(false)
89{}
90
91
92// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
93
95(
96 const topoSetSource::setAction action,
97 topoSet& set
98) const
99{
100 if (action == topoSetSource::ADD || action == topoSetSource::NEW)
101 {
102 if (verbose_)
103 {
104 Info<< " Adding all elements of cell "
105 << (isZone_ ? "zones: " : "sets: ")
106 << flatOutput(names_) << nl;
107 }
108
109 for (const word& setName : names_)
110 {
111 if (isZone_)
112 {
113 set.addSet(mesh_.cellZones()[setName]);
114 }
115 else
116 {
117 cellSet loadedSet(mesh_, setName, IOobject::NO_REGISTER);
118 set.addSet(loadedSet);
119 }
120 }
121 }
122 else if (action == topoSetSource::SUBTRACT)
123 {
124 if (verbose_)
125 {
126 Info<< " Removing all elements of cell "
127 << (isZone_ ? "zones: " : "sets: ")
128 << flatOutput(names_) << nl;
129 }
130
131 for (const word& setName : names_)
132 {
133 if (isZone_)
134 {
135 set.subtractSet(mesh_.cellZones()[setName]);
136 }
137 else
138 {
139 cellSet loadedSet(mesh_, setName, IOobject::NO_REGISTER);
140 set.subtractSet(loadedSet);
141 }
142 }
143 }
144}
145
146
147// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
@ NO_REGISTER
Do not request registration (bool: false).
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
A collection of cell labels.
Definition cellSet.H:50
A topoSetCellSource to select all the cells from given cellSet(s) or cellZone(s).
Definition cellToCell.H:168
virtual void applyToSet(const topoSetSource::setAction action, topoSet &set) const
Apply specified action to the topoSet.
Definition cellToCell.C:88
cellToCell(const polyMesh &mesh, const word &setName)
Construct from components.
Definition cellToCell.C:50
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
A class representing the concept of 1 (one) that can be used to avoid manipulating objects known to b...
Definition one.H:57
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
const cellZoneMesh & cellZones() const noexcept
Return cell zone mesh.
Definition polyMesh.H:679
The topoSetCellSource is a intermediate class for handling topoSet sources for selecting cells.
topoSetCellSource(const polyMesh &mesh)
Construct from mesh.
Class with constructor to add usage string to table.
Base class of a source for a topoSet.
static bool readNames(const dictionary &dict, wordList &names)
Helper: extract wordList of patches/zones from dictionary. Returns.
setAction
Enumeration defining various actions.
@ SUBTRACT
Subtract elements from current set.
@ ADD
Add elements to current set.
@ NEW
Create a new set and ADD elements to it.
bool verbose_
Output verbosity (default: true).
const polyMesh & mesh() const noexcept
Reference to the mesh.
const polyMesh & mesh_
Reference to the mesh.
static Istream & checkIs(Istream &is)
Check state of stream.
General set of labels of mesh quantity (points, cells, faces).
Definition topoSet.H:63
A class for handling words, derived from Foam::string.
Definition word.H:66
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
dynamicFvMesh & mesh
void set(List< bool > &bools, const labelUList &locations)
Set the listed locations (assign 'true').
Definition BitOps.C:35
Namespace for OpenFOAM.
messageStream Info
Information stream (stdout output on master, null elsewhere).
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
Definition FlatOutput.H:217
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
dictionary dict