vtkPVFoamMeshZone.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2025 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 #include "vtkOpenFOAMPoints.H"
28 
29 // OpenFOAM includes
30 #include "fvMesh.H"
31 
32 // VTK includes
33 #include "vtkPoints.h"
34 #include "vtkPolyData.h"
35 #include "vtkCellArray.h"
36 
37 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
38 
39 vtkPolyData* Foam::vtkPVFoam::pointZoneVTKMesh
40 (
41  const fvMesh& mesh,
42  const labelList& pointLabels
43 )
44 {
45  vtkPolyData* vtkmesh = vtkPolyData::New();
46 
47  const pointField& meshPoints = mesh.points();
48 
49  vtkPoints* vtkpoints = vtkPoints::New();
50  vtkpoints->Allocate(pointLabels.size());
51 
52  forAll(pointLabels, pointi)
53  {
54  vtkInsertNextOpenFOAMPoint(vtkpoints, meshPoints[pointLabels[pointi]]);
55  }
56 
57  vtkmesh->SetPoints(vtkpoints);
58  vtkpoints->Delete();
59 
60  return vtkmesh;
61 }
62 
63 
64 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:433
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:1331
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
autoPtr< CompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const viscosity &viscosity)
List< label > labelList
A List of labels.
Definition: labelList.H:56
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:42
labelList pointLabels(nPoints, -1)
void vtkInsertNextOpenFOAMPoint(vtkPoints *points, const Foam::point &p)