initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / conversion / ensight / part / ensightPart.H
blob4c79416d07d4605d2784eabcb7254c7a3ab3c26e
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software; you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::ensightPart
28 Description
29     Base class for ensightPartCells and ensightPartFaces
31 SourceFiles
32     ensightPart.C
33     ensightPartIO.C
34     ensightPartI.H
36 \*---------------------------------------------------------------------------*/
38 #ifndef ensightPart_H
39 #define ensightPart_H
41 #include "ensightFile.H"
42 #include "ensightGeoFile.H"
43 #include "typeInfo.H"
44 #include "labelList.H"
45 #include "polyMesh.H"
46 #include "Field.H"
47 #include "IOPtrList.H"
48 #include "IOstream.H"
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 namespace Foam
55 /*---------------------------------------------------------------------------*\
56                            Class ensightPart Declaration
57 \*---------------------------------------------------------------------------*/
59 class ensightPart
61     // Private data
63         // Static data members
64         static List<word> elemTypes_;
67 protected:
69     // Protected data
71         //- part number
72         label number_;
74         //- part name (or description)
75         string name_;
77         //- simple labelList with a name
78         labelListList elemLists_;
80         //- start offset for elemLists_
81         label offset_;
83         //- number of elements in this part
84         label size_;
86         //- cell or face data
87         bool isCellData_;
89         //- material id (numeric)
90         label matId_;
92         //- mesh reference used
93         const polyMesh* meshPtr_;
96     // Protected Classes
98         //- track the points used by the part and map global to local indices
99         class localPoints
100         {
101         public:
102             //- number of points used
103             label nPoints;
105             //- map global to local indices
106             labelList list;
108             // null constructor
109             localPoints()
110             :
111                 nPoints(0),
112                 list(0)
113             {}
115             // construct for mesh points
116             localPoints(const polyMesh& pMesh)
117             :
118                 nPoints(0),
119                 list(pMesh.points().size(), -1)
120             {}
121         };
124     // Protected Member Functions
126         //- reconstruct contents from Istream
127         void reconstruct(Istream&);
129         //- check for fully defined fields
130         bool isFieldDefined(const List<scalar>&) const;
132         //- write the part header
133         void writeHeader(ensightFile&, bool withDescription=false) const;
135         //- write a scalar field for idList
136         void writeFieldList
137         (
138             ensightFile& os,
139             const List<scalar>& field,
140             const List<label>& idList
141         ) const;
143         //- track points used
144         virtual localPoints calcLocalPoints() const
145         {
146             return localPoints();
147         }
149         //- write connectivities
150         virtual void writeConnectivity
151         (
152             ensightGeoFile& os,
153             const string& key,
154             const labelList& idList,
155             const labelList& pointMap
156         ) const
157         {}
160 public:
162     //- Runtime type information
163     TypeName("ensightPart");
166     // Constructors
168         //- Construct null
169         ensightPart();
171         //- Construct empty part with number and description
172         ensightPart(label partNumber, const string& partDescription);
174         //- Construct empty part with number and description
175         ensightPart
176         (
177             label partNumber,
178             const string& partDescription,
179             const polyMesh& pMesh
180         );
182         //- Construct as copy
183         ensightPart(const ensightPart&);
186     // Selectors
188         // Declare run-time constructor selection table
189         declareRunTimeSelectionTable
190         (
191             autoPtr,
192             ensightPart,
193             istream,
194             (
195                 Istream& is
196             ),
197             (is)
198         );
200         //- Construct and return clone
201         autoPtr<ensightPart> clone() const
202         {
203             return autoPtr<ensightPart>(new ensightPart(*this));
204         };
206         //- Construct on freestore from Istream
207         static autoPtr<ensightPart> New(Istream& is);
210     //- Destructor
211     virtual ~ensightPart();
214     // Static members
216         virtual List<word> const& elementTypes() const
217         {
218             return elemTypes_;
219         }
222     // Access
224         //- number of elements in this part
225         label size() const
226         {
227             return size_;
228         }
230         //- represents cell data
231         bool isCellData() const
232         {
233             return isCellData_;
234         }
236         //- represents face data
237         bool isFaceData() const
238         {
239             return !isCellData_;
240         }
242         //- part number
243         label number() const
244         {
245             return number_;
246         }
248         //- part name or description
249         const string& name() const
250         {
251             return name_;
252         }
254         //- material id
255         label materialId() const
256         {
257             return matId_;
258         }
260         //- non-const access
261         void name(const string& value)
262         {
263             name_ = value;
264         }
266         void materialId(const label value)
267         {
268             matId_ = value;
269         }
271         //- offset for element ids
272         label offset() const
273         {
274             return offset_;
275         }
278     // Edit
280         //- renumber elements
281         void renumber(labelList const&);
283         //- write summary information about the object
284         bool writeSummary(Ostream&) const;
286         //- write reconstruction information for the object
287         bool writeData(Ostream&) const;
289         //- write geometry
290         void writeGeometry(ensightGeoFile&) const;
292         //- write scalar field
293         void writeScalarField
294         (
295             ensightFile&,
296             const List<scalar>& field
297         ) const;
299         //- write vector field components
300         void writeVectorField
301         (
302             ensightFile&,
303             const List<scalar>& field0,
304             const List<scalar>& field1,
305             const List<scalar>& field2
306         ) const;
309         //- write generalized field components
310         template <class Type>
311         void writeField
312         (
313             ensightFile&,
314             const Field<Type>&
315         ) const;
318     // Member Operators
320         //- Disallow default bitwise assignment
321         void operator=(const ensightPart&)
322         {
323             notImplemented("ensightPart::operator=(const ensightPart&)");
324         }
327     // IOstream Operators
329         //- write data (reconstruction information)
330         friend Ostream& operator<<(Ostream&, const ensightPart&);
332         //- write geometry
333         friend ensightGeoFile& operator<<
334         (
335             ensightGeoFile&,
336             const ensightPart&
337         );
341 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
343 } // End namespace Foam
345 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
347 #ifdef NoRepository
348 #   include "ensightPartI.H"
349 #endif
351 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
353 #endif
355 // ************************************************************************* //