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-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 "faceSet.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(faceSet, 0);
41 
42 addToRunTimeSelectionTable(topoSet, faceSet, word);
43 addToRunTimeSelectionTable(topoSet, faceSet, size);
44 addToRunTimeSelectionTable(topoSet, faceSet, 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.nFaces());
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 faceSet::sync(const polyMesh& mesh)
114 {
115  boolList set(mesh.nFaces(), false);
116 
117  forAllConstIter(faceSet, *this, iter)
118  {
119  set[iter.key()] = true;
120  }
122 
123  label nAdded = 0;
124 
125  forAll(set, facei)
126  {
127  if (set[facei])
128  {
129  if (insert(facei))
130  {
131  nAdded++;
132  }
133  }
134  else if (found(facei))
135  {
137  << "Problem : syncing removed faces from set."
138  << abort(FatalError);
139  }
140  }
141 
142  reduce(nAdded, sumOp<label>());
143  if (debug && nAdded > 0)
144  {
145  Info<< "Added an additional " << nAdded
146  << " faces on coupled patches. "
147  << "(processorPolyPatch, cyclicPolyPatch)" << endl;
148  }
149 }
150 
151 
152 label faceSet::maxSize(const polyMesh& mesh) const
153 {
154  return mesh.nFaces();
155 }
156 
157 
158 void faceSet::updateMesh(const mapPolyMesh& morphMap)
159 {
160  updateLabels(morphMap.reverseFaceMap());
161 }
162 
163 
165 (
166  Ostream& os,
167  const primitiveMesh& mesh,
168  const label maxLen
169 ) const
170 {
171  topoSet::writeDebug(os, mesh.faceCentres(), maxLen);
172 }
173 
174 
175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 
177 } // End namespace Foam
178 
179 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
writeOption
Enumeration defining the write options.
Definition: IOobject.H:119
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 list of face labels.
Definition: faceSet.H:48
error FatalError
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:323
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:74
label nFaces() const
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
virtual label maxSize(const polyMesh &mesh) const
Return max index+1.
Definition: faceSet.C:152
readOption
Enumeration defining the read options.
Definition: IOobject.H:110
bool insert(const label &key)
Insert a new entry.
Definition: HashSet.H:111
void check(const label maxLabel)
Check validity of contents.
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.
virtual void writeDebug(Ostream &os, const primitiveMesh &, const label maxLen) const
Write maxLen items with label and coordinates.
Definition: faceSet.C:165
void updateLabels(const labelList &map)
Update map from map. Used to update cell/face labels.
bool found(const label &) const
Return true if hashedEntry is found in table.
Definition: HashTable.C:113
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
errorManip< error > abort(error &err)
Definition: errorManip.H:131
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
faceSet(const IOobject &obj)
Construct from IOobject.
Definition: faceSet.C:49
defineTypeNameAndDebug(combustionModel, 0)
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:61
virtual ~faceSet()
Destructor.
Definition: faceSet.C:107
const vectorField & faceCentres() const
static void syncFaceList(const polyMesh &mesh, UList< T > &l, const CombineOp &cop)
Synchronise values on all mesh faces.
Definition: syncTools.H:381
topoSet(const IOobject &, const word &wantedType)
Construct from IOobject as explicitly passed type.
messageStream Info
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
virtual void sync(const polyMesh &mesh)
Sync faceSet across coupled patches.
Definition: faceSet.C:113
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
virtual void updateMesh(const mapPolyMesh &morphMap)
Update any stored data for new labels.
Definition: faceSet.C:158
const labelList & reverseFaceMap() const
Reverse face map.
Definition: mapPolyMesh.H:490
Namespace for OpenFOAM.