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 #include "vtkPV3Foam.H"
00030
00031
00032 #include "IOobjectList.H"
00033 #include "vtkPV3FoamReader.h"
00034
00035
00036 #include "vtkDataArraySelection.h"
00037 #include "vtkPolyData.h"
00038 #include "vtkUnstructuredGrid.h"
00039
00040
00041
00042 #include "vtkPV3FoamVolFields.H"
00043 #include "vtkPV3FoamPointFields.H"
00044 #include "vtkPV3FoamLagrangianFields.H"
00045
00046
00047 void Foam::vtkPV3Foam::pruneObjectList
00048 (
00049 IOobjectList& objects,
00050 const wordHashSet& selected
00051 )
00052 {
00053
00054 if (!selected.size())
00055 {
00056 objects.clear();
00057 }
00058
00059
00060 forAllIter(IOobjectList, objects, iter)
00061 {
00062 if (!selected.found(iter()->name()))
00063 {
00064 objects.erase(iter);
00065 }
00066 }
00067 }
00068
00069
00070 void Foam::vtkPV3Foam::convertVolFields
00071 (
00072 vtkMultiBlockDataSet* output
00073 )
00074 {
00075 const fvMesh& mesh = *meshPtr_;
00076
00077 wordHashSet selectedFields = getSelected
00078 (
00079 reader_->GetVolFieldSelection()
00080 );
00081
00082 if (!selectedFields.size())
00083 {
00084 return;
00085 }
00086
00087
00088
00089 IOobjectList objects(mesh, dbPtr_().timeName());
00090 pruneObjectList(objects, selectedFields);
00091
00092 if (!objects.size())
00093 {
00094 return;
00095 }
00096
00097 if (debug)
00098 {
00099 Info<< "<beg> Foam::vtkPV3Foam::convertVolFields" << nl
00100 << "converting Foam volume fields" << endl;
00101 forAllConstIter(IOobjectList, objects, iter)
00102 {
00103 Info<< " " << iter()->name()
00104 << " == " << iter()->objectPath() << nl;
00105 }
00106 printMemory();
00107 }
00108
00109
00110 PtrList<PrimitivePatchInterpolation<primitivePatch> >
00111 ppInterpList(mesh.boundaryMesh().size());
00112
00113 forAll(ppInterpList, i)
00114 {
00115 ppInterpList.set
00116 (
00117 i,
00118 new PrimitivePatchInterpolation<primitivePatch>
00119 (
00120 mesh.boundaryMesh()[i]
00121 )
00122 );
00123 }
00124
00125
00126 convertVolFields<scalar>
00127 (
00128 mesh, ppInterpList, objects, output
00129 );
00130 convertVolFields<vector>
00131 (
00132 mesh, ppInterpList, objects, output
00133 );
00134 convertVolFields<sphericalTensor>
00135 (
00136 mesh, ppInterpList, objects, output
00137 );
00138 convertVolFields<symmTensor>
00139 (
00140 mesh, ppInterpList, objects, output
00141 );
00142 convertVolFields<tensor>
00143 (
00144 mesh, ppInterpList, objects, output
00145 );
00146
00147 if (debug)
00148 {
00149 Info<< "<end> Foam::vtkPV3Foam::convertVolFields" << endl;
00150 printMemory();
00151 }
00152 }
00153
00154
00155 void Foam::vtkPV3Foam::convertPointFields
00156 (
00157 vtkMultiBlockDataSet* output
00158 )
00159 {
00160 const fvMesh& mesh = *meshPtr_;
00161
00162 wordHashSet selectedFields = getSelected
00163 (
00164 reader_->GetPointFieldSelection()
00165 );
00166
00167 if (!selectedFields.size())
00168 {
00169 return;
00170 }
00171
00172
00173
00174 IOobjectList objects(mesh, dbPtr_().timeName());
00175 pruneObjectList(objects, selectedFields);
00176
00177 if (!objects.size())
00178 {
00179 return;
00180 }
00181
00182 if (debug)
00183 {
00184 Info<< "<beg> Foam::vtkPV3Foam::convertPointFields" << nl
00185 << "converting Foam volume fields" << endl;
00186 forAllConstIter(IOobjectList, objects, iter)
00187 {
00188 Info<< " " << iter()->name()
00189 << " == " << iter()->objectPath() << nl;
00190 }
00191 printMemory();
00192 }
00193
00194
00195 pointMesh pMesh(mesh);
00196
00197
00198 convertPointFields<scalar>
00199 (
00200 mesh, pMesh, objects, output
00201 );
00202 convertPointFields<vector>
00203 (
00204 mesh, pMesh, objects, output
00205 );
00206 convertPointFields<sphericalTensor>
00207 (
00208 mesh, pMesh, objects, output
00209 );
00210 convertPointFields<symmTensor>
00211 (
00212 mesh, pMesh, objects, output
00213 );
00214 convertPointFields<tensor>
00215 (
00216 mesh, pMesh, objects, output
00217 );
00218
00219 if (debug)
00220 {
00221 Info<< "<end> Foam::vtkPV3Foam::convertPointFields" << endl;
00222 printMemory();
00223 }
00224 }
00225
00226
00227 void Foam::vtkPV3Foam::convertLagrangianFields
00228 (
00229 vtkMultiBlockDataSet* output
00230 )
00231 {
00232 partInfo& selector = partInfoLagrangian_;
00233 const fvMesh& mesh = *meshPtr_;
00234
00235 wordHashSet selectedFields = getSelected
00236 (
00237 reader_->GetLagrangianFieldSelection()
00238 );
00239
00240 if (!selectedFields.size())
00241 {
00242 return;
00243 }
00244
00245 if (debug)
00246 {
00247 Info<< "<beg> Foam::vtkPV3Foam::convertLagrangianFields" << endl;
00248 printMemory();
00249 }
00250
00251 for (int partId = selector.start(); partId < selector.end(); ++partId)
00252 {
00253 const word cloudName = getPartName(partId);
00254 const label datasetNo = partDataset_[partId];
00255
00256 if (!partStatus_[partId] || datasetNo < 0)
00257 {
00258 continue;
00259 }
00260
00261
00262
00263
00264
00265 IOobjectList objects
00266 (
00267 mesh,
00268 dbPtr_().timeName(),
00269 cloud::prefix/cloudName
00270 );
00271 pruneObjectList(objects, selectedFields);
00272
00273 if (!objects.size())
00274 {
00275 continue;
00276 }
00277
00278 if (debug)
00279 {
00280 Info<< "converting Foam lagrangian fields" << nl;
00281 forAllConstIter(IOobjectList, objects, iter)
00282 {
00283 Info<< " " << iter()->name()
00284 << " == " << iter()->objectPath() << nl;
00285 }
00286 }
00287
00288 convertLagrangianFields<label>
00289 (
00290 objects, output, datasetNo
00291 );
00292 convertLagrangianFields<scalar>
00293 (
00294 objects, output, datasetNo
00295 );
00296 convertLagrangianFields<vector>
00297 (
00298 objects, output, datasetNo
00299 );
00300 convertLagrangianFields<sphericalTensor>
00301 (
00302 objects, output, datasetNo
00303 );
00304 convertLagrangianFields<symmTensor>
00305 (
00306 objects, output, datasetNo
00307 );
00308 convertLagrangianFields<tensor>
00309 (
00310 objects, output, datasetNo
00311 );
00312 }
00313
00314 if (debug)
00315 {
00316 Info<< "<end> Foam::vtkPV3Foam::convertLagrangianFields" << endl;
00317 printMemory();
00318 }
00319 }
00320
00321
00322