vtkFoamConvertPatchFaceField.H
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
00030 #ifndef vtkFoamConvertPatchFaceField_H
00031 #define vtkFoamConvertPatchFaceField_H
00032
00033
00034
00035 template<class Type>
00036 void Foam::vtkFoam::convertPatchFaceField
00037 (
00038 const word& name,
00039 const Field<Type>& ptf,
00040 const label regioni
00041 )
00042 {
00043 vtkUnstructuredGrid *vtkMesh =
00044 vtkUnstructuredGrid::SafeDownCast(reader_->GetOutput(regioni));
00045
00046 vtkFloatArray *cellTypes = vtkFloatArray::New();
00047 cellTypes->SetNumberOfTuples(ptf.size());
00048 cellTypes->SetNumberOfComponents(Type::nComponents);
00049 cellTypes->Allocate(Type::nComponents*ptf.size());
00050 cellTypes->SetName(name.c_str());
00051
00052 float vec[Type::nComponents];
00053
00054 forAll(ptf, i)
00055 {
00056 const Type& t = ptf[i];
00057 for (direction d=0; d<Type::nComponents; d++)
00058 {
00059 vec[d] = t[d];
00060 }
00061
00062 cellTypes->InsertTuple(i, vec);
00063 }
00064
00065 vtkMesh->GetCellData()->AddArray(cellTypes);
00066 cellTypes->Delete();
00067 }
00068
00069
00070 template<>
00071 void Foam::vtkFoam::convertPatchFaceField
00072 (
00073 const word& name,
00074 const Field<scalar>& psf,
00075 const label regioni
00076 )
00077 {
00078 vtkUnstructuredGrid *vtkMesh =
00079 vtkUnstructuredGrid::SafeDownCast(reader_->GetOutput(regioni));
00080
00081 vtkFloatArray *cellScalars = vtkFloatArray::New();
00082 cellScalars->SetNumberOfTuples(psf.size());
00083 cellScalars->SetNumberOfComponents(1);
00084 cellScalars->Allocate(psf.size());
00085 cellScalars->SetName(name.c_str());
00086
00087 forAll(psf, i)
00088 {
00089 cellScalars->InsertComponent(i, 0, psf[i]);
00090 }
00091
00092 vtkMesh->GetCellData()->AddArray(cellScalars);
00093 if (!vtkMesh->GetCellData()->GetScalars())
00094 {
00095 vtkMesh->GetCellData()->SetScalars(cellScalars);
00096 }
00097
00098 cellScalars->Delete();
00099 }
00100
00101
00102
00103
00104 #endif
00105
00106
Copyright © 2000-2009 OpenCFD Ltd