1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2010 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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
27 \*---------------------------------------------------------------------------*/
29 #ifndef vtkPV3FoamLagrangianFields_H
30 #define vtkPV3FoamLagrangianFields_H
34 #include "vtkOpenFOAMTupleRemap.H"
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 void Foam::vtkPV3Foam::convertLagrangianFields
41 const IOobjectList& objects,
42 vtkMultiBlockDataSet* output,
46 const arrayRange& range = arrayRangeLagrangian_;
48 forAllConstIter(IOobjectList, objects, iter)
50 // restrict to this IOField<Type>
51 if (iter()->headerClassName() == IOField<Type>::typeName)
53 IOField<Type> tf(*iter());
54 convertLagrangianField(tf, output, range, datasetNo);
61 void Foam::vtkPV3Foam::convertLagrangianField
63 const IOField<Type>& tf,
64 vtkMultiBlockDataSet* output,
65 const arrayRange& range,
69 const label nComp = pTraits<Type>::nComponents;
71 vtkFloatArray* pointData = vtkFloatArray::New();
72 pointData->SetNumberOfTuples(tf.size());
73 pointData->SetNumberOfComponents(nComp);
74 pointData->Allocate(nComp*tf.size());
75 pointData->SetName(tf.name().c_str());
79 Info<< "convert LagrangianField: "
81 << " size = " << tf.size()
83 << " nTuples = " << tf.size() << endl;
89 const Type& t = tf[i];
90 for (direction d=0; d<nComp; ++d)
92 vec[d] = component(t, d);
94 vtkOpenFOAMTupleRemap<Type>(vec);
96 pointData->InsertTuple(i, vec);
100 vtkPolyData::SafeDownCast
102 GetDataSetFromBlock(output, range, datasetNo)
104 ->AddArray(pointData);
109 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
113 // ************************************************************************* //