diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/PV3FoamReader.xml b/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/PV3FoamReader.xml index 41b44048d95e5494b510a3cf43249d4a3b62a3c7..123c736f549cdcfed15b7c9792ef46fdcf1cd940 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/PV3FoamReader.xml +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/PV3FoamReader.xml @@ -1,6 +1,6 @@ <ParaViewReaders> <Reader name="PV3FoamReader" extensions="OpenFOAM" - file_description="OpenFOAM"> + file_description="OpenFOAM Reader"> </Reader> </ParaViewReaders> diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/Make/files b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/Make/files index ba65793d66e1086ce06dee27bf5ee93cd1eb923a..0a5e64ddf14feaed6766684c4c40e2315f661006 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/Make/files +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/Make/files @@ -2,10 +2,8 @@ vtkPV3Foam.C vtkPV3FoamAddVolumeMesh.C vtkPV3FoamAddLagrangianMesh.C vtkPV3FoamAddPatchMesh.C -vtkPV3FoamAddFaceZoneMesh.C -vtkPV3FoamAddPointZoneMesh.C -vtkPV3FoamAddFaceSetMesh.C -vtkPV3FoamAddPointSetMesh.C +vtkPV3FoamAddZoneMesh.C +vtkPV3FoamAddSetMesh.C vtkPV3FoamUpdate.C vtkPV3FoamUpdateInformation.C vtkPV3FoamConvertMesh.C diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C index d62064dac3a1815063bc6f274caad3e5597becb3..a24eb02b76e487ab61c0df28522c7829ea93b14b 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C @@ -52,7 +52,7 @@ defineTypeNameAndDebug(Foam::vtkPV3Foam, 0); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -#include "vtkPV3FoamAddFields.H" +#include "vtkPV3FoamAddToSelection.H" #include "vtkPV3FoamUpdateInformationFields.H" @@ -233,13 +233,13 @@ void Foam::vtkPV3Foam::updateSelectedRegions() vtkDataArraySelection* arraySelection = reader_->GetRegionSelection(); - const label nRegions = arraySelection->GetNumberOfArrays(); + const label nSelect = arraySelection->GetNumberOfArrays(); - selectedRegions_.setSize(nRegions); - selectedRegionDatasetIds_.setSize(nRegions); + selectedRegions_.setSize(nSelect); + selectedRegionDatasetIds_.setSize(nSelect); // Read the selected patches and add to the region list - for (int regionId=0; regionId < nRegions; ++regionId) + forAll (selectedRegions_, regionId) { selectedRegions_[regionId] = arraySelection->GetArraySetting(regionId); selectedRegionDatasetIds_[regionId] = -1; @@ -269,7 +269,13 @@ Foam::stringList Foam::vtkPV3Foam::getSelectedArrayEntries if (debug) { - Info<< "selections("; + Info<< "available("; + forAll (selections, elemI) + { + Info<< " \"" << arraySelection->GetArrayName(elemI) << "\""; + } + Info<< " )\n" + << "selected("; } forAll (selections, elemI) @@ -319,28 +325,40 @@ Foam::stringList Foam::vtkPV3Foam::getSelectedArrayEntries if (debug) { - Info<< "selections("; + Info<< "available("; + for + ( + int elemI = selector.start(); + elemI < selector.end(); + ++elemI + ) + { + Info<< " \"" << arraySelection->GetArrayName(elemI) << "\""; + } + + Info<< " )\n" + << "selected("; } for ( - int regionId = selector.start(); - regionId < selector.end(); - ++regionId + int elemI = selector.start(); + elemI < selector.end(); + ++elemI ) { - if (arraySelection->GetArraySetting(regionId)) + if (arraySelection->GetArraySetting(elemI)) { if (firstWord) { selections[nElem] = getFirstWord ( - arraySelection->GetArrayName(regionId) + arraySelection->GetArrayName(elemI) ); } else { - selections[nElem] = arraySelection->GetArrayName(regionId); + selections[nElem] = arraySelection->GetArrayName(elemI); } if (debug) @@ -400,10 +418,7 @@ void Foam::vtkPV3Foam::setSelectedArrayEntries << endl; } - arraySelection->EnableArray - ( - arrayName.c_str() - ); + arraySelection->EnableArray(arrayName.c_str()); break; } } @@ -523,25 +538,37 @@ void Foam::vtkPV3Foam::UpdateInformation() { if (debug) { - Info<< "<beg> Foam::vtkPV3Foam::UpdateInformation - " - << "TimeStep = " << reader_->GetTimeStep() << endl; + Info<< "<beg> Foam::vtkPV3Foam::UpdateInformation" + << " [meshPtr=" << (meshPtr_ ? "set" : "NULL") << "] TimeStep=" + << reader_->GetTimeStep() << endl; } resetCounters(); - // preserve the currently selected values - const stringList selectedEntries = getSelectedArrayEntries - ( - reader_->GetRegionSelection() - ); + vtkDataArraySelection* arraySelection = reader_->GetRegionSelection(); + + stringList selectedEntries; + // enable 'internalMesh' on the first call + if (arraySelection->GetNumberOfArrays() == 0) + { + selectedEntries.setSize(1); + selectedEntries[0] = "internalMesh"; + } + else + { + // preserve the currently selected values + selectedEntries = getSelectedArrayEntries + ( + arraySelection + ); + } + // Clear current region list/array - reader_->GetRegionSelection()->RemoveAllArrays(); + arraySelection->RemoveAllArrays(); // Update region array updateInformationInternalMesh(); - updateInformationLagrangian(); - updateInformationPatches(); if (reader_->GetIncludeSets()) @@ -554,10 +581,10 @@ void Foam::vtkPV3Foam::UpdateInformation() updateInformationZones(); } - // Update region selection with the data just read in + // restore the currently enabled values setSelectedArrayEntries ( - reader_->GetRegionSelection(), + arraySelection, selectedEntries ); @@ -610,9 +637,7 @@ void Foam::vtkPV3Foam::Update // Convert meshes convertMeshVolume(output); - convertMeshLagrangian(output); - convertMeshPatches(output); if (reader_->GetIncludeZones()) @@ -624,16 +649,14 @@ void Foam::vtkPV3Foam::Update if (reader_->GetIncludeSets()) { - convertMeshCellSet(output); - convertMeshFaceSet(output); - convertMeshPointSet(output); + convertMeshCellSets(output); + convertMeshFaceSets(output); + convertMeshPointSets(output); } // Update fields updateVolFields(output); - updatePointFields(output); - updateLagrangianFields(output); if (debug) @@ -724,8 +747,7 @@ void Foam::vtkPV3Foam::addPatchNames(vtkRenderer* renderer) Info<< "<beg> Foam::vtkPV3Foam::addPatchNames" << endl; } - const fvMesh& mesh = *meshPtr_; - const polyBoundaryMesh& pbMesh = mesh.boundaryMesh(); + const polyBoundaryMesh& pbMesh = meshPtr_->boundaryMesh(); const selectionInfo& selector = selectInfoPatches_; diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H index 8474798f7d2cc0a50bee3f1b6536888fceac99d9..39f52c2f32c667be9e9d3741782eb939604e472e 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H @@ -29,18 +29,16 @@ Description Provides a reader interface for OpenFOAM to VTK interaction. SourceFiles - interpolatePointToCell.C - interpolatePointToCell.H vtkPV3Foam.C vtkPV3Foam.H - vtkPV3FoamAddFaceSetMesh.C - vtkPV3FoamAddFaceZoneMesh.C - vtkPV3FoamAddFields.H + vtkPV3FoamI.H vtkPV3FoamAddLagrangianMesh.C vtkPV3FoamAddPatchMesh.C - vtkPV3FoamAddPointSetMesh.C - vtkPV3FoamAddPointZoneMesh.C + vtkPV3FoamAddSetMesh.C + vtkPV3FoamAddToSelection.H vtkPV3FoamAddVolumeMesh.C + vtkPV3FoamAddZoneMesh.C + vtkPV3FoamConvertFaceField.H vtkPV3FoamConvertLagrangianFields.H vtkPV3FoamConvertMesh.C vtkPV3FoamConvertPatchFaceField.H @@ -52,7 +50,7 @@ SourceFiles vtkPV3FoamUpdateInformation.C vtkPV3FoamUpdateInformationFields.H - // Needed by VTK? + // Needed by VTK: vtkDataArrayTemplateImplicit.txx \*---------------------------------------------------------------------------*/ @@ -64,6 +62,7 @@ SourceFiles #include "fileName.H" #include "volPointInterpolation.H" #include "stringList.H" +#include "wordList.H" #include "primitivePatch.H" // * * * * * * * * * * * * * Forward Declarations * * * * * * * * * * * * * // @@ -304,9 +303,21 @@ private: //- Set info void updateInformationSets(); + //- Read zone names for zoneType from file + wordList readZoneNames(const word& zoneType); + //- Zone info void updateInformationZones(); + //- Add to paraview array selection + template<class Type> + label addToSelection + ( + vtkDataArraySelection *arraySelection, + const IOobjectList&, + const string& suffix = "" + ); + //- Field info template<template<class> class patchType, class meshType> void updateInformationFields @@ -347,20 +358,20 @@ private: //- Cell zone meshes void convertMeshCellZones(vtkMultiBlockDataSet* output); - //- Cell zone meshes + //- Face zone meshes void convertMeshFaceZones(vtkMultiBlockDataSet* output); - //- Cell zone meshes + //- Point zone meshes void convertMeshPointZones(vtkMultiBlockDataSet* output); //- Cell set meshes - void convertMeshCellSet(vtkMultiBlockDataSet* output); + void convertMeshCellSets(vtkMultiBlockDataSet* output); //- Face set meshes - void convertMeshFaceSet(vtkMultiBlockDataSet* output); + void convertMeshFaceSets(vtkMultiBlockDataSet* output); //- Point set meshes - void convertMeshPointSet(vtkMultiBlockDataSet* output); + void convertMeshPointSets(vtkMultiBlockDataSet* output); // Add mesh functions @@ -430,7 +441,7 @@ private: //- Add the fields in the selected time directory to the selection // lists template<class GeoField> - label addFields + label addObjectsToSelection ( vtkDataArraySelection* fieldSelection, const IOobjectList& objects, diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddPointSetMesh.C b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddPointSetMesh.C deleted file mode 100644 index 4a19fab3d4d411a4053a53259d0940c6d98638e2..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddPointSetMesh.C +++ /dev/null @@ -1,73 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM; if not, write to the Free Software Foundation, - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -Description - -\*---------------------------------------------------------------------------*/ - -#include "vtkPV3Foam.H" - -// Foam includes -#include "pointSet.H" -#include "vtkPV3FoamInsertNextPoint.H" - -// VTK includes -#include "vtkPoints.h" -#include "vtkPolyData.h" - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -void Foam::vtkPV3Foam::addPointSetMesh -( - const fvMesh& mesh, - const pointSet& pSet, - vtkPolyData* vtkmesh -) -{ - if (debug) - { - Info<< "<beg> Foam::vtkPV3Foam::addPointSetMesh" << endl; - } - - const pointField& meshPoints = mesh.points(); - - vtkPoints *vtkpoints = vtkPoints::New(); - vtkpoints->Allocate(pSet.size()); - - forAllConstIter(pointSet, pSet, iter) - { - vtkPV3FoamInsertNextPoint(vtkpoints, meshPoints[iter.key()]); - } - - vtkmesh->SetPoints(vtkpoints); - vtkpoints->Delete(); - - if (debug) - { - Info<< "<end> Foam::vtkPV3Foam::addPointSetMesh" << endl; - } -} - - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddPointZoneMesh.C b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddPointZoneMesh.C deleted file mode 100644 index f6369bfa238fb387df1dc3db3f7e0e73b66d4ce4..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddPointZoneMesh.C +++ /dev/null @@ -1,72 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM; if not, write to the Free Software Foundation, - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -Description - -\*---------------------------------------------------------------------------*/ - -#include "vtkPV3Foam.H" - -// Foam includes -#include "vtkPV3FoamInsertNextPoint.H" - -// VTK includes -#include "vtkPoints.h" -#include "vtkPolyData.h" - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -void Foam::vtkPV3Foam::addPointZoneMesh -( - const fvMesh& mesh, - const labelList& pointLabels, - vtkPolyData* vtkmesh -) -{ - if (debug) - { - Info<< "<beg> Foam::vtkPV3Foam::addPointZoneMesh" << endl; - } - - const pointField& meshPoints = mesh.points(); - - vtkPoints *vtkpoints = vtkPoints::New(); - vtkpoints->Allocate(pointLabels.size()); - - forAll(pointLabels, pointI) - { - vtkPV3FoamInsertNextPoint(vtkpoints, meshPoints[pointLabels[pointI]]); - } - - vtkmesh->SetPoints(vtkpoints); - vtkpoints->Delete(); - - if (debug) - { - Info<< "<beg> Foam::vtkPV3Foam::addPointZoneMesh" << endl; - } -} - - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddFaceSetMesh.C b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddSetMesh.C similarity index 82% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddFaceSetMesh.C rename to applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddSetMesh.C index 116f503a4dbcfd841e137838f2331440b3b27065..8b17ace1852d51756d1b2134fed3f6790b9c10ce 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddFaceSetMesh.C +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddSetMesh.C @@ -30,6 +30,7 @@ Description // Foam includes #include "faceSet.H" +#include "pointSet.H" #include "vtkPV3FoamInsertNextPoint.H" // VTK includes @@ -103,4 +104,36 @@ void Foam::vtkPV3Foam::addFaceSetMesh } } + +void Foam::vtkPV3Foam::addPointSetMesh +( + const fvMesh& mesh, + const pointSet& pSet, + vtkPolyData* vtkmesh +) +{ + if (debug) + { + Info<< "<beg> Foam::vtkPV3Foam::addPointSetMesh" << endl; + } + + const pointField& meshPoints = mesh.points(); + + vtkPoints *vtkpoints = vtkPoints::New(); + vtkpoints->Allocate(pSet.size()); + + forAllConstIter(pointSet, pSet, iter) + { + vtkPV3FoamInsertNextPoint(vtkpoints, meshPoints[iter.key()]); + } + + vtkmesh->SetPoints(vtkpoints); + vtkpoints->Delete(); + + if (debug) + { + Info<< "<end> Foam::vtkPV3Foam::addPointSetMesh" << endl; + } +} + // ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddFields.H b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddToSelection.H similarity index 70% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddFields.H rename to applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddToSelection.H index ff6c48bfe5a0082e20c2850e043f354336a039df..08a316268637a9e6c93a87804443a2410cb89127 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddFields.H +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddToSelection.H @@ -22,13 +22,10 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -InClass - vtkPV3Foam - \*---------------------------------------------------------------------------*/ -#ifndef vtkPV3FoamAddFields_H -#define vtkPV3FoamAddFields_H +#ifndef vtkPV3FoamAddToSelection_H +#define vtkPV3FoamAddToSelection_H // FOAM includes #include "SortableList.H" @@ -38,48 +35,48 @@ InClass // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -template<class GeoField> -Foam::label Foam::vtkPV3Foam::addFields +template<class Type> +Foam::label Foam::vtkPV3Foam::addToSelection ( - vtkDataArraySelection *fieldSelection, - const IOobjectList& objects, + vtkDataArraySelection *arraySelection, + const IOobjectList& objectLst, const string& suffix ) { - IOobjectList fieldObjects(objects.lookupClass(GeoField::typeName)); + IOobjectList objects(objectLst.lookupClass(Type::typeName)); - SortableList<word> fields(fieldObjects.size()); + SortableList<word> objectNames(objects.size()); label count = 0; - forAllConstIter(IOobjectList, fieldObjects, iter) + forAllConstIter(IOobjectList, objects, iter) { - fields[count++] = iter()->name(); + objectNames[count++] = iter()->name(); } if (count) { - fields.sort(); + objectNames.sort(); - forAll(fields, fieldI) + forAll (objectNames, objI) { if (debug) { - Info<<" addField to GUI " << GeoField::typeName - << ":" << fields[fieldI] << endl; + Info<<" addToSelection<" << Type::typeName << "> to GUI " + << ":" << objectNames[objI] << endl; } if (suffix.size()) { - fieldSelection->AddArray + arraySelection->AddArray ( - (fields[fieldI] + suffix).c_str() + (objectNames[objI] + suffix).c_str() ); } else { - fieldSelection->AddArray + arraySelection->AddArray ( - fields[fieldI].c_str() + objectNames[objI].c_str() ); } } diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddFaceZoneMesh.C b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddZoneMesh.C similarity index 82% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddFaceZoneMesh.C rename to applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddZoneMesh.C index 044d4cedaf942ee56941fd1d830ca702ccd84fc7..b9c733eeed01e8f075b1389a48586c747edaca12 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddFaceZoneMesh.C +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddZoneMesh.C @@ -38,6 +38,7 @@ Description // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + void Foam::vtkPV3Foam::addFaceZoneMesh ( const fvMesh& mesh, @@ -102,4 +103,36 @@ void Foam::vtkPV3Foam::addFaceZoneMesh } + +void Foam::vtkPV3Foam::addPointZoneMesh +( + const fvMesh& mesh, + const labelList& pointLabels, + vtkPolyData* vtkmesh +) +{ + if (debug) + { + Info<< "<beg> Foam::vtkPV3Foam::addPointZoneMesh" << endl; + } + + const pointField& meshPoints = mesh.points(); + + vtkPoints *vtkpoints = vtkPoints::New(); + vtkpoints->Allocate(pointLabels.size()); + + forAll(pointLabels, pointI) + { + vtkPV3FoamInsertNextPoint(vtkpoints, meshPoints[pointLabels[pointI]]); + } + + vtkmesh->SetPoints(vtkpoints); + vtkpoints->Delete(); + + if (debug) + { + Info<< "<beg> Foam::vtkPV3Foam::addPointZoneMesh" << endl; + } +} + // ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertMesh.C b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertMesh.C index 47239f02d716915e97f92061f0a628d2a0e55631..432372d29626aea4106d37dceb907e0c252ab90c 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertMesh.C +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertMesh.C @@ -76,7 +76,7 @@ void Foam::vtkPV3Foam::convertMeshVolume if (debug) { - Info<< "Creating VTK internal mesh" << endl; + Info<< "Creating VTK internalMesh" << endl; } const label datasetId = 0; @@ -285,14 +285,14 @@ void Foam::vtkPV3Foam::convertMeshCellZones } -void Foam::vtkPV3Foam::convertMeshCellSet +void Foam::vtkPV3Foam::convertMeshCellSets ( vtkMultiBlockDataSet* output ) { if (debug) { - Info<< "<beg> Foam::vtkPV3Foam::convertMeshCellSet" << endl; + Info<< "<beg> Foam::vtkPV3Foam::convertMeshCellSets" << endl; } const selectionInfo& selector = selectInfoCellSets_; @@ -359,10 +359,11 @@ void Foam::vtkPV3Foam::convertMeshCellSet if (debug) { - Info<< "<end> Foam::vtkPV3Foam::convertMeshCellSet" << endl; + Info<< "<end> Foam::vtkPV3Foam::convertMeshCellSets" << endl; } } + void Foam::vtkPV3Foam::convertMeshFaceZones ( vtkMultiBlockDataSet* output @@ -417,7 +418,7 @@ void Foam::vtkPV3Foam::convertMeshFaceZones vtkmesh->Delete(); } } - + if (debug) { Info<< "<end> Foam::vtkPV3Foam::convertMeshFaceZones" << endl; @@ -425,14 +426,14 @@ void Foam::vtkPV3Foam::convertMeshFaceZones } -void Foam::vtkPV3Foam::convertMeshFaceSet +void Foam::vtkPV3Foam::convertMeshFaceSets ( vtkMultiBlockDataSet* output ) { if (debug) { - Info<< "<beg> Foam::vtkPV3Foam::convertMeshFaceSet" << endl; + Info<< "<beg> Foam::vtkPV3Foam::convertMeshFaceSets" << endl; } const selectionInfo& selector = selectInfoFaceSets_; @@ -487,10 +488,10 @@ void Foam::vtkPV3Foam::convertMeshFaceSet vtkmesh->Delete(); } } - + if (debug) { - Info<< "<end> Foam::vtkPV3Foam::convertMeshFaceSet" << endl; + Info<< "<end> Foam::vtkPV3Foam::convertMeshFaceSets" << endl; } } @@ -549,7 +550,7 @@ void Foam::vtkPV3Foam::convertMeshPointZones vtkmesh->Delete(); } } - + if (debug) { Info<< "<end> Foam::vtkPV3Foam::convertMeshPointZones" << endl; @@ -558,14 +559,14 @@ void Foam::vtkPV3Foam::convertMeshPointZones -void Foam::vtkPV3Foam::convertMeshPointSet +void Foam::vtkPV3Foam::convertMeshPointSets ( vtkMultiBlockDataSet* output ) { if (debug) { - Info<< "<beg> Foam::vtkPV3Foam::convertMeshPointSet" << endl; + Info<< "<beg> Foam::vtkPV3Foam::convertMeshPointSets" << endl; } const selectionInfo& selector = selectInfoPointSets_; @@ -620,10 +621,10 @@ void Foam::vtkPV3Foam::convertMeshPointSet vtkmesh->Delete(); } } - + if (debug) { - Info<< "<end> Foam::vtkPV3Foam::convertMeshPointSet" << endl; + Info<< "<end> Foam::vtkPV3Foam::convertMeshPointSets" << endl; } } diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamI.H b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamI.H index 37f9543c560b1c923fa147800fb49896a93155ef..8f9f682cdc083f92f1456c0d597704c467fbf022 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamI.H +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamI.H @@ -28,7 +28,6 @@ License // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -//- Extract up to the first non-word characters inline Foam::word Foam::vtkPV3Foam::getFirstWord(const char* str) { if (str) @@ -46,32 +45,4 @@ inline Foam::word Foam::vtkPV3Foam::getFirstWord(const char* str) } } - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - - // ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInformation.C b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInformation.C index 9c2d144dea1cf7a2bb23f5b7c619a61af1a4c5cb..d47b7a191b63078cc907f09824216fd5dc86c43b 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInformation.C +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInformation.C @@ -22,8 +22,6 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -Description - \*---------------------------------------------------------------------------*/ #include "vtkPV3Foam.H" @@ -31,9 +29,9 @@ Description // Foam includes #include "cellSet.H" #include "faceSet.H" +#include "pointSet.H" #include "IOobjectList.H" #include "IOPtrList.H" -#include "pointSet.H" #include "polyBoundaryMeshEntries.H" #include "entry.H" #include "vtkPV3FoamReader.h" @@ -79,7 +77,7 @@ public: // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -#include "vtkPV3FoamAddFields.H" +#include "vtkPV3FoamAddToSelection.H" #include "vtkPV3FoamUpdateInformationFields.H" void Foam::vtkPV3Foam::updateInformationInternalMesh() @@ -103,6 +101,9 @@ void Foam::vtkPV3Foam::updateInformationInternalMesh() if (debug) { + // just for debug info + getSelectedArrayEntries(arraySelection); + Info<< "<end> Foam::vtkPV3Foam::updateInformationInternalMesh" << endl; } @@ -132,7 +133,7 @@ void Foam::vtkPV3Foam::updateInformationLagrangian() arraySelection->AddArray("lagrangian"); selectInfoLagrangian_ += 1; - Info<<"added cloudDirs\n"; + Info<< "... added cloudDirs\n"; if (cloudDirs.size() > 1) { @@ -149,13 +150,16 @@ void Foam::vtkPV3Foam::updateInformationLagrangian() { if (debug) { - Info<<"no clouds identified in " <<nl + Info<< "... no clouds identified in " <<nl << " " <<dbPtr_->timePath()/"lagrangian" << endl; } } if (debug) { + // just for debug info + getSelectedArrayEntries(arraySelection); + Info<< "<end> Foam::vtkPV3Foam::updateInformationLagrangian" << endl; } } @@ -165,7 +169,8 @@ void Foam::vtkPV3Foam::updateInformationPatches() { if (debug) { - Info<< "<beg> Foam::vtkPV3Foam::updateInformationPatches" << endl; + Info<< "<beg> Foam::vtkPV3Foam::updateInformationPatches" + << " [meshPtr=" << (meshPtr_ ? "set" : "NULL") << "]" << endl; } vtkDataArraySelection *arraySelection = reader_->GetRegionSelection(); @@ -209,117 +214,130 @@ void Foam::vtkPV3Foam::updateInformationPatches() if (debug) { + // just for debug info + getSelectedArrayEntries(arraySelection); + Info<< "<end> Foam::vtkPV3Foam::updateInformationPatches" << endl; } } +Foam::wordList Foam::vtkPV3Foam::readZoneNames(const word& zoneType) +{ + wordList zoneNames; + + // mesh not loaded - read from file + IOobject ioObj + ( + zoneType, + dbPtr_().findInstance + ( + polyMesh::meshSubDir, + zoneType, + IOobject::READ_IF_PRESENT + ), + polyMesh::meshSubDir, + dbPtr_(), + IOobject::READ_IF_PRESENT, + IOobject::NO_WRITE, + false + ); + + if (ioObj.headerOk()) + { + zonesEntries zones(ioObj); + + zoneNames.setSize(zones.size()); + forAll (zones, zoneI) + { + zoneNames[zoneI] = zones[zoneI].keyword(); + } + } + + return zoneNames; +} + + void Foam::vtkPV3Foam::updateInformationZones() { if (debug) { - Info<< "<beg> Foam::vtkPV3Foam::updateInformationZones" << endl; + Info<< "<beg> Foam::vtkPV3Foam::updateInformationZones" + << " [meshPtr=" << (meshPtr_ ? "set" : "NULL") << "]" << endl; } vtkDataArraySelection *arraySelection = reader_->GetRegionSelection(); - // Read cell zone information + wordList zoneNames; + + // + // cellZones information + // ~~~~~~~~~~~~~~~~~~~~~ + if (meshPtr_) { - zonesEntries zones - ( - IOobject - ( - "cellZones", - dbPtr_().findInstance(polyMesh::meshSubDir, "cellZones"), - polyMesh::meshSubDir, - dbPtr_(), - IOobject::READ_IF_PRESENT, - IOobject::NO_WRITE, - false - ) - ); - - selectInfoCellZones_ = arraySelection->GetNumberOfArrays(); - if (zones.headerOk()) - { - forAll(zones, zoneI) - { - arraySelection->AddArray - ( - (zones[zoneI].keyword() + " - cellZone").c_str() - ); - } - selectInfoCellZones_ += zones.size(); - } + zoneNames = meshPtr_->cellZones().names(); + } + else + { + zoneNames = readZoneNames("cellZones"); + } - superCellZonesCells_.setSize(selectInfoCellZones_.size()); + selectInfoCellZones_ = arraySelection->GetNumberOfArrays(); + forAll (zoneNames, zoneI) + { + arraySelection->AddArray((zoneNames[zoneI] + " - cellZone").c_str()); } + selectInfoCellZones_ += zoneNames.size(); + superCellZonesCells_.setSize(selectInfoCellZones_.size()); + - // Read face zone information + // + // faceZones information + // ~~~~~~~~~~~~~~~~~~~~~ + if (meshPtr_) { - zonesEntries zones - ( - IOobject - ( - "faceZones", - dbPtr_().findInstance(polyMesh::meshSubDir, "faceZones"), - polyMesh::meshSubDir, - dbPtr_(), - IOobject::READ_IF_PRESENT, - IOobject::NO_WRITE, - false - ) - ); - - selectInfoFaceZones_ = arraySelection->GetNumberOfArrays(); - if (zones.headerOk()) - { - forAll(zones, zoneI) - { - arraySelection->AddArray - ( - (zones[zoneI].keyword() + " - faceZone").c_str() - ); - } - selectInfoFaceZones_ += zones.size(); - } + zoneNames = meshPtr_->faceZones().names(); + } + else + { + zoneNames = readZoneNames("faceZones"); } - // Read point zone information + selectInfoFaceZones_ = arraySelection->GetNumberOfArrays(); + forAll (zoneNames, zoneI) { - zonesEntries zones - ( - IOobject - ( - "pointZones", - dbPtr_().findInstance(polyMesh::meshSubDir, "pointZones"), - polyMesh::meshSubDir, - dbPtr_(), - IOobject::READ_IF_PRESENT, - IOobject::NO_WRITE, - false - ) - ); - - selectInfoPointZones_ = arraySelection->GetNumberOfArrays(); - if (zones.headerOk()) - { - forAll(zones, zoneI) - { - arraySelection->AddArray - ( - (zones[zoneI].keyword() + " - pointZone").c_str() - ); - } - selectInfoPointZones_ += zones.size(); - } + arraySelection->AddArray((zoneNames[zoneI] + " - faceZone").c_str()); } + selectInfoFaceZones_ += zoneNames.size(); + + + // + // pointZones information + // ~~~~~~~~~~~~~~~~~~~~~~ + if (meshPtr_) + { + zoneNames = meshPtr_->pointZones().names(); + } + else + { + zoneNames = readZoneNames("pointZones"); + } + + selectInfoPointZones_ = arraySelection->GetNumberOfArrays(); + forAll (zoneNames, zoneI) + { + arraySelection->AddArray((zoneNames[zoneI] + " - pointZone").c_str()); + } + selectInfoPointZones_ += zoneNames.size(); + if (debug) { + // just for debug info + getSelectedArrayEntries(arraySelection); + Info<< "<end> Foam::vtkPV3Foam::updateInformationZones" << endl; } - } @@ -332,7 +350,7 @@ void Foam::vtkPV3Foam::updateInformationSets() vtkDataArraySelection *arraySelection = reader_->GetRegionSelection(); - // Add sets + // Add names of sets IOobjectList objects ( dbPtr_(), @@ -342,7 +360,7 @@ void Foam::vtkPV3Foam::updateInformationSets() selectInfoCellSets_ = arraySelection->GetNumberOfArrays(); - selectInfoCellSets_ += addFields<cellSet> + selectInfoCellSets_ += addToSelection<cellSet> ( arraySelection, objects, @@ -351,7 +369,7 @@ void Foam::vtkPV3Foam::updateInformationSets() superCellSetCells_.setSize(selectInfoCellSets_.size()); selectInfoFaceSets_ = arraySelection->GetNumberOfArrays(); - selectInfoFaceSets_ += addFields<faceSet> + selectInfoFaceSets_ += addToSelection<faceSet> ( arraySelection, objects, @@ -359,7 +377,7 @@ void Foam::vtkPV3Foam::updateInformationSets() ); selectInfoPointSets_ = arraySelection->GetNumberOfArrays(); - selectInfoPointSets_ += addFields<pointSet> + selectInfoPointSets_ += addToSelection<pointSet> ( arraySelection, objects, @@ -368,6 +386,9 @@ void Foam::vtkPV3Foam::updateInformationSets() if (debug) { + // just for debug info + getSelectedArrayEntries(arraySelection); + Info<< "<end> Foam::vtkPV3Foam::updateInformationSets" << endl; } } @@ -399,32 +420,32 @@ void Foam::vtkPV3Foam::updateInformationLagrangianFields() "lagrangian"/cloudName_ ); - addFields<IOField<label> > + addToSelection<IOField<label> > ( arraySelection, objects ); - addFields<IOField<scalar> > + addToSelection<IOField<scalar> > ( arraySelection, objects ); - addFields<IOField<vector> > + addToSelection<IOField<vector> > ( arraySelection, objects ); - addFields<IOField<sphericalTensor> > + addToSelection<IOField<sphericalTensor> > ( arraySelection, objects ); - addFields<IOField<symmTensor> > + addToSelection<IOField<symmTensor> > ( arraySelection, objects ); - addFields<IOField<tensor> > + addToSelection<IOField<tensor> > ( arraySelection, objects @@ -444,5 +465,4 @@ void Foam::vtkPV3Foam::updateInformationLagrangianFields() } } - // ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInformationFields.H b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInformationFields.H index 170ad74ed1be5368b93a348d06984b51526735be..a5c110e3b987e9b0f90ec47a0a4ed1c07f42df8f 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInformationFields.H +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInformationFields.H @@ -43,11 +43,23 @@ void Foam::vtkPV3Foam::updateInformationFields Info<< "<beg> Foam::vtkPV3Foam::updateInformationFields" << endl; } - // preserve the currently selected values - const stringList selectedEntries = getSelectedArrayEntries - ( - arraySelection - ); + stringList selectedEntries; + // enable 'p' and 'U' on the first call + if (arraySelection->GetNumberOfArrays() == 0) + { + selectedEntries.setSize(2); + selectedEntries[0] = "p"; + selectedEntries[1] = "U"; + } + else + { + // preserve the currently selected values + selectedEntries = getSelectedArrayEntries + ( + arraySelection + ); + } + arraySelection->RemoveAllArrays(); // Search for list of objects for this time @@ -56,33 +68,33 @@ void Foam::vtkPV3Foam::updateInformationFields //- Add volume fields to GUI /* - addFields<GeometricField<label, patchType, meshType> > + addToSelection<GeometricField<label, patchType, meshType> > ( arraySelection, objects ); */ - addFields<GeometricField<scalar, patchType, meshType> > + addToSelection<GeometricField<scalar, patchType, meshType> > ( arraySelection, objects ); - addFields<GeometricField<vector, patchType, meshType> > + addToSelection<GeometricField<vector, patchType, meshType> > ( arraySelection, objects ); - addFields<GeometricField<sphericalTensor, patchType, meshType> > + addToSelection<GeometricField<sphericalTensor, patchType, meshType> > ( arraySelection, objects ); - addFields<GeometricField<symmTensor, patchType, meshType> > + addToSelection<GeometricField<symmTensor, patchType, meshType> > ( arraySelection, objects ); - addFields<GeometricField<tensor, patchType, meshType> > + addToSelection<GeometricField<tensor, patchType, meshType> > ( arraySelection, objects