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 PROSTAR files
00026 
00027 \*---------------------------------------------------------------------------*/
00028 
00029 #include "starMesh.H"
00030 #include <OpenFOAM/polyPatch.H>
00031 
00032 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00033 
00034 void starMesh::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                                 if
00087                                 (
00088                                     cellPolys_[facePointCells[cellI]][cellFaceI]
00089                                   > nInternalFaces_
00090                                 )
00091                                 {
00092                                     Info
00093                                         << "void starMesh::createPolyBoundary()"
00094                                         << ": Problem with face: " << curFace
00095                                         << "\nProbably multiple definitions "
00096                                         << "of a single boundary face. " << endl
00097                                         << "Other boundary face: "
00098                                         << curCellFaces[cellFaceI]
00099                                         << endl;
00100 
00101                                     Info << "PROSTAR Command: vset,news,vlis";
00102                                     forAll (curCellFaces[cellFaceI], spI)
00103                                     {
00104                                         // check if the point is given by STAR
00105                                         // or created locally
00106                                         if
00107                                         (
00108                                             curCellFaces[cellFaceI][spI] > -1
00109                                          && curCellFaces[cellFaceI][spI]
00110                                                 < starPointID_.size()
00111                                         )
00112                                         {
00113                                             Info
00114                                                 << ","
00115                                                 << starPointID_
00116                                                  [curCellFaces[cellFaceI][spI]];
00117                                         }
00118                                         else
00119                                         {
00120                                             Info << ",???";
00121                                         }
00122                                     }
00123                                     Info << " $ bset,add,vset,all" << endl;
00124                                 }
00125                                 else
00126                                 {
00127                                     Info
00128                                         << "void starMesh::createPolyBoundary()"
00129                                         << ": Problem with face: " << curFace
00130                                         << "\nProbably trying to define a "
00131                                         << "boundary face on a previously "
00132                                         << "matched internal face. " << endl
00133                                         << "Internal face: "
00134                                         << curCellFaces[cellFaceI]
00135                                         << endl;
00136 
00137                                     Info << "PROSTAR Command: vset,news,vlis";
00138                                     forAll (curCellFaces[cellFaceI], spI)
00139                                     {
00140                                         // check if the point is given by STAR
00141                                         // or created locally
00142                                         if
00143                                         (
00144                                             curCellFaces[cellFaceI][spI] > -1
00145                                          && curCellFaces[cellFaceI][spI]
00146                                                 < starPointID_.size()
00147                                         )
00148                                         {
00149                                             Info
00150                                                 << ","
00151                                                 << starPointID_
00152                                                  [curCellFaces[cellFaceI][spI]];
00153                                         }
00154                                         else
00155                                         {
00156                                             Info << ",???";
00157                                         }
00158                                     }
00159                                     Info << " $ bset,add,vset,all" << endl;
00160 
00161                                 }
00162                             }
00163 
00164                             cellPolys_[facePointCells[cellI]][cellFaceI] =
00165                                 nCreatedFaces;
00166 
00167                             nBoundaryFacesFound++;
00168                         }
00169                         if (found) break;
00170                     }
00171                     if (found) break;
00172                 }
00173                 if (found) break;
00174             }
00175 
00176             nCreatedFaces++;
00177         }
00178     }
00179 
00180     // check all cellPolys_ to see if there are any missing faces
00181     label nMissingFaceFound = 0;
00182 
00183     forAll (cellPolys_, cellI)
00184     {
00185         const labelList& curFaces = cellPolys_[cellI];
00186 
00187         forAll (curFaces, faceI)
00188         {
00189             if (curFaces[faceI] < 0)
00190             {
00191                 const face& missingFace = cellFaces_[cellI][faceI];
00192 
00193                 Info << "starMesh::createPolyBoundary() : "
00194                     << "missing face found in cell " << cellI
00195                     << ".\nType: " << cellShapes_[cellI].model().name()
00196                     << ". STAR cell number: " << starCellID_[cellI]
00197                     << ". Face: " << missingFace << endl;
00198 
00199                 nMissingFaceFound++;
00200 
00201                 Info << "PROSTAR Command: vset,news,vlis";
00202                 forAll (missingFace, spI)
00203                 {
00204                     // check if the point is given by STAR or created locally
00205                     if
00206                     (
00207                         missingFace[spI] > -1
00208                      && missingFace[spI] < starPointID_.size()
00209                     )
00210                     {
00211                         Info << "," << starPointID_[missingFace[spI]];
00212                     }
00213                     else
00214                     {
00215                         Info << ",???";
00216                     }
00217                 }
00218                 Info << " $ bset,add,vset,all" << endl;
00219             }
00220         }
00221     }
00222 
00223     if (nMissingFaceFound > 0)
00224     {
00225         Info << "Number of unmatched faces: " << nMissingFaceFound << endl;
00226     }
00227 
00228     // reset the size of the face list
00229     meshFaces_.setSize(nCreatedFaces);
00230 
00231     // check the mesh for face mismatch
00232     // (faces addressed once or more than twice)
00233     labelList markupFaces(meshFaces_.size(), 0);
00234 
00235     forAll (cellPolys_, cellI)
00236     {
00237         const labelList& curFaces = cellPolys_[cellI];
00238 
00239         forAll (curFaces, faceI)
00240         {
00241             markupFaces[curFaces[faceI]]++;
00242         }
00243     }
00244 
00245     for (label i = nInternalFaces_; i < markupFaces.size(); i++)
00246     {
00247         markupFaces[i]++;
00248     }
00249 
00250     label nProblemFacesFound = 0;
00251 
00252     forAll (markupFaces, faceI)
00253     {
00254         if (markupFaces[faceI] != 2)
00255         {
00256             const face& problemFace = meshFaces_[faceI];
00257 
00258             Info << "starMesh::createPolyBoundary() : "
00259                 << "problem with face " << faceI << ": addressed "
00260                 << markupFaces[faceI] << " times (should be 2!). Face: "
00261                 << problemFace << endl;
00262 
00263             nProblemFacesFound++;
00264 
00265             Info << "PROSTAR Command: vset,news,vlis";
00266             forAll (problemFace, spI)
00267             {
00268                 // check if the point is given by STAR or created locally
00269                 if
00270                 (
00271                     problemFace[spI] > -1
00272                  && problemFace[spI] < starPointID_.size()
00273                 )
00274                 {
00275                     Info << "," << starPointID_[problemFace[spI]];
00276                 }
00277                 else
00278                 {
00279                     Info << ",???";
00280                 }
00281             }
00282             Info << " $ bset,add,vset,all" << endl;
00283         }
00284     }
00285 
00286     if (nProblemFacesFound > 0)
00287     {
00288         Info << "Number of incorrectly matched faces: "
00289             << nProblemFacesFound << endl;
00290     }
00291 
00292     Info << "Number of boundary faces: " << nBoundaryFacesFound << endl;
00293     Info << "Total number of faces: " << nCreatedFaces << endl;
00294 }
00295 
00296 
00297 List<polyPatch*> starMesh::polyBoundaryPatches(const polyMesh& pMesh)
00298 {
00299     List<polyPatch*> p(boundary_.size());
00300 
00301     forAll (boundary_, patchI)
00302     {
00303         p[patchI] = polyPatch::New
00304         (
00305             patchTypes_[patchI],
00306             patchNames_[patchI],
00307             boundary_[patchI].size(),
00308             polyBoundaryPatchStartIndices_[patchI],
00309             patchI,
00310             pMesh.boundaryMesh()
00311         ).ptr();
00312     }
00313 
00314     return p;
00315 }
00316 
00317 
00318 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines