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 vtkPV3FoamVolFields_H
00031 #define vtkPV3FoamVolFields_H
00032
00033
00034 #include "emptyFvPatchField.H"
00035 #include "wallPolyPatch.H"
00036 #include "faceSet.H"
00037 #include "volPointInterpolation.H"
00038
00039 #include "vtkPV3FoamFaceField.H"
00040 #include "vtkPV3FoamPatchField.H"
00041
00042
00043
00044 template<class Type>
00045 void Foam::vtkPV3Foam::convertVolFields
00046 (
00047 const fvMesh& mesh,
00048 const PtrList<PrimitivePatchInterpolation<primitivePatch> >& ppInterpList,
00049 const IOobjectList& objects,
00050 vtkMultiBlockDataSet* output
00051 )
00052 {
00053 const polyBoundaryMesh& patches = mesh.boundaryMesh();
00054
00055 forAllConstIter(IOobjectList, objects, iter)
00056 {
00057
00058 if
00059 (
00060 iter()->headerClassName()
00061 != GeometricField<Type, fvPatchField, volMesh>::typeName
00062 )
00063 {
00064 continue;
00065 }
00066
00067
00068 GeometricField<Type, fvPatchField, volMesh> tf
00069 (
00070 *iter(),
00071 mesh
00072 );
00073
00074
00075 autoPtr<GeometricField<Type, pointPatchField, pointMesh> > ptfPtr;
00076
00077
00078
00079 convertVolFieldBlock
00080 (
00081 tf,
00082 ptfPtr,
00083 output,
00084 partInfoVolume_,
00085 regionPolyDecomp_
00086 );
00087
00088
00089 convertVolFieldBlock
00090 (
00091 tf,
00092 ptfPtr,
00093 output,
00094 partInfoCellZones_,
00095 zonePolyDecomp_
00096 );
00097
00098
00099 convertVolFieldBlock
00100 (
00101 tf,
00102 ptfPtr,
00103 output,
00104 partInfoCellSets_,
00105 csetPolyDecomp_
00106 );
00107
00108
00109
00110
00111
00112 for
00113 (
00114 int partId = partInfoPatches_.start();
00115 partId < partInfoPatches_.end();
00116 ++partId
00117 )
00118 {
00119 const word patchName = getPartName(partId);
00120 const label datasetNo = partDataset_[partId];
00121 const label patchId = patches.findPatchID(patchName);
00122
00123 if (!partStatus_[partId] || datasetNo < 0 || patchId < 0)
00124 {
00125 continue;
00126 }
00127
00128 const fvPatchField<Type>& ptf = tf.boundaryField()[patchId];
00129
00130 if
00131 (
00132 isType<emptyFvPatchField<Type> >(ptf)
00133 ||
00134 (
00135 reader_->GetExtrapolatePatches()
00136 && !polyPatch::constraintType(patches[patchId].type())
00137 )
00138 )
00139 {
00140 fvPatch p(ptf.patch().patch(), tf.mesh().boundary());
00141
00142 tmp<Field<Type> > tpptf
00143 (
00144 fvPatchField<Type>(p, tf).patchInternalField()
00145 );
00146
00147 convertPatchField
00148 (
00149 tf.name(),
00150 tpptf(),
00151 output,
00152 partInfoPatches_,
00153 datasetNo
00154 );
00155
00156 convertPatchPointField
00157 (
00158 tf.name(),
00159 ppInterpList[patchId].faceToPointInterpolate(tpptf)(),
00160 output,
00161 partInfoPatches_,
00162 datasetNo
00163 );
00164 }
00165 else
00166 {
00167 convertPatchField
00168 (
00169 tf.name(),
00170 ptf,
00171 output,
00172 partInfoPatches_,
00173 datasetNo
00174 );
00175
00176 convertPatchPointField
00177 (
00178 tf.name(),
00179 ppInterpList[patchId].faceToPointInterpolate(ptf)(),
00180 output,
00181 partInfoPatches_,
00182 datasetNo
00183 );
00184 }
00185 }
00186
00187
00188
00189
00190 for
00191 (
00192 int partId = partInfoFaceZones_.start();
00193 partId < partInfoFaceZones_.end();
00194 ++partId
00195 )
00196 {
00197 const word zoneName = getPartName(partId);
00198 const label datasetNo = partDataset_[partId];
00199
00200 if (!partStatus_[partId] || datasetNo < 0)
00201 {
00202 continue;
00203 }
00204
00205 const faceZoneMesh& zMesh = mesh.faceZones();
00206 const label zoneId = zMesh.findZoneID(zoneName);
00207
00208 if (zoneId < 0)
00209 {
00210 continue;
00211 }
00212
00213 convertFaceField
00214 (
00215 tf,
00216 output,
00217 partInfoFaceZones_,
00218 datasetNo,
00219 mesh,
00220 zMesh[zoneId]
00221 );
00222
00223
00224 }
00225
00226
00227
00228
00229 for
00230 (
00231 int partId = partInfoFaceSets_.start();
00232 partId < partInfoFaceSets_.end();
00233 ++partId
00234 )
00235 {
00236 const word selectName = getPartName(partId);
00237 const label datasetNo = partDataset_[partId];
00238
00239 if (!partStatus_[partId] || datasetNo < 0)
00240 {
00241 continue;
00242 }
00243
00244 const faceSet fSet(mesh, selectName);
00245
00246 convertFaceField
00247 (
00248 tf,
00249 output,
00250 partInfoFaceSets_,
00251 datasetNo,
00252 mesh,
00253 fSet
00254 );
00255
00256
00257 }
00258 }
00259 }
00260
00261
00262 template<class Type>
00263 void Foam::vtkPV3Foam::convertVolFieldBlock
00264 (
00265 const GeometricField<Type, fvPatchField, volMesh>& tf,
00266 autoPtr<GeometricField<Type, pointPatchField, pointMesh> >& ptfPtr,
00267 vtkMultiBlockDataSet* output,
00268 const partInfo& selector,
00269 const List<polyDecomp>& decompLst
00270 )
00271 {
00272 for (int partId = selector.start(); partId < selector.end(); ++partId)
00273 {
00274 const label datasetNo = partDataset_[partId];
00275
00276 if (datasetNo >= 0 && partStatus_[partId])
00277 {
00278 convertVolField
00279 (
00280 tf,
00281 output,
00282 selector,
00283 datasetNo,
00284 decompLst[datasetNo]
00285 );
00286
00287 if (!ptfPtr.valid())
00288 {
00289 if (debug)
00290 {
00291 Info<< "convertVolFieldBlock interpolating:" << tf.name()
00292 << endl;
00293 }
00294
00295 ptfPtr.reset
00296 (
00297 volPointInterpolation::New(tf.mesh()).interpolate(tf).ptr()
00298 );
00299 }
00300
00301 convertPointField
00302 (
00303 ptfPtr(),
00304 tf,
00305 output,
00306 selector,
00307 datasetNo,
00308 decompLst[datasetNo]
00309 );
00310 }
00311 }
00312 }
00313
00314
00315 template<class Type>
00316 void Foam::vtkPV3Foam::convertVolField
00317 (
00318 const GeometricField<Type, fvPatchField, volMesh>& tf,
00319 vtkMultiBlockDataSet* output,
00320 const partInfo& selector,
00321 const label datasetNo,
00322 const polyDecomp& decompInfo
00323 )
00324 {
00325 const label nComp = pTraits<Type>::nComponents;
00326 const labelList& superCells = decompInfo.superCells();
00327
00328 vtkFloatArray* celldata = vtkFloatArray::New();
00329 celldata->SetNumberOfTuples(superCells.size());
00330 celldata->SetNumberOfComponents(nComp);
00331 celldata->Allocate(nComp*superCells.size());
00332 celldata->SetName(tf.name().c_str());
00333
00334 if (debug)
00335 {
00336 Info<< "convert volField: "
00337 << tf.name()
00338 << " size = " << tf.size()
00339 << " nComp=" << nComp
00340 << " nTuples = " << superCells.size() << endl;
00341 }
00342
00343 float vec[nComp];
00344 forAll(superCells, i)
00345 {
00346 const Type& t = tf[superCells[i]];
00347 for (direction d=0; d<nComp; d++)
00348 {
00349 vec[d] = component(t, d);
00350 }
00351 celldata->InsertTuple(i, vec);
00352 }
00353
00354 vtkUnstructuredGrid::SafeDownCast
00355 (
00356 GetDataSetFromBlock(output, selector, datasetNo)
00357 ) ->GetCellData()
00358 ->AddArray(celldata);
00359
00360 celldata->Delete();
00361 }
00362
00363
00364
00365
00366 #endif
00367
00368