BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / applications / utilities / postProcessing / dataConversion / foamToVTK / vtkMesh.H
blob8d981401a5a184b03f9b10dba8c87d38b83c2881
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
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
13     the Free Software Foundation, either version 3 of the License, or
14     (at your 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, see <http://www.gnu.org/licenses/>.
24 Class
25     Foam::vtkMesh
27 Description
28     Encapsulation of VTK mesh data. Holds mesh or meshsubset and
29     polyhedral-cell decomposition on it.
31 SourceFiles
32     vtkMesh.C
34 \*---------------------------------------------------------------------------*/
36 #ifndef vtkMesh_H
37 #define vtkMesh_H
39 #include "vtkTopo.H"
40 #include "fvMeshSubset.H"
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 namespace Foam
47 // Forward declaration of classes
48 class Time;
50 /*---------------------------------------------------------------------------*\
51                            Class vtkMesh Declaration
52 \*---------------------------------------------------------------------------*/
54 class vtkMesh
56     // Private data
58         //- Reference to mesh
59         fvMesh& baseMesh_;
61         //- Subsetting engine + sub-fvMesh
62         fvMeshSubset subsetter_;
64         //- Current cellSet (or empty)
65         const word setName_;
67         //- Current decomposition of topology
68         mutable autoPtr<vtkTopo> topoPtr_;
72     // Private Member Functions
74         //- Disallow default bitwise copy construct
75         vtkMesh(const vtkMesh&);
77         //- Disallow default bitwise assignment
78         void operator=(const vtkMesh&);
81 public:
83     // Constructors
85         //- Construct from components
86         vtkMesh(fvMesh& baseMesh, const word& setName = "");
89     // Member Functions
91         // Access
93             //- whole mesh
94             const fvMesh& baseMesh() const
95             {
96                 return baseMesh_;
97             }
99             const fvMeshSubset& subsetter() const
100             {
101                 return subsetter_;
102             }
104             //- Check if running subMesh
105             bool useSubMesh() const
106             {
107                 return setName_.size();
108             }
110             //- topology
111             const vtkTopo& topo() const
112             {
113                 if (topoPtr_.empty())
114                 {
115                     topoPtr_.reset(new vtkTopo(mesh()));
116                 }
117                 return topoPtr_();
118             }
120             //- Access either mesh or submesh
121             const fvMesh& mesh() const
122             {
123                 if (useSubMesh())
124                 {
125                     return subsetter_.subMesh();
126                 }
127                 else
128                 {
129                     return baseMesh_;
130                 }
131             }
133             //- Number of field cells
134             label nFieldCells() const
135             {
136                 return topo().cellTypes().size();
137             }
139             //- Number of field points
140             label nFieldPoints() const
141             {
142                 return mesh().nPoints() + topo().addPointCellLabels().size();
143             }
146         // Edit
148             //- Read mesh
149             polyMesh::readUpdateState readUpdate();
152             //- Map volume field (does in fact do very little interpolation;
153             //  just copied from fvMeshSubset)
154             template<class GeoField>
155             tmp<GeoField> interpolate(const GeoField& fld) const
156             {
157                 if (useSubMesh())
158                 {
159                     tmp<GeoField> subFld = subsetter_.interpolate(fld);
160                     subFld().rename(fld.name());
161                     return subFld;
162                 }
163                 else
164                 {
165                     return fld;
166                 }
167             }
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 } // End namespace Foam
175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
177 #endif
179 // ************************************************************************* //