Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / src / finiteVolume / fvMesh / extendedStencil / cellToCell / fullStencils / CPCCellToCellStencil.C
blob51f49c1b67cbea7e86b5203f58c6a7c10b65902b
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2008-2010 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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.
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.
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/>.
24 \*---------------------------------------------------------------------------*/
26 #include "CPCCellToCellStencil.H"
27 #include "syncTools.H"
28 #include "dummyTransform.H"
30 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
32 // Calculates per point the neighbour data (= pointCells)
33 void Foam::CPCCellToCellStencil::calcPointBoundaryData
35     const boolList& isValidBFace,
36     const labelList& boundaryPoints,
37     Map<labelList>& neiGlobal
38 ) const
40     neiGlobal.resize(2*boundaryPoints.size());
42     labelHashSet pointGlobals;
44     forAll(boundaryPoints, i)
45     {
46         label pointI = boundaryPoints[i];
48         neiGlobal.insert
49         (
50             pointI,
51             calcFaceCells
52             (
53                 isValidBFace,
54                 mesh().pointFaces()[pointI],
55                 pointGlobals
56             )
57         );
58     }
60     syncTools::syncPointMap
61     (
62         mesh(),
63         neiGlobal,
64         unionEqOp(),
65         Foam::dummyTransform()      // dummy transformation
66     );
70 // Calculates per cell the neighbour data (= cell or boundary in global
71 // numbering). First element is always cell itself!
72 void Foam::CPCCellToCellStencil::calcCellStencil
74     labelListList& globalCellCells
75 ) const
77     // Calculate points on coupled patches
78     labelList boundaryPoints(allCoupledFacesPatch()().meshPoints());
81     // Mark boundary faces to be included in stencil (i.e. not coupled or empty)
82     boolList isValidBFace;
83     validBoundaryFaces(isValidBFace);
86     // Swap pointCells for coupled points
87     Map<labelList> neiGlobal;
88     calcPointBoundaryData
89     (
90         isValidBFace,
91         boundaryPoints,
92         neiGlobal
93     );
95     globalCellCells.setSize(mesh().nCells());
97     // Do coupled points first
99     forAll(boundaryPoints, i)
100     {
101         label pointI = boundaryPoints[i];
103         const labelList& pGlobals = neiGlobal[pointI];
105         // Distribute to all pointCells
106         const labelList& pCells = mesh().pointCells(pointI);
108         forAll(pCells, j)
109         {
110             label cellI = pCells[j];
112             // Insert pGlobals into globalCellCells
113             merge
114             (
115                 globalNumbering().toGlobal(cellI),
116                 pGlobals,
117                 globalCellCells[cellI]
118             );
119         }
120     }
121     neiGlobal.clear();
123     // Do remaining points cells
124     labelHashSet pointGlobals;
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         );
138         const labelList& pCells = mesh().pointCells(pointI);
140         forAll(pCells, j)
141         {
142             label cellI = pCells[j];
144             merge
145             (
146                 globalNumbering().toGlobal(cellI),
147                 pGlobals,
148                 globalCellCells[cellI]
149             );
150         }
151     }
155 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
157 Foam::CPCCellToCellStencil::CPCCellToCellStencil(const polyMesh& mesh)
159     cellToCellStencil(mesh)
161     // Calculate per cell the (point) connected cells (in global numbering)
162     labelListList globalCellCells;
163     calcCellStencil(*this);
167 // ************************************************************************* //