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-2022 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 "polyTopoChangeMap.H"
28 #include "polyMesh.H"
29 #include "syncTools.H"
30 
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 
38 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
39 
41 
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  );
130 
131  // Convert back to labelHashSet
132 
133  labelHashSet newContents(size());
134 
135  forAll(contents, pointi)
136  {
137  if (contents[pointi])
138  {
139  newContents.insert(pointi);
140  }
141  }
142 
143  transfer(newContents);
144 }
145 
146 
147 label pointSet::maxSize(const polyMesh& mesh) const
148 {
149  return mesh.nPoints();
150 }
151 
152 
154 {
156 }
157 
158 
160 (
161  Ostream& os,
162  const primitiveMesh& mesh,
163  const label maxLen
164 ) const
165 {
166  topoSet::writeDebug(os, mesh.points(), maxLen);
167 }
168 
169 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170 
171 } // End namespace Foam
172 
173 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:477
Macros for easy insertion into run-time selection tables.
bool insert(const Key &key)
Insert a new entry.
Definition: HashSet.H:109
void transfer(HashTable< T, Key, Hash > &)
Transfer the contents of the argument table into this table.
Definition: HashTable.C:587
label size() const
Return number of elements in table.
Definition: HashTableI.H:65
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:147
virtual void sync(const polyMesh &mesh)
Sync set across coupled patches. Adds coupled points to set.
Definition: pointSet.C:113
pointSet(const IOobject &obj)
Construct from IOobject.
Definition: pointSet.C:49
virtual void writeDebug(Ostream &os, const primitiveMesh &, const label maxLen) const
Update any stored data for new labels.
Definition: pointSet.C:160
virtual ~pointSet()
Destructor.
Definition: pointSet.C:107
virtual void topoChange(const polyTopoChangeMap &map)
Update any stored data for new labels.
Definition: pointSet.C:153
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
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
virtual const pointField & points() const =0
Return mesh points.
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:65
void writeDebug(Ostream &os, const label maxElem, topoSet::const_iterator &iter, label &elemI) const
Write part of contents nicely formatted. Prints labels only.
void check(const label maxLabel)
Check validity of contents.
void updateLabels(const labelList &map)
Update map from map. Used to update cell/face labels.
A class for handling words, derived from string.
Definition: word.H:62
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)
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
defineTypeNameAndDebug(combustionModel, 0)