Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / applications / utilities / postProcessing / graphics / PV3Readers / PV3FoamReader / vtkPV3Foam / vtkPV3FoamLagrangianFields.H
blobb763eef6fb84213813f019514dc760e280e3fc9a
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2004-2010 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
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
19     for more details.
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/>.
24 InClass
25     vtkPV3Foam
27 \*---------------------------------------------------------------------------*/
29 #ifndef vtkPV3FoamLagrangianFields_H
30 #define vtkPV3FoamLagrangianFields_H
32 #include "Cloud.H"
34 #include "vtkOpenFOAMTupleRemap.H"
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 template<class Type>
39 void Foam::vtkPV3Foam::convertLagrangianFields
41     const IOobjectList& objects,
42     vtkMultiBlockDataSet* output,
43     const label datasetNo
46     const arrayRange& range = arrayRangeLagrangian_;
48     forAllConstIter(IOobjectList, objects, iter)
49     {
50         // restrict to this IOField<Type>
51         if (iter()->headerClassName() == IOField<Type>::typeName)
52         {
53             IOField<Type> tf(*iter());
54             convertLagrangianField(tf, output, range, datasetNo);
55         }
56     }
60 template<class Type>
61 void Foam::vtkPV3Foam::convertLagrangianField
63     const IOField<Type>& tf,
64     vtkMultiBlockDataSet* output,
65     const arrayRange& range,
66     const label datasetNo
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());
77     if (debug)
78     {
79         Info<< "convert LagrangianField: "
80             << tf.name()
81             << " size = " << tf.size()
82             << " nComp=" << nComp
83             << " nTuples = " << tf.size() <<  endl;
84     }
86     float vec[nComp];
87     forAll(tf, i)
88     {
89         const Type& t = tf[i];
90         for (direction d=0; d<nComp; ++d)
91         {
92             vec[d] = component(t, d);
93         }
94         vtkOpenFOAMTupleRemap<Type>(vec);
96         pointData->InsertTuple(i, vec);
97     }
100     vtkPolyData::SafeDownCast
101     (
102         GetDataSetFromBlock(output, range, datasetNo)
103     )   ->GetPointData()
104         ->AddArray(pointData);
106     pointData->Delete();
109 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
111 #endif
113 // ************************************************************************* //