FreeFOAM The Cross-Platform CFD Toolkit
labelToPoint.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) 1991-2010 OpenCFD Ltd.
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 "labelToPoint.H"
27 #include <OpenFOAM/polyMesh.H>
28 
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 
36 defineTypeNameAndDebug(labelToPoint, 0);
37 
38 addToRunTimeSelectionTable(topoSetSource, labelToPoint, word);
39 
40 addToRunTimeSelectionTable(topoSetSource, labelToPoint, istream);
41 
42 }
43 
44 
45 Foam::topoSetSource::addToUsageTable Foam::labelToPoint::usage_
46 (
47  labelToPoint::typeName,
48  "\n Usage: labelToPoint (i0 i1 .. in)\n\n"
49  " Select points by label\n\n"
50 );
51 
52 
53 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
54 
55 void Foam::labelToPoint::combine(topoSet& set, const bool add) const
56 {
57  forAll(labels_, labelI)
58  {
59  addOrDelete(set, labels_[labelI], add);
60  }
61 }
62 
63 
64 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
65 
66 // Construct from components
68 (
69  const polyMesh& mesh,
70  const labelList& labels
71 )
72 :
73  topoSetSource(mesh),
74  labels_(labels)
75 {}
76 
77 
78 // Construct from dictionary
80 (
81  const polyMesh& mesh,
82  const dictionary& dict
83 )
84 :
85  topoSetSource(mesh),
86  labels_(dict.lookup("value"))
87 {}
88 
89 
90 // Construct from Istream
92 (
93  const polyMesh& mesh,
94  Istream& is
95 )
96 :
97  topoSetSource(mesh),
98  labels_(checkIs(is))
99 {}
100 
101 
102 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
103 
105 {}
106 
107 
108 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
109 
111 (
112  const topoSetSource::setAction action,
113  topoSet& set
114 ) const
115 {
116  if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
117  {
118  Info<< " Adding points mentioned in dictionary" << " ..." << endl;
119 
120  combine(set, true);
121  }
122  else if (action == topoSetSource::DELETE)
123  {
124  Info<< " Removing points mentioned in dictionary" << " ..."
125  << endl;
126 
127  combine(set, false);
128  }
129 }
130 
131 
132 // ************************ vim: set sw=4 sts=4 et: ************************ //