Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
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 
00056 
00057 
00058 class ensightPart
00059 {
00060     
00061 
00062         
00063         static List<word> elemTypes_;
00064 
00065 
00066 protected:
00067 
00068     
00069 
00070         
00071         label number_;
00072 
00073         
00074         string name_;
00075 
00076         
00077         labelListList elemLists_;
00078 
00079         
00080         label offset_;
00081 
00082         
00083         label size_;
00084 
00085         
00086         bool isCellData_;
00087 
00088         
00089         label matId_;
00090 
00091         
00092         const polyMesh* meshPtr_;
00093 
00094 
00095     
00096 
00097         
00098         class localPoints
00099         {
00100         public:
00101             
00102             label nPoints;
00103 
00104             
00105             labelList list;
00106 
00107             
00108             localPoints()
00109             :
00110                 nPoints(0),
00111                 list(0)
00112             {}
00113 
00114             
00115             localPoints(const polyMesh& pMesh)
00116             :
00117                 nPoints(0),
00118                 list(pMesh.points().size(), -1)
00119             {}
00120         };
00121 
00122 
00123     
00124 
00125         
00126         void reconstruct(Istream&);
00127 
00128         
00129         bool isFieldDefined(const List<scalar>&) const;
00130 
00131         
00132         void writeHeader(ensightFile&, bool withDescription=false) const;
00133 
00134         
00135         void writeFieldList
00136         (
00137             ensightFile& os,
00138             const List<scalar>& field,
00139             const List<label>& idList
00140         ) const;
00141 
00142         
00143         virtual localPoints calcLocalPoints() const
00144         {
00145             return localPoints();
00146         }
00147 
00148         
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     
00162     TypeName("ensightPart");
00163 
00164 
00165     
00166 
00167         
00168         ensightPart();
00169 
00170         
00171         ensightPart(label partNumber, const string& partDescription);
00172 
00173         
00174         ensightPart
00175         (
00176             label partNumber,
00177             const string& partDescription,
00178             const polyMesh& pMesh
00179         );
00180 
00181         
00182         ensightPart(const ensightPart&);
00183 
00184 
00185     
00186 
00187         
00188         declareRunTimeSelectionTable
00189         (
00190             autoPtr,
00191             ensightPart,
00192             istream,
00193             (
00194                 Istream& is
00195             ),
00196             (is)
00197         );
00198 
00199         
00200         autoPtr<ensightPart> clone() const
00201         {
00202             return autoPtr<ensightPart>(new ensightPart(*this));
00203         };
00204 
00205         
00206         static autoPtr<ensightPart> New(Istream& is);
00207 
00208 
00209     
00210     virtual ~ensightPart();
00211 
00212 
00213     
00214 
00215         virtual List<word> const& elementTypes() const
00216         {
00217             return elemTypes_;
00218         }
00219 
00220 
00221     
00222 
00223         
00224         label size() const
00225         {
00226             return size_;
00227         }
00228 
00229         
00230         bool isCellData() const
00231         {
00232             return isCellData_;
00233         }
00234 
00235         
00236         bool isFaceData() const
00237         {
00238             return !isCellData_;
00239         }
00240 
00241         
00242         label number() const
00243         {
00244             return number_;
00245         }
00246 
00247         
00248         const string& name() const
00249         {
00250             return name_;
00251         }
00252 
00253         
00254         label materialId() const
00255         {
00256             return matId_;
00257         }
00258 
00259         
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         
00271         label offset() const
00272         {
00273             return offset_;
00274         }
00275 
00276 
00277     
00278 
00279         
00280         void renumber(labelList const&);
00281 
00282         
00283         bool writeSummary(Ostream&) const;
00284 
00285         
00286         bool writeData(Ostream&) const;
00287 
00288         
00289         void writeGeometry(ensightGeoFile&) const;
00290 
00291         
00292         void writeScalarField
00293         (
00294             ensightFile&,
00295             const List<scalar>& field
00296         ) const;
00297 
00298         
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         
00309         template <class Type>
00310         void writeField
00311         (
00312             ensightFile&,
00313             const Field<Type>&
00314         ) const;
00315 
00316 
00317     
00318 
00319         
00320         void operator=(const ensightPart&)
00321         {
00322             notImplemented("ensightPart::operator=(const ensightPart&)");
00323         }
00324 
00325 
00326     
00327 
00328         
00329         friend Ostream& operator<<(Ostream&, const ensightPart&);
00330 
00331         
00332         friend ensightGeoFile& operator<<
00333         (
00334             ensightGeoFile&,
00335             const ensightPart&
00336         );
00337 };
00338 
00339 
00340 
00341 
00342 } 
00343 
00344 
00345 
00346 #ifdef NoRepository
00347 #   include <conversion/ensightPartI.H>
00348 #endif
00349 
00350 
00351 
00352 #endif
00353 
00354