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