faceZoneToFaceZone.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-2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 "faceZoneToFaceZone.H"
30 #include "polyMesh.H"
31 #include "faceZoneSet.H"
33 
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38  defineTypeNameAndDebug(faceZoneToFaceZone, 0);
39  addToRunTimeSelectionTable(topoSetSource, faceZoneToFaceZone, word);
40  addToRunTimeSelectionTable(topoSetSource, faceZoneToFaceZone, istream);
41 
43  (
44  topoSetFaceZoneSource,
45  faceZoneToFaceZone,
46  word
47  );
49  (
50  topoSetFaceZoneSource,
51  faceZoneToFaceZone,
52  istream
53  );
54 }
55 
56 
57 Foam::topoSetSource::addToUsageTable Foam::faceZoneToFaceZone::usage_
58 (
59  faceZoneToFaceZone::typeName,
60  "\n Usage: faceZoneToFaceZone <faceZone>\n\n"
61  " Select all faces in the faceZone\n\n"
62 );
63 
64 
65 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
66 
68 (
69  const polyMesh& mesh,
70  const word& setName
71 )
72 :
74  setName_(setName)
75 {}
76 
77 
79 (
80  const polyMesh& mesh,
81  const dictionary& dict
82 )
83 :
85  setName_(dict.get<word>("zone"))
86 {}
87 
88 
90 (
91  const polyMesh& mesh,
92  Istream& is
93 )
94 :
96  setName_(checkIs(is))
97 {}
98 
99 
100 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
101 
103 (
104  const topoSetSource::setAction action,
105  topoSet& set
106 ) const
107 {
108  if (!isA<faceZoneSet>(set))
109  {
111  << "Operation only allowed on a faceZoneSet." << endl;
112  return;
113  }
114  else
115  {
116  faceZoneSet& zoneSet = refCast<faceZoneSet>(set);
117 
118  if (action == topoSetSource::ADD || action == topoSetSource::NEW)
119  {
120  if (verbose_)
121  {
122  Info<< " Adding all faces from face zone: "
123  << setName_ << " ..." << endl;
124  }
125 
126  // Load the set
127  faceZoneSet loadedSet(mesh_, setName_);
128 
129  DynamicList<label> newAddressing(zoneSet.addressing());
130  DynamicList<bool> newFlipMap(zoneSet.flipMap());
131 
132  forAll(loadedSet.addressing(), i)
133  {
134  if (!zoneSet.found(loadedSet.addressing()[i]))
135  {
136  newAddressing.append(loadedSet.addressing()[i]);
137  newFlipMap.append(loadedSet.flipMap()[i]);
138  }
139  }
140  zoneSet.addressing().transfer(newAddressing);
141  zoneSet.flipMap().transfer(newFlipMap);
142  zoneSet.updateSet();
143  }
144  else if (action == topoSetSource::SUBTRACT)
145  {
146  if (verbose_)
147  {
148  Info<< " Removing all faces from face zone: "
149  << setName_ << " ..." << endl;
150  }
151 
152  // Load the set
153  faceZoneSet loadedSet(mesh_, setName_);
154 
155  DynamicList<label> newAddressing(zoneSet.addressing().size());
156  DynamicList<bool> newFlipMap(zoneSet.flipMap().size());
157 
158  forAll(zoneSet.addressing(), i)
159  {
160  if (!loadedSet.found(zoneSet.addressing()[i]))
161  {
162  newAddressing.append(zoneSet.addressing()[i]);
163  newFlipMap.append(zoneSet.flipMap()[i]);
164  }
165  }
166  zoneSet.addressing().transfer(newAddressing);
167  zoneSet.flipMap().transfer(newFlipMap);
168  zoneSet.updateSet();
169  }
170  }
171 }
172 
173 
174 // ************************************************************************* //
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
dictionary dict
faceZoneToFaceZone(const polyMesh &mesh, const word &setName)
Construct from components.
bool verbose_
Output verbosity (default: true)
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
virtual void applyToSet(const topoSetSource::setAction action, topoSet &set) const
Apply specified action to the topoSet.
Create a new set and ADD elements to it.
Add elements to current set.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
Macros for easy insertion into run-time selection tables.
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
dynamicFvMesh & mesh
A class for handling words, derived from Foam::string.
Definition: word.H:63
setAction
Enumeration defining various actions.
const polyMesh & mesh_
Reference to the mesh.
defineTypeNameAndDebug(combustionModel, 0)
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:59
Subtract elements from current set.
#define WarningInFunction
Report a warning using Foam::Warning.
Class with constructor to add usage string to table.
messageStream Info
Information stream (stdout output on master, null elsewhere)
The topoSetFaceZoneSource is a intermediate class for handling topoSet sources for selecting face zon...
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Namespace for OpenFOAM.
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)