foamVtkVtuAdaptorTemplates.C
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-2019 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 \*---------------------------------------------------------------------------*/
27 
28 // VTK includes
29 #include "vtkFloatArray.h"
30 #include "vtkCellData.h"
31 #include "vtkPointData.h"
32 #include "vtkSmartPointer.h"
33 
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 
36 template<class Type>
37 vtkSmartPointer<vtkFloatArray>
39 (
41  const vtuAdaptor& vtuData
42 )
43 {
44  const int nComp(pTraits<Type>::nComponents);
45  const labelUList& cellMap = vtuData.cellMap();
46 
48  data->SetName(fld.name().c_str());
49  data->SetNumberOfComponents(nComp);
50  data->SetNumberOfTuples(cellMap.size());
51 
52  // DebugInfo
53  // << "Convert field: " << fld.name()
54  // << " size=" << cellMap.size()
55  // << " (" << fld.size() << " + "
56  // << (cellMap.size() - fld.size())
57  // << ") nComp=" << nComp << endl;
58 
59 
60  float scratch[pTraits<Type>::nComponents];
61 
62  vtkIdType celli = 0;
63  for (const label meshCelli : cellMap)
64  {
65  vtk::Tools::foamToVtkTuple(scratch, fld[meshCelli]);
66  data->SetTuple(celli++, scratch);
67  }
68 
69  return data;
70 }
71 
72 
73 template<class Type>
74 vtkSmartPointer<vtkFloatArray>
76 (
78  const vtuAdaptor& vtuData
79 )
80 {
81  return convertField<Type>(fld.internalField(), vtuData);
82 }
83 
84 
85 template<class Type>
86 vtkSmartPointer<vtkFloatArray>
88 (
90 ) const
91 {
92  return convertField<Type>(fld, *this);
93 }
94 
95 
96 template<class Type>
97 vtkSmartPointer<vtkFloatArray>
99 (
101 ) const
102 {
103  return convertField<Type>(fld, *this);
104 }
105 
106 
107 // ************************************************************************* //
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
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
Foam::pTraits
A traits class, which is primarily used for primitives.
Definition: pTraits.H:56
Foam::UList< label >
Foam::vtk::vtuAdaptor
Bookkeeping for vtkUnstructuredGrid.
Definition: foamVtkVtuAdaptor.H:73
Foam::UList::size
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
Foam::vtk::Tools::foamToVtkTuple
void foamToVtkTuple(float output[], const Type &val)
Copy/transcribe OpenFOAM data types to VTK format.
Definition: foamVtkToolsI.H:214
Foam::GeometricField< Type, fvPatchField, volMesh >
Foam::data
Database for solution data, solver performance and other reduced data.
Definition: data.H:55
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::foamVtkMeshMaps::cellMap
const labelList & cellMap() const noexcept
Original cell ids for all cells (regular and decomposed).
Definition: foamVtkMeshMapsI.H:41