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

createBoundaryFaces.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 
00031 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00032 
00033 // Specialist version of face comparison to deal with
00034 // PROSTAR boundary format idiosyncracies
00035 bool sammMesh::sammEqualFace
00036 (
00037     const face& boundaryFace,
00038     const face& cellFace
00039 ) const
00040 {
00041     // A PROSTAR boundary face is defined by 4 vertices irrespective
00042     // of its topology.
00043     // In order to deal with all possibilities, two faces will be
00044     // considered equal if three of the vertices are the same.
00045     label nEqual = 0;
00046 
00047     forAll (cellFace, cellFaceLabelI)
00048     {
00049         const label curCellFaceLabel = cellFace[cellFaceLabelI];
00050 
00051         forAll (boundaryFace, bouFaceLabelI)
00052         {
00053             if (boundaryFace[bouFaceLabelI] == curCellFaceLabel)
00054             {
00055                 nEqual++;
00056 
00057                 break;
00058             }
00059         }
00060     }
00061 
00062     if (nEqual >= 3)
00063     {
00064         return true;
00065     }
00066     else
00067     {
00068         return false;
00069     }
00070 }
00071 
00072 
00073 void sammMesh::createBoundaryFaces()
00074 {
00075     forAll(boundary_, patchI)
00076     {
00077         faceList& patchFaces = boundary_[patchI];
00078 
00079         const labelListList& PointCells = pointCells();
00080 
00081         forAll(patchFaces, faceI)
00082         {
00083             bool found = false;
00084 
00085             face& curFace = patchFaces[faceI];
00086             const labelList& facePoints = curFace;
00087 
00088             forAll(facePoints, pointI)
00089             {
00090                 const labelList& facePointCells =
00091                     PointCells[facePoints[pointI]];
00092 
00093                 forAll(facePointCells, cellI)
00094                 {
00095                     const faceList& curCellFaces =
00096                         cellFaces_[facePointCells[cellI]];
00097 
00098                     forAll(curCellFaces, cellFaceI)
00099                     {
00100                         if (sammEqualFace(curCellFaces[cellFaceI], curFace))
00101                         {
00102                             // Found the cell face corresponding to this face
00103                             found = true;
00104 
00105                             // Set boundary face to the corresponding cell face
00106                             // which guarantees it is outward-pointing
00107                             curFace = curCellFaces[cellFaceI];
00108                         }
00109                         if (found) break;
00110                     }
00111                     if (found) break;
00112                 }
00113                 if (found) break;
00114             }
00115             if (!found)
00116             {
00117                 FatalErrorIn("sammMesh::createBoundaryFaces()")
00118                     << "Face " << faceI
00119                     << " does not have neighbour cell." << endl
00120                     << "    face : " << endl << curFace
00121                     << abort(FatalError);
00122             }
00123         }
00124     }
00125 }
00126 
00127 
00128 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines