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

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