void Foam::vtkPV3Foam::convertMeshCellSets
(
    vtkMultiBlockDataSet* output
)
{
    if (debug)
    {
        Info<< "<beg> Foam::vtkPV3Foam::convertMeshCellSets" << endl;
        printMemory();
    }

    const selectionInfo& selector = selectInfoCellSets_;
    vtkDataArraySelection* arraySelection = reader_->GetRegionSelection();

    // Create the cell sets and add as dataset
    if (selector.size())
    {
        const fvMesh& mesh = *meshPtr_;

        for
        (
            int regionId = selector.start();
            regionId < selector.end();
            ++regionId)
        {
            if (!selectedRegions_[regionId])
            {
                continue;
            }

            word selectName = getFirstWord
            (
                arraySelection->GetArrayName(regionId)
            );

            if (debug)
            {
                Info<< "Creating VTK mesh for cellSet: " << selectName
                    << " region index: " << regionId << endl;
            }

            const cellSet cSet(mesh, selectName);
            fvMeshSubset subsetter
            (
                IOobject
                (
                    "set",
                    mesh.time().constant(),
                    mesh,
                    IOobject::NO_READ,
                    IOobject::NO_WRITE
                ),
                mesh
            );
            subsetter.setLargeCellSubset(cSet);

            const label datasetId = GetNumberOfDataSets(output, selector);

            vtkUnstructuredGrid* vtkmesh = vtkUnstructuredGrid::New();

            addVolumeMesh
            (
                subsetter.subMesh(),
                vtkmesh,
                csetSuperCells_[datasetId]
            );

            // renumber - superCells must contain global cell ids
            inplaceRenumber
            (
                subsetter.cellMap(),
                csetSuperCells_[datasetId]
            );

            AddToBlock
            (
                output, selector, datasetId, vtkmesh,
                selectName + ":cellSet"
            );
            selectedRegionDatasetIds_[regionId] = datasetId;
            vtkmesh->Delete();
        }
    }

    if (debug)
    {
        Info<< "<end> Foam::vtkPV3Foam::convertMeshCellSets" << endl;
        printMemory();
    }
}
Пример #2
0
void Foam::vtkPV3Foam::convertMeshCellSets
(
    vtkMultiBlockDataSet* output,
    int& blockNo
)
{
    arrayRange& range = arrayRangeCellSets_;
    range.block(blockNo);      // set output block
    label datasetNo = 0;       // restart at dataset 0
    const fvMesh& mesh = *meshPtr_;

    // resize for decomposed polyhedra
    csetPolyDecomp_.setSize(range.size());

    if (debug)
    {
        Info<< "<beg> Foam::vtkPV3Foam::convertMeshCellSets" << endl;
        printMemory();
    }

    for (int partId = range.start(); partId < range.end(); ++partId)
    {
        const word partName = getPartName(partId);

        if (!partStatus_[partId])
        {
            continue;
        }

        if (debug)
        {
            Info<< "Creating VTK mesh for cellSet=" << partName << endl;
        }

        const cellSet cSet(mesh, partName);
        fvMeshSubset subsetter(mesh);
        subsetter.setLargeCellSubset(cSet);

        vtkUnstructuredGrid* vtkmesh = volumeVTKMesh
                                       (
                                           subsetter.subMesh(),
                                           csetPolyDecomp_[datasetNo]
                                       );

        if (vtkmesh)
        {
            // superCells + addPointCellLabels must contain global cell ids
            inplaceRenumber
            (
                subsetter.cellMap(),
                csetPolyDecomp_[datasetNo].superCells()
            );
            inplaceRenumber
            (
                subsetter.cellMap(),
                csetPolyDecomp_[datasetNo].addPointCellLabels()
            );

            // copy pointMap as well, otherwise pointFields fail
            csetPolyDecomp_[datasetNo].pointMap() = subsetter.pointMap();

            AddToBlock(output, vtkmesh, range, datasetNo, partName);
            vtkmesh->Delete();

            partDataset_[partId] = datasetNo++;
        }
    }

    // anything added?
    if (datasetNo)
    {
        ++blockNo;
    }

    if (debug)
    {
        Info<< "<end> Foam::vtkPV3Foam::convertMeshCellSets" << endl;
        printMemory();
    }
}
void Foam::vtkPV3Foam::convertMeshCellZones
(
    vtkMultiBlockDataSet* output
)
{
    if (debug)
    {
        Info<< "<beg> Foam::vtkPV3Foam::convertMeshCellZones" << endl;
        printMemory();
    }

    const selectionInfo& selector = selectInfoCellZones_;
    const fvMesh& mesh = *meshPtr_;

    // Create the cell zone(s) and add as DataSet(CELLZONE, 0..n)
    if (selector.size())
    {
        const cellZoneMesh& czMesh = mesh.cellZones();

        // use the zoneId directly instead of the name
        for (int zoneI=0; zoneI < selector.size(); ++zoneI)
        {
            const int regionId = selector.start() + zoneI;

            if (!selectedRegions_[regionId])
            {
                continue;
            }

            if (debug)
            {
                Info<< "Creating VTK mesh for cellZone: "
                    << zoneI << endl;
            }

            fvMeshSubset subsetter
            (
                IOobject
                (
                    "set",
                    mesh.time().constant(),
                    mesh,
                    IOobject::NO_READ,
                    IOobject::NO_WRITE
                ),
                mesh
            );

            subsetter.setLargeCellSubset(labelHashSet(czMesh[zoneI]));

            const label datasetId = GetNumberOfDataSets(output, selector);

            vtkUnstructuredGrid* vtkmesh = vtkUnstructuredGrid::New();

            addVolumeMesh
            (
                subsetter.subMesh(),
                vtkmesh,
                zoneSuperCells_[datasetId]
            );

            // renumber - superCells must contain global cell ids
            inplaceRenumber
            (
                subsetter.cellMap(),
                zoneSuperCells_[datasetId]
            );

            AddToBlock
            (
                output, selector, datasetId, vtkmesh,
                czMesh.names()[zoneI] + ":cellZone"
            );
            selectedRegionDatasetIds_[regionId] = datasetId;
            vtkmesh->Delete();
        }
    }

    if (debug)
    {
        Info<< "<end> Foam::vtkPV3Foam::convertMeshCellZones" << endl;
        printMemory();
    }
}