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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2016-2018 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "pointSet.H"
30 #include "mapPolyMesh.H"
31 #include "polyMesh.H"
32 #include "syncTools.H"
33 #include "mapDistributePolyMesh.H"
35 
36 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37 
38 namespace Foam
39 {
40  defineTypeNameAndDebug(pointSet, 0);
41  addToRunTimeSelectionTable(topoSet, pointSet, word);
42  addToRunTimeSelectionTable(topoSet, pointSet, size);
43  addToRunTimeSelectionTable(topoSet, pointSet, set);
44 }
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
49 :
50  topoSet(obj, typeName)
51 {}
52 
53 
55 (
56  const polyMesh& mesh,
57  const word& name,
58  readOption r,
59  writeOption w
60 )
61 :
62  topoSet(mesh, typeName, name, r, w)
63 {
64  check(mesh.nPoints());
65 }
66 
67 
69 (
70  const polyMesh& mesh,
71  const word& name,
72  const label size,
73  writeOption w
74 )
75 :
76  topoSet(mesh, name, size, w)
77 {}
78 
79 
81 (
82  const polyMesh& mesh,
83  const word& name,
84  const topoSet& set,
85  writeOption w
86 )
87 :
88  topoSet(mesh, name, set, w)
89 {}
90 
91 
93 (
94  const polyMesh& mesh,
95  const word& name,
96  const labelHashSet& labels,
97  writeOption w
98 )
99 :
100  topoSet(mesh, name, labels, w)
101 {}
102 
103 
105 (
106  const polyMesh& mesh,
107  const word& name,
108  labelHashSet&& labels,
109  writeOption w
110 )
111 :
112  topoSet(mesh, name, std::move(labels), w)
113 {}
114 
115 
117 (
118  const polyMesh& mesh,
119  const word& name,
120  const labelUList& labels,
121  writeOption w
122 )
123 :
124  topoSet(mesh, name, labels, w)
125 {}
126 
127 
128 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
129 
131 {
132  labelHashSet& labels = *this;
133 
134  // Convert to boolList
135  // TBD: could change to using bitSet for the synchronization
136 
137  const label len = mesh.nPoints();
138 
139  boolList contents(len, false);
140 
141  for (const label pointi : labels)
142  {
143  contents.set(pointi);
144  }
145 
146  // The nullValue = 'false'
147  syncTools::syncPointList(mesh, contents, orEqOp<bool>(), false);
148 
149 
150  // Update labelHashSet
151 
152  for (label pointi=0; pointi < len; ++pointi)
153  {
154  if (contents.test(pointi))
155  {
156  labels.set(pointi);
157  }
158  }
159 }
160 
161 
162 Foam::label Foam::pointSet::maxSize(const polyMesh& mesh) const
163 {
164  return mesh.nPoints();
165 }
166 
167 
169 {
170  updateLabels(morphMap.reversePointMap());
171 }
172 
173 
175 {
176  labelHashSet& labels = *this;
177 
178  boolList contents(map.nOldPoints(), false);
179 
180  for (const label pointi : labels)
181  {
182  contents.set(pointi);
183  }
184 
185  map.distributePointData(contents);
186 
187  // The new length
188  const label len = contents.size();
189 
190  // Count - as per BitOps::count(contents)
191  label n = 0;
192  for (label i=0; i < len; ++i)
193  {
194  if (contents.test(i))
195  {
196  ++n;
197  }
198  }
199 
200 
201  // Update labelHashSet
202 
203  labels.clear();
204  labels.resize(2*n);
205 
206  for (label i=0; i < len; ++i)
207  {
208  if (contents.test(i))
209  {
210  labels.set(i);
211  }
212  }
213 }
214 
215 
217 (
218  Ostream& os,
219  const primitiveMesh& mesh,
220  const label maxLen
221 ) const
222 {
223  topoSet::writeDebug(os, mesh.points(), maxLen);
224 }
225 
226 
227 // ************************************************************************* //
Foam::topoSet::writeDebug
void writeDebug(Ostream &os, const label maxElem, topoSet::const_iterator &iter, label &elemI) const
Write part of contents nicely formatted. Prints labels only.
Definition: topoSet.C:224
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
Foam::pointSet::distribute
virtual void distribute(const mapDistributePolyMesh &)
Update any stored data for mesh redistribution.
Definition: pointSet.C:174
Foam::polyMesh::points
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:1069
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::BitOps::set
void set(List< bool > &bools, const labelRange &range)
Set the specified range 'on' in a boolList.
Definition: BitOps.C:37
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
mapPolyMesh.H
Foam::orEqOp
Definition: ops.H:86
Foam::pointSet::writeDebug
virtual void writeDebug(Ostream &os, const primitiveMesh &, const label maxLen) const
Write maxLen items with label and coordinates.
Definition: pointSet.C:217
polyMesh.H
Foam::HashSet< label, Hash< label > >
syncTools.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::syncTools::syncPointList
static void syncPointList(const polyMesh &mesh, List< T > &pointValues, const CombineOp &cop, const T &nullValue, const TransformOp &top)
Synchronize values on all mesh points.
Definition: syncToolsTemplates.C:721
Foam::primitiveMesh::nPoints
label nPoints() const noexcept
Number of mesh points.
Definition: primitiveMeshI.H:37
Foam::IOobject::writeOption
writeOption
Enumeration defining the write options.
Definition: IOobject.H:192
mapDistributePolyMesh.H
n
label n
Definition: TABSMDCalcMethod2.H:31
Foam::pointSet::maxSize
virtual label maxSize(const polyMesh &mesh) const
Return max index+1.
Definition: pointSet.C:162
Foam::check
static void check(const int retVal, const char *what)
Definition: ptscotchDecomp.C:80
Foam::topoSet
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:63
Foam::pointSet::sync
virtual void sync(const polyMesh &mesh)
Sync set across coupled patches. Adds coupled points to set.
Definition: pointSet.C:130
Foam::pointSet::updateMesh
virtual void updateMesh(const mapPolyMesh &morphMap)
Update any stored data for new labels.
Definition: pointSet.C:168
os
OBJstream os(runTime.globalPath()/outputName)
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::pointSet::pointSet
pointSet(const IOobject &obj)
Construct from IOobject.
Definition: pointSet.C:48
Foam::mapPolyMesh::reversePointMap
const labelList & reversePointMap() const
Reverse point map.
Definition: mapPolyMesh.H:469
Foam::List< bool >
Foam::UList< label >
Foam::List::set
std::enable_if< std::is_same< bool, TypeT >::value, bool >::type set(const label i, bool val=true)
A bitSet::set() method for a list of bool.
Definition: List.H:341
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:161
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::IOobject::readOption
readOption
Enumeration defining the read options.
Definition: IOobject.H:183
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::mapDistributePolyMesh
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Definition: mapDistributePolyMesh.H:66
Foam::mapDistributePolyMesh::nOldPoints
label nOldPoints() const
Number of points in mesh before distribution.
Definition: mapDistributePolyMesh.H:175
Foam::mapDistributePolyMesh::distributePointData
void distributePointData(List< T > &lst) const
Distribute list of point data.
Definition: mapDistributePolyMesh.H:242
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
pointSet.H
Foam::primitiveMesh
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:78