vtkPolyData* Foam::vtkPV4Foam::lagrangianVTKMesh ( const fvMesh& mesh, const word& cloudName ) { vtkPolyData* vtkmesh = NULL; if (debug) { Info<< "<beg> Foam::vtkPV4Foam::lagrangianVTKMesh - timePath " << mesh.time().timePath()/cloud::prefix/cloudName << endl; printMemory(); } // the region name is already in the mesh db IOobjectList sprayObjs ( mesh, mesh.time().timeName(), cloud::prefix/cloudName ); IOobject* positionsPtr = sprayObjs.lookup(word("positions")); if (positionsPtr) { Cloud<passiveParticle> parcels(mesh, cloudName, false); if (debug) { Info<< "cloud with " << parcels.size() << " parcels" << endl; } vtkmesh = vtkPolyData::New(); vtkPoints* vtkpoints = vtkPoints::New(); vtkCellArray* vtkcells = vtkCellArray::New(); vtkpoints->Allocate(parcels.size()); vtkcells->Allocate(parcels.size()); vtkIdType particleId = 0; forAllConstIter(Cloud<passiveParticle>, parcels, iter) { vtkInsertNextOpenFOAMPoint(vtkpoints, iter().position()); vtkcells->InsertNextCell(1, &particleId); particleId++; } vtkmesh->SetPoints(vtkpoints); vtkpoints->Delete(); vtkmesh->SetVerts(vtkcells); vtkcells->Delete(); }
// Construct from components Foam::lagrangianWriter::lagrangianWriter ( const vtkMesh& vMesh, const bool binary, const fileName& fName, const word& cloudName, const bool dummyCloud ) : vMesh_(vMesh), binary_(binary), fName_(fName), cloudName_(cloudName), os_(fName.c_str()) { const fvMesh& mesh = vMesh_.mesh(); // Write header writeFuns::writeHeader(os_, binary_, mesh.time().caseName()); os_ << "DATASET POLYDATA" << std::endl; if (dummyCloud) { nParcels_ = 0; os_ << "POINTS " << nParcels_ << " float" << std::endl; } else { Cloud<passiveParticle> parcels(mesh, cloudName_, false); nParcels_ = parcels.size(); os_ << "POINTS " << nParcels_ << " float" << std::endl; DynamicList<floatScalar> partField(3*parcels.size()); forAllConstIter(Cloud<passiveParticle>, parcels, elmnt) { writeFuns::insert(elmnt().position(), partField); } writeFuns::write(os_, binary_, partField); }