Loading...
Searching...
No Matches
zoneCellStencils.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) 2020 DLR
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26\*---------------------------------------------------------------------------*/
27
28#include "zoneCellStencils.H"
29#include "syncTools.H"
31#include "emptyPolyPatch.H"
32
33// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34
35namespace Foam
36{
38}
39
40
41// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
42
45{
47
48 label nNonEmpty = 0;
49
50 for (const polyPatch& pp : patches)
51 {
53 {
54 nNonEmpty += pp.size();
55 }
56 }
57 labelList nonEmptyFaces(nNonEmpty);
58 nNonEmpty = 0;
59
60 for (const polyPatch& pp : patches)
61 {
63 {
64 label facei = pp.start();
65
66 forAll(pp, i)
67 {
68 nonEmptyFaces[nNonEmpty++] = facei++;
69 }
70 }
71 }
72
74 (
75 IndirectList<face>
76 (
77 meshRef_.faces(),
78 nonEmptyFaces
79 ),
80 meshRef_.points()
81 );
82}
83
84
87{
88 const polyBoundaryMesh& patches = meshRef_.boundaryMesh();
89
90 label nCoupled = 0;
91
92 for (const polyPatch& pp : patches)
93 {
94 if (pp.coupled())
95 {
96 nCoupled += pp.size();
97 }
98 }
99 labelList coupledFaces(nCoupled);
100 nCoupled = 0;
101
102 for (const polyPatch& pp : patches)
103 {
104 if (pp.coupled())
105 {
106 label facei = pp.start();
107
108 forAll(pp, i)
109 {
110 coupledFaces[nCoupled++] = facei++;
111 }
112 }
113 }
114
116 (
118 (
119 meshRef_.faces(),
120 coupledFaces
121 ),
122 meshRef_.points()
123 );
124}
125
126
128{
129 const polyBoundaryMesh& patches = meshRef_.boundaryMesh();
130
131 isValidBFace.setSize(meshRef_.nBoundaryFaces());
132
133 isValidBFace = true;
134
135 for (const polyPatch& pp : patches)
136 {
137 if (pp.coupled() || isA<emptyPolyPatch>(pp))
138 {
139 label bFacei = pp.start() - meshRef_.nInternalFaces();
140 forAll(pp, i)
141 {
142 isValidBFace[bFacei++] = false;
143 }
144 }
145 }
146}
147
148
150(
151 const label globalI,
152 const labelList& pGlobals,
153 labelList& cCells
154)
155{
157 for (const label celli : cCells)
158 {
159 if (celli != globalI)
160 {
161 set.insert(celli);
162 }
163 }
164
165 for (const label celli : pGlobals)
166 {
167 if (celli != globalI)
168 {
169 set.insert(celli);
170 }
171 }
172
173 cCells.setSize(set.size()+1);
174 label n = 0;
175 cCells[n++] = globalI;
176
177 for (const label seti : set)
178 {
179 cCells[n++] = seti;
180 }
181}
182
183
185(
186 const label exclude0,
187 const label exclude1,
188 const boolList& isValidBFace,
189 const labelList& faceLabels,
190 labelHashSet& globals
191) const
192{
193 const labelList& own = meshRef_.faceOwner();
194 const labelList& nei = meshRef_.faceNeighbour();
195
196 for (const label facei : faceLabels)
197 {
198 const label globalOwn = globalNumbering().toGlobal(own[facei]);
199 if (globalOwn != exclude0 && globalOwn != exclude1)
200 {
201 globals.insert(globalOwn);
202 }
203
204 if (meshRef_.isInternalFace(facei))
205 {
206 const label globalNei = globalNumbering().toGlobal(nei[facei]);
207 if (globalNei != exclude0 && globalNei != exclude1)
208 {
209 globals.insert(globalNei);
210 }
211 }
212 else
213 {
214 const label bFacei = facei - meshRef_.nInternalFaces();
215
216 if (isValidBFace[bFacei])
217 {
218 label globalI = globalNumbering().toGlobal
219 (
220 meshRef_.nCells()
221 + bFacei
222 );
223
224 if (globalI != exclude0 && globalI != exclude1)
225 {
226 globals.insert(globalI);
228 }
229 }
230 }
231}
232
233
235(
236 const boolList& isValidBFace,
237 const labelList& faceLabels,
238 labelHashSet& globals
239) const
240{
241 globals.clear();
242
243 insertFaceCells
244 (
245 -1,
246 -1,
247 isValidBFace,
249 globals
250 );
252 return globals.toc();
253}
254
255
256// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
257
259:
260 labelListList(mesh.nCells()),
261 meshRef_(mesh),
262 needComm_(),
263 globalNumbering_(meshRef_.nCells() + meshRef_.nBoundaryFaces())
264{
265
266}
267
268
269// ************************************************************************* //
label n
labelList faceLabels(nFaceLabels)
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
Definition HashSet.H:229
List< Key > toc() const
The table of contents (the keys) in unsorted order.
Definition HashTable.C:141
void clear()
Remove all entries from table.
Definition HashTable.C:742
A List with indirect addressing.
bool set(const label i, bool val=true)
Definition List.H:469
void setSize(label n)
Alias for resize().
Definition List.H:536
void clear()
Clear the list, i.e. set size to zero.
Definition ListI.H:133
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
Definition autoPtr.H:178
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh,...
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
base class for cell stencil in a narrow band
globalIndex globalNumbering_
Global numbering for cells and boundary faces.
const globalIndex & globalNumbering() const noexcept
Global numbering for cells and boundary faces.
labelHashSet needComm_
cells requiring processor communciation
autoPtr< indirectPrimitivePatch > allCoupledFacesPatch() const
Return patch of all coupled faces.
autoPtr< indirectPrimitivePatch > nonEmptyFacesPatch() const
Return patch of all coupled faces.
zoneCellStencils(const zoneCellStencils &)=delete
No copy construct.
static void merge(const label globalI, const labelList &pGlobals, labelList &cCells)
Merge two lists and guarantee globalI is first.
void validBoundaryFaces(boolList &isValidBFace) const
Valid boundary faces (not empty and not coupled).
void insertFaceCells(const label exclude0, const label exclude1, const boolList &nonEmptyFace, const labelList &faceLabels, labelHashSet &globals) const
Collect cell neighbours of faces in global numbering.
const polyMesh & mesh() const noexcept
const fvMesh & meshRef_
const reference to fvMesh
labelList calcFaceCells(const boolList &nonEmptyFace, const labelList &faceLabels, labelHashSet &globals) const
Collect cell neighbours of faces in global numbering.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
const polyBoundaryMesh & patches
dynamicFvMesh & mesh
Dummy transform to be used with syncTools.
void set(List< bool > &bools, const labelUList &locations)
Set the listed locations (assign 'true').
Definition BitOps.C:35
Namespace for OpenFOAM.
List< labelList > labelListList
List of labelList.
Definition labelList.H:38
List< label > labelList
A List of labels.
Definition List.H:62
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
Definition HashSet.H:85
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
Definition typeInfo.H:87
List< bool > boolList
A List of bools.
Definition List.H:60
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299