faceSet.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-2022 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 "faceSet.H"
30 #include "polyMesh.H"
31 #include "mapPolyMesh.H"
32 #include "syncTools.H"
33 #include "mapDistributePolyMesh.H"
35 
36 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37 
38 namespace Foam
39 {
40  defineTypeNameAndDebug(faceSet, 0);
44 }
45 
46 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
47 
49 :
50  topoSet(io, typeName)
51 {}
52 
53 
55 (
56  const polyMesh& mesh,
57  const word& name,
60 )
61 :
62  topoSet(mesh, typeName, name, rOpt, wOpt)
63 {
64  check(mesh.nFaces());
65 }
66 
67 
69 (
70  const polyMesh& mesh,
71  const word& name,
72  const label size,
74 )
75 :
76  topoSet(mesh, name, size, wOpt)
77 {}
78 
79 
81 (
82  const polyMesh& mesh,
83  const word& name,
84  const topoSet& set,
86 )
87 :
88  topoSet(mesh, name, set, wOpt)
89 {}
90 
91 
93 (
94  const polyMesh& mesh,
95  const word& name,
96  const labelHashSet& labels,
98 )
99 :
100  topoSet(mesh, name, labels, wOpt)
101 {}
102 
103 
105 (
106  const polyMesh& mesh,
107  const word& name,
108  labelHashSet&& labels,
110 )
111 :
112  topoSet(mesh, name, std::move(labels), wOpt)
113 {}
114 
115 
117 (
118  const polyMesh& mesh,
119  const word& name,
120  const labelUList& labels,
122 )
123 :
124  topoSet(mesh, name, labels, wOpt)
125 {}
126 
127 
128 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
129 
130 void Foam::faceSet::sync(const polyMesh& mesh)
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.nFaces();
138 
139  boolList contents(len, false);
140 
141  for (const label facei : labels)
142  {
143  contents.set(facei);
144  }
145 
146  syncTools::syncFaceList(mesh, contents, orEqOp<bool>());
147 
148 
149  // Update labelHashSet
150 
151  for (label i=0; i < len; ++i)
152  {
153  if (contents.test(i))
154  {
155  labels.set(i);
156  }
157  }
158 }
159 
161 Foam::label Foam::faceSet::maxSize(const polyMesh& mesh) const
162 {
163  return mesh.nFaces();
164 }
165 
167 void Foam::faceSet::updateMesh(const mapPolyMesh& morphMap)
168 {
169  updateLabels(morphMap.reverseFaceMap());
170 }
171 
172 
174 {
175  labelHashSet& labels = *this;
176 
177  boolList contents(map.nOldFaces(), false);
178 
179  for (const label facei : labels)
180  {
181  contents.set(facei);
182  }
183 
184  map.distributeFaceData(contents);
185 
186  // The new length
187  const label len = contents.size();
188 
189  // Count - as per BitOps::count(contents)
190  label n = 0;
191  for (label i=0; i < len; ++i)
192  {
193  if (contents.test(i))
194  {
195  ++n;
196  }
197  }
198 
199  // Update labelHashSet
200 
201  labels.clear();
202  labels.reserve(n);
203 
204  for (label i=0; i < len; ++i)
205  {
206  if (contents.test(i))
207  {
208  labels.set(i);
209  }
210  }
211 }
212 
213 
215 (
216  Ostream& os,
217  const primitiveMesh& mesh,
218  const label maxLen
219 ) const
220 {
222 }
223 
224 
225 // ************************************************************************* //
virtual label maxSize(const polyMesh &mesh) const
Return max index+1.
Definition: faceSet.C:154
writeOption
Enumeration defining write preferences.
A list of face labels.
Definition: faceSet.H:47
virtual void distribute(const mapDistributePolyMesh &map)
Update any stored data for mesh redistribution.
Definition: faceSet.C:166
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:489
static void syncFaceList(const polyMesh &mesh, UList< T > &faceValues, const CombineOp &cop)
Synchronize values on all mesh faces.
Definition: syncTools.H:432
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
void set(List< bool > &bools, const labelUList &locations)
Set the listed locations (assign &#39;true&#39;).
Definition: BitOps.C:30
label nFaces() const noexcept
Number of mesh faces.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:157
Macros for easy insertion into run-time selection tables.
virtual void writeDebug(Ostream &os, const primitiveMesh &, const label maxLen) const
Write maxLen items with label and coordinates.
Definition: faceSet.C:208
void distributeFaceData(List< T > &values) const
Distribute list of face data.
dynamicFvMesh & mesh
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
A class for handling words, derived from Foam::string.
Definition: word.H:63
label nOldFaces() const noexcept
Number of faces in mesh before distribution.
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:217
OBJstream os(runTime.globalPath()/outputName)
defineTypeNameAndDebug(combustionModel, 0)
static void check(const int retVal, const char *what)
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:59
const vectorField & faceCentres() const
faceSet(const IOobject &io)
Construct from IOobject.
Definition: faceSet.C:41
label n
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
virtual void sync(const polyMesh &mesh)
Sync faceSet across coupled patches.
Definition: faceSet.C:123
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172
virtual void updateMesh(const mapPolyMesh &morphMap)
Update any stored data for new labels.
Definition: faceSet.C:160
const labelList & reverseFaceMap() const
Reverse face map.
Definition: mapPolyMesh.H:617
Namespace for OpenFOAM.
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)
readOption
Enumeration defining read preferences.