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-------------------------------------------------------------------------------
10License
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
26Class
27 Foam::vtk::vtuAdaptor
28
29Description
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
35Note
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
40SourceFiles
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
61class vtkDataSet;
62class vtkFloatArray;
63
64namespace Foam
65{
66namespace vtk
67{
68
69/*---------------------------------------------------------------------------*\
70 Class vtk::vtuAdaptor Declaration
71\*---------------------------------------------------------------------------*/
72
73//- Bookkeeping for vtkUnstructuredGrid
74class vtuAdaptor
75:
76 public vtk::Caching<vtkUnstructuredGrid>,
77 public foamVtkMeshMaps
78{
79public:
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// ************************************************************************* //
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.mesh().time().globalPath()/"finiteArea-edges"));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Generic GeometricField class.
Bookkeeping for mesh subsetting and/or polyhedral cell decomposition. Although the main use case is f...
const labelList & pointMap() const noexcept
Point labels for subsetted meshes.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
Bookkeeping for vtkUnstructuredGrid.
static vtkSmartPointer< vtkFloatArray > convertField(const DimensionedField< Type, volMesh > &fld, const vtuAdaptor &vtuData)
Convert internal volume field (CellData)
vtkSmartPointer< vtkUnstructuredGrid > internal(const fvMesh &mesh, const bool decompPoly=false)
Internal mesh as vtkUnstructuredGrid.
dynamicFvMesh & mesh
const pointField & points
Namespace for OpenFOAM.
Bookkeeping for internal caching.
Definition: foamVtkTools.H:88