OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

vtkMesh.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     Foam::vtkMesh
00027 
00028 Description
00029     Encapsulation of VTK mesh data. Holds mesh or meshsubset and
00030     polyhedral-cell decomposition on it.
00031 
00032 SourceFiles
00033     vtkMesh.C
00034 
00035 \*---------------------------------------------------------------------------*/
00036 
00037 #ifndef vtkMesh_H
00038 #define vtkMesh_H
00039 
00040 #include "vtkTopo.H"
00041 #include "fvMeshSubset.H"
00042 
00043 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00044 
00045 namespace Foam
00046 {
00047 
00048 // Forward declaration of classes
00049 class Time;
00050 
00051 /*---------------------------------------------------------------------------*\
00052                            Class vtkMesh Declaration
00053 \*---------------------------------------------------------------------------*/
00054 
00055 class vtkMesh
00056 {
00057     // Private data
00058 
00059         //- Reference to mesh
00060         fvMesh& baseMesh_;
00061 
00062         //- Subsetting engine + sub-fvMesh
00063         fvMeshSubset subsetter_;
00064 
00065         //- Current cellSet (or empty)
00066         const word setName_;
00067 
00068         //- Current decomposition of topology
00069         mutable autoPtr<vtkTopo> topoPtr_;
00070 
00071 
00072 
00073     // Private Member Functions
00074 
00075         //- Disallow default bitwise copy construct
00076         vtkMesh(const vtkMesh&);
00077 
00078         //- Disallow default bitwise assignment
00079         void operator=(const vtkMesh&);
00080 
00081 
00082 public:
00083 
00084     // Constructors
00085 
00086         //- Construct from components
00087         vtkMesh(fvMesh& baseMesh, const word& setName = "");
00088 
00089 
00090     // Member Functions
00091 
00092         // Access
00093 
00094             //- whole mesh
00095             const fvMesh& baseMesh() const
00096             {
00097                 return baseMesh_;
00098             }
00099 
00100             const fvMeshSubset& subsetter() const
00101             {
00102                 return subsetter_;
00103             }
00104 
00105             //- Check if running subMesh
00106             bool useSubMesh() const
00107             {
00108                 return setName_.size();
00109             }
00110 
00111             //- topology
00112             const vtkTopo& topo() const
00113             {
00114                 if (topoPtr_.empty())
00115                 {
00116                     topoPtr_.reset(new vtkTopo(mesh()));
00117                 }
00118                 return topoPtr_();
00119             }
00120 
00121             //- Access either mesh or submesh
00122             const fvMesh& mesh() const
00123             {
00124                 if (useSubMesh())
00125                 {
00126                     return subsetter_.subMesh();
00127                 }
00128                 else
00129                 {
00130                     return baseMesh_;
00131                 }
00132             }
00133 
00134             //- Number of field cells
00135             label nFieldCells() const
00136             {
00137                 return topo().cellTypes().size();
00138             }
00139 
00140             //- Number of field points
00141             label nFieldPoints() const
00142             {
00143                 return mesh().nPoints() + topo().addPointCellLabels().size();
00144             }
00145 
00146 
00147         // Edit
00148 
00149             //- Read mesh
00150             polyMesh::readUpdateState readUpdate();
00151 
00152 
00153             //- Map volume field (does in fact do very little interpolation;
00154             //  just copied from fvMeshSubset)
00155             template<class GeoField>
00156             tmp<GeoField> interpolate(const GeoField& fld) const
00157             {
00158                 if (useSubMesh())
00159                 {
00160                     tmp<GeoField> subFld = subsetter_.interpolate(fld);
00161                     subFld().rename(fld.name());
00162                     return subFld;
00163                 }
00164                 else
00165                 {
00166                     return fld;
00167                 }
00168             }
00169 };
00170 
00171 
00172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00173 
00174 } // End namespace Foam
00175 
00176 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00177 
00178 #endif
00179 
00180 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd