vtkPVFoamMeshLagrangian.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "vtkPVFoam.H"
27 
28 // OpenFOAM includes
29 #include "Cloud.H"
30 #include "fvMesh.H"
31 #include "IOobjectList.H"
32 #include "passiveParticle.H"
33 #include "vtkOpenFOAMPoints.H"
34 
35 // VTK includes
36 #include "vtkCellArray.h"
37 #include "vtkPoints.h"
38 #include "vtkPolyData.h"
39 
40 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
41 
42 vtkPolyData* Foam::vtkPVFoam::lagrangianVTKMesh
43 (
44  const fvMesh& mesh,
45  const word& cloudName
46 )
47 {
48  vtkPolyData* vtkmesh = NULL;
49 
50  if (debug)
51  {
52  Info<< "<beg> Foam::vtkPVFoam::lagrangianVTKMesh - timePath "
53  << mesh.time().timePath()/cloud::prefix/cloudName << endl;
54  printMemory();
55  }
56 
57 
58  // the region name is already in the mesh db
59  IOobjectList sprayObjs
60  (
61  mesh,
62  mesh.time().timeName(),
64  );
65 
66  IOobject* positionsPtr = sprayObjs.lookup(word("positions"));
67  if (positionsPtr)
68  {
69  Cloud<passiveParticle> parcels(mesh, cloudName, false);
70 
71  if (debug)
72  {
73  Info<< "cloud with " << parcels.size() << " parcels" << endl;
74  }
75 
76  vtkmesh = vtkPolyData::New();
77  vtkPoints* vtkpoints = vtkPoints::New();
78  vtkCellArray* vtkcells = vtkCellArray::New();
79 
80  vtkpoints->Allocate(parcels.size());
81  vtkcells->Allocate(parcels.size());
82 
83  vtkIdType particleId = 0;
84  forAllConstIter(Cloud<passiveParticle>, parcels, iter)
85  {
86  vtkInsertNextOpenFOAMPoint(vtkpoints, iter().position());
87 
88  vtkcells->InsertNextCell(1, &particleId);
89  particleId++;
90  }
91 
92  vtkmesh->SetPoints(vtkpoints);
93  vtkpoints->Delete();
94 
95  vtkmesh->SetVerts(vtkcells);
96  vtkcells->Delete();
97  }
98 
99  if (debug)
100  {
101  Info<< "<end> Foam::vtkPVFoam::lagrangianVTKMesh" << endl;
102  printMemory();
103  }
104 
105  return vtkmesh;
106 }
107 
108 
109 // ************************************************************************* //
static void printMemory()
Simple memory used debugging information.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
void vtkInsertNextOpenFOAMPoint(vtkPoints *points, const Foam::point &p)
const word cloudName(propsDict.lookup("cloudName"))
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:29
static const word prefix
The prefix to local: lagrangian.
Definition: cloud.H:71
messageStream Info