CPCCellToCellStencil.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-------------------------------------------------------------------------------
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
29#include "syncTools.H"
30#include "dummyTransform.H"
31
32// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
33
34void Foam::CPCCellToCellStencil::calcPointBoundaryData
35(
36 const boolList& isValidBFace,
37 const labelList& boundaryPoints,
38 Map<labelList>& neiGlobal
39) const
40{
41 neiGlobal.resize(2*boundaryPoints.size());
42
43 labelHashSet pointGlobals;
44
45 forAll(boundaryPoints, i)
46 {
47 label pointi = boundaryPoints[i];
48
49 neiGlobal.insert
50 (
51 pointi,
53 (
54 isValidBFace,
55 mesh().pointFaces()[pointi],
56 pointGlobals
57 )
58 );
59 }
60
62 (
63 mesh(),
64 neiGlobal,
65 ListOps::unionEqOp(),
66 Foam::dummyTransform() // dummy transformation
67 );
68}
69
70
71void Foam::CPCCellToCellStencil::calcCellStencil
72(
73 labelListList& globalCellCells
74) const
75{
76 // Calculate points on coupled patches
77 labelList boundaryPoints(allCoupledFacesPatch()().meshPoints());
78
79
80 // Mark boundary faces to be included in stencil (i.e. not coupled or empty)
81 boolList isValidBFace;
82 validBoundaryFaces(isValidBFace);
83
84
85 // Swap pointCells for coupled points
86 Map<labelList> neiGlobal;
87 calcPointBoundaryData
88 (
89 isValidBFace,
90 boundaryPoints,
91 neiGlobal
92 );
93
94 globalCellCells.setSize(mesh().nCells());
95
96 // Do coupled points first
97
98 forAll(boundaryPoints, i)
99 {
100 label pointi = boundaryPoints[i];
101
102 const labelList& pGlobals = neiGlobal[pointi];
103
104 // Distribute to all pointCells
105 const labelList& pCells = mesh().pointCells(pointi);
106
107 forAll(pCells, j)
108 {
109 label celli = pCells[j];
110
111 // Insert pGlobals into globalCellCells
112 merge
113 (
114 globalNumbering().toGlobal(celli),
115 pGlobals,
116 globalCellCells[celli]
117 );
118 }
119 }
120 neiGlobal.clear();
121
122 // Do remaining points cells
123 labelHashSet pointGlobals;
124
125 for (label pointi = 0; pointi < mesh().nPoints(); pointi++)
126 {
127 labelList pGlobals
128 (
129 calcFaceCells
130 (
131 isValidBFace,
132 mesh().pointFaces()[pointi],
133 pointGlobals
134 )
135 );
136
137 const labelList& pCells = mesh().pointCells(pointi);
138
139 forAll(pCells, j)
140 {
141 label celli = pCells[j];
142
143 merge
144 (
145 globalNumbering().toGlobal(celli),
146 pGlobals,
147 globalCellCells[celli]
148 );
149 }
150 }
151}
152
153
154// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
155
157:
159{
160 // Calculate per cell the (point) connected cells (in global numbering)
161 labelListList globalCellCells;
162 calcCellStencil(*this);
163}
164
165
166// ************************************************************************* //
baseclass for extended cell centred addressing. Contains per cell a list of neighbouring cells and/or...
const polyMesh & mesh() const
labelList calcFaceCells(const boolList &nonEmptyFace, const labelList &faceLabels, labelHashSet &globals) const
Collect cell neighbours of faces in global numbering.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
const labelListList & pointCells() const
label nPoints() const noexcept
Number of mesh points.
static void syncPointMap(const polyMesh &mesh, Map< T > &pointValues, const CombineOp &cop, const TransformOp &top)
Synchronize values on selected points.
dynamicFvMesh & mesh
Dummy transform to be used with syncTools.
List< label > labelList
A List of labels.
Definition: List.H:66
List< labelList > labelListList
A List of labelList.
Definition: labelList.H:56
List< bool > boolList
A List of bools.
Definition: List.H:64
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
Definition: HashSet.H:85
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333