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

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