1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
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
28 \*---------------------------------------------------------------------------*/
30 #ifndef vtkFoamConvertPatchPointField_H
31 #define vtkFoamConvertPatchPointField_H
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 void Foam::vtkFoam::convertPatchPointField
39 const Field<Type>& pptf,
43 vtkUnstructuredGrid *vtkMesh =
44 vtkUnstructuredGrid::SafeDownCast(reader_->GetOutput(regioni));
46 vtkFloatArray *pointTypes = vtkFloatArray::New();
47 pointTypes->SetNumberOfTuples(pptf.size());
48 pointTypes->SetNumberOfComponents(Type::nComponents);
49 pointTypes->Allocate(Type::nComponents*pptf.size());
50 pointTypes->SetName(name.c_str());
52 float vec[Type::nComponents];
56 for (direction d=0; d<Type::nComponents; d++)
61 pointTypes->InsertTuple(i, vec);
64 vtkMesh->GetPointData()->AddArray(pointTypes);
70 void Foam::vtkFoam::convertPatchPointField
73 const Field<scalar>& ppsf,
77 vtkUnstructuredGrid *vtkMesh =
78 vtkUnstructuredGrid::SafeDownCast(reader_->GetOutput(regioni));
80 vtkFloatArray *pointScalars = vtkFloatArray::New();
81 pointScalars->SetNumberOfTuples(ppsf.size());
82 pointScalars->SetNumberOfComponents(1);
83 pointScalars->Allocate(ppsf.size());
84 pointScalars->SetName(name.c_str());
86 for (int i=0; i<ppsf.size(); i++)
88 pointScalars->InsertComponent(i, 0, ppsf[i]);
91 vtkMesh->GetPointData()->AddArray(pointScalars);
92 if (!vtkMesh->GetPointData()->GetScalars())
94 vtkMesh->GetPointData()->SetScalars(pointScalars);
97 pointScalars->Delete();
101 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
105 // ************************************************************************* //