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 vtkPV3FoamLagrangianFields_H
31 #define vtkPV3FoamLagrangianFields_H
35 #include "vtkOpenFOAMTupleRemap.H"
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 void Foam::vtkPV3Foam::convertLagrangianFields
42 const IOobjectList& objects,
43 vtkMultiBlockDataSet* output,
47 const partInfo& selector = partInfoLagrangian_;
49 forAllConstIter(IOobjectList, objects, iter)
51 // restrict to this IOField<Type>
52 if (iter()->headerClassName() == IOField<Type>::typeName)
54 IOField<Type> tf(*iter());
55 convertLagrangianField(tf, output, selector, datasetNo);
62 void Foam::vtkPV3Foam::convertLagrangianField
64 const IOField<Type>& tf,
65 vtkMultiBlockDataSet* output,
66 const partInfo& selector,
70 const label nComp = pTraits<Type>::nComponents;
72 vtkFloatArray *pointData = vtkFloatArray::New();
73 pointData->SetNumberOfTuples( tf.size() );
74 pointData->SetNumberOfComponents( nComp );
75 pointData->Allocate( nComp*tf.size() );
76 pointData->SetName( tf.name().c_str() );
80 Info<< "convert LagrangianField: "
82 << " size = " << tf.size()
84 << " nTuples = " << tf.size() << endl;
90 const Type& t = tf[i];
91 for (direction d=0; d<nComp; d++)
93 vec[d] = component(t, d);
95 vtkOpenFOAMTupleRemap<Type>(vec);
97 pointData->InsertTuple(i, vec);
101 vtkPolyData::SafeDownCast
103 GetDataSetFromBlock(output, selector, datasetNo)
105 ->AddArray(pointData);
110 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
114 // ************************************************************************* //