Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 #include "CFCCellToCellStencil.H"
00027 #include <OpenFOAM/syncTools.H>
00028 #include <OpenFOAM/SortableList.H>
00029 #include <OpenFOAM/emptyPolyPatch.H>
00030 
00031 
00032 
00033 
00034 void Foam::CFCCellToCellStencil::calcFaceBoundaryData
00035 (
00036     labelList& neiGlobal
00037 ) const
00038 {
00039     const polyBoundaryMesh& patches = mesh().boundaryMesh();
00040     const label nBnd = mesh().nFaces()-mesh().nInternalFaces();
00041     const labelList& own = mesh().faceOwner();
00042 
00043     neiGlobal.setSize(nBnd);
00044 
00045     forAll(patches, patchI)
00046     {
00047         const polyPatch& pp = patches[patchI];
00048         label faceI = pp.start();
00049 
00050         if (pp.coupled())
00051         {
00052             
00053             forAll(pp, i)
00054             {
00055                 label bFaceI = faceI-mesh().nInternalFaces(); 
00056                 neiGlobal[bFaceI] = globalNumbering().toGlobal(own[faceI]);
00057                 faceI++;
00058             }
00059         }
00060         else if (isA<emptyPolyPatch>(pp))
00061         {
00062             forAll(pp, i)
00063             {
00064                 label bFaceI = faceI-mesh().nInternalFaces(); 
00065                 neiGlobal[bFaceI] = -1;
00066                 faceI++;
00067             }
00068         }
00069         else
00070         {
00071             
00072             forAll(pp, i)
00073             {
00074                 label bFaceI = faceI-mesh().nInternalFaces(); 
00075                 neiGlobal[bFaceI] =
00076                     globalNumbering().toGlobal(mesh().nCells()+bFaceI);
00077                 faceI++;
00078             }
00079         }
00080     }
00081     syncTools::swapBoundaryFaceList(mesh(), neiGlobal, false);
00082 }
00083 
00084 
00085 
00086 
00087 void Foam::CFCCellToCellStencil::calcCellStencil(labelListList& globalCellCells)
00088  const
00089 {
00090     const label nBnd = mesh().nFaces()-mesh().nInternalFaces();
00091     const labelList& own = mesh().faceOwner();
00092     const labelList& nei = mesh().faceNeighbour();
00093 
00094 
00095     
00096     
00097 
00098     labelList neiGlobal(nBnd);
00099     calcFaceBoundaryData(neiGlobal);
00100 
00101 
00102     
00103     
00104 
00105     globalCellCells.setSize(mesh().nCells());
00106     forAll(globalCellCells, cellI)
00107     {
00108         const cell& cFaces = mesh().cells()[cellI];
00109 
00110         labelList& cCells = globalCellCells[cellI];
00111 
00112         cCells.setSize(cFaces.size()+1);
00113 
00114         label nNbr = 0;
00115 
00116         
00117         cCells[nNbr++] = globalNumbering().toGlobal(cellI);
00118 
00119         
00120         forAll(cFaces, i)
00121         {
00122             label faceI = cFaces[i];
00123 
00124             if (mesh().isInternalFace(faceI))
00125             {
00126                 label nbrCellI = own[faceI];
00127                 if (nbrCellI == cellI)
00128                 {
00129                     nbrCellI = nei[faceI];
00130                 }
00131                 cCells[nNbr++] = globalNumbering().toGlobal(nbrCellI);
00132             }
00133             else
00134             {
00135                 label nbrCellI = neiGlobal[faceI-mesh().nInternalFaces()];
00136                 if (nbrCellI != -1)
00137                 {
00138                     cCells[nNbr++] = nbrCellI;
00139                 }
00140             }
00141         }
00142         cCells.setSize(nNbr);
00143     }
00144 }
00145 
00146 
00147 
00148 
00149 Foam::CFCCellToCellStencil::CFCCellToCellStencil(const polyMesh& mesh)
00150 :
00151     cellToCellStencil(mesh)
00152 {
00153     
00154     calcCellStencil(*this);
00155 }
00156 
00157 
00158