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

ensightPart.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-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 Class
00025     Foam::ensightPart
00026 
00027 Description
00028     Base class for ensightPartCells and ensightPartFaces
00029 
00030 SourceFiles
00031     ensightPart.C
00032     ensightPartIO.C
00033     ensightPartI.H
00034 
00035 \*---------------------------------------------------------------------------*/
00036 
00037 #ifndef ensightPart_H
00038 #define ensightPart_H
00039 
00040 #include <conversion/ensightFile.H>
00041 #include <conversion/ensightGeoFile.H>
00042 #include <OpenFOAM/typeInfo.H>
00043 #include <OpenFOAM/labelList.H>
00044 #include <OpenFOAM/polyMesh.H>
00045 #include <OpenFOAM/Field.H>
00046 #include <OpenFOAM/IOPtrList.H>
00047 #include <OpenFOAM/IOstream.H>
00048 
00049 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00050 
00051 namespace Foam
00052 {
00053 
00054 /*---------------------------------------------------------------------------*\
00055                            Class ensightPart Declaration
00056 \*---------------------------------------------------------------------------*/
00057 
00058 class ensightPart
00059 {
00060     // Private data
00061 
00062         // Static data members
00063         static List<word> elemTypes_;
00064 
00065 
00066 protected:
00067 
00068     // Protected data
00069 
00070         //- part number
00071         label number_;
00072 
00073         //- part name (or description)
00074         string name_;
00075 
00076         //- simple labelList with a name
00077         labelListList elemLists_;
00078 
00079         //- start offset for elemLists_
00080         label offset_;
00081 
00082         //- number of elements in this part
00083         label size_;
00084 
00085         //- cell or face data
00086         bool isCellData_;
00087 
00088         //- material id (numeric)
00089         label matId_;
00090 
00091         //- mesh reference used
00092         const polyMesh* meshPtr_;
00093 
00094 
00095     // Protected Classes
00096 
00097         //- track the points used by the part and map global to local indices
00098         class localPoints
00099         {
00100         public:
00101             //- number of points used
00102             label nPoints;
00103 
00104             //- map global to local indices
00105             labelList list;
00106 
00107             // null constructor
00108             localPoints()
00109             :
00110                 nPoints(0),
00111                 list(0)
00112             {}
00113 
00114             // construct for mesh points
00115             localPoints(const polyMesh& pMesh)
00116             :
00117                 nPoints(0),
00118                 list(pMesh.points().size(), -1)
00119             {}
00120         };
00121 
00122 
00123     // Protected Member Functions
00124 
00125         //- reconstruct contents from Istream
00126         void reconstruct(Istream&);
00127 
00128         //- check for fully defined fields
00129         bool isFieldDefined(const List<scalar>&) const;
00130 
00131         //- write the part header
00132         void writeHeader(ensightFile&, bool withDescription=false) const;
00133 
00134         //- write a scalar field for idList
00135         void writeFieldList
00136         (
00137             ensightFile& os,
00138             const List<scalar>& field,
00139             const List<label>& idList
00140         ) const;
00141 
00142         //- track points used
00143         virtual localPoints calcLocalPoints() const
00144         {
00145             return localPoints();
00146         }
00147 
00148         //- write connectivities
00149         virtual void writeConnectivity
00150         (
00151             ensightGeoFile& os,
00152             const string& key,
00153             const labelList& idList,
00154             const labelList& pointMap
00155         ) const
00156         {}
00157 
00158 
00159 public:
00160 
00161     //- Runtime type information
00162     TypeName("ensightPart");
00163 
00164 
00165     // Constructors
00166 
00167         //- Construct null
00168         ensightPart();
00169 
00170         //- Construct empty part with number and description
00171         ensightPart(label partNumber, const string& partDescription);
00172 
00173         //- Construct empty part with number and description
00174         ensightPart
00175         (
00176             label partNumber,
00177             const string& partDescription,
00178             const polyMesh& pMesh
00179         );
00180 
00181         //- Construct as copy
00182         ensightPart(const ensightPart&);
00183 
00184 
00185     // Selectors
00186 
00187         // Declare run-time constructor selection table
00188         declareRunTimeSelectionTable
00189         (
00190             autoPtr,
00191             ensightPart,
00192             istream,
00193             (
00194                 Istream& is
00195             ),
00196             (is)
00197         );
00198 
00199         //- Construct and return clone
00200         autoPtr<ensightPart> clone() const
00201         {
00202             return autoPtr<ensightPart>(new ensightPart(*this));
00203         };
00204 
00205         //- Construct on freestore from Istream
00206         static autoPtr<ensightPart> New(Istream& is);
00207 
00208 
00209     //- Destructor
00210     virtual ~ensightPart();
00211 
00212 
00213     // Static members
00214 
00215         virtual List<word> const& elementTypes() const
00216         {
00217             return elemTypes_;
00218         }
00219 
00220 
00221     // Access
00222 
00223         //- number of elements in this part
00224         label size() const
00225         {
00226             return size_;
00227         }
00228 
00229         //- represents cell data
00230         bool isCellData() const
00231         {
00232             return isCellData_;
00233         }
00234 
00235         //- represents face data
00236         bool isFaceData() const
00237         {
00238             return !isCellData_;
00239         }
00240 
00241         //- part number
00242         label number() const
00243         {
00244             return number_;
00245         }
00246 
00247         //- part name or description
00248         const string& name() const
00249         {
00250             return name_;
00251         }
00252 
00253         //- material id
00254         label materialId() const
00255         {
00256             return matId_;
00257         }
00258 
00259         //- non-const access
00260         void name(const string& value)
00261         {
00262             name_ = value;
00263         }
00264 
00265         void materialId(const label value)
00266         {
00267             matId_ = value;
00268         }
00269 
00270         //- offset for element ids
00271         label offset() const
00272         {
00273             return offset_;
00274         }
00275 
00276 
00277     // Edit
00278 
00279         //- renumber elements
00280         void renumber(labelList const&);
00281 
00282         //- write summary information about the object
00283         bool writeSummary(Ostream&) const;
00284 
00285         //- write reconstruction information for the object
00286         bool writeData(Ostream&) const;
00287 
00288         //- write geometry
00289         void writeGeometry(ensightGeoFile&) const;
00290 
00291         //- write scalar field
00292         void writeScalarField
00293         (
00294             ensightFile&,
00295             const List<scalar>& field
00296         ) const;
00297 
00298         //- write vector field components
00299         void writeVectorField
00300         (
00301             ensightFile&,
00302             const List<scalar>& field0,
00303             const List<scalar>& field1,
00304             const List<scalar>& field2
00305         ) const;
00306 
00307 
00308         //- write generalized field components
00309         template <class Type>
00310         void writeField
00311         (
00312             ensightFile&,
00313             const Field<Type>&
00314         ) const;
00315 
00316 
00317     // Member Operators
00318 
00319         //- Disallow default bitwise assignment
00320         void operator=(const ensightPart&)
00321         {
00322             notImplemented("ensightPart::operator=(const ensightPart&)");
00323         }
00324 
00325 
00326     // IOstream Operators
00327 
00328         //- write data (reconstruction information)
00329         friend Ostream& operator<<(Ostream&, const ensightPart&);
00330 
00331         //- write geometry
00332         friend ensightGeoFile& operator<<
00333         (
00334             ensightGeoFile&,
00335             const ensightPart&
00336         );
00337 };
00338 
00339 
00340 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00341 
00342 } // End namespace Foam
00343 
00344 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00345 
00346 #ifdef NoRepository
00347 #   include <conversion/ensightPartI.H>
00348 #endif
00349 
00350 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00351 
00352 #endif
00353 
00354 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines