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

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