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
27 \*---------------------------------------------------------------------------*/
29 #include "vtkPV3Foam.H"
34 #include "IOobjectList.H"
35 #include "passiveParticle.H"
36 #include "vtkPV3FoamPoints.H"
39 #include "vtkCellArray.h"
40 #include "vtkPoints.h"
41 #include "vtkPolyData.h"
43 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
45 vtkPolyData* Foam::vtkPV3Foam::lagrangianVTKMesh
51 vtkPolyData* vtkmesh = NULL;
55 Info<< "<beg> Foam::vtkPV3Foam::lagrangianVTKMesh - timePath "
56 << mesh.time().timePath()/cloud::prefix/cloudName << endl;
61 // the region name is already in the mesh db
62 IOobjectList sprayObjs
65 mesh.time().timeName(),
66 cloud::prefix/cloudName
69 IOobject* positionsPtr = sprayObjs.lookup("positions");
72 Cloud<passiveParticle> parcels(mesh, cloudName, false);
76 Info<< "cloud with " << parcels.size() << " parcels" << endl;
79 vtkmesh = vtkPolyData::New();
80 vtkPoints* vtkpoints = vtkPoints::New();
81 vtkCellArray* vtkcells = vtkCellArray::New();
83 vtkpoints->Allocate( parcels.size() );
84 vtkcells->Allocate( parcels.size() );
86 vtkIdType particleId = 0;
87 forAllConstIter(Cloud<passiveParticle>, parcels, iter)
89 vtkPV3FoamInsertNextPoint(vtkpoints, iter().position());
91 vtkcells->InsertNextCell(1, &particleId);
95 vtkmesh->SetPoints(vtkpoints);
98 vtkmesh->SetVerts(vtkcells);
104 Info<< "<end> Foam::vtkPV3Foam::lagrangianVTKMesh" << endl;
112 // ************************************************************************* //