1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "CFCCellToCellStencil.H"
28 #include "syncTools.H"
29 #include "SortableList.H"
30 #include "emptyPolyPatch.H"
32 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
34 // Calculates per face the neighbour data (= cell or boundary face)
35 void Foam::CFCCellToCellStencil::calcFaceBoundaryData
40 const polyBoundaryMesh& patches = mesh().boundaryMesh();
41 const label nBnd = mesh().nFaces()-mesh().nInternalFaces();
42 const labelList& own = mesh().faceOwner();
44 neiGlobal.setSize(nBnd);
46 forAll(patches, patchI)
48 const polyPatch& pp = patches[patchI];
49 label faceI = pp.start();
53 // For coupled faces get the cell on the other side
56 label bFaceI = faceI-mesh().nInternalFaces();
57 neiGlobal[bFaceI] = globalNumbering().toGlobal(own[faceI]);
61 else if (isA<emptyPolyPatch>(pp))
65 label bFaceI = faceI-mesh().nInternalFaces();
66 neiGlobal[bFaceI] = -1;
72 // For noncoupled faces get the boundary face.
75 label bFaceI = faceI-mesh().nInternalFaces();
77 globalNumbering().toGlobal(mesh().nCells()+bFaceI);
82 syncTools::swapBoundaryFaceList(mesh(), neiGlobal, false);
86 // Calculates per cell the neighbour data (= cell or boundary in global
87 // numbering). First element is always cell itself!
88 void Foam::CFCCellToCellStencil::calcCellStencil(labelListList& globalCellCells)
91 const label nBnd = mesh().nFaces()-mesh().nInternalFaces();
92 const labelList& own = mesh().faceOwner();
93 const labelList& nei = mesh().faceNeighbour();
96 // Calculate coupled neighbour (in global numbering)
97 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
99 labelList neiGlobal(nBnd);
100 calcFaceBoundaryData(neiGlobal);
103 // Determine cellCells in global numbering
104 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
106 globalCellCells.setSize(mesh().nCells());
107 forAll(globalCellCells, cellI)
109 const cell& cFaces = mesh().cells()[cellI];
111 labelList& cCells = globalCellCells[cellI];
113 cCells.setSize(cFaces.size()+1);
118 cCells[nNbr++] = globalNumbering().toGlobal(cellI);
120 // Collect neighbouring cells/faces
123 label faceI = cFaces[i];
125 if (mesh().isInternalFace(faceI))
127 label nbrCellI = own[faceI];
128 if (nbrCellI == cellI)
130 nbrCellI = nei[faceI];
132 cCells[nNbr++] = globalNumbering().toGlobal(nbrCellI);
136 label nbrCellI = neiGlobal[faceI-mesh().nInternalFaces()];
139 cCells[nNbr++] = nbrCellI;
143 cCells.setSize(nNbr);
148 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
150 Foam::CFCCellToCellStencil::CFCCellToCellStencil(const polyMesh& mesh)
152 cellToCellStencil(mesh)
154 // Calculate per cell the (face) connected cells (in global numbering)
155 calcCellStencil(*this);
159 // ************************************************************************* //