zoneToPoint.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 | Copyright (C) 2011 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 "zoneToPoint.H"
27 #include "polyMesh.H"
28 
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 
36 defineTypeNameAndDebug(zoneToPoint, 0);
37 
38 addToRunTimeSelectionTable(topoSetSource, zoneToPoint, word);
39 
40 addToRunTimeSelectionTable(topoSetSource, zoneToPoint, istream);
41 
42 }
43 
44 
45 Foam::topoSetSource::addToUsageTable Foam::zoneToPoint::usage_
46 (
47  zoneToPoint::typeName,
48  "\n Usage: zoneToPoint zone\n\n"
49  " Select all points in the pointZone."
50  " Note:accepts wildcards for zone.\n\n"
51 );
52 
53 
54 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
55 
56 void Foam::zoneToPoint::combine(topoSet& set, const bool add) const
57 {
58  bool hasMatched = false;
59 
60  forAll(mesh_.pointZones(), i)
61  {
62  const pointZone& zone = mesh_.pointZones()[i];
63 
64  if (zoneName_.match(zone.name()))
65  {
66  const labelList& pointLabels = mesh_.pointZones()[i];
67 
68  Info<< " Found matching zone " << zone.name()
69  << " with " << pointLabels.size() << " points." << endl;
70 
71  hasMatched = true;
72 
73  forAll(pointLabels, i)
74  {
75  // Only do active points
76  if (pointLabels[i] < mesh_.nPoints())
77  {
78  addOrDelete(set, pointLabels[i], add);
79  }
80  }
81  }
82  }
83 
84  if (!hasMatched)
85  {
86  WarningIn("zoneToPoint::combine(topoSet&, const bool)")
87  << "Cannot find any pointZone named " << zoneName_ << endl
88  << "Valid names are " << mesh_.pointZones().names() << endl;
89  }
90 }
91 
92 
93 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
94 
95 // Construct from components
97 (
98  const polyMesh& mesh,
99  const word& zoneName
100 )
101 :
102  topoSetSource(mesh),
103  zoneName_(zoneName)
104 {}
105 
106 
107 // Construct from dictionary
109 (
110  const polyMesh& mesh,
111  const dictionary& dict
112 )
113 :
114  topoSetSource(mesh),
115  zoneName_(dict.lookup("name"))
116 {}
117 
118 
119 // Construct from Istream
121 (
122  const polyMesh& mesh,
123  Istream& is
124 )
125 :
126  topoSetSource(mesh),
127  zoneName_(checkIs(is))
128 {}
129 
130 
131 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
132 
134 {}
135 
136 
137 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
138 
140 (
141  const topoSetSource::setAction action,
142  topoSet& set
143 ) const
144 {
145  if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
146  {
147  Info<< " Adding all points of pointZone " << zoneName_ << " ..."
148  << endl;
149 
150  combine(set, true);
151  }
152  else if (action == topoSetSource::DELETE)
153  {
154  Info<< " Removing all points of pointZone " << zoneName_ << " ..."
155  << endl;
156 
157  combine(set, false);
158  }
159 }
160 
161 
162 // ************************************************************************* //
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:61
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
A class for handling words, derived from string.
Definition: word.H:59
messageStream Info
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
Namespace for OpenFOAM.
AccessType combine(const List< T > &, AccessOp aop=accessOp< T >())
Combines sublists into one big list.
Definition: ListListOps.C:34
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
#define WarningIn(functionName)
Report a warning using Foam::Warning.
zoneToPoint(const polyMesh &mesh, const word &zoneName)
Construct from components.
Definition: zoneToPoint.C:97
#define forAll(list, i)
Definition: UList.H:421
virtual ~zoneToPoint()
Destructor.
Definition: zoneToPoint.C:133
setAction
Enumeration defining the valid actions.
Definition: topoSetSource.H:82
Macros for easy insertion into run-time selection tables.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:452
List< label > labelList
A List of labels.
Definition: labelList.H:56
virtual void applyToSet(const topoSetSource::setAction action, topoSet &) const
Definition: zoneToPoint.C:140
Base class of a source for a topoSet.
Definition: topoSetSource.H:63
Class with constructor to add usage string to table.
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
defineTypeNameAndDebug(combustionModel, 0)