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

ensightMesh.H

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 Class
00026     Foam::ensightMesh
00027 
00028 Description
00029 
00030 SourceFiles
00031     ensightMesh.C
00032 
00033 \*---------------------------------------------------------------------------*/
00034 
00035 #ifndef ensightMesh_H
00036 #define ensightMesh_H
00037 
00038 #include "cellSets.H"
00039 #include "faceSets.H"
00040 #include "HashTable.H"
00041 #include "HashSet.H"
00042 #include "fvMesh.H"
00043 #include "OFstream.H"
00044 #include <fstream>
00045 
00046 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00047 
00048 namespace Foam
00049 {
00050 
00051 class fvMesh;
00052 class argList;
00053 
00054 /*---------------------------------------------------------------------------*\
00055                            Class ensightMesh Declaration
00056 \*---------------------------------------------------------------------------*/
00057 
00058 class ensightMesh
00059 {
00060         class nFacePrimitives
00061         {
00062         public:
00063 
00064             label nPoints;
00065             label nTris;
00066             label nQuads;
00067             label nPolys;
00068 
00069             nFacePrimitives()
00070             :
00071                 nPoints(0),
00072                 nTris(0),
00073                 nQuads(0),
00074                 nPolys(0)
00075             {}
00076         };
00077 
00078 
00079     // Private data
00080 
00081         //- Reference to the OpenFOAM mesh
00082         const fvMesh& mesh_;
00083 
00084         //- Set binary file output
00085         bool binary_;
00086 
00087         //- The ensight part id for the first patch
00088         label patchPartOffset_;
00089 
00090         cellSets meshCellSets_;
00091 
00092         List<faceSets> boundaryFaceSets_;
00093 
00094         wordList allPatchNames_;
00095 
00096         List<labelList> allPatchProcs_;
00097 
00098         wordHashSet patchNames_;
00099 
00100         HashTable<nFacePrimitives> nPatchPrims_;
00101 
00102 
00103     // Private Member Functions
00104 
00105         //- Disallow default bitwise copy construct
00106         ensightMesh(const ensightMesh&);
00107 
00108         //- Disallow default bitwise assignment
00109         void operator=(const ensightMesh&);
00110 
00111         void writePoints
00112         (
00113             const scalarField& pointsComponent,
00114             OFstream& ensightGeometryFile
00115         ) const;
00116 
00117         cellShapeList map
00118         (
00119             const cellShapeList& cellShapes,
00120             const labelList& prims
00121         ) const;
00122 
00123         cellShapeList map
00124         (
00125             const cellShapeList& cellShapes,
00126             const labelList& hexes,
00127             const labelList& wedges
00128         ) const;
00129 
00130         void writePrims
00131         (
00132             const cellShapeList& cellShapes,
00133             const label pointOffset,
00134             OFstream& ensightGeometryFile
00135         ) const;
00136 
00137         void writePolys
00138         (
00139             const labelList& polys,
00140             const cellList& cellFaces,
00141             const faceList& faces,
00142             const label pointOffset,
00143             OFstream& ensightGeometryFile
00144         ) const;
00145 
00146         void writeAllPrims
00147         (
00148             const char* key,
00149             const label nPrims,
00150             const cellShapeList& cellShapes,
00151             const labelList& pointOffsets,
00152             OFstream& ensightGeometryFile
00153         ) const;
00154 
00155         void writeFacePrims
00156         (
00157             const char* key,
00158             const faceList& patchFaces,
00159             const label pointOffset,
00160             OFstream& ensightGeometryFile
00161         ) const;
00162 
00163         faceList map
00164         (
00165             const faceList& patchFaces,
00166             const labelList& prims
00167         ) const;
00168 
00169         void writeAllFacePrims
00170         (
00171             const char* key,
00172             const labelList& prims,
00173             const label nPrims,
00174             const faceList& patchFaces,
00175             const labelList& pointOffsets,
00176             const labelList& patchProcessors,
00177             OFstream& ensightGeometryFile
00178         ) const;
00179 
00180         void writeAscii
00181         (
00182             const fileName& postProcPath,
00183             const word& prepend,
00184             const label timeIndex,
00185             Ostream& ensightCaseFile
00186         ) const;
00187 
00188         void writeBinary
00189         (
00190             const fileName& postProcPath,
00191             const word& prepend,
00192             const label timeIndex,
00193             Ostream& ensightCaseFile
00194         ) const;
00195 
00196         void writePrimsBinary
00197         (
00198             const cellShapeList& cellShapes,
00199             const label pointOffset,
00200             std::ofstream& ensightGeometryFile
00201         ) const;
00202 
00203         void writeAllPrimsBinary
00204         (
00205             const char* key,
00206             const label nPrims,
00207             const cellShapeList& cellShapes,
00208             const labelList& pointOffsets,
00209             std::ofstream& ensightGeometryFile
00210         ) const;
00211 
00212         void writePolysBinary
00213         (
00214             const labelList& polys,
00215             const cellList& cellFaces,
00216             const faceList& faces,
00217             const label pointOffset,
00218             std::ofstream& ensightGeometryFile
00219         ) const;
00220 
00221         void writeAllFacePrimsBinary
00222         (
00223             const char* key,
00224             const labelList& prims,
00225             const label nPrims,
00226             const faceList& patchFaces,
00227             const labelList& pointOffsets,
00228             const labelList& patchProcessors,
00229             std::ofstream& ensightGeometryFile
00230         ) const;
00231 
00232         void writeFacePrimsBinary
00233         (
00234             const char* key,
00235             const faceList& patchFaces,
00236             const label pointOffset,
00237             std::ofstream& ensightGeometryFile
00238         ) const;
00239 
00240 
00241 public:
00242 
00243     // Constructors
00244 
00245         //- Construct from fvMesh
00246         ensightMesh(const fvMesh&, const argList& args, const bool binary);
00247 
00248 
00249     //- Destructor
00250     ~ensightMesh();
00251 
00252 
00253     // Member Functions
00254 
00255         // Access
00256 
00257             const fvMesh& mesh() const
00258             {
00259                 return mesh_;
00260             }
00261 
00262             const cellSets& meshCellSets() const
00263             {
00264                 return meshCellSets_;
00265             }
00266 
00267             const List<faceSets>& boundaryFaceSets() const
00268             {
00269                 return boundaryFaceSets_;
00270             }
00271 
00272             const wordList& allPatchNames() const
00273             {
00274                 return allPatchNames_;
00275             }
00276 
00277             const List<labelList>& allPatchProcs() const
00278             {
00279                 return allPatchProcs_;
00280             }
00281 
00282             const wordHashSet& patchNames() const
00283             {
00284                 return patchNames_;
00285             }
00286 
00287             const HashTable<nFacePrimitives>& nPatchPrims() const
00288             {
00289                 return nPatchPrims_;
00290             }
00291 
00292             //- The ensight part id for the first patch
00293             label patchPartOffset() const
00294             {
00295                 return patchPartOffset_;
00296             }
00297 
00298 
00299     // I-O
00300 
00301         void write
00302         (
00303             const fileName& postProcPath,
00304             const word& prepend,
00305             const label timeIndex,
00306             Ostream& ensightCaseFile
00307         ) const;
00308 };
00309 
00310 
00311 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00312 
00313 } // End namespace Foam
00314 
00315 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00316 
00317 #endif
00318 
00319 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd