vtkPV3FoamMeshLagrangian.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "vtkPV3Foam.H"
00030
00031
00032 #include "Cloud.H"
00033 #include "fvMesh.H"
00034 #include "IOobjectList.H"
00035 #include "passiveParticle.H"
00036 #include "vtkPV3FoamPoints.H"
00037
00038
00039 #include "vtkCellArray.h"
00040 #include "vtkPoints.h"
00041 #include "vtkPolyData.h"
00042
00043
00044
00045 vtkPolyData* Foam::vtkPV3Foam::lagrangianVTKMesh
00046 (
00047 const fvMesh& mesh,
00048 const word& cloudName
00049 )
00050 {
00051 vtkPolyData* vtkmesh = NULL;
00052
00053 if (debug)
00054 {
00055 Info<< "<beg> Foam::vtkPV3Foam::lagrangianVTKMesh - timePath "
00056 << mesh.time().timePath()/cloud::prefix/cloudName << endl;
00057 printMemory();
00058 }
00059
00060
00061
00062 IOobjectList sprayObjs
00063 (
00064 mesh,
00065 mesh.time().timeName(),
00066 cloud::prefix/cloudName
00067 );
00068
00069 IOobject* positionsPtr = sprayObjs.lookup("positions");
00070 if (positionsPtr)
00071 {
00072 Cloud<passiveParticle> parcels(mesh, cloudName, false);
00073
00074 if (debug)
00075 {
00076 Info<< "cloud with " << parcels.size() << " parcels" << endl;
00077 }
00078
00079 vtkmesh = vtkPolyData::New();
00080 vtkPoints* vtkpoints = vtkPoints::New();
00081 vtkCellArray* vtkcells = vtkCellArray::New();
00082
00083 vtkpoints->Allocate( parcels.size() );
00084 vtkcells->Allocate( parcels.size() );
00085
00086 vtkIdType particleId = 0;
00087 forAllConstIter(Cloud<passiveParticle>, parcels, iter)
00088 {
00089 vtkPV3FoamInsertNextPoint(vtkpoints, iter().position());
00090
00091 vtkcells->InsertNextCell(1, &particleId);
00092 particleId++;
00093 }
00094
00095 vtkmesh->SetPoints(vtkpoints);
00096 vtkpoints->Delete();
00097
00098 vtkmesh->SetVerts(vtkcells);
00099 vtkcells->Delete();
00100 }
00101
00102 if (debug)
00103 {
00104 Info<< "<end> Foam::vtkPV3Foam::lagrangianVTKMesh" << endl;
00105 printMemory();
00106 }
00107
00108 return vtkmesh;
00109 }
00110
00111
00112
Copyright © 2000-2009 OpenCFD Ltd