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

createPatches.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 Description
00026 
00027 
00028 \*---------------------------------------------------------------------------*/
00029 
00030 #include "blockMesh.H"
00031 
00032 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00033 
00034 Foam::faceList Foam::blockMesh::createPatchFaces
00035 (
00036     const polyPatch& patchTopologyFaces
00037 )
00038 {
00039     blockMesh& blocks = *this;
00040 
00041     labelList blockLabels = patchTopologyFaces.polyPatch::faceCells();
00042 
00043     label nFaces=0;
00044 
00045     forAll(patchTopologyFaces, patchTopologyFaceLabel)
00046     {
00047         label blockLabel = blockLabels[patchTopologyFaceLabel];
00048 
00049         faceList blockFaces
00050         (
00051             blocks[blockLabel].blockDef().blockShape().faces()
00052         );
00053 
00054         forAll(blockFaces, blockFaceLabel)
00055         {
00056             if
00057             (
00058                 blockFaces[blockFaceLabel]
00059              == patchTopologyFaces[patchTopologyFaceLabel]
00060             )
00061             {
00062                 nFaces +=
00063                     blocks[blockLabel].boundaryPatches()[blockFaceLabel].size();
00064             }
00065         }
00066     }
00067 
00068 
00069     faceList patchFaces(nFaces);
00070     face quadFace(4);
00071     label faceLabel = 0;
00072 
00073     forAll(patchTopologyFaces, patchTopologyFaceLabel)
00074     {
00075         label blockLabel = blockLabels[patchTopologyFaceLabel];
00076 
00077         faceList blockFaces
00078         (
00079             blocks[blockLabel].blockDef().blockShape().faces()
00080         );
00081 
00082         forAll(blockFaces, blockFaceLabel)
00083         {
00084             if
00085             (
00086                 blockFaces[blockFaceLabel]
00087                 == patchTopologyFaces[patchTopologyFaceLabel]
00088             )
00089             {
00090                 const labelListList& blockPatchFaces =
00091                     blocks[blockLabel].boundaryPatches()[blockFaceLabel];
00092 
00093                 forAll(blockPatchFaces, blockFaceLabel)
00094                 {
00095                     // Lookup the face points
00096                     // and collapse duplicate point labels
00097 
00098                     quadFace[0] =
00099                         mergeList_
00100                         [
00101                             blockPatchFaces[blockFaceLabel][0]
00102                           + blockOffsets_[blockLabel]
00103                         ];
00104 
00105                     label nUnique = 1;
00106 
00107                     for
00108                     (
00109                         label facePointLabel = 1;
00110                         facePointLabel < 4;
00111                         facePointLabel++
00112                     )
00113                     {
00114                         quadFace[nUnique] =
00115                             mergeList_
00116                             [
00117                                 blockPatchFaces[blockFaceLabel][facePointLabel]
00118                               + blockOffsets_[blockLabel]
00119                             ];
00120 
00121                         if (quadFace[nUnique] != quadFace[nUnique-1])
00122                         {
00123                             nUnique++;
00124                         }
00125                     }
00126 
00127                     if (quadFace[nUnique-1] == quadFace[0])
00128                     {
00129                         nUnique--;
00130                     }
00131 
00132                     if (nUnique == 4)
00133                     {
00134                         patchFaces[faceLabel++] = quadFace;
00135                     }
00136                     else if (nUnique == 3)
00137                     {
00138                         patchFaces[faceLabel++] = face
00139                         (
00140                             labelList::subList(quadFace, 3)
00141                         );
00142                     }
00143                     // else the face has collapsed to an edge or point
00144                 }
00145             }
00146         }
00147     }
00148 
00149     patchFaces.setSize(faceLabel);
00150 
00151     return patchFaces;
00152 }
00153 
00154 
00155 Foam::faceListList Foam::blockMesh::createPatches()
00156 {
00157     Info<< "\nCreating patches\n";
00158 
00159     const polyPatchList& patchTopologies = topology().boundaryMesh();
00160     faceListList patches(patchTopologies.size());
00161 
00162     forAll(patchTopologies, patchLabel)
00163     {
00164         patches[patchLabel] =
00165             createPatchFaces(patchTopologies[patchLabel]);
00166     }
00167 
00168     return patches;
00169 }
00170 
00171 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd