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

starMesh.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 "starMesh.H"
00028 #include "emptyPolyPatch.H"
00029 #include "demandDrivenData.H"
00030 #include "cellModeller.H"
00031 
00032 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00033 
00034 // Merge tolerances
00035 // Moni, tolerances:
00036 const scalar starMesh::smallMergeTol_ = 1e-3;
00037 const scalar starMesh::cpMergePointTol_ = 1e-4;
00038 
00039 // const scalar starMesh::smallMergeTol_ = 4e-4;
00040 // const scalar starMesh::cpMergePointTol_ = 1e-3;
00041 
00042 // Cell shape models
00043 const cellModel* starMesh::unknownPtr_ = cellModeller::lookup("unknown");
00044 const cellModel* starMesh::tetPtr_ = cellModeller::lookup("tet");
00045 const cellModel* starMesh::pyrPtr_ = cellModeller::lookup("pyr");
00046 const cellModel* starMesh::tetWedgePtr_ = cellModeller::lookup("tetWedge");
00047 const cellModel* starMesh::prismPtr_ = cellModeller::lookup("prism");
00048 const cellModel* starMesh::wedgePtr_ = cellModeller::lookup("wedge");
00049 const cellModel* starMesh::hexPtr_ = cellModeller::lookup("hex");
00050 
00051 const cellModel* starMesh::sammTrim1Ptr_ = cellModeller::lookup("sammTrim1");
00052 const cellModel* starMesh::sammTrim2Ptr_ = cellModeller::lookup("sammTrim2");
00053 const cellModel* starMesh::sammTrim3Ptr_ = cellModeller::lookup("sammTrim3");
00054 const cellModel* starMesh::sammTrim4Ptr_ = cellModeller::lookup("sammTrim4");
00055 const cellModel* starMesh::sammTrim5Ptr_ = cellModeller::lookup("sammTrim5");
00056 const cellModel* starMesh::sammTrim8Ptr_ = cellModeller::lookup("hexagonalPrism");
00057 
00058 // Regular cell point addressing
00059 // SAMM point addressing
00060 const label starMesh::regularAddressingTable[6][8] =
00061 {
00062     { 0,  1,  2,  4, -1, -1, -1, -1},    // tet
00063     { 0,  1,  2,  3,  4, -1, -1, -1},    // pyramid
00064     { 0,  1,  2,  4,  6, -1, -1, -1},    // tet wedge
00065     { 0,  1,  2,  4,  5,  6, -1, -1},    // prism
00066     { 7,  6,  5,  3,  2,  1,  0, -1},    // wedge
00067     { 0,  1,  2,  3,  4,  5,  6,  7}     // hex
00068 };
00069 
00070 
00071 // SAMM point addressing
00072 const label starMesh::sammAddressingTable[9][12] =
00073 {
00074     {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},    // samm0 - empty
00075     { 3,  2,  6,  7, 11,  9,  1,  5,  4, 12, -1, -1},    // samm1+
00076     {13,  5,  6,  2, 10, 12,  4,  7,  3, 11, -1, -1},    // samm2+
00077     { 2,  3,  0,  1, 10, 11, 12,  4,  8,  9, -1, -1},    // samm3+
00078     { 0,  1,  3,  4, 13,  8,  9, 10, 11, 12, -1, -1},    // samm4+
00079     {12,  7,  6,  5,  8, 11, 10,  9, -1, -1, -1, -1},    // samm5+
00080     {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},    // samm6 - empty
00081     {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},    // samm7 - empty
00082     {11,  3, 15, 12,  4,  8, 10,  2, 14, 13,  5,  9}     // samm8+
00083 };
00084 
00085 
00086 // lookup table giving FOAM face number when looked up with shape index
00087 // (first index) and STAR face number
00088 // - first column is always -1
00089 // - last column is -1 for all but hexagonal prism
00090 // WARNING: Possible bug for sammTrim2 
00091 // The lookup table for SAMM shapes is based on the rotation of the
00092 // shape. This would imply that the table below needs to be split between
00093 // the regular shapes (3-9), which are OK, and the SAMM shapes, for which
00094 // the face lookup needs to be done based on the rotation. Thus, for a samm
00095 // cell, firts find out the face index in the normal rotation using the cell
00096 // face permutation table and then use the index from the shape face lookup.
00097 // Additionally, have in mind that this silliness does not allow matches
00098 // on face 7 and 8 of the samm cell. 
00099 
00100 const label starMesh::sammFacePermutationTable[24][8] =
00101 {
00102   {-1, 1, 2, 3, 4, 5, 6, 7},    // permutation   0
00103   {-1, 3, 4, 5, 6, 1, 2, 7},    // permutation   1
00104   {-1, 5, 6, 1, 2, 3, 4, 7},    // permutation   2
00105   {-1, 1, 2, 5, 6, 4, 3, 7},    // permutation   3
00106   {-1, 3, 4, 1, 2, 6, 5, 7},    // permutation   4
00107   {-1, 5, 6, 3, 4, 2, 1, 7},    // permutation   5
00108   {-1, 1, 2, 4, 3, 6, 5, 7},    // permutation   6
00109   {-1, 3, 4, 6, 5, 2, 1, 7},    // permutation   7
00110   {-1, 5, 6, 2, 1, 4, 3, 7},    // permutation   8
00111   {-1, 1, 2, 6, 5, 3, 4, 7},    // permutation   9
00112   {-1, 3, 4, 2, 1, 5, 6, 7},    // permutation  10
00113   {-1, 5, 6, 4, 3, 1, 2, 7},    // permutation  11
00114   {-1, 2, 1, 5, 6, 3, 4, 7},    // permutation  12
00115   {-1, 4, 3, 1, 2, 5, 6, 7},    // permutation  13
00116   {-1, 6, 5, 3, 4, 1, 2, 7},    // permutation  14
00117   {-1, 2, 1, 3, 4, 6, 5, 7},    // permutation  15
00118   {-1, 4, 3, 5, 6, 2, 1, 7},    // permutation  16
00119   {-1, 6, 5, 1, 2, 4, 3, 7},    // permutation  17
00120   {-1, 2, 1, 6, 5, 4, 3, 7},    // permutation  18
00121   {-1, 4, 3, 2, 1, 6, 5, 7},    // permutation  19
00122   {-1, 6, 5, 4, 3, 2, 1, 7},    // permutation  20
00123   {-1, 2, 1, 4, 3, 5, 6, 7},    // permutation  21
00124   {-1, 4, 3, 6, 5, 1, 2, 7},    // permutation  22
00125   {-1, 6, 5, 2, 1, 3, 4, 7}     // permutation  23
00126 };
00127 
00128 const label starMesh::shapeFaceLookup[19][9] =
00129 {
00130     {-1, -1, -1, -1, -1, -1, -1, -1, -1},    // shape  0 - empty+
00131     {-1, -1, -1, -1, -1, -1, -1, -1, -1},    // shape  1 - empty+
00132     {-1, -1, -1, -1, -1, -1, -1, -1, -1},    // shape  2 - empty+
00133     {-1,  4,  5,  2,  3,  0,  1, -1, -1},    // shape  3 - hex+
00134     {-1,  1,  0,  5,  4,  2,  3, -1, -1},    // shape  4 - wedge+
00135     {-1,  0,  1,  4, -1,  2,  3, -1, -1},    // shape  5 - prism+
00136     {-1,  0, -1,  4,  2,  1,  3, -1, -1},    // shape  6 - pyr+
00137     {-1,  3, -1,  2, -1,  1,  0, -1, -1},    // shape  7 - tet+
00138     {-1, -1, -1, -1, -1, -1, -1, -1, -1},    // shape  8 - splitHex (empty)
00139     {-1,  0, -1,  1, -1,  2,  3, -1, -1},    // shape  9 - tetWedge+
00140     {-1, -1, -1, -1, -1, -1, -1, -1, -1},    // shape 10 - empty+
00141     {-1,  1,  0,  3,  2,  5,  4,  6, -1},    // shape 11 - sammTrim1
00142     {-1,  5,  4,  1,  0,  3,  2,  6, -1},    // shape 12 - sammTrim2
00143     {-1,  2,  3,  0,  1,  4,  5,  6, -1},    // shape 13 - sammTrim3
00144     {-1,  2,  3,  0,  1,  4,  5,  6, -1},    // shape 14 - sammTrim4
00145     {-1,  5,  2,  4,  3,  1,  0, -1, -1},    // shape 15 - sammTrim5
00146     {-1, -1, -1, -1, -1, -1, -1, -1, -1},    // shape 16 - empty
00147     {-1, -1, -1, -1, -1, -1, -1, -1, -1},    // shape 17 - empty
00148     {-1,  1,  0,  6,  7,  2,  3,  4,  5}     // shape 18 - sammTrim8
00149 };
00150 
00151 
00152 // The star to foam face order mapping tables are potentially incomplete
00153 // Currently available data is listed below.
00154 // 1) hex and degenerate hex: OK
00155 // samm trim 1:
00156 // star number: 1 2 3 4 5 6 7 8  In ROTATION 0
00157 // foam number: 5 4 1 0 3 2 6
00158 // confirmed:   1 0 3 2 5 4 6
00159 
00160 // samm trim 2:
00161 // star number: 1 2 3 4 5 6 7 8  In ROTATION 0
00162 // foam number: 5 4 1 0 3 2 6
00163 // confirmed:     4   0 3 2
00164 
00165 // samm trim 3:
00166 // star number: 1 2 3 4 5 6 7 8  In ROTATION 0
00167 // foam number: 2 3 0 1 4 5 6
00168 // confirmed:
00169 
00170 // samm trim 4:
00171 // star number: 1 2 3 4 5 6 7 8  In ROTATION 0
00172 // foam number: 2 3 0 1 4 5 6
00173 // confirmed:
00174 
00175 // samm trim 5:
00176 // star number: 1 2 3 4 5 6 7 8  In ROTATION 0
00177 // foam number: 2 4 3 1 0 5
00178 // confirmed:   5 2 4 3 1 0
00179 
00180 // samm trim 8:
00181 // star number: 1 2 3 4 5 6 7 8  In ROTATION 0
00182 // foam number: 2 5 4 7 1 0 3 6
00183 // confirmed:   1 0 6 
00184 
00185 
00186 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00187 
00188 // Make polyhedral mesh data (packing)
00189 void starMesh::createPolyMeshData()
00190 {
00191     Info << "Creating a polyMesh" << endl;
00192 
00193     createPolyCells();
00194 
00195     Info<< "\nNumber of internal faces: "
00196         << nInternalFaces_ << endl;
00197 
00198     createPolyBoundary();
00199 }
00200 
00201 
00202 // Clear extra storage before creation of the mesh to remove
00203 // a memory peak
00204 void starMesh::clearExtraStorage()
00205 {
00206     Info << "Clearing extra storage" << endl;
00207 
00208     starPointLabelLookup_.setSize(0);
00209     starPointID_.setSize(0);
00210     starCellID_.setSize(0);
00211     starCellLabelLookup_.setSize(0);
00212     starCellPermutation_.setSize(0);
00213     cellFaces_.setSize(0);
00214     boundaryCellIDs_.setSize(0);
00215     boundaryCellFaceIDs_.setSize(0);
00216     couples_.clear();
00217 
00218     deleteDemandDrivenData(pointCellsPtr_);
00219 }
00220 
00221 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00222 
00223 // Construct from components
00224 starMesh::starMesh
00225 (
00226     const fileName& prefix,
00227     const Time& rt,
00228     const scalar scaleFactor
00229 )
00230 :
00231     casePrefix_(prefix),
00232     runTime_(rt),
00233     points_(0),
00234     cellShapes_(0),
00235     boundary_(0),
00236     patchTypes_(0),
00237     defaultFacesName_("defaultFaces"),
00238     defaultFacesType_(emptyPolyPatch::typeName),
00239     patchNames_(0),
00240     patchPhysicalTypes_(0),
00241     starPointLabelLookup_(0),
00242     starPointID_(0),
00243     starCellID_(0),
00244     starCellLabelLookup_(0),
00245     starCellPermutation_(0),
00246     cellFaces_(0),
00247     boundaryCellIDs_(0),
00248     boundaryCellFaceIDs_(0),
00249     meshFaces_(0),
00250     cellPolys_(0),
00251     nInternalFaces_(0),
00252     polyBoundaryPatchStartIndices_(0),
00253     pointCellsPtr_(NULL),
00254     couples_(0),
00255     isShapeMesh_(true)
00256 {
00257     readPoints(scaleFactor);
00258 
00259     readCells();
00260 
00261     readBoundary();
00262 
00263     fixCollapsedEdges();
00264 
00265     readCouples();
00266 
00267     if (couples_.size())
00268     {
00269         createCoupleMatches();
00270     }
00271 
00272     markBoundaryFaces();
00273 
00274     mergeCoupleFacePoints();
00275 
00276     purgeCellShapes();
00277 
00278     collectBoundaryFaces();
00279 }
00280 
00281 
00282 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00283 
00284 starMesh::~starMesh()
00285 {
00286     deleteDemandDrivenData(pointCellsPtr_);
00287 }
00288 
00289 
00290 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00291 
00292 
00293 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd