FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "CPCCellToCellStencil.H"
00027 #include <OpenFOAM/syncTools.H>
00028 
00029 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00030 
00031 // Calculates per point the neighbour data (= pointCells)
00032 void Foam::CPCCellToCellStencil::calcPointBoundaryData
00033 (
00034     const boolList& isValidBFace,
00035     const labelList& boundaryPoints,
00036     Map<labelList>& neiGlobal
00037 ) const
00038 {
00039     neiGlobal.resize(2*boundaryPoints.size());
00040 
00041     labelHashSet pointGlobals;
00042 
00043     forAll(boundaryPoints, i)
00044     {
00045         label pointI = boundaryPoints[i];
00046 
00047         neiGlobal.insert
00048         (
00049             pointI,
00050             calcFaceCells
00051             (
00052                 isValidBFace,
00053                 mesh().pointFaces()[pointI],
00054                 pointGlobals
00055             )
00056         );
00057     }
00058 
00059     syncTools::syncPointMap
00060     (
00061         mesh(),
00062         neiGlobal,
00063         unionEqOp(),
00064         false           // apply separation
00065     );
00066 }
00067 
00068 
00069 // Calculates per cell the neighbour data (= cell or boundary in global
00070 // numbering). First element is always cell itself!
00071 void Foam::CPCCellToCellStencil::calcCellStencil
00072 (
00073     labelListList& globalCellCells
00074 ) const
00075 {
00076     // Calculate points on coupled patches
00077     labelList boundaryPoints(allCoupledFacesPatch()().meshPoints());
00078 
00079 
00080     // Mark boundary faces to be included in stencil (i.e. not coupled or empty)
00081     boolList isValidBFace;
00082     validBoundaryFaces(isValidBFace);
00083 
00084 
00085     // Swap pointCells for coupled points
00086     Map<labelList> neiGlobal;
00087     calcPointBoundaryData
00088     (
00089         isValidBFace,
00090         boundaryPoints,
00091         neiGlobal
00092     );
00093 
00094     globalCellCells.setSize(mesh().nCells());
00095 
00096     // Do coupled points first
00097 
00098     forAll(boundaryPoints, i)
00099     {
00100         label pointI = boundaryPoints[i];
00101 
00102         const labelList& pGlobals = neiGlobal[pointI];
00103 
00104         // Distribute to all pointCells
00105         const labelList& pCells = mesh().pointCells(pointI);
00106 
00107         forAll(pCells, j)
00108         {
00109             label cellI = pCells[j];
00110 
00111             // Insert pGlobals into globalCellCells
00112             merge
00113             (
00114                 globalNumbering().toGlobal(cellI),
00115                 pGlobals,
00116                 globalCellCells[cellI]
00117             );
00118         }
00119     }
00120     neiGlobal.clear();
00121 
00122     // Do remaining points cells
00123     labelHashSet pointGlobals;
00124 
00125     for (label pointI = 0; pointI < mesh().nPoints(); pointI++)
00126     {
00127         labelList pGlobals
00128         (
00129             calcFaceCells
00130             (
00131                 isValidBFace,
00132                 mesh().pointFaces()[pointI],
00133                 pointGlobals
00134             )
00135         );
00136 
00137         const labelList& pCells = mesh().pointCells(pointI);
00138 
00139         forAll(pCells, j)
00140         {
00141             label cellI = pCells[j];
00142 
00143             merge
00144             (
00145                 globalNumbering().toGlobal(cellI),
00146                 pGlobals,
00147                 globalCellCells[cellI]
00148             );
00149         }
00150     }
00151 }
00152 
00153 
00154 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00155 
00156 Foam::CPCCellToCellStencil::CPCCellToCellStencil(const polyMesh& mesh)
00157 :
00158     cellToCellStencil(mesh)
00159 {
00160     // Calculate per cell the (point) connected cells (in global numbering)
00161     labelListList globalCellCells;
00162     calcCellStencil(*this);
00163 }
00164 
00165 
00166 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines