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-2024 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  const bool parRun
39 )
40 {
41  if (cellData.size() != mesh.nCells())
42  {
44  << "Number of values " << cellData.size()
45  << " != number of cells " << mesh.nCells() << nl
46  << abort(FatalError);
47  }
48 
49  neighbourCellData.resize(mesh.nBoundaryFaces());
50 
51  for (const polyPatch& pp : mesh.boundaryMesh())
52  {
53  const auto& faceCells = pp.faceCells();
54 
55  // ie, boundarySlice() = patchInternalList()
57  (
58  neighbourCellData,
59  faceCells.size(),
60  pp.offset()
62  }
63 
64  syncTools::swapBoundaryFacePositions(mesh, neighbourCellData, parRun);
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 
130  for (const polyPatch& pp : mesh.boundaryMesh())
131  {
132  if (pp.coupled())
133  {
134  if (!refCast<const coupledPolyPatch>(pp).owner())
135  {
136  isMaster.unset(pp.range());
137  }
138  }
139  }
140 
141  return isMaster;
142 }
143 
144 
146 (
147  const polyMesh& mesh
148 )
149 {
150  bitSet isMaster(mesh.nFaces(), true);
151 
152  for (const polyPatch& pp : mesh.boundaryMesh())
153  {
154  if (pp.coupled())
155  {
156  if (!refCast<const coupledPolyPatch>(pp).owner())
157  {
158  isMaster.unset(pp.range());
159  }
160  }
161  else
162  {
163  isMaster.unset(pp.range());
164  }
165  }
166 
167  return isMaster;
168 }
169 
170 
172 (
173  const polyMesh& mesh
174 )
175 {
176  bitSet isMaster(mesh.nFaces(), true);
177 
178  for (const polyPatch& pp : mesh.boundaryMesh())
179  {
180  if (!pp.coupled())
181  {
182  isMaster.unset(pp.range());
183  }
184  }
185 
186  return isMaster;
187 }
188 
189 
190 // ************************************************************************* //
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:116
static bitSet getMasterFaces(const polyMesh &mesh)
Get per face whether it is uncoupled or a master of a coupled set of faces.
Definition: syncTools.C:119
void resize(const label len)
Adjust allocated size of list.
Definition: ListI.H:153
label nPoints() const noexcept
Number of mesh points.
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:608
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:56
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:493
Various mesh related information for a parallel run. Upon construction, constructs all info using par...
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
Smooth ATC in cells next to a set of patches supplied by type.
Definition: faceCells.H:52
label nFaces() const noexcept
Number of mesh faces.
List< labelList > labelListList
List of labelList.
Definition: labelList.H:38
static bitSet getInternalOrCoupledFaces(const polyMesh &mesh)
Get per face whether it is internal or coupled.
Definition: syncTools.C:165
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
A List obtained as a section of another List.
Definition: SubList.H:50
dynamicFvMesh & mesh
bitSet & unset(const bitSet &other)
Unset (subtract) the bits specified in the other bitset, which is a set difference corresponds to the...
Definition: bitSetI.H:536
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
Definition: polyMesh.H:609
static bitSet getMasterPoints(const polyMesh &mesh)
Get per point whether it is uncoupled or a master of a coupled set of points.
Definition: syncTools.C:61
static bitSet getMasterEdges(const polyMesh &mesh)
Get per edge whether it is uncoupled or a master of a coupled set of edges.
Definition: syncTools.C:90
static void swapBoundaryCellPositions(const polyMesh &mesh, const UList< point > &cellData, List< point > &neighbourCellData, const bool parRun=UPstream::parRun())
Extract and swap to obtain neighbour cell positions for all boundary faces.
Definition: syncTools.C:27
static void swapBoundaryFacePositions(const polyMesh &mesh, UList< point > &positions, const bool parRun=UPstream::parRun())
Swap coupled positions. Uses eqOp.
Definition: syncTools.H:545
const globalMeshData & globalData() const
Return parallel info (demand-driven)
Definition: polyMesh.C:1311
errorManip< error > abort(error &err)
Definition: errorManip.H:139
label nEdges() const
Number of mesh edges.
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:105
static bitSet getInternalOrMasterFaces(const polyMesh &mesh)
Get per face whether it is internal or a master of a coupled set of faces.
Definition: syncTools.C:139
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:59
A List with indirect addressing. Like IndirectList but does not store addressing. ...
Definition: faMatrix.H:52
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:75
List< label > labelList
A List of labels.
Definition: List.H:62
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:69
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())