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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2018 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 "syncTools.H"
30 
31 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
32 
34 (
35  const polyMesh& mesh,
36  const UList<point>& cellData,
37  List<point>& neighbourCellData
38 )
39 {
40  if (cellData.size() != mesh.nCells())
41  {
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  neighbourCellData.resize(mesh.nBoundaryFaces());
51 
52  for (const polyPatch& pp : patches)
53  {
54  label bFacei = pp.start()-mesh.nInternalFaces();
55 
56  const labelUList& faceCells = pp.faceCells();
57 
58  for (const label celli : faceCells)
59  {
60  neighbourCellData[bFacei] = cellData[celli];
61  ++bFacei;
62  }
63  }
64  syncTools::swapBoundaryFacePositions(mesh, neighbourCellData);
65 }
66 
67 
69 {
70  bitSet isMaster(mesh.nPoints());
71  bitSet unvisited(mesh.nPoints(), true);
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, i)
80  {
81  const label meshPointi = meshPoints[i];
82 
83  if (!slaves[i].empty() || !transformedSlaves[i].empty())
84  {
85  isMaster.set(meshPointi);
86  }
87  unvisited.unset(meshPointi);
88  }
89 
90  // Add in all unvisited points
91  isMaster |= unvisited;
92 
93  return isMaster;
94 }
95 
96 
98 {
99  bitSet isMaster(mesh.nEdges());
100  bitSet unvisited(mesh.nEdges(), true);
101 
102  const globalMeshData& globalData = mesh.globalData();
103  const labelList& meshEdges = globalData.coupledPatchMeshEdges();
104  const labelListList& slaves = globalData.globalEdgeSlaves();
105  const labelListList& transformedSlaves =
106  globalData.globalEdgeTransformedSlaves();
107 
108  forAll(meshEdges, i)
109  {
110  const label meshEdgei = meshEdges[i];
111 
112  if (!slaves[i].empty() || !transformedSlaves[i].empty())
113  {
114  isMaster.set(meshEdgei);
115  }
116  unvisited.unset(meshEdgei);
117  }
118 
119  // Add in all unvisited edges
120  isMaster |= unvisited;
121 
122  return isMaster;
123 }
124 
125 
127 {
128  bitSet isMaster(mesh.nFaces(), true);
129 
131 
132  for (const polyPatch& pp : patches)
133  {
134  if (pp.coupled())
135  {
136  if (!refCast<const coupledPolyPatch>(pp).owner())
137  {
138  isMaster.unset(pp.range());
139  }
140  }
141  }
142 
143  return isMaster;
144 }
145 
146 
148 (
149  const polyMesh& mesh
150 )
151 {
152  bitSet isMaster(mesh.nFaces(), true);
153 
155 
156  for (const polyPatch& pp : patches)
157  {
158  if (pp.coupled())
159  {
160  if (!refCast<const coupledPolyPatch>(pp).owner())
161  {
162  isMaster.unset(pp.range());
163  }
164  }
165  else
166  {
167  isMaster.unset(pp.range());
168  }
169  }
170 
171  return isMaster;
172 }
173 
174 
176 (
177  const polyMesh& mesh
178 )
179 {
180  bitSet isMaster(mesh.nFaces(), true);
181 
183 
184  for (const polyPatch& pp : patches)
185  {
186  if (!pp.coupled())
187  {
188  isMaster.unset(pp.range());
189  }
190  }
191 
192  return isMaster;
193 }
194 
195 
196 // ************************************************************************* //
Foam::syncTools::getInternalOrCoupledFaces
static bitSet getInternalOrCoupledFaces(const polyMesh &mesh)
Get per face whether it is internal or coupled.
Definition: syncTools.C:176
Foam::bitSet
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:63
Foam::List::resize
void resize(const label len)
Adjust allocated size of list.
Definition: ListI.H:139
Foam::polyBoundaryMesh
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
Definition: polyBoundaryMesh.H:63
Foam::primitiveMesh::nEdges
label nEdges() const
Number of mesh edges.
Definition: primitiveMeshI.H:67
Foam::syncTools::getMasterPoints
static bitSet getMasterPoints(const polyMesh &mesh)
Definition: syncTools.C:68
Foam::polyMesh::boundaryMesh
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:444
Foam::syncTools::getMasterFaces
static bitSet getMasterFaces(const polyMesh &mesh)
Definition: syncTools.C:126
syncTools.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::syncTools::swapBoundaryCellPositions
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:34
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:68
Foam::FatalError
error FatalError
Foam::globalMeshData
Various mesh related information for a parallel run. Upon construction, constructs all info using par...
Definition: globalMeshData.H:107
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:144
Foam::syncTools::getMasterEdges
static bitSet getMasterEdges(const polyMesh &mesh)
Definition: syncTools.C:97
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::UList
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:103
patches
const polyBoundaryMesh & patches
Definition: convertProcessorPatches.H:65
Foam::List::set
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:341
Foam::primitiveMesh::nFaces
label nFaces() const noexcept
Number of mesh faces.
Definition: primitiveMeshI.H:90
Foam::UList::size
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
Foam::polyMesh::globalData
const globalMeshData & globalData() const
Return parallel info.
Definition: polyMesh.C:1295
Foam::faceCells
Smooth ATC in cells next to a set of patches supplied by type.
Definition: faceCells.H:56
Foam::syncTools::getInternalOrMasterFaces
static bitSet getInternalOrMasterFaces(const polyMesh &mesh)
Definition: syncTools.C:148