From 57949f8e824988a0c11e4d16ee7ce70fb254b09a Mon Sep 17 00:00:00 2001 From: mattijs Date: Fri, 1 Aug 2008 17:56:48 +0100 Subject: [PATCH 1/5] status was not cleared --- src/autoMesh/autoHexMesh/meshRefinement/meshRefinement.H | 4 +++- src/meshTools/searchableSurface/searchableSphere.C | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/autoMesh/autoHexMesh/meshRefinement/meshRefinement.H b/src/autoMesh/autoHexMesh/meshRefinement/meshRefinement.H index d27eaae413..012ef08d00 100644 --- a/src/autoMesh/autoHexMesh/meshRefinement/meshRefinement.H +++ b/src/autoMesh/autoHexMesh/meshRefinement/meshRefinement.H @@ -570,7 +570,9 @@ public: // region and split them. autoPtr dupNonManifoldPoints(); - //- Create baffle for every internal face where ownPatch != -1 + //- Create baffle for every internal face where ownPatch != -1. + // External faces get repatched according to ownPatch (neiPatch + // should be -1 for these) autoPtr createBaffles ( const labelList& ownPatch, diff --git a/src/meshTools/searchableSurface/searchableSphere.C b/src/meshTools/searchableSurface/searchableSphere.C index 039be46749..47abfbfff5 100644 --- a/src/meshTools/searchableSurface/searchableSphere.C +++ b/src/meshTools/searchableSurface/searchableSphere.C @@ -233,10 +233,9 @@ void Foam::searchableSphere::findLineAll { info.setSize(start.size()); - pointIndexHit near, far; - forAll(start, i) { + pointIndexHit near, far; findLineAll(start[i], end[i], near, far); if (near.hit()) @@ -260,6 +259,10 @@ void Foam::searchableSphere::findLineAll info[i].setSize(1); info[i][0] = far; } + else + { + info[i].clear(); + } } } } From fa0b03433813daaf3981126b1806716bab1a317e Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 1 Aug 2008 20:04:38 +0200 Subject: [PATCH 2/5] PV3FoamReader - neater multiblocks and dual output ports - normal mesh data on port0 - Lagrangian data on port1 - no fixed block numbers for dividing internalMesh, patches, zones etc. This helps avoid ugly gaps in the multiblock output - avoid segfault if Lagrangian fields are converted without positions TODO: - can we label the output ports? - the selection of Lagrangian data and fields is wonky. --- .../PV3FoamReader/vtkPV3FoamReader.cxx | 222 ++++++++++-------- .../PV3FoamReader/vtkPV3FoamReader.h | 9 +- .../PV3FoamReader/vtkPV3Foam/Make/files | 2 +- .../PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C | 178 ++++++++------ .../PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H | 91 ++++--- ...FoamUpdate.C => vtkPV3FoamConvertFields.C} | 82 +------ .../vtkPV3FoamConvertLagrangianFields.H | 54 +++-- .../vtkPV3Foam/vtkPV3FoamConvertMesh.C | 162 +++++++++++-- .../vtkPV3Foam/vtkPV3FoamConvertPointFields.H | 138 ++++++----- .../vtkPV3Foam/vtkPV3FoamConvertVolFields.H | 145 ++++++------ .../vtkPV3Foam/vtkPV3FoamUpdateInformation.C | 10 +- .../vtkPV3FoamUpdateInformationFields.H | 11 +- 12 files changed, 628 insertions(+), 476 deletions(-) rename applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/{vtkPV3FoamUpdate.C => vtkPV3FoamConvertFields.C} (75%) diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.cxx b/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.cxx index 81885deee7..fc12c30b8a 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.cxx +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.cxx @@ -36,6 +36,7 @@ vtkCxxRevisionMacro(vtkPV3FoamReader, "$Revision: 1.5$"); vtkStandardNewMacro(vtkPV3FoamReader); +#undef EXPERIMENTAL_TIME_CACHING vtkPV3FoamReader::vtkPV3FoamReader() { @@ -47,7 +48,16 @@ vtkPV3FoamReader::vtkPV3FoamReader() FileName = NULL; foamData_ = NULL; - output1_ = NULL; + output0_ = NULL; + + // Add second output for the Lagrangian + this->SetNumberOfOutputPorts(2); + vtkMultiBlockDataSet *lagrangian; + lagrangian = vtkMultiBlockDataSet::New(); + lagrangian->ReleaseData(); + + this->GetExecutive()->SetOutputData(1, lagrangian); + lagrangian->Delete(); TimeStep = 0; TimeStepRange[0] = 0; @@ -60,8 +70,7 @@ vtkPV3FoamReader::vtkPV3FoamReader() IncludeZones = 0; ShowPatchNames = 0; - UpdateGUI = 1; - UpdateGUIOld = 1; + UpdateGUI = 0; RegionSelection = vtkDataArraySelection::New(); VolFieldSelection = vtkDataArraySelection::New(); @@ -114,6 +123,12 @@ vtkPV3FoamReader::~vtkPV3FoamReader() delete [] FileName; } + if (output0_) + { + output0_->Delete(); + } + + RegionSelection->RemoveObserver(this->SelectionObserver); VolFieldSelection->RemoveObserver(this->SelectionObserver); PointFieldSelection->RemoveObserver(this->SelectionObserver); @@ -149,22 +164,19 @@ int vtkPV3FoamReader::RequestInformation return 0; } - vtkInformation *outInfo = outputVector->GetInformationObject(0); + int nInfo = outputVector->GetNumberOfInformationObjects(); + + if (Foam::vtkPV3Foam::debug) + { + cout<<"RequestInformation with " << nInfo << " item(s)\n"; + for (int infoI = 0; infoI < nInfo; ++infoI) + { + outputVector->GetInformationObject(infoI)->Print(cout); + } + } if (!foamData_) { - vtkDebugMacro("RequestInformation: creating foamData_"); - vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::SafeDownCast - ( - outInfo->Get(vtkMultiBlockDataSet::DATA_OBJECT()) - ); - - if (Foam::vtkPV3Foam::debug) - { - cout<< "constructed vtkPV3Foam with output: "; - output->Print(cout); - } - foamData_ = new Foam::vtkPV3Foam(FileName, this); } else @@ -175,12 +187,17 @@ int vtkPV3FoamReader::RequestInformation int nTimeSteps = 0; double* timeSteps = foamData_->findTimes(nTimeSteps); - outInfo->Set - ( - vtkStreamingDemandDrivenPipeline::TIME_STEPS(), - timeSteps, - nTimeSteps - ); + + // set identical time steps for all ports + for (int infoI = 0; infoI < nInfo; ++infoI) + { + outputVector->GetInformationObject(infoI)->Set + ( + vtkStreamingDemandDrivenPipeline::TIME_STEPS(), + timeSteps, + nTimeSteps + ); + } double timeRange[2]; if (nTimeSteps) @@ -190,21 +207,25 @@ int vtkPV3FoamReader::RequestInformation if (Foam::vtkPV3Foam::debug > 1) { - cout<<"nTimeSteps " << nTimeSteps << "\n"; - cout<<"timeRange " << timeRange[0] << " to " << timeRange[1] << "\n"; + cout<<"nTimeSteps " << nTimeSteps << "\n" + <<"timeRange " << timeRange[0] << " to " << timeRange[1] + << "\n"; - for (int i = 0; i < nTimeSteps; ++i) + for (int timeI = 0; timeI < nTimeSteps; ++timeI) { - cout<< "step[" << i << "] = " << timeSteps[i] << "\n"; + cout<< "step[" << timeI << "] = " << timeSteps[timeI] << "\n"; } } - outInfo->Set - ( - vtkStreamingDemandDrivenPipeline::TIME_RANGE(), - timeRange, - 2 - ); + for (int infoI = 0; infoI < nInfo; ++infoI) + { + outputVector->GetInformationObject(infoI)->Set + ( + vtkStreamingDemandDrivenPipeline::TIME_RANGE(), + timeRange, + 2 + ); + } } delete timeSteps; @@ -229,75 +250,41 @@ int vtkPV3FoamReader::RequestData return 0; } + int nInfo = outputVector->GetNumberOfInformationObjects(); + if (Foam::vtkPV3Foam::debug) { - int nInfo = outputVector->GetNumberOfInformationObjects(); - cout<<"requestData with " << nInfo << " items\n"; - - for (int i = 0; i < nInfo; ++i) + cout<<"RequestData with " << nInfo << " item(s)\n"; + for (int infoI = 0; infoI < nInfo; ++infoI) { - vtkInformation *info = outputVector->GetInformationObject(i); - info->Print(cout); + outputVector->GetInformationObject(infoI)->Print(cout); } } - vtkInformation* outInfo = outputVector->GetInformationObject(0); + // take port0 as the lead for other outputs + vtkInformation *outInfo = outputVector->GetInformationObject(0); + vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::SafeDownCast ( - outInfo->Get(vtkMultiBlockDataSet::DATA_OBJECT()) + outInfo->Get + ( + vtkMultiBlockDataSet::DATA_OBJECT() + ) ); - if (Foam::vtkPV3Foam::debug) - { - vtkInformation* outputInfo = this->GetOutputPortInformation(0); - outputInfo->Print(cout); - vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::SafeDownCast + vtkMultiBlockDataSet* lagrangianOutput = vtkMultiBlockDataSet::SafeDownCast + ( + outputVector->GetInformationObject(1)->Get ( - outputInfo->Get(vtkMultiBlockDataSet::DATA_OBJECT()) - ); - if (output) - { - output->Print(cout); - } - else - { - cout<< "no output\n"; - } - - vtkInformation* execInfo = this->GetExecutive()->GetOutputInformation(0); - execInfo->Print(cout); - - outInfo->Print(cout); - - vtkMultiBlockDataSet* dobj = vtkMultiBlockDataSet::SafeDownCast - ( - outInfo->Get(vtkMultiBlockDataSet::DATA_OBJECT()) - ); - if (dobj) - { - dobj->Print(cout); - - vtkInformation* dobjInfo = dobj->GetInformation(); - dobjInfo->Print(cout); - } - else - { - cout<< "no data_object\n"; - } - } + vtkMultiBlockDataSet::DATA_OBJECT() + ) + ); if (outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS())) { - if (Foam::vtkPV3Foam::debug) - { - cout<<"Has UPDATE_TIME_STEPS\n"; - cout<<"output->GetNumberOfBlocks() = " - << output->GetNumberOfBlocks() << "\n"; - } - // Get the requested time step. - // We only supprt requests of a single time step + // We only support requests for a single time step int nRequestedTimeSteps = outInfo->Length ( vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS() @@ -313,24 +300,56 @@ int vtkPV3FoamReader::RequestData } } - if - ( - (UpdateGUIOld == GetUpdateGUI()) - || (output->GetNumberOfBlocks() == 0) - ) + if (Foam::vtkPV3Foam::debug) + { + cout<< "update output with " + << output->GetNumberOfBlocks() << " blocks\n"; + } + +#ifdef EXPERIMENTAL_TIME_CACHING + bool needsUpdate = false; + + if (!output0_) + { + output0_ = vtkMultiBlockDataSet::New(); + needsUpdate = true; + } + + // This experimental bit of code seems to work for the geometry, + // but trashes the fields and still triggers the GeometryFilter + if (needsUpdate) { foamData_->Update(output); + output0_->ShallowCopy(output); + } + else + { + output->ShallowCopy(output0_); + } - if (ShowPatchNames == 1) + if (Foam::vtkPV3Foam::debug) + { + if (needsUpdate) { - addPatchNamesToView(); + cout<< "full UPDATE ---------\n"; } else { - removePatchNamesFromView(); + cout<< "cached UPDATE ---------\n"; } + + cout<< "UPDATED output: "; + output->Print(cout); + + cout<< "UPDATED output0_: "; + output0_->Print(cout); } - UpdateGUIOld = GetUpdateGUI(); + +#else + + foamData_->Update(output, lagrangianOutput); + +#endif return 1; } @@ -597,4 +616,19 @@ void vtkPV3FoamReader::SelectionModified() Modified(); } + +int vtkPV3FoamReader::FillOutputPortInformation +( + int port, + vtkInformation* info +) +{ + if (port == 0) + { + return this->Superclass::FillOutputPortInformation(port, info); + } + info->Set(vtkDataObject::DATA_TYPE_NAME(), "vtkMultiBlockDataSet"); + return 1; +} + // ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.h b/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.h index 8611884b51..77985be212 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.h +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.h @@ -157,11 +157,12 @@ protected: vtkInformationVector* ); + virtual int FillOutputPortInformation(int, vtkInformation*); + // The observer to modify this object when the array selections // are modified vtkCallbackCommand* SelectionObserver; - private: vtkPV3FoamReader(const vtkPV3FoamReader&); // Not implemented. @@ -183,16 +184,16 @@ private: int IncludeZones; int ShowPatchNames; + //- Dummy variable/switch for provoking a reader update int UpdateGUI; - int UpdateGUIOld; vtkDataArraySelection* RegionSelection; vtkDataArraySelection* VolFieldSelection; vtkDataArraySelection* PointFieldSelection; vtkDataArraySelection* LagrangianFieldSelection; - //- Access to the output port1 - vtkMultiBlockDataSet* output1_; + //- Cached data for output port0 + vtkMultiBlockDataSet* output0_; //BTX Foam::vtkPV3Foam* foamData_; diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/Make/files b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/Make/files index 0a5e64ddf1..8fb98bc9ad 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/Make/files +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/Make/files @@ -4,8 +4,8 @@ vtkPV3FoamAddLagrangianMesh.C vtkPV3FoamAddPatchMesh.C vtkPV3FoamAddZoneMesh.C vtkPV3FoamAddSetMesh.C -vtkPV3FoamUpdate.C vtkPV3FoamUpdateInformation.C vtkPV3FoamConvertMesh.C +vtkPV3FoamConvertFields.C LIB = $(FOAM_LIBBIN)/libvtkPV3Foam diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C index 8af700450c..2d6e5756ce 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C @@ -213,6 +213,8 @@ bool Foam::vtkPV3Foam::setTime(const double& requestedTime) if (meshPtr_->readUpdate() != polyMesh::UNCHANGED) { meshChanged_ = true; + reader_->UpdateProgress(0.05); + // patches, zones etc might have changed UpdateInformation(); } @@ -464,15 +466,15 @@ Foam::vtkPV3Foam::vtkPV3Foam reader_(reader), dbPtr_(NULL), meshPtr_(NULL), - selectInfoVolume_(VOLUME, "unzoned"), - selectInfoPatches_(PATCHES, "patches"), - selectInfoLagrangian_(LAGRANGIAN, "lagrangian"), - selectInfoCellZones_(CELLZONE, "cellZone"), - selectInfoFaceZones_(FACEZONE, "faceZone"), - selectInfoPointZones_(POINTZONE, "pointZone"), - selectInfoCellSets_(CELLSET, "cellSet"), - selectInfoFaceSets_(FACESET, "faceSet"), - selectInfoPointSets_(POINTSET, "pointSet"), + selectInfoVolume_("unzoned"), + selectInfoPatches_("patches"), + selectInfoLagrangian_("lagrangian"), + selectInfoCellZones_("cellZone"), + selectInfoFaceZones_("faceZone"), + selectInfoPointZones_("pointZone"), + selectInfoCellSets_("cellSet"), + selectInfoFaceSets_("faceSet"), + selectInfoPointSets_("pointSet"), patchTextActorsPtrs_(0), nMesh_(0), timeIndex_(-1), @@ -543,11 +545,7 @@ Foam::vtkPV3Foam::~vtkPV3Foam() Info<< " Foam::vtkPV3Foam::~vtkPV3Foam" << endl; } - if (meshPtr_) - { - delete meshPtr_; - meshPtr_ = NULL; - } + delete meshPtr_; } @@ -575,10 +573,11 @@ void Foam::vtkPV3Foam::UpdateInformation() } else { - // preserve the currently selected values + // preserve the enabled selections selectedEntries = getSelectedArrayEntries ( - arraySelection + arraySelection, + false ); } @@ -600,7 +599,7 @@ void Foam::vtkPV3Foam::UpdateInformation() updateInformationZones(); } - // restore the currently enabled values + // restore the enabled selections setSelectedArrayEntries ( arraySelection, @@ -635,23 +634,72 @@ void Foam::vtkPV3Foam::UpdateInformation() } +void Foam::vtkPV3Foam::updateFoamMesh() +{ + if (debug) + { + Info<< " Foam::vtkPV3Foam::updateFoamMesh" << endl; + printMemory(); + } + + if (!reader_->GetCacheMesh()) + { + delete meshPtr_; + meshPtr_ = NULL; + } + + // Check to see if the FOAM mesh has been created + if (!meshPtr_) + { + if (debug) + { + Info<< "Creating Foam mesh" << endl; + } + meshPtr_ = new fvMesh + ( + IOobject + ( + fvMesh::defaultRegion, + dbPtr_().timeName(), + dbPtr_() + ) + ); + + meshChanged_ = true; + } + else + { + if (debug) + { + Info<< "Using existing Foam mesh" << endl; + } + } + + if (debug) + { + Info<< " Foam::vtkPV3Foam::updateFoamMesh" << endl; + printMemory(); + } +} + + void Foam::vtkPV3Foam::Update ( - vtkMultiBlockDataSet* output + vtkMultiBlockDataSet* output, + vtkMultiBlockDataSet* lagrangianOutput ) { if (debug) { - cout<< " Foam::vtkPV3Foam::Update" << nl - <<"Update\n"; - output->Print(cout); + cout<< " Foam::vtkPV3Foam::Update - output with " + << output->GetNumberOfBlocks() << " and " + << lagrangianOutput->GetNumberOfBlocks() << " blocks\n"; - cout<<"Internally:\n"; output->Print(cout); - - cout<< " has " << output->GetNumberOfBlocks() << " blocks\n"; + lagrangianOutput->Print(cout); printMemory(); } + reader_->UpdateProgress(0.1); // Set up region selection(s) updateSelectedRegions(); @@ -661,65 +709,37 @@ void Foam::vtkPV3Foam::Update reader_->UpdateProgress(0.2); // Convert meshes - convertMeshVolume(output); - convertMeshLagrangian(output); - convertMeshPatches(output); + int blockNo = 0; + + convertMeshVolume(output, blockNo); + convertMeshPatches(output, blockNo); reader_->UpdateProgress(0.4); if (reader_->GetIncludeZones()) { - convertMeshCellZones(output); - convertMeshFaceZones(output); - convertMeshPointZones(output); + convertMeshCellZones(output, blockNo); + convertMeshFaceZones(output, blockNo); + convertMeshPointZones(output, blockNo); } if (reader_->GetIncludeSets()) { - convertMeshCellSets(output); - convertMeshFaceSets(output); - convertMeshPointSets(output); + convertMeshCellSets(output, blockNo); + convertMeshFaceSets(output, blockNo); + convertMeshPointSets(output, blockNo); } + + blockNo = 0; + convertMeshLagrangian(lagrangianOutput, blockNo); + reader_->UpdateProgress(0.8); // Update fields - updateVolFields(output); - updatePointFields(output); - updateLagrangianFields(output); + convertVolFields(output); + convertPointFields(output); + convertLagrangianFields(lagrangianOutput); reader_->UpdateProgress(1.0); - if (debug) - { - Info<< "Number of data sets after update" << nl - << " VOLUME = " - << GetNumberOfDataSets(output, selectInfoVolume_) << nl - << " PATCHES = " - << GetNumberOfDataSets(output, selectInfoPatches_) << nl - << " LAGRANGIAN = " - << GetNumberOfDataSets(output, selectInfoLagrangian_) << nl - << " CELLZONE = " - << GetNumberOfDataSets(output, selectInfoCellZones_) << nl - << " FACEZONE = " - << GetNumberOfDataSets(output, selectInfoFaceZones_) << nl - << " POINTZONE = " - << GetNumberOfDataSets(output, selectInfoPointZones_) << nl - << " CELLSET = " - << GetNumberOfDataSets(output, selectInfoCellSets_) << nl - << " FACESET = " - << GetNumberOfDataSets(output, selectInfoFaceSets_) << nl - << " POINTSET = " - << GetNumberOfDataSets(output, selectInfoPointSets_) << nl; - - // traverse blocks: - cout<< "nBlocks = " << output->GetNumberOfBlocks() << "\n"; - cout<< "done Update\n"; - output->Print(cout); - cout<< " has " << output->GetNumberOfBlocks() << " blocks\n"; - output->GetInformation()->Print(cout); - - cout<<"ShouldIReleaseData :" << output->ShouldIReleaseData() << "\n"; - printMemory(); - } - meshChanged_ = fieldsChanged_ = false; } @@ -778,15 +798,11 @@ void Foam::vtkPV3Foam::addPatchNames(vtkRenderer* renderer) Info<< " Foam::vtkPV3Foam::addPatchNames" << endl; } - const polyBoundaryMesh& pbMesh = meshPtr_->boundaryMesh(); - - const selectionInfo& selector = selectInfoPatches_; - - // the currently selected patches, strip off any suffix + // get the display patches, strip off any suffix const stringList selectedPatches = getSelectedArrayEntries ( reader_->GetRegionSelection(), - selector, + selectInfoPatches_, true ); @@ -795,9 +811,15 @@ void Foam::vtkPV3Foam::addPatchNames(vtkRenderer* renderer) Info<<"... add patches: " << selectedPatches << endl; } + if (!selectedPatches.size()) + { + return; + } + + const polyBoundaryMesh& pbMesh = meshPtr_->boundaryMesh(); + // Find the total number of zones // Each zone will take the patch name - // Number of zones per patch ... zero zones should be skipped labelList nZones(pbMesh.size(), 0); @@ -948,7 +970,7 @@ void Foam::vtkPV3Foam::addPatchNames(vtkRenderer* renderer) if (debug) { - Info<< " Foam::vtkPV3Foam::addPatchNames)" << endl; + Info<< " Foam::vtkPV3Foam::addPatchNames" << endl; } } @@ -965,7 +987,7 @@ void Foam::vtkPV3Foam::removePatchNames(vtkRenderer* renderer) renderer->RemoveViewProp(patchTextActorsPtrs_[patchI]); patchTextActorsPtrs_[patchI]->Delete(); } - patchTextActorsPtrs_.setSize(0); + patchTextActorsPtrs_.clear(); } diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H index 0fbed64bfa..f78ba346b4 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H @@ -38,6 +38,7 @@ SourceFiles vtkPV3FoamAddToSelection.H vtkPV3FoamAddVolumeMesh.C vtkPV3FoamAddZoneMesh.C + vtkPV3FoamConvertFields.C vtkPV3FoamConvertFaceField.H vtkPV3FoamConvertLagrangianFields.H vtkPV3FoamConvertMesh.C @@ -46,7 +47,6 @@ SourceFiles vtkPV3FoamConvertPointFields.H vtkPV3FoamConvertVolFields.H vtkPV3FoamInsertNextPoint.H - vtkPV3FoamUpdate.C vtkPV3FoamUpdateInformation.C vtkPV3FoamUpdateInformationFields.H @@ -111,17 +111,17 @@ public: //- bookkeeping for the GUI checklists and the multi-block organization class selectionInfo { - int block_; const char *name_; + int block_; int start_; int size_; public: - selectionInfo(const int blockNo, const char *name) + selectionInfo(const char *name, const int blockNo=0) : - block_(blockNo), name_(name), + block_(blockNo), start_(-1), size_(0) {} @@ -132,6 +132,13 @@ public: return block_; } + int block(int blockNo) + { + int prev = block_; + block_ = blockNo; + return prev; + } + const char* name() const { return name_; @@ -170,6 +177,15 @@ public: { size_ += n; } + + friend Ostream& operator<<(Ostream& os, const selectionInfo& s) + { + os << "selector: " << s.name_ + << " (block " << s.block_ << ") " + << " = " << s.start_ << " + " << s.size_; + return os; + } + }; @@ -177,22 +193,6 @@ private: // Private data - //BTX - //- Indices for datasets in vtkMultiBlockDataSet - enum - { - VOLUME = 0, // internal mesh - PATCHES = 1, // patches - LAGRANGIAN = 2, - CELLZONE = 3, - FACEZONE = 4, - POINTZONE = 5, - CELLSET = 6, - FACESET = 7, - POINTSET = 8 - }; - //ETX - //- Access to the controlling vtkPV3FoamReader vtkPV3FoamReader* reader_; @@ -270,7 +270,7 @@ private: const selectionInfo&, const label datasetNo, vtkDataSet* dataset, - const string& blockName = string::null + const string& blockName=string::null ); // Convenience method use to convert the readers from VTK 5 @@ -322,7 +322,7 @@ private: ( vtkDataArraySelection *arraySelection, const IOobjectList&, - const string& suffix = "" + const string& suffix=string::null ); //- Field info @@ -342,43 +342,43 @@ private: void updateFoamMesh(); //- Volume fields - void updateVolFields(vtkMultiBlockDataSet* output); + void updateVolFields(vtkMultiBlockDataSet*); //- Point fields - void updatePointFields(vtkMultiBlockDataSet* output); + void updatePointFields(vtkMultiBlockDataSet*); //- Lagrangian fields - void updateLagrangianFields(vtkMultiBlockDataSet* output); + void updateLagrangianFields(vtkMultiBlockDataSet*); // Mesh conversion functions //- Volume mesh - void convertMeshVolume(vtkMultiBlockDataSet* output); + void convertMeshVolume(vtkMultiBlockDataSet*, int& blockNo); //- Lagrangian mesh - void convertMeshLagrangian(vtkMultiBlockDataSet* output); + void convertMeshLagrangian(vtkMultiBlockDataSet*, int& blockNo); //- Patch meshes - void convertMeshPatches(vtkMultiBlockDataSet* output); + void convertMeshPatches(vtkMultiBlockDataSet*, int& blockNo); //- Cell zone meshes - void convertMeshCellZones(vtkMultiBlockDataSet* output); + void convertMeshCellZones(vtkMultiBlockDataSet*, int& blockNo); //- Face zone meshes - void convertMeshFaceZones(vtkMultiBlockDataSet* output); + void convertMeshFaceZones(vtkMultiBlockDataSet*, int& blockNo); //- Point zone meshes - void convertMeshPointZones(vtkMultiBlockDataSet* output); + void convertMeshPointZones(vtkMultiBlockDataSet*, int& blockNo); //- Cell set meshes - void convertMeshCellSets(vtkMultiBlockDataSet* output); + void convertMeshCellSets(vtkMultiBlockDataSet*, int& blockNo); //- Face set meshes - void convertMeshFaceSets(vtkMultiBlockDataSet* output); + void convertMeshFaceSets(vtkMultiBlockDataSet*, int& blockNo); //- Point set meshes - void convertMeshPointSets(vtkMultiBlockDataSet* output); + void convertMeshPointSets(vtkMultiBlockDataSet*, int& blockNo); // Add mesh functions @@ -444,6 +444,17 @@ private: vtkPolyData* ); + // Field conversion functions + + //- Convert volume fields + void convertVolFields(vtkMultiBlockDataSet*); + + //- Convert point fields + void convertPointFields(vtkMultiBlockDataSet*); + + //- Convert Lagrangian fields + void convertLagrangianFields(vtkMultiBlockDataSet*); + //- Add the fields in the selected time directory to the selection // lists @@ -452,7 +463,7 @@ private: ( vtkDataArraySelection* fieldSelection, const IOobjectList& objects, - const string& suffix = string::null + const string& suffix=string::null ); @@ -578,7 +589,7 @@ private: static stringList getSelectedArrayEntries ( vtkDataArraySelection* arraySelection, - const bool firstWord = false + const bool firstWord=false ); //- Store the current selection(s) for a sub-selection @@ -586,7 +597,7 @@ private: ( vtkDataArraySelection* arraySelection, const selectionInfo&, - const bool firstWord = false + const bool firstWord=false ); //- Set selection(s) @@ -631,7 +642,11 @@ public: //- Update void UpdateInformation(); - void Update(vtkMultiBlockDataSet* output); + void Update + ( + vtkMultiBlockDataSet* output, + vtkMultiBlockDataSet* lagrangianOutput + ); //- Allocate and return a list of selected times // returns the count via the parameter diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdate.C b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertFields.C similarity index 75% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdate.C rename to applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertFields.C index 8f4a83c43f..543fc63eb0 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdate.C +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertFields.C @@ -43,63 +43,15 @@ Description #include "vtkPV3FoamConvertPointFields.H" #include "vtkPV3FoamConvertLagrangianFields.H" -void Foam::vtkPV3Foam::updateFoamMesh() -{ - if (debug) - { - Info<< " Foam::vtkPV3Foam::updateFoamMesh" << endl; - printMemory(); - } - if (!reader_->GetCacheMesh()) - { - delete meshPtr_; - meshPtr_ = NULL; - } - - // Check to see if the FOAM mesh has been created - if (!meshPtr_) - { - if (debug) - { - Info<< "Creating Foam mesh" << endl; - } - meshPtr_ = new fvMesh - ( - IOobject - ( - fvMesh::defaultRegion, - dbPtr_().timeName(), - dbPtr_() - ) - ); - - meshChanged_ = true; - } - else - { - if (debug) - { - Info<< "Using existing Foam mesh" << endl; - } - } - - if (debug) - { - Info<< " Foam::vtkPV3Foam::updateFoamMesh" << endl; - printMemory(); - } -} - - -void Foam::vtkPV3Foam::updateVolFields +void Foam::vtkPV3Foam::convertVolFields ( vtkMultiBlockDataSet* output ) { if (debug) { - Info<< " Foam::vtkPV3Foam::updateVolFields" << endl; + Info<< " Foam::vtkPV3Foam::convertVolFields" << endl; printMemory(); } @@ -135,12 +87,7 @@ void Foam::vtkPV3Foam::updateVolFields ) ); } -/* - convertVolFields - ( - mesh, pInterp, objects, arraySelection, output - ); -*/ + convertVolFields ( mesh, pInterp, ppInterpList, objects, arraySelection, output @@ -164,20 +111,20 @@ void Foam::vtkPV3Foam::updateVolFields if (debug) { - Info<< " Foam::vtkPV3Foam::updateVolFields" << endl; + Info<< " Foam::vtkPV3Foam::convertVolFields" << endl; printMemory(); } } -void Foam::vtkPV3Foam::updatePointFields +void Foam::vtkPV3Foam::convertPointFields ( vtkMultiBlockDataSet* output ) { if (debug) { - Info<< " Foam::vtkPV3Foam::updatePointFields" << endl; + Info<< " Foam::vtkPV3Foam::convertPointFields" << endl; printMemory(); } @@ -188,12 +135,6 @@ void Foam::vtkPV3Foam::updatePointFields vtkDataArraySelection* arraySelection = reader_->GetPointFieldSelection(); -/* - convertPointFields - ( - mesh, objects, arraySelection, output - ); -*/ convertPointFields ( mesh, objects, arraySelection, output @@ -217,20 +158,20 @@ void Foam::vtkPV3Foam::updatePointFields if (debug) { - Info<< " Foam::vtkPV3Foam::updatePointFields" << endl; + Info<< " Foam::vtkPV3Foam::convertPointFields" << endl; printMemory(); } } -void Foam::vtkPV3Foam::updateLagrangianFields +void Foam::vtkPV3Foam::convertLagrangianFields ( vtkMultiBlockDataSet* output ) { if (debug) { - Info<< " Foam::vtkPV3Foam::updateLagrangianFields" << endl; + Info<< " Foam::vtkPV3Foam::convertLagrangianFields" << endl; printMemory(); } @@ -251,7 +192,8 @@ void Foam::vtkPV3Foam::updateLagrangianFields // Convert Lagrangian fields if (debug) { - Info<< "converting Foam Lagrangian fields" << endl; + Info<< "converting Lagrangian fields - " + << selectInfoLagrangian_ << endl; } convertLagrangianFields @@ -282,7 +224,7 @@ void Foam::vtkPV3Foam::updateLagrangianFields if (debug) { - Info<< " Foam::vtkPV3Foam::updateLagrangianFields" << endl; + Info<< " Foam::vtkPV3Foam::convertLagrangianFields" << endl; printMemory(); } } diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertLagrangianFields.H b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertLagrangianFields.H index 0ccc3f81a0..b77fadaa9d 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertLagrangianFields.H +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertLagrangianFields.H @@ -42,12 +42,6 @@ void Foam::vtkPV3Foam::convertLagrangianFields ) { const selectionInfo& selector = selectInfoLagrangian_; - const label datasetId = 0; - - if (!selector.size()) - { - return; - } IOobjectList fieldObjects ( @@ -58,28 +52,46 @@ void Foam::vtkPV3Foam::convertLagrangianFields ); label nFields = fieldSelection->GetNumberOfArrays(); - for (label i=0; iGetArraySetting(i)) + const word fieldName = fieldSelection->GetArrayName(i); + + if + ( + !fieldSelection->GetArraySetting(i) + || !fieldObjects.found(fieldName)) { - const word fieldName = fieldSelection->GetArrayName(i); + continue; + } - if (fieldObjects.found(fieldName)) + IOField iotf + ( + IOobject + ( + fieldName, + mesh.time().timeName(), + "lagrangian"/cloudName_, + mesh, + IOobject::MUST_READ + ) + ); + + + // Convert Lagrangian points + for + ( + int regionId = selector.start(); + regionId < selector.end(); + ++regionId + ) + { + if (selectedRegions_[regionId]) { - IOField iotf + convertLagrangianField ( - IOobject - ( - fieldName, - mesh.time().timeName(), - "lagrangian"/cloudName_, - mesh, - IOobject::MUST_READ - ) + iotf, output, selector, + selectedRegionDatasetIds_[regionId] ); - - convertLagrangianField(iotf, output, selector, datasetId); } } } diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertMesh.C b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertMesh.C index 33b5891f04..acd0ed5f03 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertMesh.C +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertMesh.C @@ -45,7 +45,8 @@ Description void Foam::vtkPV3Foam::convertMeshVolume ( - vtkMultiBlockDataSet* output + vtkMultiBlockDataSet* output, + int& blockNo ) { if (debug) @@ -54,8 +55,12 @@ void Foam::vtkPV3Foam::convertMeshVolume printMemory(); } - const selectionInfo& selector = selectInfoVolume_; const fvMesh& mesh = *meshPtr_; + selectionInfo& selector = selectInfoVolume_; + + // set output block and note if anything was added + selector.block(blockNo); + bool created = false; // Create the internal mesh and add as dataset 0 for @@ -88,6 +93,13 @@ void Foam::vtkPV3Foam::convertMeshVolume AddToBlock(output, selector, datasetId, vtkmesh, "internalMesh"); selectedRegionDatasetIds_[regionId] = datasetId; vtkmesh->Delete(); + + created = true; + } + + if (created) + { + ++blockNo; } if (debug) @@ -100,7 +112,8 @@ void Foam::vtkPV3Foam::convertMeshVolume void Foam::vtkPV3Foam::convertMeshLagrangian ( - vtkMultiBlockDataSet* output + vtkMultiBlockDataSet* output, + int& blockNo ) { if (debug) @@ -109,10 +122,14 @@ void Foam::vtkPV3Foam::convertMeshLagrangian printMemory(); } - const selectionInfo& selector = selectInfoLagrangian_; const fvMesh& mesh = *meshPtr_; + selectionInfo& selector = selectInfoLagrangian_; - // Create the Lagrangian mesh and add as dataset 0 + // set output block and note if anything was added + selector.block(blockNo); + bool created = false; + + // Create a single Lagrangian mesh and add as dataset 0 for ( int regionId = selector.start(); @@ -138,7 +155,15 @@ void Foam::vtkPV3Foam::convertMeshLagrangian AddToBlock(output, selector, datasetId, vtkmesh, cloudName_); selectedRegionDatasetIds_[regionId] = datasetId; vtkmesh->Delete(); + + created = true; } + + if (created) + { + ++blockNo; + } + if (debug) { Info<< " Foam::vtkPV3Foam::convertMeshLagrangian" << endl; @@ -149,7 +174,8 @@ void Foam::vtkPV3Foam::convertMeshLagrangian void Foam::vtkPV3Foam::convertMeshPatches ( - vtkMultiBlockDataSet* output + vtkMultiBlockDataSet* output, + int& blockNo ) { if (debug) @@ -158,12 +184,16 @@ void Foam::vtkPV3Foam::convertMeshPatches printMemory(); } - const selectionInfo& selector = selectInfoPatches_; + const fvMesh& mesh = *meshPtr_; + selectionInfo& selector = selectInfoPatches_; vtkDataArraySelection* arraySelection = reader_->GetRegionSelection(); + // set output block and note if anything was added + selector.block(blockNo); + bool created = false; + if (selector.size()) { - const fvMesh& mesh = *meshPtr_; const polyBoundaryMesh& patches = mesh.boundaryMesh(); // Create the patches and add as dataset ... @@ -208,9 +238,18 @@ void Foam::vtkPV3Foam::convertMeshPatches ); selectedRegionDatasetIds_[regionId] = datasetId; vtkmesh->Delete(); + + created = true; } } + if (created) + { + ++blockNo; + } + + + if (debug) { Info<< " Foam::vtkPV3Foam::convertMeshPatches" << endl; @@ -221,7 +260,8 @@ void Foam::vtkPV3Foam::convertMeshPatches void Foam::vtkPV3Foam::convertMeshCellZones ( - vtkMultiBlockDataSet* output + vtkMultiBlockDataSet* output, + int& blockNo ) { if (debug) @@ -230,8 +270,12 @@ void Foam::vtkPV3Foam::convertMeshCellZones printMemory(); } - const selectionInfo& selector = selectInfoCellZones_; const fvMesh& mesh = *meshPtr_; + selectionInfo& selector = selectInfoCellZones_; + + // set output block and note if anything was added + selector.block(blockNo); + bool created = false; // Create the cell zone(s) and add as DataSet(CELLZONE, 0..n) if (selector.size()) @@ -282,9 +326,16 @@ void Foam::vtkPV3Foam::convertMeshCellZones ); selectedRegionDatasetIds_[regionId] = datasetId; vtkmesh->Delete(); + + created = true; } } + if (created) + { + ++blockNo; + } + if (debug) { Info<< " Foam::vtkPV3Foam::convertMeshCellZones" << endl; @@ -295,7 +346,8 @@ void Foam::vtkPV3Foam::convertMeshCellZones void Foam::vtkPV3Foam::convertMeshCellSets ( - vtkMultiBlockDataSet* output + vtkMultiBlockDataSet* output, + int& blockNo ) { if (debug) @@ -304,14 +356,17 @@ void Foam::vtkPV3Foam::convertMeshCellSets printMemory(); } - const selectionInfo& selector = selectInfoCellSets_; + const fvMesh& mesh = *meshPtr_; + selectionInfo& selector = selectInfoCellSets_; vtkDataArraySelection* arraySelection = reader_->GetRegionSelection(); + // set output block and note if anything was added + selector.block(blockNo); + bool created = false; + // Create the cell sets and add as dataset if (selector.size()) { - const fvMesh& mesh = *meshPtr_; - for ( int regionId = selector.start(); @@ -363,9 +418,16 @@ void Foam::vtkPV3Foam::convertMeshCellSets ); selectedRegionDatasetIds_[regionId] = datasetId; vtkmesh->Delete(); + + created = true; } } + if (created) + { + ++blockNo; + } + if (debug) { Info<< " Foam::vtkPV3Foam::convertMeshCellSets" << endl; @@ -376,7 +438,8 @@ void Foam::vtkPV3Foam::convertMeshCellSets void Foam::vtkPV3Foam::convertMeshFaceZones ( - vtkMultiBlockDataSet* output + vtkMultiBlockDataSet* output, + int& blockNo ) { if (debug) @@ -385,8 +448,12 @@ void Foam::vtkPV3Foam::convertMeshFaceZones printMemory(); } - const selectionInfo& selector = selectInfoFaceZones_; const fvMesh& mesh = *meshPtr_; + selectionInfo& selector = selectInfoFaceZones_; + + // set output block and note if anything was added + selector.block(blockNo); + bool created = false; // Create the cell zone(s) and add as datasets if (selector.size()) @@ -427,9 +494,17 @@ void Foam::vtkPV3Foam::convertMeshFaceZones ); selectedRegionDatasetIds_[regionId] = datasetId; vtkmesh->Delete(); + + created = true; } } + + if (created) + { + ++blockNo; + } + if (debug) { Info<< " Foam::vtkPV3Foam::convertMeshFaceZones" << endl; @@ -440,7 +515,8 @@ void Foam::vtkPV3Foam::convertMeshFaceZones void Foam::vtkPV3Foam::convertMeshFaceSets ( - vtkMultiBlockDataSet* output + vtkMultiBlockDataSet* output, + int& blockNo ) { if (debug) @@ -449,14 +525,17 @@ void Foam::vtkPV3Foam::convertMeshFaceSets printMemory(); } - const selectionInfo& selector = selectInfoFaceSets_; + const fvMesh& mesh = *meshPtr_; + selectionInfo& selector = selectInfoFaceSets_; vtkDataArraySelection* arraySelection = reader_->GetRegionSelection(); + // set output block and note if anything was added + selector.block(blockNo); + bool created = false; + // Create the face sets and add as dataset if (selector.size()) { - const fvMesh& mesh = *meshPtr_; - for ( int regionId = selector.start(); @@ -499,9 +578,16 @@ void Foam::vtkPV3Foam::convertMeshFaceSets ); selectedRegionDatasetIds_[regionId] = datasetId; vtkmesh->Delete(); + + created = true; } } + if (created) + { + ++blockNo; + } + if (debug) { Info<< " Foam::vtkPV3Foam::convertMeshFaceSets" << endl; @@ -512,7 +598,8 @@ void Foam::vtkPV3Foam::convertMeshFaceSets void Foam::vtkPV3Foam::convertMeshPointZones ( - vtkMultiBlockDataSet* output + vtkMultiBlockDataSet* output, + int& blockNo ) { if (debug) @@ -521,8 +608,12 @@ void Foam::vtkPV3Foam::convertMeshPointZones printMemory(); } - const selectionInfo& selector = selectInfoPointZones_; const fvMesh& mesh = *meshPtr_; + selectionInfo& selector = selectInfoPointZones_; + + // set output block and note if anything was added + selector.block(blockNo); + bool created = false; // Create the point sets and add as dataset if (selector.size()) @@ -563,9 +654,17 @@ void Foam::vtkPV3Foam::convertMeshPointZones ); selectedRegionDatasetIds_[regionId] = datasetId; vtkmesh->Delete(); + + created = true; } } + if (created) + { + ++blockNo; + } + + if (debug) { Info<< " Foam::vtkPV3Foam::convertMeshPointZones" << endl; @@ -577,7 +676,8 @@ void Foam::vtkPV3Foam::convertMeshPointZones void Foam::vtkPV3Foam::convertMeshPointSets ( - vtkMultiBlockDataSet* output + vtkMultiBlockDataSet* output, + int& blockNo ) { if (debug) @@ -586,14 +686,17 @@ void Foam::vtkPV3Foam::convertMeshPointSets printMemory(); } - const selectionInfo& selector = selectInfoPointSets_; + const fvMesh& mesh = *meshPtr_; + selectionInfo& selector = selectInfoPointSets_; vtkDataArraySelection* arraySelection = reader_->GetRegionSelection(); + // set output block and note if anything was added + selector.block(blockNo); + bool created = false; + // Create the point sets and add as dataset if (selector.size()) { - const fvMesh& mesh = *meshPtr_; - for ( int regionId = selector.start(); @@ -636,9 +739,16 @@ void Foam::vtkPV3Foam::convertMeshPointSets ); selectedRegionDatasetIds_[regionId] = datasetId; vtkmesh->Delete(); + + created = true; } } + if (created) + { + ++blockNo; + } + if (debug) { Info<< " Foam::vtkPV3Foam::convertMeshPointSets" << endl; diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertPointFields.H b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertPointFields.H index d26a0eb365..dbbe22d663 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertPointFields.H +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertPointFields.H @@ -52,81 +52,93 @@ void Foam::vtkPV3Foam::convertPointFields ) ); - label nSelectedFields = fieldSelection->GetNumberOfArrays(); + label nFields = fieldSelection->GetNumberOfArrays(); const polyBoundaryMesh& patches = mesh.boundaryMesh(); - for (label i=0; iGetArraySetting(i)) + const word fieldName = fieldSelection->GetArrayName(i); + + if + ( + !fieldSelection->GetArraySetting(i) + || !fieldObjects.found(fieldName)) { - word fieldName = fieldSelection->GetArrayName(i); + continue; + } - if (fieldObjects.found(fieldName)) + if (debug) + { + Info<< "Foam::vtkPV3Foam::convertPointFields : " + << fieldName << endl; + } + + pointMesh pMesh(mesh); + + GeometricField ptf + ( + IOobject + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::MUST_READ + ), + pMesh + ); + + + // + // Convert internal mesh - if activated + // + for + ( + int regionId = selectInfoVolume_.start(); + regionId < selectInfoVolume_.end(); + ++regionId + ) + { + const label datasetId = selectedRegionDatasetIds_[regionId]; + + if (!selectedRegions_[regionId] || datasetId < 0) { + continue; + } - if (debug) + convertPointField + ( + ptf, + GeometricField::null(), + output, + selectInfoVolume_, + datasetId + ); + } + + + // + // Convert patches - if activated + // + label regionId = selectInfoPatches_.start(); + forAll (patches, patchI) + { + if (patches[patchI].size()) + { + const label datasetId = selectedRegionDatasetIds_[regionId]; + + if (selectedRegions_[regionId] && datasetId >= 0) { - Info<< "Foam::vtkPV3Foam::convertPointFields : " << fieldName - << endl; - } - pointMesh pMesh(mesh); - - GeometricField ptf - ( - IOobject + convertPatchPointField ( fieldName, - mesh.time().timeName(), - mesh, - IOobject::MUST_READ - ), - pMesh - ); - - // Convert internal mesh - for - ( - int regionId = selectInfoVolume_.start(); - regionId < selectInfoVolume_.end(); - ++regionId - ) - { - if (selectedRegions_[regionId]) - { - convertPointField - ( - ptf, - GeometricField::null(), - output, - selectInfoVolume_, - selectedRegionDatasetIds_[regionId] - ); - } - } - - - // Convert patches - label regionId = selectInfoPatches_.start(); - forAll (patches, patchI) - { - if (patches[patchI].size()) - { - if (selectedRegions_[regionId]) - { - convertPatchPointField - ( - fieldName, - ptf.boundaryField()[patchI] - .patchInternalField()(), - output, - selectInfoPatches_, - selectedRegionDatasetIds_[regionId] - ); - } - regionId++; - } + ptf.boundaryField()[patchI].patchInternalField()(), + output, + selectInfoPatches_, + datasetId + ); } + regionId++; } } } diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertVolFields.H b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertVolFields.H index 7543f58c9c..7ed194bfa5 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertVolFields.H +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertVolFields.H @@ -78,8 +78,7 @@ void Foam::vtkPV3Foam::convertVolFields if (debug) { - Info<< "converting Foam volume field: " << fieldName - << endl; + Info<< "converting volume field: " << fieldName << endl; } GeometricField tf @@ -99,7 +98,10 @@ void Foam::vtkPV3Foam::convertVolFields pInterp.interpolate(tf) ); - // Convert internal mesh + + // + // Convert internal mesh - if activated + // for ( int regionId = selectInfoVolume_.start(); @@ -107,29 +109,34 @@ void Foam::vtkPV3Foam::convertVolFields ++regionId ) { - if (selectedRegions_[regionId]) + const label datasetId = selectedRegionDatasetIds_[regionId]; + + if (!selectedRegions_[regionId] || datasetId < 0) { - convertVolField - ( - tf, - output, - selectInfoVolume_, - selectedRegionDatasetIds_[regionId], - superCells_ - ); - convertPointField - ( - tptf(), - tf, - output, - selectInfoVolume_, - selectedRegionDatasetIds_[regionId] - ); + continue; } + + convertVolField + ( + tf, + output, + selectInfoVolume_, + datasetId, + superCells_ + ); + convertPointField + ( + tptf(), + tf, + output, + selectInfoVolume_, + datasetId + ); } - - // Convert patches + // + // Convert patches - if activated + // for ( int regionId = selectInfoPatches_.start(); @@ -137,7 +144,9 @@ void Foam::vtkPV3Foam::convertVolFields ++regionId ) { - if (!selectedRegions_[regionId]) + const label datasetId = selectedRegionDatasetIds_[regionId]; + + if (!selectedRegions_[regionId] || datasetId < 0) { continue; } @@ -176,7 +185,7 @@ void Foam::vtkPV3Foam::convertVolFields fvPatchField(p, tf).patchInternalField()(), output, selectInfoPatches_, - selectedRegionDatasetIds_[regionId] + datasetId ); } else @@ -187,7 +196,7 @@ void Foam::vtkPV3Foam::convertVolFields ptf, output, selectInfoPatches_, - selectedRegionDatasetIds_[regionId] + datasetId ); } @@ -197,11 +206,13 @@ void Foam::vtkPV3Foam::convertVolFields ppInterpList[patchId].faceToPointInterpolate(ptf)(), output, selectInfoPatches_, - selectedRegionDatasetIds_[regionId] + datasetId ); } - // Convert cell zones + // + // Convert cell zones - if activated + // for ( int regionId = selectInfoCellZones_.start(); @@ -209,37 +220,35 @@ void Foam::vtkPV3Foam::convertVolFields ++regionId ) { - if (!selectedRegions_[regionId]) + const label datasetId = selectedRegionDatasetIds_[regionId]; + + if (!selectedRegions_[regionId] || datasetId < 0) { continue; } if (debug) { - - word selectName = getFirstWord - ( - arraySelector->GetArrayName(regionId) - ); - - Info<< "wish to convert cellzone: " << selectName + Info<< "wish to convert cellzone: " + << getFirstWord(arraySelector->GetArrayName(regionId)) << " regionId: " << regionId << " volume field: " << fieldName << endl; } - const label datasetId = - selectedRegionDatasetIds_[regionId]; - convertVolField ( tf, - output, selectInfoCellZones_, datasetId, + output, + selectInfoCellZones_, + datasetId, zoneSuperCells_[datasetId] ); } - // Convert cell sets + // + // Convert cell sets - if activated + // for ( int regionId = selectInfoCellSets_.start(); @@ -247,36 +256,35 @@ void Foam::vtkPV3Foam::convertVolFields ++regionId ) { - if (!selectedRegions_[regionId]) + const label datasetId = selectedRegionDatasetIds_[regionId]; + + if (!selectedRegions_[regionId] || datasetId < 0) { continue; } if (debug) { - word selectName = getFirstWord - ( - arraySelector->GetArrayName(regionId) - ); - - Info<< "wish to convert cellset: " << selectName + Info<< "wish to convert cellset: " + << getFirstWord(arraySelector->GetArrayName(regionId)) << " regionId: " << regionId << " volume field: " << fieldName << endl; } - const label datasetId = - selectedRegionDatasetIds_[regionId]; - convertVolField ( tf, - output, selectInfoCellSets_, datasetId, + output, + selectInfoCellSets_, + datasetId, csetSuperCells_[datasetId] ); } - // Convert face zones + // + // Convert face zones - if activated + // for ( int regionId = selectInfoFaceZones_.start(); @@ -284,19 +292,17 @@ void Foam::vtkPV3Foam::convertVolFields ++regionId ) { - if (!selectedRegions_[regionId]) + const label datasetId = selectedRegionDatasetIds_[regionId]; + + if (!selectedRegions_[regionId] || datasetId < 0) { continue; } if (debug) { - word selectName = getFirstWord - ( - arraySelector->GetArrayName(regionId) - ); - - Info<< "wish to convert facezone: " << selectName + Info<< "wish to convert facezone: " + << getFirstWord(arraySelector->GetArrayName(regionId)) << " regionId: " << regionId << " volume field: " << fieldName << endl; @@ -305,19 +311,20 @@ void Foam::vtkPV3Foam::convertVolFields const faceZoneMesh& fzMesh = mesh.faceZones(); const label zoneI = regionId - selectInfoFaceZones_.start(); - const label datasetId = - selectedRegionDatasetIds_[regionId]; - convertFaceField ( tf, - output, selectInfoFaceZones_, datasetId, + output, + selectInfoFaceZones_, + datasetId, mesh, fzMesh[zoneI] ); } - // Convert face sets + // + // Convert face sets - if activated + // for ( int regionId = selectInfoFaceSets_.start(); @@ -325,7 +332,9 @@ void Foam::vtkPV3Foam::convertVolFields ++regionId ) { - if (!selectedRegions_[regionId]) + const label datasetId = selectedRegionDatasetIds_[regionId]; + + if (!selectedRegions_[regionId] || datasetId < 0) { continue; } @@ -345,13 +354,13 @@ void Foam::vtkPV3Foam::convertVolFields const faceSet fSet(mesh, selectName); - const label datasetId = - selectedRegionDatasetIds_[regionId]; convertFaceField ( tf, - output, selectInfoFaceSets_, datasetId, + output, + selectInfoFaceSets_, + datasetId, mesh, fSet ); diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInformation.C b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInformation.C index 031d8aad58..3f18047ced 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInformation.C +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInformation.C @@ -432,11 +432,13 @@ void Foam::vtkPV3Foam::updateInformationLagrangianFields() vtkDataArraySelection *arraySelection = reader_->GetLagrangianFieldSelection(); - // preserve the currently selected values - const stringList selectedEntries = getSelectedArrayEntries + // preserve the enabled selections + stringList selectedEntries = getSelectedArrayEntries ( - arraySelection + arraySelection, + true ); + arraySelection->RemoveAllArrays(); // TODO - currently hard-coded to ONE cloud @@ -478,7 +480,7 @@ void Foam::vtkPV3Foam::updateInformationLagrangianFields() objects ); - // restore the currently enabled values + // restore the enabled selections setSelectedArrayEntries ( arraySelection, diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInformationFields.H b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInformationFields.H index b9d7df9fa5..601a7f5326 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInformationFields.H +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInformationFields.H @@ -53,7 +53,7 @@ void Foam::vtkPV3Foam::updateInformationFields } else { - // preserve the currently selected values + // preserve the enabled selections selectedEntries = getSelectedArrayEntries ( arraySelection @@ -67,13 +67,6 @@ void Foam::vtkPV3Foam::updateInformationFields // Populate the GUI volume/point field arrays //- Add volume fields to GUI -/* - addToSelection > - ( - arraySelection, - objects - ); -*/ addToSelection > ( arraySelection, @@ -100,7 +93,7 @@ void Foam::vtkPV3Foam::updateInformationFields objects ); - // restore the currently enabled values + // restore the enabled selections setSelectedArrayEntries ( arraySelection, From 775ef2c843bdf5777ce16b64dbdc4bffb9f8dfc0 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Sat, 2 Aug 2008 16:05:22 +0200 Subject: [PATCH 3/5] PV3FoamReader improvements - various GUI properties are now animateable="0" (meaning they no longer show up on the time-line) - move reader switches to the bottom of the GUI - move Lagrangian fields above pointFields for better visibility - basic support for multiple clouds - filter fields based on selection before looping over all the geometry bits - mesh conversion functions now return VTK mesh types for easier handling - faceZones mesh conversion had points/faces allocation reversed - updateInfo with every call to setTime() that changes the timeIndex This seems to be the only way to notice Lagrangian fields - restore displaying patchnames that got forgotten in the last commit - misc reorganization --- .../PV3FoamReader/PV3FoamReader_SM.xml | 348 ++++++------ .../PV3FoamReader/vtkPV3FoamReader.cxx | 23 +- .../PV3FoamReader/vtkPV3FoamReader.h | 108 ++-- .../PV3FoamReader/vtkPV3Foam/Make/files | 16 +- .../PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C | 248 +++++---- .../PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H | 300 +++++------ .../vtkPV3Foam/vtkPV3FoamAddToSelection.H | 9 +- .../vtkPV3Foam/vtkPV3FoamConvertFields.C | 233 --------- .../vtkPV3FoamConvertLagrangianFields.H | 151 ------ ...nvertFaceField.H => vtkPV3FoamFaceField.H} | 43 +- .../vtkPV3Foam/vtkPV3FoamFields.C | 332 ++++++++++++ ...ntField.H => vtkPV3FoamLagrangianFields.H} | 62 ++- ...kPV3FoamConvertMesh.C => vtkPV3FoamMesh.C} | 494 +++++++++--------- ...ngianMesh.C => vtkPV3FoamMeshLagrangian.C} | 79 ++- ...amAddPatchMesh.C => vtkPV3FoamMeshPatch.C} | 23 +- ...V3FoamAddSetMesh.C => vtkPV3FoamMeshSet.C} | 40 +- ...AddVolumeMesh.C => vtkPV3FoamMeshVolume.C} | 66 +-- ...FoamAddZoneMesh.C => vtkPV3FoamMeshZone.C} | 45 +- ...atchFaceField.H => vtkPV3FoamPatchField.H} | 58 +- ...tPointFields.H => vtkPV3FoamPointFields.H} | 119 ++--- ...amInsertNextPoint.H => vtkPV3FoamPoints.H} | 32 +- ...teInformation.C => vtkPV3FoamUpdateInfo.C} | 227 ++++---- ...nFields.H => vtkPV3FoamUpdateInfoFields.H} | 36 +- ...nvertVolFields.H => vtkPV3FoamVolFields.H} | 201 ++++--- 24 files changed, 1660 insertions(+), 1633 deletions(-) delete mode 100644 applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertFields.C delete mode 100644 applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertLagrangianFields.H rename applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/{vtkPV3FoamConvertFaceField.H => vtkPV3FoamFaceField.H} (80%) create mode 100644 applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamFields.C rename applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/{vtkPV3FoamConvertPatchPointField.H => vtkPV3FoamLagrangianFields.H} (63%) rename applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/{vtkPV3FoamConvertMesh.C => vtkPV3FoamMesh.C} (50%) rename applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/{vtkPV3FoamAddLagrangianMesh.C => vtkPV3FoamMeshLagrangian.C} (55%) rename applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/{vtkPV3FoamAddPatchMesh.C => vtkPV3FoamMeshPatch.C} (84%) rename applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/{vtkPV3FoamAddSetMesh.C => vtkPV3FoamMeshSet.C} (80%) rename applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/{vtkPV3FoamAddVolumeMesh.C => vtkPV3FoamMeshVolume.C} (85%) rename applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/{vtkPV3FoamAddZoneMesh.C => vtkPV3FoamMeshZone.C} (76%) rename applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/{vtkPV3FoamConvertPatchFaceField.H => vtkPV3FoamPatchField.H} (63%) rename applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/{vtkPV3FoamConvertPointFields.H => vtkPV3FoamPointFields.H} (65%) rename applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/{vtkPV3FoamInsertNextPoint.H => vtkPV3FoamPoints.H} (72%) rename applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/{vtkPV3FoamUpdateInformation.C => vtkPV3FoamUpdateInfo.C} (61%) rename applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/{vtkPV3FoamUpdateInformationFields.H => vtkPV3FoamUpdateInfoFields.H} (78%) rename applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/{vtkPV3FoamConvertVolFields.H => vtkPV3FoamVolFields.H} (62%) diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/PV3FoamReader_SM.xml b/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/PV3FoamReader_SM.xml index 07620fd849..d522660cc4 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/PV3FoamReader_SM.xml +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/PV3FoamReader_SM.xml @@ -1,191 +1,189 @@ - - + - name="PV3FoamReader" - class="vtkPV3FoamReader"> + + + + + Specifies the filename for the OpenFOAM Reader + + - - - - + + + + + Available timestep values + + - + + + - - - - Available timestep values. - - + + + + + + + + + + + - - - + + + + + + + + + + + - - - - + + + + + + + + + + + - - - - + + + + + + + + + + + - - - - + + + + - - - - + + + + - - - - - - - - - - - + + + + - - - - - - - - - - - + + + + - - - - - - - - - - - + + + + - - - - - - - - - - - + + + + - - - - - - - - - - - - + + diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.cxx b/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.cxx index fc12c30b8a..2ad4f68cb0 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.cxx +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.cxx @@ -59,11 +59,10 @@ vtkPV3FoamReader::vtkPV3FoamReader() this->GetExecutive()->SetOutputData(1, lagrangian); lagrangian->Delete(); - TimeStep = 0; TimeStepRange[0] = 0; TimeStepRange[1] = 0; - CacheMesh = 0; + CacheMesh = 1; ExtrapolateWalls = 0; IncludeSets = 0; @@ -181,7 +180,7 @@ int vtkPV3FoamReader::RequestInformation } else { - foamData_->UpdateInformation(); + foamData_->updateInfo(); } int nTimeSteps = 0; @@ -349,6 +348,15 @@ int vtkPV3FoamReader::RequestData foamData_->Update(output, lagrangianOutput); + if (ShowPatchNames) + { + addPatchNamesToView(); + } + else + { + removePatchNamesFromView(); + } + #endif return 1; @@ -408,7 +416,13 @@ void vtkPV3FoamReader::PrintSelf(ostream& os, vtkIndent indent) os<< indent << "Time step range: " << this->TimeStepRange[0] << " - " << this->TimeStepRange[1] << "\n"; - os<< indent << "Time step: " << this->TimeStep << endl; + os<< indent << "Time step: " << this->GetTimeStep() << endl; +} + + +int vtkPV3FoamReader::GetTimeStep() +{ + return foamData_ ? foamData_->timeIndex() : -1; } @@ -446,7 +460,6 @@ int vtkPV3FoamReader::GetRegionArrayStatus(const char* name) void vtkPV3FoamReader::SetRegionArrayStatus(const char* name, int status) { vtkDebugMacro(<<"SetRegionArrayStatus"); - if (status) { RegionSelection->EnableArray(name); diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.h b/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.h index 77985be212..88fbae9b31 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.h +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.h @@ -21,20 +21,16 @@ #ifndef __vtkPV3FoamReader_h #define __vtkPV3FoamReader_h -#include "vtkMultiBlockDataSetAlgorithm.h" - // Foam forward declarations namespace Foam { class vtkPV3Foam; } +// VTK includes +#include "vtkMultiBlockDataSetAlgorithm.h" + // VTK forward declarations -class vtkUnstructuredGrid; -class vtkPoints; -class vtkIntArray; -class vtkFloatArray; -class vtkDoubleArray; class vtkDataArraySelection; class vtkCallbackCommand; @@ -44,41 +40,31 @@ class VTK_IO_EXPORT vtkPV3FoamReader public vtkMultiBlockDataSetAlgorithm { public: + vtkTypeRevisionMacro(vtkPV3FoamReader,vtkMultiBlockDataSetAlgorithm); + void PrintSelf(ostream&, vtkIndent); static vtkPV3FoamReader* New(); - vtkTypeRevisionMacro - ( - vtkPV3FoamReader, - vtkMultiBlockDataSetAlgorithm - ); - - void PrintSelf - ( - ostream& os, - vtkIndent indent - ); + // Description: + // Get the current timestep and the timestep range. + vtkGetVector2Macro(TimeStepRange, int); // Description: // Set/Get the filename. vtkSetStringMacro(FileName); vtkGetStringMacro(FileName); - // Time control - // Set/Get the timestep and the timestep range - vtkSetMacro(TimeStep, int); - vtkGetMacro(TimeStep, int); - vtkSetVector2Macro(TimeStepRange, int); - vtkGetVector2Macro(TimeStepRange, int); - + // Description: // GUI update control vtkSetMacro(UpdateGUI, int); vtkGetMacro(UpdateGUI, int); + // Description: // FOAM mesh caching control vtkSetMacro(CacheMesh, int); vtkGetMacro(CacheMesh, int); + // Description: // FOAM extrapolate internal values onto the walls vtkSetMacro(ExtrapolateWalls, int); vtkGetMacro(ExtrapolateWalls, int); @@ -87,42 +73,53 @@ public: vtkSetMacro(IncludeSets, int); vtkGetMacro(IncludeSets, int); + // Description: // FOAM read zones control vtkSetMacro(IncludeZones, int); vtkGetMacro(IncludeZones, int); + // Description: // FOAM display patch names control vtkSetMacro(ShowPatchNames, int); vtkGetMacro(ShowPatchNames, int); + // Description: + // Get the current timestep + int GetTimeStep(); + + // Description: // Region selection list control vtkDataArraySelection* GetRegionSelection(); - int GetNumberOfRegionArrays(); - const char* GetRegionArrayName(int index); - int GetRegionArrayStatus(const char* name); + int GetNumberOfRegionArrays(); + int GetRegionArrayStatus(const char* name); void SetRegionArrayStatus(const char* name, int status); + const char* GetRegionArrayName(int index); + // Description: // volField selection list control vtkDataArraySelection* GetVolFieldSelection(); - int GetNumberOfVolFieldArrays(); - const char* GetVolFieldArrayName(int index); - int GetVolFieldArrayStatus(const char* name); + int GetNumberOfVolFieldArrays(); + int GetVolFieldArrayStatus(const char* name); void SetVolFieldArrayStatus(const char* name, int status); + const char* GetVolFieldArrayName(int index); + // Description: // pointField selection list control vtkDataArraySelection* GetPointFieldSelection(); - int GetNumberOfPointFieldArrays(); - int GetPointFieldArrayStatus(const char* name); + int GetNumberOfPointFieldArrays(); + int GetPointFieldArrayStatus(const char* name); void SetPointFieldArrayStatus(const char* name, int status); const char* GetPointFieldArrayName(int index); + // Description: // lagrangianField selection list control vtkDataArraySelection* GetLagrangianFieldSelection(); - int GetNumberOfLagrangianFieldArrays(); - int GetLagrangianFieldArrayStatus(const char* name); + int GetNumberOfLagrangianFieldArrays(); + int GetLagrangianFieldArrayStatus(const char* name); void SetLagrangianFieldArrayStatus(const char* name, int status); const char* GetLagrangianFieldArrayName(int index); + // Description: // Callback registered with the SelectionObserver // for all the selection lists static void SelectionModifiedCallback @@ -138,18 +135,13 @@ public: protected: + //- Construct null vtkPV3FoamReader(); + + //- Destructor ~vtkPV3FoamReader(); - char* FileName; - - virtual int RequestData - ( - vtkInformation*, - vtkInformationVector**, - vtkInformationVector* - ); - + //- Return information about mesh, times, etc without loading anything virtual int RequestInformation ( vtkInformation*, @@ -157,16 +149,30 @@ protected: vtkInformationVector* ); + //- Get the mesh/fields for a particular time + //- Destructor + virtual int RequestData + ( + vtkInformation*, + vtkInformationVector**, + vtkInformationVector* + ); + + //- Fill in additional port information virtual int FillOutputPortInformation(int, vtkInformation*); - // The observer to modify this object when the array selections - // are modified + // The observer to modify this object when array selections are modified vtkCallbackCommand* SelectionObserver; + char* FileName; + private: - vtkPV3FoamReader(const vtkPV3FoamReader&); // Not implemented. - void operator=(const vtkPV3FoamReader&); // Not implemented. + //- Disallow default bitwise copy construct + vtkPV3FoamReader(const vtkPV3FoamReader&); + + //- Disallow default bitwise assignment + void operator=(const vtkPV3FoamReader&); //- Add patch names to the view void addPatchNamesToView(); @@ -174,9 +180,7 @@ private: //- Remove patch names from the view void removePatchNamesFromView(); - int TimeStep; int TimeStepRange[2]; - int CacheMesh; int ExtrapolateWalls; @@ -184,7 +188,7 @@ private: int IncludeZones; int ShowPatchNames; - //- Dummy variable/switch for provoking a reader update + //- Dummy variable/switch for invoke a reader update int UpdateGUI; vtkDataArraySelection* RegionSelection; @@ -192,7 +196,7 @@ private: vtkDataArraySelection* PointFieldSelection; vtkDataArraySelection* LagrangianFieldSelection; - //- Cached data for output port0 + //- Cached data for output port0 (experimental!) vtkMultiBlockDataSet* output0_; //BTX diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/Make/files b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/Make/files index 8fb98bc9ad..4bb4f69970 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/Make/files +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/Make/files @@ -1,11 +1,11 @@ vtkPV3Foam.C -vtkPV3FoamAddVolumeMesh.C -vtkPV3FoamAddLagrangianMesh.C -vtkPV3FoamAddPatchMesh.C -vtkPV3FoamAddZoneMesh.C -vtkPV3FoamAddSetMesh.C -vtkPV3FoamUpdateInformation.C -vtkPV3FoamConvertMesh.C -vtkPV3FoamConvertFields.C +vtkPV3FoamFields.C +vtkPV3FoamMesh.C +vtkPV3FoamMeshLagrangian.C +vtkPV3FoamMeshPatch.C +vtkPV3FoamMeshSet.C +vtkPV3FoamMeshVolume.C +vtkPV3FoamMeshZone.C +vtkPV3FoamUpdateInfo.C LIB = $(FOAM_LIBBIN)/libvtkPV3Foam diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C index 2d6e5756ce..9595e37ff7 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C @@ -25,13 +25,12 @@ License \*---------------------------------------------------------------------------*/ #include "vtkPV3Foam.H" +#include "vtkPV3FoamReader.h" // Foam includes -#include "Time.H" #include "fvMesh.H" -#include "IOobjectList.H" +#include "Time.H" #include "patchZones.H" -#include "vtkPV3FoamReader.h" #include "IFstream.H" // VTK includes @@ -54,8 +53,7 @@ defineTypeNameAndDebug(Foam::vtkPV3Foam, 0); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // #include "vtkPV3FoamAddToSelection.H" -#include "vtkPV3FoamUpdateInformationFields.H" - +#include "vtkPV3FoamUpdateInfoFields.H" void Foam::vtkPV3Foam::AddToBlock ( @@ -161,19 +159,19 @@ Foam::label Foam::vtkPV3Foam::GetNumberOfDataSets void Foam::vtkPV3Foam::resetCounters() { // Reset region ids and sizes - selectInfoVolume_.reset(); - selectInfoPatches_.reset(); - selectInfoLagrangian_.reset(); - selectInfoCellZones_.reset(); - selectInfoFaceZones_.reset(); - selectInfoPointZones_.reset(); - selectInfoCellSets_.reset(); - selectInfoFaceSets_.reset(); - selectInfoPointSets_.reset(); + regionInfoVolume_.reset(); + regionInfoPatches_.reset(); + regionInfoLagrangian_.reset(); + regionInfoCellZones_.reset(); + regionInfoFaceZones_.reset(); + regionInfoPointZones_.reset(); + regionInfoCellSets_.reset(); + regionInfoFaceSets_.reset(); + regionInfoPointSets_.reset(); } -bool Foam::vtkPV3Foam::setTime(const double& requestedTime) +int Foam::vtkPV3Foam::setTime(const double& requestedTime) { if (debug) { @@ -186,17 +184,12 @@ bool Foam::vtkPV3Foam::setTime(const double& requestedTime) // Get times list instantList Times = runTime.times(); - bool found = false; - int nearestIndex = Time::findClosestTimeIndex(Times, requestedTime); + int foundIndex = Time::findClosestTimeIndex(Times, requestedTime); + int nearestIndex = foundIndex; - if (nearestIndex == -1) + if (foundIndex < 0) { nearestIndex = 0; - found = false; - } - else - { - found = true; } // see what has changed @@ -213,16 +206,17 @@ bool Foam::vtkPV3Foam::setTime(const double& requestedTime) if (meshPtr_->readUpdate() != polyMesh::UNCHANGED) { meshChanged_ = true; - reader_->UpdateProgress(0.05); - - // patches, zones etc might have changed - UpdateInformation(); } } else { meshChanged_ = true; } + + reader_->UpdateProgress(0.05); + + // this seems to be needed for catching Lagrangian fields + updateInfo(); } if (debug) @@ -233,91 +227,109 @@ bool Foam::vtkPV3Foam::setTime(const double& requestedTime) << " fieldsChanged=" << fieldsChanged_ << endl; } - return found; + return foundIndex; } -void Foam::vtkPV3Foam::updateSelectedRegions() +void Foam::vtkPV3Foam::updateRegionStatus() { if (debug) { - Info<< " Foam::vtkPV3Foam::updateSelectedRegions" << endl; + Info<< " Foam::vtkPV3Foam::updateRegionStatus" << endl; } - vtkDataArraySelection* arraySelection = reader_->GetRegionSelection(); - - const label nSelect = arraySelection->GetNumberOfArrays(); - - if (selectedRegions_.size() != nSelect) + vtkDataArraySelection* regionSelection = reader_->GetRegionSelection(); + const label nSelect = regionSelection->GetNumberOfArrays(); + if (regionStatus_.size() != nSelect) { - selectedRegions_.setSize(nSelect); - selectedRegions_ = 0; + regionStatus_.setSize(nSelect); + regionStatus_ = false; meshChanged_ = true; } - selectedRegionDatasetIds_.setSize(nSelect); + // this needs fixing if we wish to re-use the datasets + regionDataset_.setSize(nSelect); + regionDataset_ = -1; // Read the selected cell regions, zones, patches and add to region list - forAll (selectedRegions_, regionId) + forAll(regionStatus_, regionId) { - int setting = arraySelection->GetArraySetting(regionId); + int setting = regionSelection->GetArraySetting(regionId); - if (selectedRegions_[regionId] != setting) + if (regionStatus_[regionId] != setting) { - selectedRegions_[regionId] = setting; + regionStatus_[regionId] = setting; meshChanged_ = true; } - selectedRegionDatasetIds_[regionId] = -1; - if (debug) { Info<< " region[" << regionId << "] = " - << selectedRegions_[regionId] - << " : " << arraySelection->GetArrayName(regionId) << endl; + << regionStatus_[regionId] + << " : " << regionSelection->GetArrayName(regionId) << endl; } } if (debug) { - Info<< " Foam::vtkPV3Foam::updateSelectedRegions" << endl; + Info<< " Foam::vtkPV3Foam::updateRegionStatus" << endl; } } +Foam::wordHashSet Foam::vtkPV3Foam::getSelected +( + vtkDataArraySelection* select +) +{ + int nElem = select->GetNumberOfArrays(); + wordHashSet selections(2*nElem); + + for (int elemI=0; elemI < nElem; ++elemI) + { + if (select->GetArraySetting(elemI)) + { + word name(getFirstWord(select->GetArrayName(elemI))); + selections.insert(name); + } + } + + return selections; +} + Foam::stringList Foam::vtkPV3Foam::getSelectedArrayEntries ( - vtkDataArraySelection* arraySelection, + vtkDataArraySelection* select, const bool firstWord ) { - stringList selections(arraySelection->GetNumberOfArrays()); + stringList selections(select->GetNumberOfArrays()); label nElem = 0; if (debug) { Info<< "available("; - forAll (selections, elemI) + forAll(selections, elemI) { - Info<< " \"" << arraySelection->GetArrayName(elemI) << "\""; + Info<< " \"" << select->GetArrayName(elemI) << "\""; } Info<< " )\n" << "selected("; } - forAll (selections, elemI) + forAll(selections, elemI) { - if (arraySelection->GetArraySetting(elemI)) + if (select->GetArraySetting(elemI)) { if (firstWord) { selections[nElem] = getFirstWord ( - arraySelection->GetArrayName(elemI) + select->GetArrayName(elemI) ); } else { - selections[nElem] = arraySelection->GetArrayName(elemI); + selections[nElem] = select->GetArrayName(elemI); } if (debug) @@ -341,7 +353,7 @@ Foam::stringList Foam::vtkPV3Foam::getSelectedArrayEntries Foam::stringList Foam::vtkPV3Foam::getSelectedArrayEntries ( - vtkDataArraySelection* arraySelection, + vtkDataArraySelection* select, const selectionInfo& selector, const bool firstWord ) @@ -359,7 +371,7 @@ Foam::stringList Foam::vtkPV3Foam::getSelectedArrayEntries ++elemI ) { - Info<< " \"" << arraySelection->GetArrayName(elemI) << "\""; + Info<< " \"" << select->GetArrayName(elemI) << "\""; } Info<< " )\n" @@ -373,18 +385,18 @@ Foam::stringList Foam::vtkPV3Foam::getSelectedArrayEntries ++elemI ) { - if (arraySelection->GetArraySetting(elemI)) + if (select->GetArraySetting(elemI)) { if (firstWord) { selections[nElem] = getFirstWord ( - arraySelection->GetArrayName(elemI) + select->GetArrayName(elemI) ); } else { - selections[nElem] = arraySelection->GetArrayName(elemI); + selections[nElem] = select->GetArrayName(elemI); } if (debug) @@ -408,7 +420,7 @@ Foam::stringList Foam::vtkPV3Foam::getSelectedArrayEntries void Foam::vtkPV3Foam::setSelectedArrayEntries ( - vtkDataArraySelection* arraySelection, + vtkDataArraySelection* select, const stringList& selections ) { @@ -416,13 +428,13 @@ void Foam::vtkPV3Foam::setSelectedArrayEntries { Info<< " Foam::vtkPV3Foam::setSelectedArrayEntries" << endl; } - const label nEntries = arraySelection->GetNumberOfArrays(); + const label nEntries = select->GetNumberOfArrays(); // Reset all current entries to 'not selected' - arraySelection->DisableAllArrays(); + select->DisableAllArrays(); // Loop through entries, setting values from selectedEntries - forAll (selections, elemI) + forAll(selections, elemI) { if (debug > 1) { @@ -432,7 +444,7 @@ void Foam::vtkPV3Foam::setSelectedArrayEntries for (label i=0; iGetArrayName(i); + string arrayName = select->GetArrayName(i); if (arrayName == selections[elemI]) { @@ -443,7 +455,7 @@ void Foam::vtkPV3Foam::setSelectedArrayEntries << endl; } - arraySelection->EnableArray(arrayName.c_str()); + select->EnableArray(arrayName.c_str()); break; } } @@ -466,20 +478,19 @@ Foam::vtkPV3Foam::vtkPV3Foam reader_(reader), dbPtr_(NULL), meshPtr_(NULL), - selectInfoVolume_("unzoned"), - selectInfoPatches_("patches"), - selectInfoLagrangian_("lagrangian"), - selectInfoCellZones_("cellZone"), - selectInfoFaceZones_("faceZone"), - selectInfoPointZones_("pointZone"), - selectInfoCellSets_("cellSet"), - selectInfoFaceSets_("faceSet"), - selectInfoPointSets_("pointSet"), - patchTextActorsPtrs_(0), nMesh_(0), timeIndex_(-1), meshChanged_(true), - fieldsChanged_(true) + fieldsChanged_(true), + regionInfoVolume_("unzoned"), + regionInfoPatches_("patches"), + regionInfoLagrangian_("lagrangian"), + regionInfoCellZones_("cellZone"), + regionInfoFaceZones_("faceZone"), + regionInfoPointZones_("pointZone"), + regionInfoCellSets_("cellSet"), + regionInfoFaceSets_("faceSet"), + regionInfoPointSets_("pointSet") { if (debug) { @@ -528,11 +539,7 @@ Foam::vtkPV3Foam::vtkPV3Foam dbPtr_().functionObjects().off(); - // Set initial cloud name - // TODO - TEMPORARY MEASURE UNTIL CAN PROCESS MULTIPLE CLOUDS - cloudName_ = ""; - - UpdateInformation(); + updateInfo(); } @@ -551,22 +558,22 @@ Foam::vtkPV3Foam::~vtkPV3Foam() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::vtkPV3Foam::UpdateInformation() +void Foam::vtkPV3Foam::updateInfo() { if (debug) { - Info<< " Foam::vtkPV3Foam::UpdateInformation" - << " [meshPtr=" << (meshPtr_ ? "set" : "NULL") << "] TimeStep=" - << reader_->GetTimeStep() << endl; + Info<< " Foam::vtkPV3Foam::updateInfo" + << " [meshPtr=" << (meshPtr_ ? "set" : "NULL") << "] timeIndex=" + << timeIndex_ << endl; } resetCounters(); - vtkDataArraySelection* arraySelection = reader_->GetRegionSelection(); + vtkDataArraySelection* regionSelection = reader_->GetRegionSelection(); stringList selectedEntries; // enable 'internalMesh' on the first call - if (arraySelection->GetNumberOfArrays() == 0 && !meshPtr_) + if (regionSelection->GetNumberOfArrays() == 0 && !meshPtr_) { selectedEntries.setSize(1); selectedEntries[0] = "internalMesh"; @@ -576,33 +583,25 @@ void Foam::vtkPV3Foam::UpdateInformation() // preserve the enabled selections selectedEntries = getSelectedArrayEntries ( - arraySelection, + regionSelection, false ); } // Clear current region list/array - arraySelection->RemoveAllArrays(); + regionSelection->RemoveAllArrays(); - // Update region array - updateInformationInternalMesh(); - updateInformationLagrangian(); - updateInformationPatches(); - - if (reader_->GetIncludeSets()) - { - updateInformationSets(); - } - - if (reader_->GetIncludeZones()) - { - updateInformationZones(); - } + // Update region array - add Lagrangian at the bottom + updateInfoInternalMesh(); + updateInfoPatches(); + updateInfoSets(); + updateInfoZones(); + updateInfoLagrangian(); // restore the enabled selections setSelectedArrayEntries ( - arraySelection, + regionSelection, selectedEntries ); @@ -611,24 +610,20 @@ void Foam::vtkPV3Foam::UpdateInformation() fieldsChanged_ = true; } - // Update volField array - updateInformationFields + // Update volume, point and lagrangian fields + updateInfoFields ( reader_->GetVolFieldSelection() ); - - // Update pointField array - updateInformationFields + updateInfoFields ( reader_->GetPointFieldSelection() ); - - // Update lagrangian field array - updateInformationLagrangianFields(); + updateInfoLagrangianFields(); if (debug) { - Info<< " Foam::vtkPV3Foam::UpdateInformation" << endl; + Info<< " Foam::vtkPV3Foam::updateInfo" << endl; } } @@ -702,7 +697,7 @@ void Foam::vtkPV3Foam::Update reader_->UpdateProgress(0.1); // Set up region selection(s) - updateSelectedRegions(); + updateRegionStatus(); // Update the Foam mesh updateFoamMesh(); @@ -793,29 +788,25 @@ void Foam::vtkPV3Foam::addPatchNames(vtkRenderer* renderer) // Remove any patch names previously added to the renderer removePatchNames(renderer); - if (debug) - { - Info<< " Foam::vtkPV3Foam::addPatchNames" << endl; - } - // get the display patches, strip off any suffix const stringList selectedPatches = getSelectedArrayEntries ( reader_->GetRegionSelection(), - selectInfoPatches_, + regionInfoPatches_, true ); - if (debug) - { - Info<<"... add patches: " << selectedPatches << endl; - } - if (!selectedPatches.size()) { return; } + if (debug) + { + Info<< " Foam::vtkPV3Foam::addPatchNames" << nl + <<"... add patches: " << selectedPatches << endl; + } + const polyBoundaryMesh& pbMesh = meshPtr_->boundaryMesh(); // Find the total number of zones @@ -977,11 +968,6 @@ void Foam::vtkPV3Foam::addPatchNames(vtkRenderer* renderer) void Foam::vtkPV3Foam::removePatchNames(vtkRenderer* renderer) { - if (debug) - { - Info<< "removePatchNames()" << endl; - } - forAll(patchTextActorsPtrs_, patchI) { renderer->RemoveViewProp(patchTextActorsPtrs_[patchI]); diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H index f78ba346b4..3907348cc0 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H @@ -32,23 +32,22 @@ SourceFiles vtkPV3Foam.C vtkPV3Foam.H vtkPV3FoamI.H - vtkPV3FoamAddLagrangianMesh.C - vtkPV3FoamAddPatchMesh.C - vtkPV3FoamAddSetMesh.C + vtkPV3FoamFields.C + vtkPV3FoamMesh.C + vtkPV3FoamMeshLagrangian.C + vtkPV3FoamMeshPatch.C + vtkPV3FoamMeshSet.C + vtkPV3FoamMeshVolume.C + vtkPV3FoamMeshZone.C + vtkPV3FoamFaceField.H + vtkPV3FoamLagrangianFields.H + vtkPV3FoamPatchField.H + vtkPV3FoamPointFields.H + vtkPV3FoamPoints.H + vtkPV3FoamUpdateInfo.C + vtkPV3FoamUpdateInfoFields.H + vtkPV3FoamVolFields.H vtkPV3FoamAddToSelection.H - vtkPV3FoamAddVolumeMesh.C - vtkPV3FoamAddZoneMesh.C - vtkPV3FoamConvertFields.C - vtkPV3FoamConvertFaceField.H - vtkPV3FoamConvertLagrangianFields.H - vtkPV3FoamConvertMesh.C - vtkPV3FoamConvertPatchFaceField.H - vtkPV3FoamConvertPatchPointField.H - vtkPV3FoamConvertPointFields.H - vtkPV3FoamConvertVolFields.H - vtkPV3FoamInsertNextPoint.H - vtkPV3FoamUpdateInformation.C - vtkPV3FoamUpdateInformationFields.H // Needed by VTK: vtkDataArrayTemplateImplicit.txx @@ -104,9 +103,55 @@ class List; class vtkPV3Foam { -public: + // Private data - // Public data + //- Access to the controlling vtkPV3FoamReader + vtkPV3FoamReader* reader_; + + //- Foam time control + autoPtr