vtkPV3FoamFaceField.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 vtkPV3FoamFaceField_H
00031 #define vtkPV3FoamFaceField_H
00032
00033
00034 #include "vtkCellData.h"
00035 #include "vtkFloatArray.h"
00036 #include "vtkMultiBlockDataSet.h"
00037 #include "vtkPolyData.h"
00038
00039
00040 template<class Type>
00041 void Foam::vtkPV3Foam::convertFaceField
00042 (
00043 const GeometricField<Type, fvPatchField, volMesh>& tf,
00044 vtkMultiBlockDataSet* output,
00045 const partInfo& selector,
00046 const label datasetNo,
00047 const fvMesh& mesh,
00048 const labelList& faceLabels
00049 )
00050 {
00051 const label nComp = pTraits<Type>::nComponents;
00052 const label nInternalFaces = mesh.nInternalFaces();
00053 const labelList& faceOwner = mesh.faceOwner();
00054 const labelList& faceNeigh = mesh.faceNeighbour();
00055
00056 vtkFloatArray *cellData = vtkFloatArray::New();
00057 cellData->SetNumberOfTuples( faceLabels.size() );
00058 cellData->SetNumberOfComponents( nComp );
00059 cellData->Allocate( nComp*faceLabels.size() );
00060 cellData->SetName( tf.name().c_str() );
00061
00062 if (debug)
00063 {
00064 Info<< "convert convertFaceField: "
00065 << tf.name()
00066 << " size = " << tf.size()
00067 << " nComp=" << nComp
00068 << " nTuples = " << faceLabels.size() << endl;
00069 }
00070
00071 float vec[nComp];
00072
00073
00074
00075 forAll(faceLabels, faceI)
00076 {
00077 const label faceNo = faceLabels[faceI];
00078 if (faceNo < nInternalFaces)
00079 {
00080 Type t = 0.5*(tf[faceOwner[faceNo]] + tf[faceNeigh[faceNo]]);
00081
00082 for (direction d=0; d<nComp; d++)
00083 {
00084 vec[d] = component(t, d);
00085 }
00086 }
00087 else
00088 {
00089 const Type& t = tf[faceOwner[faceNo]];
00090 for (direction d=0; d<nComp; d++)
00091 {
00092 vec[d] = component(t, d);
00093 }
00094 }
00095
00096 cellData->InsertTuple(faceI, vec);
00097 }
00098
00099
00100 vtkPolyData::SafeDownCast
00101 (
00102 GetDataSetFromBlock(output, selector, datasetNo)
00103 ) ->GetCellData()
00104 ->AddArray(cellData);
00105
00106 cellData->Delete();
00107 }
00108
00109
00110 template<class Type>
00111 void Foam::vtkPV3Foam::convertFaceField
00112 (
00113 const GeometricField<Type, fvPatchField, volMesh>& tf,
00114 vtkMultiBlockDataSet* output,
00115 const partInfo& selector,
00116 const label datasetNo,
00117 const fvMesh& mesh,
00118 const faceSet& fSet
00119 )
00120 {
00121 const label nComp = pTraits<Type>::nComponents;
00122 const label nInternalFaces = mesh.nInternalFaces();
00123 const labelList& faceOwner = mesh.faceOwner();
00124 const labelList& faceNeigh = mesh.faceNeighbour();
00125
00126 vtkFloatArray *cellData = vtkFloatArray::New();
00127 cellData->SetNumberOfTuples( fSet.size() );
00128 cellData->SetNumberOfComponents( nComp );
00129 cellData->Allocate( nComp*fSet.size() );
00130 cellData->SetName( tf.name().c_str() );
00131
00132 if (debug)
00133 {
00134 Info<< "convert convertFaceField: "
00135 << tf.name()
00136 << " size = " << tf.size()
00137 << " nComp=" << nComp
00138 << " nTuples = " << fSet.size() << endl;
00139 }
00140
00141 float vec[nComp];
00142
00143
00144
00145 label faceI = 0;
00146 forAllConstIter(faceSet, fSet, iter)
00147 {
00148 const label faceNo = iter.key();
00149
00150 if (faceNo < nInternalFaces)
00151 {
00152 Type t = 0.5*(tf[faceOwner[faceNo]] + tf[faceNeigh[faceNo]]);
00153
00154 for (direction d=0; d<nComp; d++)
00155 {
00156 vec[d] = component(t, d);
00157 }
00158 }
00159 else
00160 {
00161 const Type& t = tf[faceOwner[faceNo]];
00162 for (direction d=0; d<nComp; d++)
00163 {
00164 vec[d] = component(t, d);
00165 }
00166 }
00167
00168 cellData->InsertTuple(faceI, vec);
00169 ++faceI;
00170 }
00171
00172
00173 vtkPolyData::SafeDownCast
00174 (
00175 GetDataSetFromBlock(output, selector, datasetNo)
00176 ) ->GetCellData()
00177 ->AddArray(cellData);
00178
00179 cellData->Delete();
00180 }
00181
00182
00183
00184 #endif
00185
00186
Copyright © 2000-2009 OpenCFD Ltd