OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

CPCCellToCellStencil.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "CPCCellToCellStencil.H"
00028 #include "syncTools.H"
00029 
00030 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00031 
00032 // Calculates per point the neighbour data (= pointCells)
00033 void Foam::CPCCellToCellStencil::calcPointBoundaryData
00034 (
00035     const boolList& isValidBFace,
00036     const labelList& boundaryPoints,
00037     Map<labelList>& neiGlobal
00038 ) const
00039 {
00040     neiGlobal.resize(2*boundaryPoints.size());
00041 
00042     labelHashSet pointGlobals;
00043 
00044     forAll(boundaryPoints, i)
00045     {
00046         label pointI = boundaryPoints[i];
00047 
00048         neiGlobal.insert
00049         (
00050             pointI,
00051             calcFaceCells
00052             (
00053                 isValidBFace,
00054                 mesh().pointFaces()[pointI],
00055                 pointGlobals
00056             )
00057         );
00058     }
00059 
00060     syncTools::syncPointMap
00061     (
00062         mesh(),
00063         neiGlobal,
00064         unionEqOp(),
00065         false           // apply separation
00066     );
00067 }
00068 
00069 
00070 // Calculates per cell the neighbour data (= cell or boundary in global
00071 // numbering). First element is always cell itself!
00072 void Foam::CPCCellToCellStencil::calcCellStencil
00073 (
00074     labelListList& globalCellCells
00075 ) const
00076 {
00077     // Calculate points on coupled patches
00078     labelList boundaryPoints(allCoupledFacesPatch()().meshPoints());
00079 
00080 
00081     // Mark boundary faces to be included in stencil (i.e. not coupled or empty)
00082     boolList isValidBFace;
00083     validBoundaryFaces(isValidBFace);
00084 
00085 
00086     // Swap pointCells for coupled points
00087     Map<labelList> neiGlobal;
00088     calcPointBoundaryData
00089     (
00090         isValidBFace,
00091         boundaryPoints,
00092         neiGlobal
00093     );
00094 
00095     globalCellCells.setSize(mesh().nCells());
00096 
00097     // Do coupled points first
00098 
00099     forAll(boundaryPoints, i)
00100     {
00101         label pointI = boundaryPoints[i];
00102 
00103         const labelList& pGlobals = neiGlobal[pointI];
00104 
00105         // Distribute to all pointCells
00106         const labelList& pCells = mesh().pointCells(pointI);
00107 
00108         forAll(pCells, j)
00109         {
00110             label cellI = pCells[j];
00111 
00112             // Insert pGlobals into globalCellCells
00113             merge
00114             (
00115                 globalNumbering().toGlobal(cellI),
00116                 pGlobals,
00117                 globalCellCells[cellI]
00118             );
00119         }
00120     }
00121     neiGlobal.clear();
00122 
00123     // Do remaining points cells
00124     labelHashSet pointGlobals;
00125 
00126     for (label pointI = 0; pointI < mesh().nPoints(); pointI++)
00127     {
00128         labelList pGlobals
00129         (
00130             calcFaceCells
00131             (
00132                 isValidBFace,
00133                 mesh().pointFaces()[pointI],
00134                 pointGlobals
00135             )
00136         );
00137 
00138         const labelList& pCells = mesh().pointCells(pointI);
00139 
00140         forAll(pCells, j)
00141         {
00142             label cellI = pCells[j];
00143 
00144             merge
00145             (
00146                 globalNumbering().toGlobal(cellI),
00147                 pGlobals,
00148                 globalCellCells[cellI]
00149             );
00150         }
00151     }
00152 }
00153 
00154 
00155 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00156 
00157 Foam::CPCCellToCellStencil::CPCCellToCellStencil(const polyMesh& mesh)
00158 :
00159     cellToCellStencil(mesh)
00160 {
00161     // Calculate per cell the (point) connected cells (in global numbering)
00162     labelListList globalCellCells;
00163     calcCellStencil(*this);
00164 }
00165 
00166 
00167 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd