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

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