FreeFOAM The Cross-Platform CFD Toolkit
faceToPoint.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 "faceToPoint.H"
27 #include <OpenFOAM/polyMesh.H>
28 #include <meshTools/faceSet.H>
29 
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 
37 defineTypeNameAndDebug(faceToPoint, 0);
38 
39 addToRunTimeSelectionTable(topoSetSource, faceToPoint, word);
40 
41 addToRunTimeSelectionTable(topoSetSource, faceToPoint, istream);
42 
43 }
44 
45 
46 Foam::topoSetSource::addToUsageTable Foam::faceToPoint::usage_
47 (
48  faceToPoint::typeName,
49  "\n Usage: faceToPoint <faceSet> all\n\n"
50  " Select all points of faces in the faceSet\n\n"
51 );
52 
53 template<>
55 {
56  "all"
57 };
58 
60  Foam::faceToPoint::faceActionNames_;
61 
62 
63 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
64 
65 void Foam::faceToPoint::combine(topoSet& set, const bool add) const
66 {
67  // Load the set
68  faceSet loadedSet(mesh_, setName_);
69 
70  // Add all points from faces in loadedSet
71  for
72  (
73  faceSet::const_iterator iter = loadedSet.begin();
74  iter != loadedSet.end();
75  ++iter
76  )
77  {
78  const face& f = mesh_.faces()[iter.key()];
79 
80  forAll(f, fp)
81  {
82  addOrDelete(set, f[fp], add);
83  }
84  }
85 }
86 
87 
88 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
89 
90 // Construct from components
92 (
93  const polyMesh& mesh,
94  const word& setName,
95  const faceAction option
96 )
97 :
98  topoSetSource(mesh),
99  setName_(setName),
100  option_(option)
101 {}
102 
103 
104 // Construct from dictionary
106 (
107  const polyMesh& mesh,
108  const dictionary& dict
109 )
110 :
111  topoSetSource(mesh),
112  setName_(dict.lookup("set")),
113  option_(faceActionNames_.read(dict.lookup("option")))
114 {}
115 
116 
117 // Construct from Istream
119 (
120  const polyMesh& mesh,
121  Istream& is
122 )
123 :
124  topoSetSource(mesh),
125  setName_(checkIs(is)),
126  option_(faceActionNames_.read(checkIs(is)))
127 {}
128 
129 
130 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
131 
133 {}
134 
135 
136 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
137 
139 (
140  const topoSetSource::setAction action,
141  topoSet& set
142 ) const
143 {
144  if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
145  {
146  Info<< " Adding points from face in faceSet " << setName_
147  << " ..." << endl;
148 
149  combine(set, true);
150  }
151  else if (action == topoSetSource::DELETE)
152  {
153  Info<< " Removing points from face in faceSet " << setName_
154  << " ..." << endl;
155 
156  combine(set, false);
157  }
158 }
159 
160 
161 // ************************ vim: set sw=4 sts=4 et: ************************ //