1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 \*---------------------------------------------------------------------------*/
29 #include "vtkPV3Foam.H"
35 #include "fvMeshSubset.H"
36 #include "vtkPV3FoamReader.h"
39 #include "vtkDataArraySelection.h"
40 #include "vtkMultiBlockDataSet.h"
41 #include "vtkPolyData.h"
42 #include "vtkUnstructuredGrid.h"
44 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
46 void Foam::vtkPV3Foam::convertMeshVolume
48 vtkMultiBlockDataSet* output,
52 partInfo& selector = partInfoVolume_;
53 selector.block(blockNo); // set output block
54 label datasetNo = 0; // restart at dataset 0
55 const fvMesh& mesh = *meshPtr_;
57 // resize for decomposed polyhedra
58 regionPolyDecomp_.setSize(selector.size());
62 Info<< "<beg> Foam::vtkPV3Foam::convertMeshVolume" << endl;
66 // Convert the internalMesh
67 // this looks like more than one part, but it isn't
68 for (int partId = selector.start(); partId < selector.end(); ++partId)
70 const word partName = "internalMesh";
72 if (!partStatus_[partId])
77 vtkUnstructuredGrid* vtkmesh = volumeVTKMesh
80 regionPolyDecomp_[datasetNo]
85 AddToBlock(output, vtkmesh, selector, datasetNo, partName);
88 partDataset_[partId] = datasetNo++;
100 Info<< "<end> Foam::vtkPV3Foam::convertMeshVolume" << endl;
106 void Foam::vtkPV3Foam::convertMeshLagrangian
108 vtkMultiBlockDataSet* output,
112 partInfo& selector = partInfoLagrangian_;
113 selector.block(blockNo); // set output block
114 label datasetNo = 0; // restart at dataset 0
115 const fvMesh& mesh = *meshPtr_;
119 Info<< "<beg> Foam::vtkPV3Foam::convertMeshLagrangian" << endl;
123 for (int partId = selector.start(); partId < selector.end(); ++partId)
125 const word cloudName = getPartName(partId);
127 if (!partStatus_[partId])
132 vtkPolyData* vtkmesh = lagrangianVTKMesh(mesh, cloudName);
136 AddToBlock(output, vtkmesh, selector, datasetNo, cloudName);
139 partDataset_[partId] = datasetNo++;
151 Info<< "<end> Foam::vtkPV3Foam::convertMeshLagrangian" << endl;
157 void Foam::vtkPV3Foam::convertMeshPatches
159 vtkMultiBlockDataSet* output,
163 partInfo& selector = partInfoPatches_;
164 selector.block(blockNo); // set output block
165 label datasetNo = 0; // restart at dataset 0
166 const fvMesh& mesh = *meshPtr_;
167 const polyBoundaryMesh& patches = mesh.boundaryMesh();
171 Info<< "<beg> Foam::vtkPV3Foam::convertMeshPatches" << endl;
175 for (int partId = selector.start(); partId < selector.end(); ++partId)
177 const word patchName = getPartName(partId);
178 const label patchId = patches.findPatchID(patchName);
180 if (!partStatus_[partId] || patchId < 0)
187 Info<< "Creating VTK mesh for patch[" << patchId <<"] "
188 << patchName << endl;
191 vtkPolyData* vtkmesh = patchVTKMesh(patches[patchId]);
195 AddToBlock(output, vtkmesh, selector, datasetNo, patchName);
198 partDataset_[partId] = datasetNo++;
210 Info<< "<end> Foam::vtkPV3Foam::convertMeshPatches" << endl;
216 void Foam::vtkPV3Foam::convertMeshCellZones
218 vtkMultiBlockDataSet* output,
222 partInfo& selector = partInfoCellZones_;
223 selector.block(blockNo); // set output block
224 label datasetNo = 0; // restart at dataset 0
225 const fvMesh& mesh = *meshPtr_;
227 // resize for decomposed polyhedra
228 zonePolyDecomp_.setSize(selector.size());
230 if (!selector.size())
237 Info<< "<beg> Foam::vtkPV3Foam::convertMeshCellZones" << endl;
241 const cellZoneMesh& zMesh = mesh.cellZones();
242 for (int partId = selector.start(); partId < selector.end(); ++partId)
244 const word zoneName = getPartName(partId);
245 const label zoneId = zMesh.findZoneID(zoneName);
247 if (!partStatus_[partId] || zoneId < 0)
254 Info<< "Creating VTK mesh for cellZone[" << zoneId << "] "
258 fvMeshSubset subsetMesh
263 mesh.time().constant(),
271 subsetMesh.setLargeCellSubset(labelHashSet(zMesh[zoneId]));
273 vtkUnstructuredGrid* vtkmesh = volumeVTKMesh
275 subsetMesh.subMesh(),
276 zonePolyDecomp_[datasetNo]
281 // superCells + addPointCellLabels must contain global cell ids
284 subsetMesh.cellMap(),
285 zonePolyDecomp_[datasetNo].superCells()
289 subsetMesh.cellMap(),
290 zonePolyDecomp_[datasetNo].addPointCellLabels()
293 // copy pointMap as well, otherwise pointFields fail
294 zonePolyDecomp_[datasetNo].pointMap() = subsetMesh.pointMap();
296 AddToBlock(output, vtkmesh, selector, datasetNo, zoneName);
299 partDataset_[partId] = datasetNo++;
311 Info<< "<end> Foam::vtkPV3Foam::convertMeshCellZones" << endl;
317 void Foam::vtkPV3Foam::convertMeshCellSets
319 vtkMultiBlockDataSet* output,
323 partInfo& selector = partInfoCellSets_;
324 selector.block(blockNo); // set output block
325 label datasetNo = 0; // restart at dataset 0
326 const fvMesh& mesh = *meshPtr_;
328 // resize for decomposed polyhedra
329 csetPolyDecomp_.setSize(selector.size());
333 Info<< "<beg> Foam::vtkPV3Foam::convertMeshCellSets" << endl;
337 for (int partId = selector.start(); partId < selector.end(); ++partId)
339 const word partName = getPartName(partId);
341 if (!partStatus_[partId])
348 Info<< "Creating VTK mesh for cellSet=" << partName << endl;
351 const cellSet cSet(mesh, partName);
353 fvMeshSubset subsetMesh
358 mesh.time().constant(),
366 subsetMesh.setLargeCellSubset(cSet);
368 vtkUnstructuredGrid* vtkmesh = volumeVTKMesh
370 subsetMesh.subMesh(),
371 csetPolyDecomp_[datasetNo]
376 // superCells + addPointCellLabels must contain global cell ids
379 subsetMesh.cellMap(),
380 csetPolyDecomp_[datasetNo].superCells()
384 subsetMesh.cellMap(),
385 csetPolyDecomp_[datasetNo].addPointCellLabels()
388 // copy pointMap as well, otherwise pointFields fail
389 csetPolyDecomp_[datasetNo].pointMap() = subsetMesh.pointMap();
391 AddToBlock(output, vtkmesh, selector, datasetNo, partName);
394 partDataset_[partId] = datasetNo++;
406 Info<< "<end> Foam::vtkPV3Foam::convertMeshCellSets" << endl;
412 void Foam::vtkPV3Foam::convertMeshFaceZones
414 vtkMultiBlockDataSet* output,
418 partInfo& selector = partInfoFaceZones_;
419 selector.block(blockNo); // set output block
420 label datasetNo = 0; // restart at dataset 0
421 const fvMesh& mesh = *meshPtr_;
423 if (!selector.size())
430 Info<< "<beg> Foam::vtkPV3Foam::convertMeshFaceZones" << endl;
434 const faceZoneMesh& zMesh = mesh.faceZones();
435 for (int partId = selector.start(); partId < selector.end(); ++partId)
437 const word zoneName = getPartName(partId);
438 const label zoneId = zMesh.findZoneID(zoneName);
440 if (!partStatus_[partId] || zoneId < 0)
447 Info<< "Creating VTKmesh for faceZone[" << zoneId << "] "
451 vtkPolyData* vtkmesh = faceZoneVTKMesh(mesh, zMesh[zoneId]);
454 AddToBlock(output, vtkmesh, selector, datasetNo, zoneName);
457 partDataset_[partId] = datasetNo++;
469 Info<< "<end> Foam::vtkPV3Foam::convertMeshFaceZones" << endl;
475 void Foam::vtkPV3Foam::convertMeshFaceSets
477 vtkMultiBlockDataSet* output,
481 partInfo& selector = partInfoFaceSets_;
482 selector.block(blockNo); // set output block
483 label datasetNo = 0; // restart at dataset 0
484 const fvMesh& mesh = *meshPtr_;
488 Info<< "<beg> Foam::vtkPV3Foam::convertMeshFaceSets" << endl;
492 for (int partId = selector.start(); partId < selector.end(); ++partId)
494 const word partName = getPartName(partId);
496 if (!partStatus_[partId])
503 Info<< "Creating VTK mesh for faceSet=" << partName << endl;
506 const faceSet fSet(mesh, partName);
508 vtkPolyData* vtkmesh = faceSetVTKMesh(mesh, fSet);
511 AddToBlock(output, vtkmesh, selector, datasetNo, partName);
514 partDataset_[partId] = datasetNo++;
526 Info<< "<end> Foam::vtkPV3Foam::convertMeshFaceSets" << endl;
532 void Foam::vtkPV3Foam::convertMeshPointZones
534 vtkMultiBlockDataSet* output,
538 partInfo& selector = partInfoPointZones_;
539 selector.block(blockNo); // set output block
540 label datasetNo = 0; // restart at dataset 0
541 const fvMesh& mesh = *meshPtr_;
545 Info<< "<beg> Foam::vtkPV3Foam::convertMeshPointZones" << endl;
551 const pointZoneMesh& zMesh = mesh.pointZones();
552 for (int partId = selector.start(); partId < selector.end(); ++partId)
554 word zoneName = getPartName(partId);
555 label zoneId = zMesh.findZoneID(zoneName);
557 if (!partStatus_[partId] || zoneId < 0)
562 vtkPolyData* vtkmesh = pointZoneVTKMesh(mesh, zMesh[zoneId]);
565 AddToBlock(output, vtkmesh, selector, datasetNo, zoneName);
568 partDataset_[partId] = datasetNo++;
581 Info<< "<end> Foam::vtkPV3Foam::convertMeshPointZones" << endl;
588 void Foam::vtkPV3Foam::convertMeshPointSets
590 vtkMultiBlockDataSet* output,
594 partInfo& selector = partInfoPointSets_;
595 selector.block(blockNo); // set output block
596 label datasetNo = 0; // restart at dataset 0
597 const fvMesh& mesh = *meshPtr_;
601 Info<< "<beg> Foam::vtkPV3Foam::convertMeshPointSets" << endl;
605 for (int partId = selector.start(); partId < selector.end(); ++partId)
607 word partName = getPartName(partId);
609 if (!partStatus_[partId])
616 Info<< "Creating VTK mesh for pointSet=" << partName << endl;
619 const pointSet pSet(mesh, partName);
621 vtkPolyData* vtkmesh = pointSetVTKMesh(mesh, pSet);
624 AddToBlock(output, vtkmesh, selector, datasetNo, partName);
627 partDataset_[partId] = datasetNo++;
639 Info<< "<end> Foam::vtkPV3Foam::convertMeshPointSets" << endl;
644 // ************************************************************************* //