initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / applications / utilities / postProcessing / graphics / PV3FoamReader / vtkPV3Foam / vtkPV3FoamLagrangianFields.H
blob58422d69f49eb4a78b1db291d32df7a7596f6783
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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
25 InClass
26     vtkPV3Foam
28 \*---------------------------------------------------------------------------*/
30 #ifndef vtkPV3FoamLagrangianFields_H
31 #define vtkPV3FoamLagrangianFields_H
33 #include "Cloud.H"
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 template<class Type>
38 void Foam::vtkPV3Foam::convertLagrangianFields
40     const IOobjectList& objects,
41     vtkMultiBlockDataSet* output,
42     const label datasetNo
45     const partInfo& selector = partInfoLagrangian_;
47     forAllConstIter(IOobjectList, objects, iter)
48     {
49         // restrict to this IOField<Type>
50         if (iter()->headerClassName() == IOField<Type>::typeName)
51         {
52             IOField<Type> tf(*iter());
53             convertLagrangianField(tf, output, selector, datasetNo);
54         }
55     }
59 template<class Type>
60 void Foam::vtkPV3Foam::convertLagrangianField
62     const IOField<Type>& tf,
63     vtkMultiBlockDataSet* output,
64     const partInfo& selector,
65     const label datasetNo
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() );
76     if (debug)
77     {
78         Info<< "convert LagrangianField: "
79             << tf.name()
80             << " size = " << tf.size()
81             << " nComp=" << nComp
82             << " nTuples = " << tf.size() <<  endl;
83     }
85     float vec[nComp];
86     forAll(tf, i)
87     {
88         const Type& t = tf[i];
89         for (direction d=0; d<nComp; d++)
90         {
91             vec[d] = component(t, d);
92         }
94         pointData->InsertTuple(i, vec);
95     }
98     vtkPolyData::SafeDownCast
99     (
100         GetDataSetFromBlock(output, selector, datasetNo)
101     )   ->GetPointData()
102         ->AddArray(pointData);
104     pointData->Delete();
107 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
109 #endif
111 // ************************************************************************* //