faceSet.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 "faceSet.H"
27 #include "polyMesh.H"
28 #include "polyTopoChangeMap.H"
29 #include "syncTools.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
37 
41 }
42 
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
47 :
48  topoSet(obj, typeName)
49 {}
50 
51 
53 (
54  const polyMesh& mesh,
55  const word& name,
56  readOption r,
57  writeOption w
58 )
59 :
60  topoSet(mesh, typeName, name, r, w)
61 {
62  check(mesh.nFaces());
63 }
64 
65 
67 (
68  const polyMesh& mesh,
69  const word& name,
70  const label size,
71  writeOption w
72 )
73 :
74  topoSet(mesh, name, size, w)
75 {}
76 
77 
79 (
80  const polyMesh& mesh,
81  const word& name,
82  const topoSet& set,
83  writeOption w
84 )
85 :
86  topoSet(mesh, name, set, w)
87 {}
88 
89 
91 (
92  const polyMesh& mesh,
93  const word& name,
94  const labelHashSet& set,
95  writeOption w
96 )
97 :
98  topoSet(mesh, name, set, w)
99 {}
100 
101 
102 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
103 
105 {}
106 
107 
108 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
109 
111 {
112  boolList set(mesh.nFaces(), false);
113 
114  forAllConstIter(faceSet, *this, iter)
115  {
116  set[iter.key()] = true;
117  }
119 
120  label nAdded = 0;
121 
122  forAll(set, facei)
123  {
124  if (set[facei])
125  {
126  if (insert(facei))
127  {
128  nAdded++;
129  }
130  }
131  else if (found(facei))
132  {
134  << "Problem : syncing removed faces from set."
135  << abort(FatalError);
136  }
137  }
138 
139  reduce(nAdded, sumOp<label>());
140  if (debug && nAdded > 0)
141  {
142  Info<< "Added an additional " << nAdded
143  << " faces on coupled patches. "
144  << "(processorPolyPatch, cyclicPolyPatch)" << endl;
145  }
146 }
147 
148 
150 {
151  return mesh.nFaces();
152 }
153 
154 
156 {
157  updateLabels(map.reverseFaceMap());
158 }
159 
160 
162 (
163  Ostream& os,
164  const primitiveMesh& mesh,
165  const label maxLen
166 ) const
167 {
168  topoSet::writeDebug(os, mesh.faceCentres(), maxLen);
169 }
170 
171 
172 // ************************************************************************* //
bool found
#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.
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 list of face labels.
Definition: faceSet.H:51
virtual label maxSize(const polyMesh &mesh) const
Return max index+1.
Definition: faceSet.C:149
virtual void sync(const polyMesh &mesh)
Sync faceSet across coupled patches.
Definition: faceSet.C:110
faceSet(const IOobject &obj)
Construct from IOobject.
Definition: faceSet.C:46
virtual void writeDebug(Ostream &os, const primitiveMesh &, const label maxLen) const
Write maxLen items with label and coordinates.
Definition: faceSet.C:162
virtual ~faceSet()
Destructor.
Definition: faceSet.C:104
virtual void topoChange(const polyTopoChangeMap &map)
Update any stored data for new labels.
Definition: faceSet.C:155
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 & reverseFaceMap() const
Reverse face map.
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:75
const vectorField & faceCentres() const
label nFaces() const
static void syncFaceList(const polyMesh &mesh, UList< T > &l, const CombineOp &cop)
Synchronise values on all mesh faces.
Definition: syncTools.H:387
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)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
void insert(const scalar, DynamicList< floatScalar > &)
Append scalar to given DynamicList.
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)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:258
errorManip< error > abort(error &err)
Definition: errorManip.H:131
messageStream Info
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
defineTypeNameAndDebug(combustionModel, 0)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
error FatalError