All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CPCCellToCellStencil.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "CPCCellToCellStencil.H"
27 #include "syncTools.H"
28 #include "dummyTransform.H"
29 
30 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
31 
32 void Foam::CPCCellToCellStencil::calcPointBoundaryData
33 (
34  const boolList& isValidBFace,
35  const labelList& boundaryPoints,
36  Map<labelList>& neiGlobal
37 ) const
38 {
39  neiGlobal.resize(2*boundaryPoints.size());
40 
41  labelHashSet pointGlobals;
42 
43  forAll(boundaryPoints, i)
44  {
45  label pointi = boundaryPoints[i];
46 
47  neiGlobal.insert
48  (
49  pointi,
51  (
52  isValidBFace,
53  mesh().pointFaces()[pointi],
54  pointGlobals
55  )
56  );
57  }
58 
60  (
61  mesh(),
62  neiGlobal,
63  unionEqOp(),
64  Foam::dummyTransform() // dummy transformation
65  );
66 }
67 
68 
69 void Foam::CPCCellToCellStencil::calcCellStencil
70 (
71  labelListList& globalCellCells
72 ) const
73 {
74  // Calculate points on coupled patches
75  labelList boundaryPoints(allCoupledFacesPatch()().meshPoints());
76 
77 
78  // Mark boundary faces to be included in stencil (i.e. not coupled or empty)
79  boolList isValidBFace;
80  validBoundaryFaces(isValidBFace);
81 
82 
83  // Swap pointCells for coupled points
84  Map<labelList> neiGlobal;
85  calcPointBoundaryData
86  (
87  isValidBFace,
88  boundaryPoints,
89  neiGlobal
90  );
91 
92  globalCellCells.setSize(mesh().nCells());
93 
94  // Do coupled points first
95 
96  forAll(boundaryPoints, i)
97  {
98  label pointi = boundaryPoints[i];
99 
100  const labelList& pGlobals = neiGlobal[pointi];
101 
102  // Distribute to all pointCells
103  const labelList& pCells = mesh().pointCells(pointi);
104 
105  forAll(pCells, j)
106  {
107  label celli = pCells[j];
108 
109  // Insert pGlobals into globalCellCells
110  merge
111  (
112  globalNumbering().toGlobal(celli),
113  pGlobals,
114  globalCellCells[celli]
115  );
116  }
117  }
118  neiGlobal.clear();
119 
120  // Do remaining points cells
121  labelHashSet pointGlobals;
122 
123  for (label pointi = 0; pointi < mesh().nPoints(); pointi++)
124  {
125  labelList pGlobals
126  (
128  (
129  isValidBFace,
130  mesh().pointFaces()[pointi],
131  pointGlobals
132  )
133  );
134 
135  const labelList& pCells = mesh().pointCells(pointi);
136 
137  forAll(pCells, j)
138  {
139  label celli = pCells[j];
140 
141  merge
142  (
143  globalNumbering().toGlobal(celli),
144  pGlobals,
145  globalCellCells[celli]
146  );
147  }
148  }
149 }
150 
151 
152 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
153 
155 :
156  cellToCellStencil(mesh)
157 {
158  // Calculate per cell the (point) connected cells (in global numbering)
159  labelListList globalCellCells;
160  calcCellStencil(*this);
161 }
162 
163 
164 // ************************************************************************* //
static void merge(const label global0, const label global1, const labelList &listA, labelList &listB)
Merge two lists.
List< labelList > labelListList
A List of labelList.
Definition: labelList.H:57
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
List< bool > boolList
Bool container classes.
Definition: boolList.H:50
Dummy transform to be used with syncTools.
HashSet< label, Hash< label > > labelHashSet
A HashSet with label keys.
Definition: HashSet.H:211
List< label > labelList
A List of labels.
Definition: labelList.H:56
static void syncPointMap(const polyMesh &, Map< T > &pointValues, const CombineOp &cop, const TransformOp &top)
Synchronize values on selected points.
const labelListList & pointCells() const
void validBoundaryFaces(boolList &isValidBFace) const
Valid boundary faces (not empty and not coupled)
labelList calcFaceCells(const boolList &nonEmptyFace, const labelList &faceLabels, labelHashSet &globals) const
Collect cell neighbours of faces in global numbering.
CPCCellToCellStencil(const polyMesh &)
Construct from all cells and boundary faces.
const globalIndex & globalNumbering() const
Global numbering for cells and boundary faces.
const polyMesh & mesh() const
label nPoints() const
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
autoPtr< indirectPrimitivePatch > allCoupledFacesPatch() const
Return patch of all coupled faces.
baseclass for extended cell centred addressing. Contains per cell a list of neighbouring cells and/or...