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

sammMesh.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 \*---------------------------------------------------------------------------*/
00026 
00027 #include "sammMesh.H"
00028 #include "emptyPolyPatch.H"
00029 #include "demandDrivenData.H"
00030 #include "cellModeller.H"
00031 
00032 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00033 
00034 // Cell shape models
00035 const cellModel* sammMesh::unknownPtr_ = cellModeller::lookup("unknown");
00036 const cellModel* sammMesh::hexPtr_ = cellModeller::lookup("hex");
00037 const cellModel* sammMesh::wedgePtr_ = cellModeller::lookup("wedge");
00038 const cellModel* sammMesh::prismPtr_ = cellModeller::lookup("prism");
00039 const cellModel* sammMesh::pyrPtr_ = cellModeller::lookup("pyr");
00040 const cellModel* sammMesh::tetPtr_ = cellModeller::lookup("tet");
00041 const cellModel* sammMesh::tetWedgePtr_ = cellModeller::lookup("tetWedge");
00042 
00043 const cellModel* sammMesh::sammTrim1Ptr_ = cellModeller::lookup("sammTrim1");
00044 const cellModel* sammMesh::sammTrim2Ptr_ = cellModeller::lookup("sammTrim2");
00045 const cellModel* sammMesh::sammTrim3Ptr_ = cellModeller::lookup("sammTrim3");
00046 const cellModel* sammMesh::sammTrim4Ptr_ = cellModeller::lookup("sammTrim4");
00047 const cellModel* sammMesh::sammTrim5Ptr_ = cellModeller::lookup("sammTrim5");
00048 const cellModel* sammMesh::sammTrim8Ptr_ = cellModeller::lookup("hexagonalPrism");
00049 
00050 // lookup table giving FOAM face number when looked up with shape index
00051 // (first index) and STAR face number
00052 // - first column is always -1
00053 // - last column is -1 for all but hexagonal prism
00054 // WARNING: Possible bug for sammTrim2
00055 // There is a possibility that the lookup table for SAMM shapes is based on
00056 // the rotation of the shape. This would imply that the table below would need
00057 // to be split between the regular shapes (3-9), which are OK, and the SAMM
00058 // shapes, for which the face lookup needs to be done based on the rotation.
00059 // However, at the moment I haven't got enough info to complete the toble and
00060 // there are no cases that break it. Please reconsider in the light of mode
00061 // information.
00062 const label sammMesh::shapeFaceLookup[19][9] =
00063 {
00064     {-1, -1, -1, -1, -1, -1, -1, -1, -1},    // shape  0 - empty+
00065     {-1, -1, -1, -1, -1, -1, -1, -1, -1},    // shape  1 - empty+
00066     {-1, -1, -1, -1, -1, -1, -1, -1, -1},    // shape  2 - empty+
00067     {-1,  4,  5,  2,  3,  0,  1, -1, -1},    // shape  3 - hex+
00068     {-1,  4,  5,  2,  3,  0,  1, -1, -1},    // shape  4 - wedge+
00069     {-1,  0,  1,  4, -1,  2,  3, -1, -1},    // shape  5 - prism+
00070     {-1,  0, -1,  4,  2,  1,  3, -1, -1},    // shape  6 - pyr+
00071     {-1,  3, -1,  2, -1,  1,  0, -1, -1},    // shape  7 - tet+
00072     {-1, -1, -1, -1, -1, -1, -1, -1, -1},    // shape  8 - splitHex (empty)
00073     {-1,  0, -1,  1, -1,  2,  3, -1, -1},    // shape  9 - tetWedge+
00074     {-1, -1, -1, -1, -1, -1, -1, -1, -1},    // shape 10 - empty+
00075     {-1,  5,  4,  0,  1,  2,  3,  6, -1},    // shape 11 - sammTrim1+
00076 //    {-1,  1,  0,  2,  3,  4,  5,  6, -1},    // shape 12 - sammTrim2 ?
00077     {-1, 1,  0,  2,  4,  3,  5,  6, -1},    // shape 12 - sammTrim2  f(4)=4
00078     {-1,  5,  4,  0,  1,  2,  3,  6, -1},    // shape 13 - sammTrim3+
00079     {-1,  5,  4,  1,  0,  3,  2,  6, -1},    // shape 14 - sammTrim4
00080     {-1,  4,  3,  2,  5,  1,  0, -1, -1},    // shape 15 - sammTrim5
00081     {-1, -1, -1, -1, -1, -1, -1, -1, -1},    // shape 16 - empty
00082     {-1, -1, -1, -1, -1, -1, -1, -1, -1},    // shape 17 - empty
00083     {-1,  0,  1,  2,  5,  3,  6,  4,  7}     // shape 18 - sammTrim8
00084 };
00085 
00086 // SAMM cell lookup data
00087 
00088 // List of pointers used instead of pointer list o avoid
00089 // de-allocation problems
00090 List<const cellModel*> sammMesh::sammShapeLookup
00091 (
00092     256,
00093     reinterpret_cast<cellModel*>(0)
00094 );
00095 
00096 List<const label*> sammMesh::sammAddressingTable
00097 (
00098     256,
00099     reinterpret_cast<label*>(0)
00100 );
00101 
00102 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00103 
00104 // Make polyhedral mesh data (packing)
00105 void sammMesh::createPolyMeshData()
00106 {
00107     Info << "Creating a polyMesh" << endl;
00108 
00109     createPolyCells();
00110 
00111     Info<< "\nNumber of internal faces: "
00112         << nInternalFaces_ << endl;
00113 
00114     createPolyBoundary();
00115 
00116     label nProblemCells = 0;
00117 
00118     // check that there is no zeros in the cellPolys_
00119     forAll (cellPolys_, cellI)
00120     {
00121         const labelList& curFaceLabels = cellPolys_[cellI];
00122 
00123         forAll (curFaceLabels, faceI)
00124         {
00125             if (curFaceLabels[faceI] == -1)
00126             {
00127                 Info << "cell " << cellI
00128                     << " has got an unmatched face. "
00129                     << "Index: " << cellShapes_[cellI].model().index() << endl
00130 //                     << "cell shape: " << cellShapes_[cellI] << endl
00131 //                     << "shape faces: " << cellShapes_[cellI].faces() << endl
00132                     << "cellPolys: " << cellPolys_[cellI] << endl
00133 //                     << "cell faces: " << cellFaces_[cellI]
00134                     << endl;
00135 
00136                 nProblemCells++;
00137 
00138                 break;
00139             }
00140         }
00141     }
00142 
00143     if (nProblemCells > 0)
00144     {
00145         Info << "Number of problem cells: " << nProblemCells << endl;
00146     }
00147 }
00148 
00149 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00150 
00151 // Construct from components
00152 sammMesh::sammMesh
00153 (
00154     const fileName& prefix,
00155     const Time& rt,
00156     const scalar scaleFactor
00157 )
00158 :
00159     casePrefix_(prefix),
00160     runTime_(rt),
00161     points_(0),
00162     cellShapes_(0),
00163     boundary_(0),
00164     patchTypes_(0),
00165     defaultFacesName_("defaultFaces"),
00166     defaultFacesType_(emptyPolyPatch::typeName),
00167     patchNames_(0),
00168     patchPhysicalTypes_(0),
00169     starPointLabelLookup_(0),
00170     starCellLabelLookup_(0),
00171     cellFaces_(0),
00172     meshFaces_(0),
00173     cellPolys_(0),
00174     nInternalFaces_(0),
00175     polyBoundaryPatchStartIndices_(0),
00176     pointCellsPtr_(NULL),
00177     isShapeMesh_(true)
00178 {
00179     // Fill in the lookup tables
00180     fillSammCellShapeTable();
00181     fillSammAddressingTable();
00182 
00183     readPoints(scaleFactor);
00184 
00185     readCells();
00186 
00187     readBoundary();
00188 
00189     fixCollapsedEdges();
00190 
00191     readCouples();
00192 
00193     // create boundary faces
00194     createBoundaryFaces();
00195 
00196     // after all this is done do couples
00197 }
00198 
00199 
00200 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00201 
00202 sammMesh::~sammMesh()
00203 {
00204     deleteDemandDrivenData(pointCellsPtr_);
00205 }
00206 
00207 
00208 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00209 
00210 
00211 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd