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

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