OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

vtkPV3FoamLagrangianFields.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 InClass
00026     vtkPV3Foam
00027 
00028 \*---------------------------------------------------------------------------*/
00029 
00030 #ifndef vtkPV3FoamLagrangianFields_H
00031 #define vtkPV3FoamLagrangianFields_H
00032 
00033 #include "Cloud.H"
00034 
00035 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00036 
00037 template<class Type>
00038 void Foam::vtkPV3Foam::convertLagrangianFields
00039 (
00040     const IOobjectList& objects,
00041     vtkMultiBlockDataSet* output,
00042     const label datasetNo
00043 )
00044 {
00045     const partInfo& selector = partInfoLagrangian_;
00046 
00047     forAllConstIter(IOobjectList, objects, iter)
00048     {
00049         // restrict to this IOField<Type>
00050         if (iter()->headerClassName() == IOField<Type>::typeName)
00051         {
00052             IOField<Type> tf(*iter());
00053             convertLagrangianField(tf, output, selector, datasetNo);
00054         }
00055     }
00056 }
00057 
00058 
00059 template<class Type>
00060 void Foam::vtkPV3Foam::convertLagrangianField
00061 (
00062     const IOField<Type>& tf,
00063     vtkMultiBlockDataSet* output,
00064     const partInfo& selector,
00065     const label datasetNo
00066 )
00067 {
00068     const label nComp = pTraits<Type>::nComponents;
00069 
00070     vtkFloatArray *pointData = vtkFloatArray::New();
00071     pointData->SetNumberOfTuples( tf.size() );
00072     pointData->SetNumberOfComponents( nComp );
00073     pointData->Allocate( nComp*tf.size() );
00074     pointData->SetName( tf.name().c_str() );
00075 
00076     if (debug)
00077     {
00078         Info<< "convert LagrangianField: "
00079             << tf.name()
00080             << " size = " << tf.size()
00081             << " nComp=" << nComp
00082             << " nTuples = " << tf.size() <<  endl;
00083     }
00084 
00085     float vec[nComp];
00086     forAll(tf, i)
00087     {
00088         const Type& t = tf[i];
00089         for (direction d=0; d<nComp; d++)
00090         {
00091             vec[d] = component(t, d);
00092         }
00093 
00094         pointData->InsertTuple(i, vec);
00095     }
00096 
00097 
00098     vtkPolyData::SafeDownCast
00099     (
00100         GetDataSetFromBlock(output, selector, datasetNo)
00101     )   ->GetPointData()
00102         ->AddArray(pointData);
00103 
00104     pointData->Delete();
00105 }
00106 
00107 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00108 
00109 #endif
00110 
00111 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd