FreeFOAM The Cross-Platform CFD Toolkit
pointSet.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 "pointSet.H"
27 #include <OpenFOAM/mapPolyMesh.H>
28 #include <OpenFOAM/polyMesh.H>
29 #include <OpenFOAM/syncTools.H>
30 
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 
38 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
39 
40 defineTypeNameAndDebug(pointSet, 0);
41 
42 addToRunTimeSelectionTable(topoSet, pointSet, word);
43 addToRunTimeSelectionTable(topoSet, pointSet, size);
44 addToRunTimeSelectionTable(topoSet, pointSet, set);
45 
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
50 :
51  topoSet(obj, typeName)
52 {}
53 
54 
56 (
57  const polyMesh& mesh,
58  const word& name,
59  readOption r,
60  writeOption w
61 )
62 :
63  topoSet(mesh, typeName, name, r, w)
64 {
65  check(mesh.nPoints());
66 }
67 
68 
70 (
71  const polyMesh& mesh,
72  const word& name,
73  const label size,
74  writeOption w
75 )
76 :
77  topoSet(mesh, name, size, w)
78 {}
79 
80 
82 (
83  const polyMesh& mesh,
84  const word& name,
85  const topoSet& set,
86  writeOption w
87 )
88 :
89  topoSet(mesh, name, set, w)
90 {}
91 
92 
94 (
95  const polyMesh& mesh,
96  const word& name,
97  const labelHashSet& set,
98  writeOption w
99 )
100 :
101  topoSet(mesh, name, set, w)
102 {}
103 
104 
105 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
106 
108 {}
109 
110 
111 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
112 
113 void pointSet::sync(const polyMesh& mesh)
114 {
115  // Convert to boolList
116 
117  boolList contents(mesh.nPoints(), false);
118 
119  forAllConstIter(pointSet, *this, iter)
120  {
121  contents[iter.key()] = true;
122  }
124  (
125  mesh,
126  contents,
127  orEqOp<bool>(),
128  false, // null value
129  false // no separation
130  );
131 
132  // Convert back to labelHashSet
133 
134  labelHashSet newContents(size());
135 
136  forAll(contents, pointI)
137  {
138  if (contents[pointI])
139  {
140  newContents.insert(pointI);
141  }
142  }
143 
144  transfer(newContents);
145 }
146 
147 
148 label pointSet::maxSize(const polyMesh& mesh) const
149 {
150  return mesh.nPoints();
151 }
152 
153 
154 void pointSet::updateMesh(const mapPolyMesh& morphMap)
155 {
156  updateLabels(morphMap.reversePointMap());
157 }
158 
159 
161 (
162  Ostream& os,
163  const primitiveMesh& mesh,
164  const label maxLen
165 ) const
166 {
167  topoSet::writeDebug(os, mesh.points(), maxLen);
168 }
169 
170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
171 
172 } // End namespace Foam
173 
174 // ************************ vim: set sw=4 sts=4 et: ************************ //