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 vtkPV3FoamLagrangianFields_H
31 #define vtkPV3FoamLagrangianFields_H
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 void Foam::vtkPV3Foam::convertLagrangianFields
40 const IOobjectList& objects,
41 vtkMultiBlockDataSet* output,
45 const partInfo& selector = partInfoLagrangian_;
47 forAllConstIter(IOobjectList, objects, iter)
49 // restrict to this IOField<Type>
50 if (iter()->headerClassName() == IOField<Type>::typeName)
52 IOField<Type> tf(*iter());
53 convertLagrangianField(tf, output, selector, datasetNo);
60 void Foam::vtkPV3Foam::convertLagrangianField
62 const IOField<Type>& tf,
63 vtkMultiBlockDataSet* output,
64 const partInfo& selector,
68 const label nComp = pTraits<Type>::nComponents;
70 vtkFloatArray *pointData = vtkFloatArray::New();
71 pointData->SetNumberOfTuples( tf.size() );
72 pointData->SetNumberOfComponents( nComp );
73 pointData->Allocate( nComp*tf.size() );
74 pointData->SetName( tf.name().c_str() );
78 Info<< "convert LagrangianField: "
80 << " size = " << tf.size()
82 << " nTuples = " << tf.size() << endl;
88 const Type& t = tf[i];
89 for (direction d=0; d<nComp; d++)
91 vec[d] = component(t, d);
94 pointData->InsertTuple(i, vec);
98 vtkPolyData::SafeDownCast
100 GetDataSetFromBlock(output, selector, datasetNo)
102 ->AddArray(pointData);
107 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
111 // ************************************************************************* //