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-------------------------------------------------------------------------------
11License
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
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 }
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 =
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// ************************************************************************* //
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
void resize(const label len)
Adjust allocated size of list.
Definition: ListI.H:139
const labelList & meshPoints() const
Return labelList of mesh points in patch.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: UList.H:94
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:66
void set(const bitSet &bitset)
Set specified bits from another bitset.
Definition: bitSetI.H:590
bitSet & unset(const bitSet &other)
Definition: bitSetI.H:628
Smooth ATC in cells next to a set of patches supplied by type.
Definition: faceCells.H:59
Various mesh related information for a parallel run. Upon construction, constructs all info using par...
const labelListList & globalEdgeTransformedSlaves() const
const labelList & coupledPatchMeshEdges() const
Return map from coupledPatch edges to mesh edges.
const labelListList & globalPointSlaves() const
const labelListList & globalPointTransformedSlaves() const
const indirectPrimitivePatch & coupledPatch() const
Return patch of all coupled faces.
const labelListList & globalEdgeSlaves() const
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
const globalMeshData & globalData() const
Return parallel info.
Definition: polyMesh.C:1310
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:456
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:75
label nBoundaryFaces() const noexcept
Number of boundary faces (== nFaces - nInternalFaces)
label nInternalFaces() const noexcept
Number of internal faces.
label nPoints() const noexcept
Number of mesh points.
label nCells() const noexcept
Number of mesh cells.
label nFaces() const noexcept
Number of mesh faces.
label nEdges() const
Number of mesh edges.
static bitSet getMasterFaces(const polyMesh &mesh)
Definition: syncTools.C:126
static void swapBoundaryFacePositions(const polyMesh &mesh, UList< point > &positions)
Swap coupled positions. Uses eqOp.
Definition: syncTools.H:461
static bitSet getInternalOrCoupledFaces(const polyMesh &mesh)
Get per face whether it is internal or coupled.
Definition: syncTools.C:176
static bitSet getMasterPoints(const polyMesh &mesh)
Definition: syncTools.C:68
static bitSet getMasterEdges(const polyMesh &mesh)
Definition: syncTools.C:97
static bitSet getInternalOrMasterFaces(const polyMesh &mesh)
Definition: syncTools.C:148
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
const polyBoundaryMesh & patches
dynamicFvMesh & mesh
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
errorManip< error > abort(error &err)
Definition: errorManip.H:144
error FatalError
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333