vtkFoamConvertPointField.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 vtkFoamConvertPointField_H
00031 #define vtkFoamConvertPointField_H
00032
00033
00034
00035 #include "interpolatePointToCell.H"
00036
00037 template<class Type>
00038 void Foam::vtkFoam::convertPointField
00039 (
00040 const GeometricField<Type, pointPatchField, pointMesh>& ptf,
00041 const GeometricField<Type, fvPatchField, volMesh>& tf
00042 )
00043 {
00044 vtkUnstructuredGrid *vtkMesh =
00045 vtkUnstructuredGrid::SafeDownCast(reader_->GetOutput(0));
00046
00047 vtkFloatArray *pointTypes = vtkFloatArray::New();
00048 pointTypes->SetNumberOfTuples(ptf.size() + addPointCellLabels_.size());
00049 pointTypes->SetNumberOfComponents(Type::nComponents);
00050 pointTypes->Allocate(Type::nComponents*ptf.size());
00051 pointTypes->SetName(ptf.name().c_str());
00052
00053 float vec[Type::nComponents];
00054
00055 forAll(ptf, i)
00056 {
00057 for (direction d=0; d<Type::nComponents; d++)
00058 {
00059 vec[d] = ptf[i][d];
00060 }
00061
00062 pointTypes->InsertTuple(i, vec);
00063 }
00064
00065 label i = ptf.size();
00066
00067 if (&tf != &GeometricField<Type, fvPatchField, volMesh>::null())
00068 {
00069 forAll(addPointCellLabels_, api)
00070 {
00071 Type t = tf[addPointCellLabels_[api]];
00072
00073 for (direction d=0; d<Type::nComponents; d++)
00074 {
00075 vec[d] = t[d];
00076 }
00077
00078 pointTypes->InsertTuple(i++, vec);
00079 }
00080 }
00081 else
00082 {
00083 forAll(addPointCellLabels_, api)
00084 {
00085 Type t = interpolatePointToCell(ptf, addPointCellLabels_[api]);
00086
00087 for (direction d=0; d<Type::nComponents; d++)
00088 {
00089 vec[d] = t[d];
00090 }
00091
00092 pointTypes->InsertTuple(i++, vec);
00093 }
00094 }
00095
00096 vtkMesh->GetPointData()->AddArray(pointTypes);
00097 pointTypes->Delete();
00098 }
00099
00100
00101 template<>
00102 void Foam::vtkFoam::convertPointField
00103 (
00104 const GeometricField<scalar, pointPatchField, pointMesh>& psf,
00105 const GeometricField<scalar, fvPatchField, volMesh>& sf
00106 )
00107 {
00108 vtkUnstructuredGrid *vtkMesh =
00109 vtkUnstructuredGrid::SafeDownCast(reader_->GetOutput(0));
00110
00111 vtkFloatArray *pointScalars = vtkFloatArray::New();
00112 pointScalars->SetNumberOfTuples(psf.size() + addPointCellLabels_.size());
00113 pointScalars->SetNumberOfComponents(1);
00114 pointScalars->Allocate(psf.size());
00115 pointScalars->SetName(psf.name().c_str());
00116
00117 for (int i=0; i<psf.size(); i++)
00118 {
00119 pointScalars->InsertComponent(i, 0, psf[i]);
00120 }
00121
00122 label i = psf.size();
00123
00124 if (&sf != &GeometricField<scalar, fvPatchField, volMesh>::null())
00125 {
00126 forAll(addPointCellLabels_, api)
00127 {
00128 pointScalars->InsertComponent
00129 (
00130 i++,
00131 0,
00132 sf[addPointCellLabels_[api]]
00133 );
00134 }
00135 }
00136 else
00137 {
00138 forAll(addPointCellLabels_, api)
00139 {
00140 pointScalars->InsertComponent
00141 (
00142 i++,
00143 0,
00144 interpolatePointToCell(psf, addPointCellLabels_[api])
00145 );
00146 }
00147 }
00148
00149 vtkMesh->GetPointData()->AddArray(pointScalars);
00150 if (!vtkMesh->GetPointData()->GetScalars())
00151 {
00152 vtkMesh->GetPointData()->SetScalars(pointScalars);
00153 }
00154
00155 pointScalars->Delete();
00156 }
00157
00158
00159
00160
00161 #endif
00162
00163
Copyright © 2000-2009 OpenCFD Ltd