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

createPolyBoundary.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     Create intermediate mesh files from SAMM files
00027 
00028 \*---------------------------------------------------------------------------*/
00029 
00030 #include "sammMesh.H"
00031 #include "polyPatch.H"
00032 
00033 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00034 
00035 void sammMesh::createPolyBoundary()
00036 {
00037     label nBoundaryFacesFound = 0;
00038 
00039     polyBoundaryPatchStartIndices_.setSize(boundary_.size());
00040 
00041     label nCreatedFaces = nInternalFaces_;
00042 
00043     const labelListList& PointCells = pointCells();
00044 
00045     forAll (boundary_, patchI)
00046     {
00047         const faceList& curShapePatch = boundary_[patchI];
00048 
00049         polyBoundaryPatchStartIndices_[patchI] = nCreatedFaces;
00050 
00051         forAll (curShapePatch, faceI)
00052         {
00053             bool found = false;
00054 
00055             const face& curFace = curShapePatch[faceI];
00056 
00057             meshFaces_[nCreatedFaces] = curFace;
00058 
00059             // Must find which cell this face belongs to in order to
00060             // mark it in the cellPolys_
00061             const labelList& facePoints = curFace;
00062 
00063             forAll(facePoints, pointI)
00064             {
00065                 const labelList& facePointCells =
00066                     PointCells[facePoints[pointI]];
00067 
00068                 forAll(facePointCells, cellI)
00069                 {
00070                     const faceList& curCellFaces =
00071                         cellFaces_[facePointCells[cellI]];
00072 
00073                     forAll(curCellFaces, cellFaceI)
00074                     {
00075                         if (curCellFaces[cellFaceI] == curFace)
00076                         {
00077                             // Found the cell face corresponding to this face
00078                             found = true;
00079 
00080                             // Debugging
00081                             if
00082                             (
00083                                 cellPolys_[facePointCells[cellI]][cellFaceI]
00084                              != -1
00085                             )
00086                             {
00087                                 FatalErrorIn
00088                                 (
00089                                     "void sammMesh::createPolyBoundary()"
00090                                 )   << "This looks like an already detected "
00091                                     << "internal face"
00092                                     << abort(FatalError);
00093                             }
00094 
00095                             cellPolys_[facePointCells[cellI]][cellFaceI] =
00096                                 nCreatedFaces;
00097 
00098                             nBoundaryFacesFound++;
00099                         }
00100                         if (found) break;
00101                     }
00102                     if (found) break;
00103                 }
00104                 if (found) break;
00105             }
00106 
00107             nCreatedFaces++;
00108         }
00109     }
00110 
00111     // reset the size of the face list
00112     meshFaces_.setSize(nCreatedFaces);
00113 
00114     Info << "Number of boundary faces: " << nBoundaryFacesFound << endl;
00115     Info << "Total number of faces: " << nCreatedFaces << endl;
00116 }
00117 
00118 
00119 List<polyPatch* > sammMesh::polyBoundaryPatches(const polyMesh& pMesh)
00120 {
00121     List<polyPatch* > p(boundary_.size());
00122 
00123     forAll (boundary_, patchI)
00124     {
00125         const faceList& curShapePatch = boundary_[patchI];
00126 
00127         p[patchI] = polyPatch::New
00128         (
00129             patchTypes_[patchI],
00130             patchNames_[patchI],
00131             curShapePatch.size(),
00132             polyBoundaryPatchStartIndices_[patchI],
00133             patchI,
00134             pMesh.boundaryMesh()
00135         ).ptr();
00136 
00137         p[patchI]->physicalType() = patchPhysicalTypes_[patchI];
00138     }
00139 
00140     return p;
00141 }
00142 
00143 
00144 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd