initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / applications / utilities / postProcessing / dataConversion / foamToVTK / vtkMesh.H
blobd2b1e9f0e32e66816734c3738dc114941f484e0b
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::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     // Private data
59         //- Reference to mesh
60         fvMesh& baseMesh_;
62         //- Subsetting engine + sub-fvMesh
63         fvMeshSubset subsetter_;
65         //- Current cellSet (or empty)
66         const word setName_;
68         //- Current decomposition of topology
69         mutable autoPtr<vtkTopo> topoPtr_;
73     // Private Member Functions
75         //- Disallow default bitwise copy construct
76         vtkMesh(const vtkMesh&);
78         //- Disallow default bitwise assignment
79         void operator=(const vtkMesh&);
82 public:
84     // Constructors
86         //- Construct from components
87         vtkMesh(fvMesh& baseMesh, const word& setName = "");
90     // Member Functions
92         // Access
94             //- whole mesh
95             const fvMesh& baseMesh() const
96             {
97                 return baseMesh_;
98             }
100             const fvMeshSubset& subsetter() const
101             {
102                 return subsetter_;
103             }
105             //- Check if running subMesh
106             bool useSubMesh() const
107             {
108                 return setName_.size();
109             }
111             //- topology
112             const vtkTopo& topo() const
113             {
114                 if (topoPtr_.empty())
115                 {
116                     topoPtr_.reset(new vtkTopo(mesh()));
117                 }
118                 return topoPtr_();
119             }
121             //- Access either mesh or submesh
122             const fvMesh& mesh() const
123             {
124                 if (useSubMesh())
125                 {
126                     return subsetter_.subMesh();
127                 }
128                 else
129                 {
130                     return baseMesh_;
131                 }
132             }
134             //- Number of field cells
135             label nFieldCells() const
136             {
137                 return topo().cellTypes().size();
138             }
140             //- Number of field points
141             label nFieldPoints() const
142             {
143                 return mesh().nPoints() + topo().addPointCellLabels().size();
144             }
147         // Edit
149             //- Read mesh
150             polyMesh::readUpdateState readUpdate();
153             //- Map volume field (does in fact do very little interpolation;
154             //  just copied from fvMeshSubset)
155             template<class GeoField>
156             tmp<GeoField> interpolate(const GeoField& fld) const
157             {
158                 if (useSubMesh())
159                 {
160                     tmp<GeoField> subFld = subsetter_.interpolate(fld);
161                     subFld().rename(fld.name());
162                     return subFld;
163                 }
164                 else
165                 {
166                     return fld;
167                 }
168             }
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174 } // End namespace Foam
176 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
178 #endif
180 // ************************************************************************* //