1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 void Foam::vtkPV3Foam::convertPatchField
46 const Field<Type>& ptf,
47 vtkMultiBlockDataSet* output,
48 const partInfo& selector,
52 const label nComp = pTraits<Type>::nComponents;
54 vtkFloatArray* cellData = vtkFloatArray::New();
55 cellData->SetNumberOfTuples( ptf.size() );
56 cellData->SetNumberOfComponents( nComp );
57 cellData->Allocate( nComp*ptf.size() );
58 cellData->SetName( name.c_str() );
63 const Type& t = ptf[i];
64 for (direction d=0; d<nComp; d++)
66 vec[d] = component(t, d);
68 cellData->InsertTuple(i, vec);
71 vtkPolyData::SafeDownCast
73 GetDataSetFromBlock(output, selector, datasetNo)
81 // as above, but with PointData()
83 void Foam::vtkPV3Foam::convertPatchPointField
86 const Field<Type>& pptf,
87 vtkMultiBlockDataSet* output,
88 const partInfo& selector,
92 const label nComp = pTraits<Type>::nComponents;
94 vtkFloatArray *pointData = vtkFloatArray::New();
95 pointData->SetNumberOfTuples( pptf.size() );
96 pointData->SetNumberOfComponents( nComp );
97 pointData->Allocate( nComp*pptf.size() );
98 pointData->SetName( name.c_str() );
103 const Type& t = pptf[i];
104 for (direction d=0; d<nComp; d++)
106 vec[d] = component(t, d);
109 pointData->InsertTuple(i, vec);
112 vtkPolyData::SafeDownCast
114 GetDataSetFromBlock(output, selector, datasetNo)
116 ->AddArray(pointData);
121 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
125 // ************************ vim: set sw=4 sts=4 et: ************************ //