syncTools.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 | Copyright (C) 2011-2013 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 "syncTools.H"
27 
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
29 
31 (
32  const polyMesh& mesh,
33  const UList<point>& cellData,
34  List<point>& neighbourCellData
35 )
36 {
37  if (cellData.size() != mesh.nCells())
38  {
40  (
41  "syncTools<class T>::swapBoundaryCellPositions"
42  "(const polyMesh&, const UList<T>&, List<T>&)"
43  ) << "Number of cell values " << cellData.size()
44  << " is not equal to the number of cells in the mesh "
45  << mesh.nCells() << abort(FatalError);
46  }
47 
48  const polyBoundaryMesh& patches = mesh.boundaryMesh();
49 
50  label nBnd = mesh.nFaces()-mesh.nInternalFaces();
51 
52  neighbourCellData.setSize(nBnd);
53 
54  forAll(patches, patchI)
55  {
56  const polyPatch& pp = patches[patchI];
57  const labelUList& faceCells = pp.faceCells();
58  forAll(faceCells, i)
59  {
60  label bFaceI = pp.start()+i-mesh.nInternalFaces();
61  neighbourCellData[bFaceI] = cellData[faceCells[i]];
62  }
63  }
64  syncTools::swapBoundaryFacePositions(mesh, neighbourCellData);
65 }
66 
67 
69 {
70  PackedBoolList isMasterPoint(mesh.nPoints());
71  PackedBoolList donePoint(mesh.nPoints());
72 
73  const globalMeshData& globalData = mesh.globalData();
74  const labelList& meshPoints = globalData.coupledPatch().meshPoints();
75  const labelListList& slaves = globalData.globalPointSlaves();
76  const labelListList& transformedSlaves =
77  globalData.globalPointTransformedSlaves();
78 
79  forAll(meshPoints, coupledPointI)
80  {
81  label meshPointI = meshPoints[coupledPointI];
82  if
83  (
84  (
85  slaves[coupledPointI].size()
86  + transformedSlaves[coupledPointI].size()
87  )
88  > 0
89  )
90  {
91  isMasterPoint[meshPointI] = true;
92  }
93  donePoint[meshPointI] = true;
94  }
95 
96 
97  // Do all other points
98  // ~~~~~~~~~~~~~~~~~~~
99 
100  forAll(donePoint, pointI)
101  {
102  if (!donePoint[pointI])
103  {
104  isMasterPoint[pointI] = true;
105  }
106  }
107 
108  return isMasterPoint;
109 }
110 
111 
113 {
114  PackedBoolList isMasterEdge(mesh.nEdges());
115  PackedBoolList doneEdge(mesh.nEdges());
116 
117  const globalMeshData& globalData = mesh.globalData();
118  const labelList& meshEdges = globalData.coupledPatchMeshEdges();
119  const labelListList& slaves = globalData.globalEdgeSlaves();
120  const labelListList& transformedSlaves =
121  globalData.globalEdgeTransformedSlaves();
122 
123  forAll(meshEdges, coupledEdgeI)
124  {
125  label meshEdgeI = meshEdges[coupledEdgeI];
126  if
127  (
128  (
129  slaves[coupledEdgeI].size()
130  + transformedSlaves[coupledEdgeI].size()
131  )
132  > 0
133  )
134  {
135  isMasterEdge[meshEdgeI] = true;
136  }
137  doneEdge[meshEdgeI] = true;
138  }
139 
140 
141  // Do all other edges
142  // ~~~~~~~~~~~~~~~~~~
143 
144  forAll(doneEdge, edgeI)
145  {
146  if (!doneEdge[edgeI])
147  {
148  isMasterEdge[edgeI] = true;
149  }
150  }
151 
152  return isMasterEdge;
153 }
154 
155 
157 {
158  PackedBoolList isMasterFace(mesh.nFaces(), 1);
159 
160  const polyBoundaryMesh& patches = mesh.boundaryMesh();
161 
162  forAll(patches, patchI)
163  {
164  if (patches[patchI].coupled())
165  {
166  const coupledPolyPatch& pp =
167  refCast<const coupledPolyPatch>(patches[patchI]);
168 
169  if (!pp.owner())
170  {
171  forAll(pp, i)
172  {
173  isMasterFace.unset(pp.start()+i);
174  }
175  }
176  }
177  }
178 
179  return isMasterFace;
180 }
181 
182 
184 (
185  const polyMesh& mesh
186 )
187 {
188  PackedBoolList isMasterFace(mesh.nFaces(), 1);
189 
190  const polyBoundaryMesh& patches = mesh.boundaryMesh();
191 
192  forAll(patches, patchI)
193  {
194  const polyPatch& pp = patches[patchI];
195 
196  if (pp.coupled())
197  {
198  if (!refCast<const coupledPolyPatch>(pp).owner())
199  {
200  forAll(pp, i)
201  {
202  isMasterFace.unset(pp.start()+i);
203  }
204  }
205  }
206  else
207  {
208  forAll(pp, i)
209  {
210  isMasterFace.unset(pp.start()+i);
211  }
212  }
213  }
214 
215  return isMasterFace;
216 }
217 
218 
220 (
221  const polyMesh& mesh
222 )
223 {
224  PackedBoolList isMasterFace(mesh.nFaces(), 1);
225 
226  const polyBoundaryMesh& patches = mesh.boundaryMesh();
227 
228  forAll(patches, patchI)
229  {
230  const polyPatch& pp = patches[patchI];
231 
232  if (!pp.coupled())
233  {
234  forAll(pp, i)
235  {
236  isMasterFace.unset(pp.start()+i);
237  }
238  }
239  }
240 
241  return isMasterFace;
242 }
243 
244 
245 // ************************************************************************* //
static PackedBoolList getMasterFaces(const polyMesh &)
Get per face whether it is uncoupled or a master of a.
Definition: syncTools.C:156
label nFaces() const
virtual bool coupled() const
Return true if this patch is geometrically coupled (i.e. faces and.
Definition: polyPatch.H:310
static PackedBoolList getInternalOrMasterFaces(const polyMesh &)
Get per face whether it is internal or a master of a.
Definition: syncTools.C:184
const labelUList & faceCells() const
Return face-cell addressing.
Definition: polyPatch.C:316
A bit-packed bool list.
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
static PackedBoolList getMasterEdges(const polyMesh &)
Get per edge whether it is uncoupled or a master of a.
Definition: syncTools.C:112
label nCells() const
label nEdges() const
static PackedBoolList getMasterPoints(const polyMesh &)
Get per point whether it is uncoupled or a master of a.
Definition: syncTools.C:68
static PackedBoolList getInternalOrCoupledFaces(const polyMesh &)
Get per face whether it is internal or coupled.
Definition: syncTools.C:220
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
patches[0]
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
static void swapBoundaryCellPositions(const polyMesh &mesh, const UList< point > &cellData, List< point > &neighbourCellData)
Swap to obtain neighbour cell positions for all boundary faces.
Definition: syncTools.C:31
void setSize(const label)
Reset size of List.
Definition: List.C:318
Foam::polyBoundaryMesh.
#define forAll(list, i)
Definition: UList.H:421
label size() const
Return the number of elements in the UList.
Definition: UListI.H:299
errorManip< error > abort(error &err)
Definition: errorManip.H:131
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:421
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:314
Various mesh related information for a parallel run. Upon construction, constructs all info using par...
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:300
label nInternalFaces() const
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
error FatalError
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:60
virtual bool owner() const =0
Does this side own the patch ?
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
label nPoints() const
const globalMeshData & globalData() const
Return parallel info.
Definition: polyMesh.C:1200