BUGFIX: Illegal use of uninitialised value (backport)
[foam-extend-3.2.git] / applications / utilities / postProcessing / dataConversion / foamToVTK / vtkMesh.H
blob90f17501d9f5e86edf25c31512872326a8d7b2e4
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
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::vtkMesh
28 Description
29     Encapsulation of VTK mesh data. Holds mesh or meshsubset and
30     polyhedral-cell decomposition on it.
32 SourceFiles
33     vtkMesh.C
35 \*---------------------------------------------------------------------------*/
37 #ifndef vtkMesh_H
38 #define vtkMesh_H
40 #include "vtkTopo.H"
41 #include "fvMeshSubset.H"
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 namespace Foam
48 // Forward declaration of classes
49 class Time;
51 /*---------------------------------------------------------------------------*\
52                            Class vtkMesh Declaration
53 \*---------------------------------------------------------------------------*/
55 class vtkMesh
57     public fvMesh
59     // Private data
61         //- Mesh subset
62         fvMeshSubset subsetMesh_;
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(const IOobject& io, const word& setName = "");
89     // Destructor
91         virtual ~vtkMesh();
94     // Member Functions
96         // Access
98             const fvMeshSubset& subsetMesh() const
99             {
100                 return subsetMesh_;
101             }
103             //- Check if running subMesh
104             bool useSubMesh() const
105             {
106                 return setName_.size();
107             }
109             //- topology
110             const vtkTopo& topo() const
111             {
112                 if (topoPtr_.empty())
113                 {
114                     topoPtr_.reset(new vtkTopo(mesh()));
115                 }
116                 return topoPtr_();
117             }
119             //- Access either mesh or submesh
120             const fvMesh& mesh() const
121             {
122                 if (useSubMesh())
123                 {
124                     return subsetMesh_.subMesh();
125                 }
126                 else
127                 {
128                     return *this;
129                 }
130             }
132             //- Access either pointMesh of base or pointMesh of subset
133             const pointMesh& pMesh() const
134             {
135                 if (useSubMesh())
136                 {
137                     return pointMesh::New(subsetMesh_.subMesh());
138                 }
139                 else
140                 {
141                     return pointMesh::New(*this);
142                 }
143             }
145             //- Number of field cells
146             label nFieldCells() const
147             {
148                 return topo().cellTypes().size();
149             }
151             //- Number of field points
152             label nFieldPoints() const
153             {
154                 return mesh().nPoints() + topo().addPointCellLabels().size();
155             }
158         // Edit
160             //- Read mesh
161             polyMesh::readUpdateState readUpdate();
164             //- Map volume field (does in fact do very little interpolation;
165             //  just copied from fvMeshSubset)
166             template<class GeoField>
167             tmp<GeoField> interpolate(const GeoField& fld) const
168             {
169                 if (useSubMesh())
170                 {
171                     tmp<GeoField> subFld = subsetMesh_.interpolate(fld);
172                     subFld().rename(fld.name());
173                     return subFld;
174                 }
175                 else
176                 {
177                     return fld;
178                 }
179             }
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185 } // End namespace Foam
187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
189 #endif
191 // ************************************************************************* //