1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
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
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
28 \*---------------------------------------------------------------------------*/
30 #ifndef vtkPV3FoamPatchField_H
31 #define vtkPV3FoamPatchField_H
34 #include "vtkCellData.h"
35 #include "vtkFloatArray.h"
36 #include "vtkMultiBlockDataSet.h"
37 #include "vtkPointData.h"
38 #include "vtkPolyData.h"
40 #include "vtkOpenFOAMTupleRemap.H"
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 void Foam::vtkPV3Foam::convertPatchField
48 const Field<Type>& ptf,
49 vtkMultiBlockDataSet* output,
50 const partInfo& selector,
54 const label nComp = pTraits<Type>::nComponents;
56 vtkFloatArray* cellData = vtkFloatArray::New();
57 cellData->SetNumberOfTuples( ptf.size() );
58 cellData->SetNumberOfComponents( nComp );
59 cellData->Allocate( nComp*ptf.size() );
60 cellData->SetName( name.c_str() );
65 const Type& t = ptf[i];
66 for (direction d=0; d<nComp; d++)
68 vec[d] = component(t, d);
70 vtkOpenFOAMTupleRemap<Type>(vec);
72 cellData->InsertTuple(i, vec);
75 vtkPolyData::SafeDownCast
77 GetDataSetFromBlock(output, selector, datasetNo)
85 // as above, but with PointData()
87 void Foam::vtkPV3Foam::convertPatchPointField
90 const Field<Type>& pptf,
91 vtkMultiBlockDataSet* output,
92 const partInfo& selector,
96 const label nComp = pTraits<Type>::nComponents;
98 vtkFloatArray *pointData = vtkFloatArray::New();
99 pointData->SetNumberOfTuples( pptf.size() );
100 pointData->SetNumberOfComponents( nComp );
101 pointData->Allocate( nComp*pptf.size() );
102 pointData->SetName( name.c_str() );
107 const Type& t = pptf[i];
108 for (direction d=0; d<nComp; d++)
110 vec[d] = component(t, d);
112 vtkOpenFOAMTupleRemap<Type>(vec);
114 pointData->InsertTuple(i, vec);
117 vtkPolyData::SafeDownCast
119 GetDataSetFromBlock(output, selector, datasetNo)
121 ->AddArray(pointData);
126 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
130 // ************************************************************************* //