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) 2011-2013 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 // Calculates per point the neighbour data (= pointCells)
34 (
35  const boolList& isValidBFace,
36  const labelList& boundaryPoints,
37  Map<labelList>& neiGlobal
38 ) const
39 {
40  neiGlobal.resize(2*boundaryPoints.size());
41 
42  labelHashSet pointGlobals;
43 
44  forAll(boundaryPoints, i)
45  {
46  label pointI = boundaryPoints[i];
47 
48  neiGlobal.insert
49  (
50  pointI,
51  calcFaceCells
52  (
53  isValidBFace,
54  mesh().pointFaces()[pointI],
55  pointGlobals
56  )
57  );
58  }
59 
60  syncTools::syncPointMap
61  (
62  mesh(),
63  neiGlobal,
64  unionEqOp(),
65  Foam::dummyTransform() // dummy transformation
66  );
67 }
68 
69 
70 // Calculates per cell the neighbour data (= cell or boundary in global
71 // numbering). First element is always cell itself!
73 (
74  labelListList& globalCellCells
75 ) const
76 {
77  // Calculate points on coupled patches
78  labelList boundaryPoints(allCoupledFacesPatch()().meshPoints());
79 
80 
81  // Mark boundary faces to be included in stencil (i.e. not coupled or empty)
82  boolList isValidBFace;
83  validBoundaryFaces(isValidBFace);
84 
85 
86  // Swap pointCells for coupled points
87  Map<labelList> neiGlobal;
88  calcPointBoundaryData
89  (
90  isValidBFace,
91  boundaryPoints,
92  neiGlobal
93  );
94 
95  globalCellCells.setSize(mesh().nCells());
96 
97  // Do coupled points first
98 
99  forAll(boundaryPoints, i)
100  {
101  label pointI = boundaryPoints[i];
102 
103  const labelList& pGlobals = neiGlobal[pointI];
104 
105  // Distribute to all pointCells
106  const labelList& pCells = mesh().pointCells(pointI);
107 
108  forAll(pCells, j)
109  {
110  label cellI = pCells[j];
111 
112  // Insert pGlobals into globalCellCells
113  merge
114  (
115  globalNumbering().toGlobal(cellI),
116  pGlobals,
117  globalCellCells[cellI]
118  );
119  }
120  }
121  neiGlobal.clear();
122 
123  // Do remaining points cells
124  labelHashSet pointGlobals;
125 
126  for (label pointI = 0; pointI < mesh().nPoints(); pointI++)
127  {
128  labelList pGlobals
129  (
130  calcFaceCells
131  (
132  isValidBFace,
133  mesh().pointFaces()[pointI],
134  pointGlobals
135  )
136  );
137 
138  const labelList& pCells = mesh().pointCells(pointI);
139 
140  forAll(pCells, j)
141  {
142  label cellI = pCells[j];
143 
144  merge
145  (
146  globalNumbering().toGlobal(cellI),
147  pGlobals,
148  globalCellCells[cellI]
149  );
150  }
151  }
152 }
153 
154 
155 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
156 
158 :
160 {
161  // Calculate per cell the (point) connected cells (in global numbering)
162  labelListList globalCellCells;
163  calcCellStencil(*this);
164 }
165 
166 
167 // ************************************************************************* //
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
dummyTransform.H
Dummy transform to be used with syncTools.
Foam::Map
A HashTable to objects of type <T> with a label key.
Definition: PrimitivePatchTemplate.H:68
Foam::dummyTransform
Definition: dummyTransform.H:44
Foam::HashSet< label, Hash< label > >
syncTools.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::label
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
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::CPCCellToCellStencil::CPCCellToCellStencil
CPCCellToCellStencil(const polyMesh &)
Construct from all cells and boundary faces.
Definition: CPCCellToCellStencil.C:157
Foam::CPCCellToCellStencil::calcCellStencil
void calcCellStencil(labelListList &globalCellCells) const
Definition: CPCCellToCellStencil.C:73
Foam::List::setSize
void setSize(const label)
Reset size of List.
CPCCellToCellStencil.H
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::CPCCellToCellStencil::calcPointBoundaryData
void calcPointBoundaryData(const boolList &isValidBFace, const labelList &boundaryPoints, Map< labelList > &neiGlobal) const
Calculates per point the neighbour data (= pointCells)
Definition: CPCCellToCellStencil.C:34
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
Foam::cellToCellStencil
baseclass for extended cell centred addressing. Contains per cell a list of neighbouring cells and/or...
Definition: cellToCellStencil.H:54
Foam::cellToCellStencil::unionEqOp
Combine operator for labelLists.
Definition: cellToCellStencil.H:87
merge
bool merge(dictionary &, const dictionary &, const bool, const HashTable< wordList, word > &)
Definition: changeDictionary.C:222