Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
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/>.
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 {
135 {
136 isMaster.unset(pp.range());
137 }
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 {
157 {
158 isMaster.unset(pp.range());
159 }
160 }
161 else
162 {
163 isMaster.unset(pp.range());
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// ************************************************************************* //
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
void resize(const label len)
Adjust allocated size of list.
Definition ListI.H:153
const labelList & meshPoints() const
Return labelList of mesh points in patch.
A non-owning sub-view of a List (allocated or unallocated storage).
Definition SubList.H:61
A List with indirect addressing. Like IndirectList but does not store addressing.
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:89
bool unset(const label i)
Unset the bool entry at specified position, always false for out-of-range access.
Definition UList.H:885
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition bitSet.H:61
void set(const bitSet &bitset)
Set specified bits from another bitset.
Definition bitSetI.H:502
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:540
Smooth ATC in cells next to a set of patches supplied by type.
Definition faceCells.H:55
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
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
Definition polyMesh.H:609
A patch is a list of labels that address the faces in the global face list.
Definition polyPatch.H:73
label nFaces() const noexcept
Number of mesh faces.
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
static void swapBoundaryFacePositions(const polyMesh &mesh, UList< point > &positions, const bool parRun=UPstream::parRun())
Swap coupled positions. Uses eqOp.
Definition syncTools.H:545
static bitSet getInternalOrCoupledFaces(const polyMesh &mesh)
Get per face whether it is internal or coupled.
Definition syncTools.C:165
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 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 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 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
dynamicFvMesh & mesh
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
Definition typeInfo.H:172
List< labelList > labelListList
List of labelList.
Definition labelList.H:38
List< label > labelList
A List of labels.
Definition List.H:62
errorManip< error > abort(error &err)
Definition errorManip.H:139
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299