foamVtkVtuAdaptor.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2017-2020 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::vtk::vtuAdaptor
28 
29 Description
30  A low-level backend adaptor for converting OpenFOAM volume meshes/fields
31  to VTK internal representation.
32  The output is a single piece vtkUnstructuredGrid dataset.
33  Multiblock composition is done by the caller.
34 
35 Note
36  This was originally part of the catalystFvMesh function object backend,
37  which was prototyped in the ParaView reader module.
38  This adaptor unifies many common elements of both.
39 
40 SourceFiles
41  foamVtkVtuAdaptorI.H
42  foamVtkVtuAdaptorTemplates.C
43 
44 \*---------------------------------------------------------------------------*/
45 
46 #ifndef Foam_vtk_vtuAdaptor_H
47 #define Foam_vtk_vtuAdaptor_H
48 
49 #include "fvMesh.H"
50 #include "volFieldsFwd.H"
51 #include "foamVtkTools.H"
52 #include "foamVtkMeshMaps.H"
53 #include "foamVtuSizing.H"
54 
55 #include "vtkUnstructuredGrid.h"
56 #include "vtkMultiBlockDataSet.h"
57 
58 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
59 
60 // Forward Declarations
61 class vtkDataSet;
62 class vtkFloatArray;
63 
64 namespace Foam
65 {
66 namespace vtk
67 {
68 
69 /*---------------------------------------------------------------------------*\
70  Class vtk::vtuAdaptor Declaration
71 \*---------------------------------------------------------------------------*/
72 
73 //- Bookkeeping for vtkUnstructuredGrid
74 class vtuAdaptor
75 :
76  public vtk::Caching<vtkUnstructuredGrid>,
77  public foamVtkMeshMaps
78 {
79 public:
80 
81  // Member Functions
82 
83  // Mesh Conversion
84 
85  //- The vtk points for the mesh (and decomposition)
86  inline vtkSmartPointer<vtkPoints> points
87  (
88  const fvMesh& mesh
89  ) const;
90 
91  //- The vtk points for the mesh (and decomposition)
92  //- using the provided pointMap
93  inline vtkSmartPointer<vtkPoints> points
94  (
95  const fvMesh& mesh,
96  const labelUList& pointMap
97  ) const;
98 
99  //- Internal mesh as vtkUnstructuredGrid.
100  // Calling this automatically populates the sizing and vtk::Caching
101  inline vtkSmartPointer<vtkUnstructuredGrid> internal
102  (
103  const fvMesh& mesh,
104  const bool decompPoly = false
105  );
106 
107 
108  // Field Conversion
109 
110  //- Convert internal volume field (CellData)
111  template<class Type>
112  static vtkSmartPointer<vtkFloatArray>
114  (
116  const vtuAdaptor& vtuData
117  );
118 
119  //- Convert internal volume field (CellData)
120  template<class Type>
121  static vtkSmartPointer<vtkFloatArray>
123  (
125  const vtuAdaptor& vtuData
126  );
127 
128 
129  //- Convert internal volume field (CellData)
130  template<class Type>
131  vtkSmartPointer<vtkFloatArray>
133  (
135  ) const;
136 
137  //- Convert internal volume field (CellData)
138  template<class Type>
139  vtkSmartPointer<vtkFloatArray>
141  (
143  ) const;
144 };
145 
146 
147 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
148 
149 } // End namespace vtk
150 } // End namespace Foam
151 
152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 
154 #include "foamVtkVtuAdaptorI.H"
155 
156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157 
158 #ifdef NoRepository
160 #endif
161 
162 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
163 
164 #endif
165 
166 // ************************************************************************* //
volFieldsFwd.H
foamVtkTools.H
Foam::vtk::vtuAdaptor::points
vtkSmartPointer< vtkPoints > points(const fvMesh &mesh) const
The vtk points for the mesh (and decomposition)
Definition: foamVtkVtuAdaptorI.H:32
foamVtuSizing.H
foamVtkVtuAdaptorI.H
fld
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Definition: gmvOutputLagrangian.H:23
Foam::vtk::vtuAdaptor::convertField
static vtkSmartPointer< vtkFloatArray > convertField(const DimensionedField< Type, volMesh > &fld, const vtuAdaptor &vtuData)
Convert internal volume field (CellData)
Definition: foamVtkVtuAdaptorTemplates.C:39
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::UList< label >
Foam::vtk::vtuAdaptor
Bookkeeping for vtkUnstructuredGrid.
Definition: foamVtkVtuAdaptor.H:73
Foam::GeometricField< Type, fvPatchField, volMesh >
Foam::foamVtkMeshMaps::pointMap
const labelList & pointMap() const noexcept
Point labels for subsetted meshes.
Definition: foamVtkMeshMapsI.H:55
foamVtkVtuAdaptorTemplates.C
foamVtkMeshMaps.H
Foam::foamVtkMeshMaps
Bookkeeping for mesh subsetting and/or polyhedral cell decomposition. Although the main use case is f...
Definition: foamVtkMeshMaps.H:58
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54
Foam::vtk::Caching
Bookkeeping for internal caching.
Definition: foamVtkTools.H:87