zoneToFace.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "zoneToFace.H"
27 #include "polyMesh.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34  defineTypeNameAndDebug(zoneToFace, 0);
35  addToRunTimeSelectionTable(topoSetSource, zoneToFace, word);
36  addToRunTimeSelectionTable(topoSetSource, zoneToFace, istream);
37 }
38 
39 
40 Foam::topoSetSource::addToUsageTable Foam::zoneToFace::usage_
41 (
42  zoneToFace::typeName,
43  "\n Usage: zoneToFace zone\n\n"
44  " Select all faces in the faceZone."
45  " Note:accepts wildcards for zone.\n\n"
46 );
47 
48 
49 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
50 
51 void Foam::zoneToFace::combine(topoSet& set, const bool add) const
52 {
53  bool hasMatched = false;
54 
55  forAll(mesh_.faceZones(), i)
56  {
57  const faceZone& zone = mesh_.faceZones()[i];
58 
59  if (zoneName_.match(zone.name()))
60  {
61  const labelList& faceLabels = mesh_.faceZones()[i];
62 
63  Info<< " Found matching zone " << zone.name()
64  << " with " << faceLabels.size() << " faces." << endl;
65 
66  hasMatched = true;
67 
68  forAll(faceLabels, i)
69  {
70  // Only do active faces
71  if (faceLabels[i] < mesh_.nFaces())
72  {
73  addOrDelete(set, faceLabels[i], add);
74  }
75  }
76  }
77  }
78 
79  if (!hasMatched)
80  {
82  << "Cannot find any faceZone named " << zoneName_ << endl
83  << "Valid names are " << mesh_.faceZones().names() << endl;
84  }
85 }
86 
87 
88 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
89 
91 (
92  const polyMesh& mesh,
93  const word& zoneName
94 )
95 :
96  topoSetSource(mesh),
97  zoneName_(zoneName)
98 {}
99 
100 
102 (
103  const polyMesh& mesh,
104  const dictionary& dict
105 )
106 :
107  topoSetSource(mesh),
108  zoneName_(dict.lookup("name"))
109 {}
110 
111 
113 (
114  const polyMesh& mesh,
115  Istream& is
116 )
117 :
118  topoSetSource(mesh),
119  zoneName_(checkIs(is))
120 {}
121 
122 
123 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
124 
126 {}
127 
128 
129 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
130 
132 (
133  const topoSetSource::setAction action,
134  topoSet& set
135 ) const
136 {
137  if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
138  {
139  Info<< " Adding all faces of faceZone " << zoneName_ << " ..."
140  << endl;
141 
142  combine(set, true);
143  }
144  else if (action == topoSetSource::DELETE)
145  {
146  Info<< " Removing all faces of faceZone " << zoneName_ << " ..."
147  << endl;
148 
149  combine(set, false);
150  }
151 }
152 
153 
154 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
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:256
virtual ~zoneToFace()
Destructor.
Definition: zoneToFace.C:125
zoneToFace(const polyMesh &mesh, const word &zoneName)
Construct from components.
Definition: zoneToFace.C:91
AccessType combine(const List< T > &, AccessOp aop=accessOp< T >())
Combines sublists into one big list.
Definition: ListListOps.C:34
Macros for easy insertion into run-time selection tables.
Base class of a source for a topoSet.
Definition: topoSetSource.H:63
A class for handling words, derived from string.
Definition: word.H:59
setAction
Enumeration defining the valid actions.
Definition: topoSetSource.H:82
List< label > labelList
A List of labels.
Definition: labelList.H:56
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
defineTypeNameAndDebug(combustionModel, 0)
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:61
virtual void applyToSet(const topoSetSource::setAction action, topoSet &) const
Definition: zoneToFace.C:132
#define WarningInFunction
Report a warning using Foam::Warning.
Class with constructor to add usage string to table.
messageStream Info
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Namespace for OpenFOAM.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:576