FreeFOAM The Cross-Platform CFD Toolkit
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 | Copyright (C) 1991-2010 OpenCFD Ltd.
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 <OpenFOAM/syncTools.H>
28 
29 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
30 
31 // Calculates per point the neighbour data (= pointCells)
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  false // apply separation
65  );
66 }
67 
68 
69 // Calculates per cell the neighbour data (= cell or boundary in global
70 // numbering). First element is always cell itself!
71 void 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 
156 Foam::CPCCellToCellStencil::CPCCellToCellStencil(const polyMesh& mesh)
157 :
158  cellToCellStencil(mesh)
159 {
160  // Calculate per cell the (point) connected cells (in global numbering)
161  labelListList globalCellCells;
162  calcCellStencil(*this);
163 }
164 
165 
166 // ************************ vim: set sw=4 sts=4 et: ************************ //