pointSet.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2025 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 "pointSet.H"
27 #include "polyMesh.H"
28 #include "polyTopoChangeMap.H"
29 #include "syncTools.H"
31 
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
38 
42 }
43 
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
48 :
49  topoSet(obj, typeName)
50 {}
51 
52 
54 (
55  const polyMesh& mesh,
56  const word& name,
57  readOption r,
58  writeOption w
59 )
60 :
61  topoSet(mesh, typeName, name, r, w)
62 {
63  check(mesh.nPoints());
64 }
65 
66 
68 (
69  const polyMesh& mesh,
70  const word& name,
71  const label size,
72  writeOption w
73 )
74 :
75  topoSet(mesh, name, size, w)
76 {}
77 
78 
80 (
81  const polyMesh& mesh,
82  const word& name,
83  const topoSet& set,
84  writeOption w
85 )
86 :
87  topoSet(mesh, name, set, w)
88 {}
89 
90 
92 (
93  const polyMesh& mesh,
94  const word& name,
95  const labelHashSet& set,
96  writeOption w
97 )
98 :
99  topoSet(mesh, name, set, w)
100 {}
101 
102 
103 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
104 
106 {}
107 
108 
109 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
110 
112 {
113  // Convert to boolList
114 
115  boolList contents(mesh.nPoints(), false);
116 
117  forAllConstIter(pointSet, *this, iter)
118  {
119  contents[iter.key()] = true;
120  }
122  (
123  mesh,
124  contents,
125  orEqOp<bool>(),
126  false // null value
127  );
128 
129  // Convert back to labelHashSet
130 
131  labelHashSet newContents(size());
132 
133  forAll(contents, pointi)
134  {
135  if (contents[pointi])
136  {
137  newContents.insert(pointi);
138  }
139  }
140 
141  transfer(newContents);
142 }
143 
144 
146 {
147  return mesh.nPoints();
148 }
149 
150 
152 {
153  updateLabels(map.reversePointMap());
154 }
155 
156 
158 (
159  Ostream& os,
160  const primitiveMesh& mesh,
161  const label maxLen
162 ) const
163 {
164  topoSet::writeDebug(os, mesh.points(), maxLen);
165 }
166 
167 
168 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:433
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:476
Macros for easy insertion into run-time selection tables.
bool insert(const Key &key)
Insert a new entry.
Definition: HashSet.H:109
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
readOption
Enumeration defining the read options.
Definition: IOobject.H:117
writeOption
Enumeration defining the write options.
Definition: IOobject.H:126
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A set of point labels.
Definition: pointSet.H:51
virtual label maxSize(const polyMesh &mesh) const
Return max index+1.
Definition: pointSet.C:145
virtual void sync(const polyMesh &mesh)
Sync set across coupled patches. Adds coupled points to set.
Definition: pointSet.C:111
pointSet(const IOobject &obj)
Construct from IOobject.
Definition: pointSet.C:47
virtual void writeDebug(Ostream &os, const primitiveMesh &, const label maxLen) const
Update any stored data for new labels.
Definition: pointSet.C:158
virtual ~pointSet()
Destructor.
Definition: pointSet.C:105
virtual void topoChange(const polyTopoChangeMap &map)
Update any stored data for new labels.
Definition: pointSet.C:151
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:1331
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
const labelList & reversePointMap() const
Reverse point map.
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:75
label nPoints() const
static void syncPointList(const polyMesh &, List< T > &, const CombineOp &cop, const T &nullValue, const TransformOp &top)
Synchronise values on all mesh points.
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:61
void check(const label maxLabel)
Check validity of contents.
Definition: topoSet.C:180
A class for handling words, derived from string.
Definition: word.H:62
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
addToRunTimeSelectionTable(polyPatch, mergedCyclicPolyPatch, word)
defineTypeNameAndDebug(combustionModel, 0)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.