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-2018 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 "mapPolyMesh.H"
28 #include "polyMesh.H"
29 #include "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  );
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 
153 void pointSet::updateMesh(const mapPolyMesh& morphMap)
154 {
155  updateLabels(morphMap.reversePointMap());
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
writeOption
Enumeration defining the write options.
Definition: IOobject.H:119
const labelList & reversePointMap() const
Reverse point map.
Definition: mapPolyMesh.H:458
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
A set of point labels.
Definition: pointSet.H:48
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:74
virtual void updateMesh(const mapPolyMesh &morphMap)
Update any stored data for new labels.
Definition: pointSet.C:153
virtual const pointField & points() const =0
Return mesh points.
void transfer(HashTable< nil, label, Hash< label > > &)
Transfer the contents of the argument table into this table.
Definition: HashTable.C:513
readOption
Enumeration defining the read options.
Definition: IOobject.H:110
bool insert(const Key &key)
Insert a new entry.
Definition: HashSet.H:111
void check(const label maxLabel)
Check validity of contents.
label size() const
Return number of elements in table.
Definition: HashTableI.H:65
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
Macros for easy insertion into run-time selection tables.
pointSet(const IOobject &obj)
Construct from IOobject.
Definition: pointSet.C:49
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:59
void writeDebug(Ostream &os, const label maxElem, topoSet::const_iterator &iter, label &elemI) const
Write part of contents nicely formatted. Prints labels only.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:29
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
defineTypeNameAndDebug(combustionModel, 0)
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:61
virtual label maxSize(const polyMesh &mesh) const
Return max index+1.
Definition: pointSet.C:147
virtual ~pointSet()
Destructor.
Definition: pointSet.C:107
static void syncPointList(const polyMesh &, List< T > &, const CombineOp &cop, const T &nullValue, const TransformOp &top)
Synchronise values on all mesh points.
topoSet(const IOobject &, const word &wantedType)
Construct from IOobject as explicitly passed type.
label nPoints() const
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
virtual void sync(const polyMesh &mesh)
Sync set across coupled patches. Adds coupled points to set.
Definition: pointSet.C:113
virtual void writeDebug(Ostream &os, const primitiveMesh &, const label maxLen) const
Update any stored data for new labels.
Definition: pointSet.C:160
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
Namespace for OpenFOAM.