diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/kineticTheoryModel/kineticTheoryModel.C b/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/kineticTheoryModel/kineticTheoryModel.C index 724602009a..44e276ddde 100644 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/kineticTheoryModel/kineticTheoryModel.C +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/kineticTheoryModel/kineticTheoryModel.C @@ -238,8 +238,7 @@ void Foam::kineticTheoryModel::solve() volScalarField ThetaSqrt = sqrt(Theta_); // 'thermal' conductivity (Table 3.3, p. 49) - volScalarField kappa_ = - conductivityModel_->kappa(alpha, Theta_, gs0_, rhoa_, da_, e_); + kappa_ = conductivityModel_->kappa(alpha, Theta_, gs0_, rhoa_, da_, e_); // particle viscosity (Table 3.2, p.47) mua_ = viscosityModel_->mua(alpha, Theta_, gs0_, rhoa_, da_, e_); @@ -351,8 +350,7 @@ void Foam::kineticTheoryModel::solve() mua_.min(1.0e+2); mua_.max(0.0); - lambda_ = (4.0/3.0)*sqr(alpha_)*rhoa_*da_*gs0_*(1.0 + e_) - *ThetaSqrt/sqrtPi; + lambda_ = (4.0/3.0)*sqr(alpha_)*rhoa_*da_*gs0_*(1.0 + e_)*ThetaSqrt/sqrtPi; Info<< "kinTheory: max(Theta) = " << max(Theta_).value() << endl; diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/kineticTheoryModel/kineticTheoryModel.H b/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/kineticTheoryModel/kineticTheoryModel.H index 8b7a3e145c..a17c2bb4a0 100644 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/kineticTheoryModel/kineticTheoryModel.H +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/kineticTheoryModels/kineticTheoryModel/kineticTheoryModel.H @@ -178,6 +178,11 @@ public: { return lambda_; } + + const volScalarField& kappa() const + { + return kappa_; + } }; diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/PV3FoamReader_SM.xml b/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/PV3FoamReader_SM.xml index 07620fd849..59c118281f 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/PV3FoamReader_SM.xml +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/PV3FoamReader_SM.xml @@ -1,191 +1,211 @@ - - + - name="PV3FoamReader" - class="vtkPV3FoamReader"> + + + + + Specifies the filename for the OpenFOAM Reader. + + - - - - + + + + + Available timestep values. + + - + + + + - - - - Available timestep values. - - + + + + + + + + + + + - - - + + + + + + + + + + + - - - - + + + + + + + + + + + - - - - + + + + + + + + + + + - - - - + + + + + Extrapolate internalField to wall and empty patches + + - - - - + + + + Searches the polyMesh/sets/ directory + + + - - - - - - - - - - - + + + + ZoneMesh information is used to find {cell,face,point}Zones. + The polyMesh/ directory is only checked on startup. + + + - - - - - - - - - - - + + + + + Show patch names in render window. + + - - - - - - - - - - - + + + + + Cache the fvMesh in memory. + + - - - - - - - - - - - - - - - + + + + + A simple way cause a reader GUI modification. + + - - - - - - - + + diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.cxx b/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.cxx index 81885deee7..70a6230bfe 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,23 +48,30 @@ 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; TimeStepRange[1] = 0; - CacheMesh = 0; + CacheMesh = 1; ExtrapolateWalls = 0; IncludeSets = 0; IncludeZones = 0; ShowPatchNames = 0; - UpdateGUI = 1; - UpdateGUIOld = 1; + UpdateGUI = 0; - RegionSelection = vtkDataArraySelection::New(); + PartSelection = vtkDataArraySelection::New(); VolFieldSelection = vtkDataArraySelection::New(); PointFieldSelection = vtkDataArraySelection::New(); LagrangianFieldSelection = vtkDataArraySelection::New(); @@ -77,7 +85,7 @@ vtkPV3FoamReader::vtkPV3FoamReader() ); SelectionObserver->SetClientData(this); - RegionSelection->AddObserver + PartSelection->AddObserver ( vtkCommand::ModifiedEvent, this->SelectionObserver @@ -114,14 +122,20 @@ vtkPV3FoamReader::~vtkPV3FoamReader() delete [] FileName; } - RegionSelection->RemoveObserver(this->SelectionObserver); + if (output0_) + { + output0_->Delete(); + } + + + PartSelection->RemoveObserver(this->SelectionObserver); VolFieldSelection->RemoveObserver(this->SelectionObserver); PointFieldSelection->RemoveObserver(this->SelectionObserver); LagrangianFieldSelection->RemoveObserver(this->SelectionObserver); SelectionObserver->Delete(); - RegionSelection->Delete(); + PartSelection->Delete(); VolFieldSelection->Delete(); PointFieldSelection->Delete(); LagrangianFieldSelection->Delete(); @@ -149,38 +163,40 @@ 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 { - foamData_->UpdateInformation(); + foamData_->updateInfo(); } 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 +206,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 +249,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 +299,65 @@ 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); + + if (ShowPatchNames) + { + addPatchNamesToView(); + } + else + { + removePatchNamesFromView(); + } + +#endif return 1; } @@ -389,52 +416,57 @@ 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; } // ---------------------------------------------------------------------- -// Region selection list control +// Parts selection list control -vtkDataArraySelection* vtkPV3FoamReader::GetRegionSelection() +vtkDataArraySelection* vtkPV3FoamReader::GetPartSelection() { - vtkDebugMacro(<<"GetRegionSelection"); - return RegionSelection; + vtkDebugMacro(<<"GetPartSelection"); + return PartSelection; } -int vtkPV3FoamReader::GetNumberOfRegionArrays() +int vtkPV3FoamReader::GetNumberOfPartArrays() { - vtkDebugMacro(<<"GetNumberOfRegionArrays"); - return RegionSelection->GetNumberOfArrays(); + vtkDebugMacro(<<"GetNumberOfPartArrays"); + return PartSelection->GetNumberOfArrays(); } -const char* vtkPV3FoamReader::GetRegionArrayName(int index) +const char* vtkPV3FoamReader::GetPartArrayName(int index) { - vtkDebugMacro(<<"GetRegionArrayName"); - return RegionSelection->GetArrayName(index); + vtkDebugMacro(<<"GetPartArrayName"); + return PartSelection->GetArrayName(index); } -int vtkPV3FoamReader::GetRegionArrayStatus(const char* name) +int vtkPV3FoamReader::GetPartArrayStatus(const char* name) { - vtkDebugMacro(<<"GetRegionArrayStatus"); - return RegionSelection->ArrayIsEnabled(name); + vtkDebugMacro(<<"GetPartArrayStatus"); + return PartSelection->ArrayIsEnabled(name); } -void vtkPV3FoamReader::SetRegionArrayStatus(const char* name, int status) +void vtkPV3FoamReader::SetPartArrayStatus(const char* name, int status) { - vtkDebugMacro(<<"SetRegionArrayStatus"); - + vtkDebugMacro(<<"SetPartArrayStatus"); if (status) { - RegionSelection->EnableArray(name); + PartSelection->EnableArray(name); } else { - RegionSelection->DisableArray(name); + PartSelection->DisableArray(name); } } @@ -597,4 +629,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..fde87527de 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); - // Region selection list control - vtkDataArraySelection* GetRegionSelection(); - int GetNumberOfRegionArrays(); - const char* GetRegionArrayName(int index); - int GetRegionArrayStatus(const char* name); - void SetRegionArrayStatus(const char* name, int status); + // Description: + // Get the current timestep + int GetTimeStep(); + // Description: + // Parts selection list control + vtkDataArraySelection* GetPartSelection(); + int GetNumberOfPartArrays(); + int GetPartArrayStatus(const char* name); + void SetPartArrayStatus(const char* name, int status); + const char* GetPartArrayName(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,15 +149,30 @@ protected: vtkInformationVector* ); - // The observer to modify this object when the array selections - // are modified + //- 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 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(); @@ -173,9 +180,7 @@ private: //- Remove patch names from the view void removePatchNamesFromView(); - int TimeStep; int TimeStepRange[2]; - int CacheMesh; int ExtrapolateWalls; @@ -183,16 +188,16 @@ private: int IncludeZones; int ShowPatchNames; + //- Dummy variable/switch for invoke a reader update int UpdateGUI; - int UpdateGUIOld; - vtkDataArraySelection* RegionSelection; + vtkDataArraySelection* PartSelection; vtkDataArraySelection* VolFieldSelection; vtkDataArraySelection* PointFieldSelection; vtkDataArraySelection* LagrangianFieldSelection; - //- Access to the output port1 - vtkMultiBlockDataSet* output1_; + //- Cached data for output port0 (experimental!) + 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..9699e3c71e 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/Make/files +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/Make/files @@ -1,11 +1,12 @@ vtkPV3Foam.C -vtkPV3FoamAddVolumeMesh.C -vtkPV3FoamAddLagrangianMesh.C -vtkPV3FoamAddPatchMesh.C -vtkPV3FoamAddZoneMesh.C -vtkPV3FoamAddSetMesh.C -vtkPV3FoamUpdate.C -vtkPV3FoamUpdateInformation.C -vtkPV3FoamConvertMesh.C +vtkPV3FoamFields.C +vtkPV3FoamMesh.C +vtkPV3FoamMeshLagrangian.C +vtkPV3FoamMeshPatch.C +vtkPV3FoamMeshSet.C +vtkPV3FoamMeshVolume.C +vtkPV3FoamMeshZone.C +vtkPV3FoamUpdateInfo.C +vtkPV3FoamUtilities.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..10ccf69126 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C @@ -25,27 +25,19 @@ 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 -#include "vtkCharArray.h" #include "vtkDataArraySelection.h" -#include "vtkDataSet.h" -#include "vtkFieldData.h" #include "vtkMultiBlockDataSet.h" #include "vtkRenderer.h" #include "vtkTextActor.h" #include "vtkTextProperty.h" -#include "vtkPolyData.h" -#include "vtkUnstructuredGrid.h" -#include "vtkInformation.h" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -54,126 +46,51 @@ defineTypeNameAndDebug(Foam::vtkPV3Foam, 0); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // #include "vtkPV3FoamAddToSelection.H" -#include "vtkPV3FoamUpdateInformationFields.H" - - -void Foam::vtkPV3Foam::AddToBlock -( - vtkMultiBlockDataSet* output, - const selectionInfo& selector, - const label datasetNo, - vtkDataSet* dataset, - const string& blockName -) -{ - const int blockNo = selector.block(); - - vtkDataObject* blockDO = output->GetBlock(blockNo); - vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO); - if (blockDO && !block) - { - FatalErrorIn("Foam::vtkPV3Foam::AddToBlock") - << "Block already has a vtkDataSet assigned to it" << nl << endl; - return; - } - - if (!block) - { - block = vtkMultiBlockDataSet::New(); - output->SetBlock(blockNo, block); - block->Delete(); - } - - if (block) - { - if (debug) - { - Info<< "block[" << blockNo << "] has " - << block->GetNumberOfBlocks() - << " datasets prior to adding set " << datasetNo - << " with name: " << blockName << endl; - } - - // when assigning dataset 0, also name the parent block - if (!datasetNo && selector.name()) - { - output->GetMetaData(blockNo)->Set - ( - vtkCompositeDataSet::NAME(), - selector.name() - ); - } - } - - - block->SetBlock(datasetNo, dataset); - - if (blockName.size()) - { - block->GetMetaData(datasetNo)->Set - ( - vtkCompositeDataSet::NAME(), blockName.c_str() - ); - } - -} - - -vtkDataSet* Foam::vtkPV3Foam::GetDataSetFromBlock -( - vtkMultiBlockDataSet* output, - const selectionInfo& selector, - const label datasetNo -) -{ - const int blockNo = selector.block(); - - vtkDataObject* blockDO = output->GetBlock(blockNo); - vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO); - if (block) - { - return vtkDataSet::SafeDownCast(block->GetBlock(datasetNo)); - } - - return 0; -} - - -Foam::label Foam::vtkPV3Foam::GetNumberOfDataSets -( - vtkMultiBlockDataSet* output, - const selectionInfo& selector -) -{ - const int blockNo = selector.block(); - - vtkDataObject* blockDO = output->GetBlock(blockNo); - vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO); - if (block) - { - return block->GetNumberOfBlocks(); - } - - return 0; -} - +#include "vtkPV3FoamUpdateInfoFields.H" 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(); + // Reset mesh part ids and sizes + partInfoVolume_.reset(); + partInfoPatches_.reset(); + partInfoLagrangian_.reset(); + partInfoCellZones_.reset(); + partInfoFaceZones_.reset(); + partInfoPointZones_.reset(); + partInfoCellSets_.reset(); + partInfoFaceSets_.reset(); + partInfoPointSets_.reset(); } -bool Foam::vtkPV3Foam::setTime(const double& requestedTime) +void Foam::vtkPV3Foam::reduceMemory() +{ + forAll(regionPolyDecomp_, i) + { + regionPolyDecomp_[i].clear(); + } + + forAll(zonePolyDecomp_, i) + { + zonePolyDecomp_[i].clear(); + } + + forAll(csetPolyDecomp_, i) + { + csetPolyDecomp_[i].clear(); + } + + if (!reader_->GetCacheMesh()) + { + delete meshPtr_; + meshPtr_ = NULL; + } +} + + + + +int Foam::vtkPV3Foam::setTime(const double& requestedTime) { if (debug) { @@ -186,17 +103,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,14 +125,17 @@ bool Foam::vtkPV3Foam::setTime(const double& requestedTime) if (meshPtr_->readUpdate() != polyMesh::UNCHANGED) { meshChanged_ = true; - // 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) @@ -231,228 +146,55 @@ bool Foam::vtkPV3Foam::setTime(const double& requestedTime) << " fieldsChanged=" << fieldsChanged_ << endl; } - return found; + return foundIndex; } -void Foam::vtkPV3Foam::updateSelectedRegions() +void Foam::vtkPV3Foam::updateMeshPartsStatus() { if (debug) { - Info<< " Foam::vtkPV3Foam::updateSelectedRegions" << endl; + Info<< " Foam::vtkPV3Foam::updateMeshPartsStatus" << endl; } - vtkDataArraySelection* arraySelection = reader_->GetRegionSelection(); + vtkDataArraySelection* selection = reader_->GetPartSelection(); + label nElem = selection->GetNumberOfArrays(); - const label nSelect = arraySelection->GetNumberOfArrays(); - - if (selectedRegions_.size() != nSelect) + if (partStatus_.size() != nElem) { - selectedRegions_.setSize(nSelect); - selectedRegions_ = 0; + partStatus_.setSize(nElem); + partStatus_ = false; meshChanged_ = true; } - selectedRegionDatasetIds_.setSize(nSelect); + // this needs fixing if we wish to re-use the datasets + partDataset_.setSize(nElem); + partDataset_ = -1; - // Read the selected cell regions, zones, patches and add to region list - forAll (selectedRegions_, regionId) + // Read the selected mesh parts (zones, patches ...) and add to list + forAll(partStatus_, partId) { - int setting = arraySelection->GetArraySetting(regionId); + const int setting = selection->GetArraySetting(partId); - if (selectedRegions_[regionId] != setting) + if (partStatus_[partId] != setting) { - selectedRegions_[regionId] = setting; + partStatus_[partId] = setting; meshChanged_ = true; } - selectedRegionDatasetIds_[regionId] = -1; - if (debug) { - Info<< " region[" << regionId << "] = " - << selectedRegions_[regionId] - << " : " << arraySelection->GetArrayName(regionId) << endl; + Info<< " part[" << partId << "] = " + << partStatus_[partId] + << " : " << selection->GetArrayName(partId) << endl; } } if (debug) { - Info<< " Foam::vtkPV3Foam::updateSelectedRegions" << endl; + Info<< " Foam::vtkPV3Foam::updateMeshPartsStatus" << endl; } } - -Foam::stringList Foam::vtkPV3Foam::getSelectedArrayEntries -( - vtkDataArraySelection* arraySelection, - const bool firstWord -) -{ - stringList selections(arraySelection->GetNumberOfArrays()); - label nElem = 0; - - if (debug) - { - Info<< "available("; - forAll (selections, elemI) - { - Info<< " \"" << arraySelection->GetArrayName(elemI) << "\""; - } - Info<< " )\n" - << "selected("; - } - - forAll (selections, elemI) - { - if (arraySelection->GetArraySetting(elemI)) - { - if (firstWord) - { - selections[nElem] = getFirstWord - ( - arraySelection->GetArrayName(elemI) - ); - } - else - { - selections[nElem] = arraySelection->GetArrayName(elemI); - } - - if (debug) - { - Info<< " " << selections[nElem]; - } - - ++nElem; - } - } - - if (debug) - { - Info<< " )" << endl; - } - - selections.setSize(nElem); - return selections; -} - - -Foam::stringList Foam::vtkPV3Foam::getSelectedArrayEntries -( - vtkDataArraySelection* arraySelection, - const selectionInfo& selector, - const bool firstWord -) -{ - stringList selections(selector.size()); - label nElem = 0; - - if (debug) - { - Info<< "available("; - for - ( - int elemI = selector.start(); - elemI < selector.end(); - ++elemI - ) - { - Info<< " \"" << arraySelection->GetArrayName(elemI) << "\""; - } - - Info<< " )\n" - << "selected("; - } - - for - ( - int elemI = selector.start(); - elemI < selector.end(); - ++elemI - ) - { - if (arraySelection->GetArraySetting(elemI)) - { - if (firstWord) - { - selections[nElem] = getFirstWord - ( - arraySelection->GetArrayName(elemI) - ); - } - else - { - selections[nElem] = arraySelection->GetArrayName(elemI); - } - - if (debug) - { - Info<< " " << selections[nElem]; - } - - ++nElem; - } - } - - if (debug) - { - Info<< " )" << endl; - } - - selections.setSize(nElem); - return selections; -} - - -void Foam::vtkPV3Foam::setSelectedArrayEntries -( - vtkDataArraySelection* arraySelection, - const stringList& selections -) -{ - if (debug > 1) - { - Info<< " Foam::vtkPV3Foam::setSelectedArrayEntries" << endl; - } - const label nEntries = arraySelection->GetNumberOfArrays(); - - // Reset all current entries to 'not selected' - arraySelection->DisableAllArrays(); - - // Loop through entries, setting values from selectedEntries - forAll (selections, elemI) - { - if (debug > 1) - { - Info<< "selections[" << elemI << "] = " << selections[elemI] - << endl; - } - - for (label i=0; iGetArrayName(i); - - if (arrayName == selections[elemI]) - { - if (debug > 1) - { - Info<< "enabling array: " << arrayName << " Index = " - << i - << endl; - } - - arraySelection->EnableArray(arrayName.c_str()); - break; - } - } - } - if (debug > 1) - { - Info<< " Foam::vtkPV3Foam::setSelectedArrayEntries" << endl; - } -} - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::vtkPV3Foam::vtkPV3Foam @@ -464,20 +206,19 @@ 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"), - patchTextActorsPtrs_(0), nMesh_(0), timeIndex_(-1), meshChanged_(true), - fieldsChanged_(true) + fieldsChanged_(true), + partInfoVolume_("unzoned"), + partInfoPatches_("patches"), + partInfoLagrangian_("lagrangian"), + partInfoCellZones_("cellZone"), + partInfoFaceZones_("faceZone"), + partInfoPointZones_("pointZone"), + partInfoCellSets_("cellSet"), + partInfoFaceSets_("faceSet"), + partInfoPointSets_("pointSet") { if (debug) { @@ -526,11 +267,7 @@ Foam::vtkPV3Foam::vtkPV3Foam dbPtr_().functionObjects().off(); - // Set initial cloud name - // TODO - TEMPORARY MEASURE UNTIL CAN PROCESS MULTIPLE CLOUDS - cloudName_ = ""; - - UpdateInformation(); + updateInfo(); } @@ -543,183 +280,190 @@ Foam::vtkPV3Foam::~vtkPV3Foam() Info<< " Foam::vtkPV3Foam::~vtkPV3Foam" << endl; } - if (meshPtr_) - { - delete meshPtr_; - meshPtr_ = NULL; - } + delete meshPtr_; } // * * * * * * * * * * * * * * * 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* partSelection = reader_->GetPartSelection(); - stringList selectedEntries; // enable 'internalMesh' on the first call - if (arraySelection->GetNumberOfArrays() == 0 && !meshPtr_) + // or preserve the enabled selections + stringList enabledEntries; + if (!partSelection->GetNumberOfArrays() && !meshPtr_) { - selectedEntries.setSize(1); - selectedEntries[0] = "internalMesh"; + enabledEntries.setSize(1); + enabledEntries[0] = "internalMesh"; } else { - // preserve the currently selected values - selectedEntries = getSelectedArrayEntries - ( - arraySelection - ); + enabledEntries = getSelectedArrayEntries(partSelection); } - // Clear current region list/array - arraySelection->RemoveAllArrays(); + // Clear current mesh parts list + partSelection->RemoveAllArrays(); - // Update region array - updateInformationInternalMesh(); - updateInformationLagrangian(); - updateInformationPatches(); + // Update mesh parts list - add Lagrangian at the bottom + updateInfoInternalMesh(); + updateInfoPatches(); + updateInfoSets(); + updateInfoZones(); + updateInfoLagrangian(); - if (reader_->GetIncludeSets()) - { - updateInformationSets(); - } - - if (reader_->GetIncludeZones()) - { - updateInformationZones(); - } - - // restore the currently enabled values - setSelectedArrayEntries - ( - arraySelection, - selectedEntries - ); + // restore the enabled selections + setSelectedArrayEntries(partSelection, enabledEntries); if (meshChanged_) { 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; } } +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(); + // Set up mesh parts selection(s) + updateMeshPartsStatus(); + + reader_->UpdateProgress(0.15); // Update the Foam mesh updateFoamMesh(); - reader_->UpdateProgress(0.2); - - // Convert meshes - convertMeshVolume(output); - convertMeshLagrangian(output); - convertMeshPatches(output); reader_->UpdateProgress(0.4); + // Convert meshes - start port0 at block=0 + int blockNo = 0; + + convertMeshVolume(output, blockNo); + convertMeshPatches(output, blockNo); + reader_->UpdateProgress(0.6); + if (reader_->GetIncludeZones()) { - convertMeshCellZones(output); - convertMeshFaceZones(output); - convertMeshPointZones(output); + convertMeshCellZones(output, blockNo); + convertMeshFaceZones(output, blockNo); + convertMeshPointZones(output, blockNo); + reader_->UpdateProgress(0.65); } if (reader_->GetIncludeSets()) { - convertMeshCellSets(output); - convertMeshFaceSets(output); - convertMeshPointSets(output); + convertMeshCellSets(output, blockNo); + convertMeshFaceSets(output, blockNo); + convertMeshPointSets(output, blockNo); + reader_->UpdateProgress(0.7); } + + // restart port1 at block=0 + 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(0.95); + + // reclaim some memory + reduceMemory(); 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; } @@ -773,31 +517,28 @@ void Foam::vtkPV3Foam::addPatchNames(vtkRenderer* renderer) // Remove any patch names previously added to the renderer removePatchNames(renderer); + // get the display patches, strip off any suffix + wordHashSet selectedPatches = getSelected + ( + reader_->GetPartSelection(), + partInfoPatches_ + ); + + if (!selectedPatches.size()) + { + return; + } + if (debug) { - Info<< " Foam::vtkPV3Foam::addPatchNames" << endl; + Info<< " Foam::vtkPV3Foam::addPatchNames" << nl + <<"... add patches: " << selectedPatches << endl; } const polyBoundaryMesh& pbMesh = meshPtr_->boundaryMesh(); - const selectionInfo& selector = selectInfoPatches_; - - // the currently selected patches, strip off any suffix - const stringList selectedPatches = getSelectedArrayEntries - ( - reader_->GetRegionSelection(), - selector, - true - ); - - if (debug) - { - Info<<"... add patches: " << selectedPatches << endl; - } - // 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); @@ -815,68 +556,60 @@ void Foam::vtkPV3Foam::addPatchNames(vtkRenderer* renderer) const polyPatch& pp = pbMesh[patchI]; // Only include the patch if it is selected - bool isSelected = false; - forAll(selectedPatches, elemI) + if (!selectedPatches.found(pp.name())) { - if (pp.name() == selectedPatches[elemI]) + continue; + } + + const labelListList& edgeFaces = pp.edgeFaces(); + const vectorField& n = pp.faceNormals(); + + boolList featEdge(pp.nEdges(), false); + + forAll(edgeFaces, edgeI) + { + const labelList& eFaces = edgeFaces[edgeI]; + + if (eFaces.size() != 2) { - isSelected = true; - break; + featEdge[edgeI] = true; + } + else if (mag(n[eFaces[0]] & n[eFaces[1]]) < 0.5) + { + featEdge[edgeI] = true; } } - if (isSelected) + // Do topological analysis of patch, find disconnected regions + patchZones pZones(pp, featEdge); + + nZones[patchI] = pZones.nZones(); + + labelList zoneNFaces(pZones.nZones(), 0); + + // Save start of information for current patch + label patchStart = zoneCentre.size(); + + // Create storage for additional zone centres + forAll(zoneNFaces, zoneI) { - const labelListList& edgeFaces = pp.edgeFaces(); - const vectorField& n = pp.faceNormals(); + zoneCentre.append(vector::zero); + } - boolList featEdge(pp.nEdges(), false); + // Do averaging per individual zone + forAll(pp, faceI) + { + label zoneI = pZones[faceI]; + zoneCentre[patchStart+zoneI] += pp[faceI].centre(pp.points()); + zoneNFaces[zoneI]++; + } - forAll(edgeFaces, edgeI) - { - const labelList& eFaces = edgeFaces[edgeI]; - - if (eFaces.size() != 2) - { - featEdge[edgeI] = true; - } - else if (mag(n[eFaces[0]] & n[eFaces[1]]) < 0.5) - { - featEdge[edgeI] = true; - } - } - - // Do topological analysis of patch. Determine disconnected regions - patchZones pZones(pp, featEdge); - - nZones[patchI] = pZones.nZones(); - - labelList zoneNFaces(pZones.nZones(), 0); - - // Save start of information for current patch - label patchStart = zoneCentre.size(); - - // Create storage for additional zone centres - forAll(zoneNFaces, zoneI) - { - zoneCentre.append(vector::zero); - } - - // Do averaging per individual zone - - forAll(pp, faceI) - { - label zoneI = pZones[faceI]; - zoneCentre[patchStart+zoneI] += pp[faceI].centre(pp.points()); - zoneNFaces[zoneI]++; - } - - for (label i=0; i Foam::vtkPV3Foam::addPatchNames)" << endl; + Info<< " Foam::vtkPV3Foam::addPatchNames" << endl; } } void Foam::vtkPV3Foam::removePatchNames(vtkRenderer* renderer) { - if (debug) - { - Info<< "removePatchNames()" << endl; - } - forAll(patchTextActorsPtrs_, patchI) { renderer->RemoveViewProp(patchTextActorsPtrs_[patchI]); patchTextActorsPtrs_[patchI]->Delete(); } - patchTextActorsPtrs_.setSize(0); + patchTextActorsPtrs_.clear(); } @@ -982,46 +710,4 @@ void Foam::vtkPV3Foam::PrintSelf(ostream& os, vtkIndent indent) const << (dbPtr_.valid() ? dbPtr_().times().size() : 0) << endl; } - -// parse these bits of info from /proc/meminfo (Linux) -// -// MemTotal: 2062660 kB -// MemFree: 1124400 kB -// -// used = MemTotal - MemFree is what the free(1) uses. -// -void Foam::vtkPV3Foam::printMemory() -{ - const char* meminfo = "/proc/meminfo"; - - if (exists(meminfo)) - { - IFstream is(meminfo); - label memTotal = 0; - label memFree = 0; - - string line; - - while (is.getLine(line).good()) - { - char tag[32]; - int value; - - if (sscanf(line.c_str(), "%30s %d", tag, &value) == 2) - { - if (!strcmp(tag, "MemTotal:")) - { - memTotal = value; - } - else if (!strcmp(tag, "MemFree:")) - { - memFree = value; - } - } - } - - Info << "memUsed: " << (memTotal - memFree) << " kB\n"; - } -} - // ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H index 0fbed64bfa..ada85c1373 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H @@ -32,23 +32,23 @@ 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 + vtkPV3FoamUtilities.C + vtkPV3FoamVolFields.H vtkPV3FoamAddToSelection.H - vtkPV3FoamAddVolumeMesh.C - vtkPV3FoamAddZoneMesh.C - vtkPV3FoamConvertFaceField.H - vtkPV3FoamConvertLagrangianFields.H - vtkPV3FoamConvertMesh.C - vtkPV3FoamConvertPatchFaceField.H - vtkPV3FoamConvertPatchPointField.H - vtkPV3FoamConvertPointFields.H - vtkPV3FoamConvertVolFields.H - vtkPV3FoamInsertNextPoint.H - vtkPV3FoamUpdate.C - vtkPV3FoamUpdateInformation.C - vtkPV3FoamUpdateInformationFields.H // Needed by VTK: vtkDataArrayTemplateImplicit.txx @@ -104,24 +104,22 @@ class List; class vtkPV3Foam { -public: + // Private classes - // Public data - - //- bookkeeping for the GUI checklists and the multi-block organization - class selectionInfo + //- Bookkeeping for GUI checklists and the multi-block organization + class partInfo { - int block_; const char *name_; + int block_; int start_; int size_; public: - selectionInfo(const int blockNo, const char *name) + partInfo(const char *name, const int blockNo=0) : - block_(blockNo), name_(name), + block_(blockNo), start_(-1), size_(0) {} @@ -132,6 +130,13 @@ public: return block_; } + int block(int blockNo) + { + int prev = block_; + block_ = blockNo; + return prev; + } + const char* name() const { return name_; @@ -172,26 +177,67 @@ public: } }; - -private: - - // Private data - - //BTX - //- Indices for datasets in vtkMultiBlockDataSet - enum + //- bookkeeping for polyhedral cell decomposition + // hide in extra pointMap (cellSet/cellZone) for now + class polyDecomp { - VOLUME = 0, // internal mesh - PATCHES = 1, // patches - LAGRANGIAN = 2, - CELLZONE = 3, - FACEZONE = 4, - POINTZONE = 5, - CELLSET = 6, - FACESET = 7, - POINTSET = 8 + labelList superCells_; + labelList addPointCellLabels_; + labelList pointMap_; + + public: + + polyDecomp() + {} + + //- Label of original cell for decomposed cells + labelList& superCells() + { + return superCells_; + } + + //- Label of original cell for decomposed cells + const labelList& superCells() const + { + return superCells_; + } + + //- Cell-centre labels for additional points of decomposed cells + labelList& addPointCellLabels() + { + return addPointCellLabels_; + } + + //- Cell-centre labels for additional points of decomposed cells + const labelList& addPointCellLabels() const + { + return addPointCellLabels_; + } + + //- Point labels for subsetted meshes + labelList& pointMap() + { + return pointMap_; + } + + //- Point labels for subsetted meshes + const labelList& pointMap() const + { + return pointMap_; + } + + + //- Clear + void clear() + { + superCells_.clear(); + addPointCellLabels_.clear(); + pointMap_.clear(); + } }; - //ETX + + + // Private Data //- Access to the controlling vtkPV3FoamReader vtkPV3FoamReader* reader_; @@ -202,64 +248,51 @@ private: //- Foam mesh fvMesh* meshPtr_; - //- First instance and size of various regions - selectionInfo selectInfoVolume_; - selectionInfo selectInfoPatches_; - selectionInfo selectInfoLagrangian_; - selectionInfo selectInfoCellZones_; - selectionInfo selectInfoFaceZones_; - selectionInfo selectInfoPointZones_; - selectionInfo selectInfoCellSets_; - selectionInfo selectInfoFaceSets_; - selectionInfo selectInfoPointSets_; + //- Number of meshes + // TODO - for info only - only set up to process ONE mesh + int nMesh_; - //- Selected regions - // [0] = internal mesh, then lagrangian, patches, zones, sets - boolList selectedRegions_; + //- The time index + int timeIndex_; - //- Selected regions indices in each respective block - labelList selectedRegionDatasetIds_; + //- Track changes in mesh geometry + bool meshChanged_; - //- Labels of cell-centres used as additional points when decomposing - // polyhedra - labelList addPointCellLabels_; + //- Track changes in fields + bool fieldsChanged_; - //- Label of original cell for decomposed cells - // - internal mesh - labelList superCells_; + //- Selected geometrical parts (internalMesh, patches, ...) + boolList partStatus_; - //- Label of original cell for decomposed cells - // - cellZone meshes - List zoneSuperCells_; + //- Datasets corresponding to selected geometrical pieces + // a negative number indicates that no vtkmesh exists for this piece + labelList partDataset_; - //- Label of original cell for decomposed cells - // - cellSet meshes - List csetSuperCells_; + //- First instance and size of various mesh parts + // used to index into partStatus_ and partDataset_ + partInfo partInfoVolume_; + partInfo partInfoPatches_; + partInfo partInfoLagrangian_; + partInfo partInfoCellZones_; + partInfo partInfoFaceZones_; + partInfo partInfoPointZones_; + partInfo partInfoCellSets_; + partInfo partInfoFaceSets_; + partInfo partInfoPointSets_; - //- List of patch names + //- Decomposed cells information (mesh regions) + // TODO: regions + List regionPolyDecomp_; + + //- Decomposed cells information (cellZone meshes) + List zonePolyDecomp_; + + //- Decomposed cells information (cellSet meshes) + List csetPolyDecomp_; + + //- List of patch names for rendering to window List patchTextActorsPtrs_; - - // Dataset sizes - - //- Number of meshes - // TODO - for info only - only set up to process ONE mesh - int nMesh_; - - //- Cloud name to be processed - // TODO - currently only set up to process ONE cloud - word cloudName_; - - //- The time index - int timeIndex_; - - //- Track changes in mesh geometry - bool meshChanged_; - - //- Track changes in fields - bool fieldsChanged_; - - // Private Member Functions // Convenience method use to convert the readers from VTK 5 @@ -267,10 +300,10 @@ private: static void AddToBlock ( vtkMultiBlockDataSet* output, - const selectionInfo&, - const label datasetNo, vtkDataSet* dataset, - const string& blockName = string::null + const partInfo&, + const label datasetNo, + const string& datasetName ); // Convenience method use to convert the readers from VTK 5 @@ -278,7 +311,7 @@ private: static vtkDataSet* GetDataSetFromBlock ( vtkMultiBlockDataSet* output, - const selectionInfo&, + const partInfo&, const label datasetNo ); @@ -287,7 +320,7 @@ private: static label GetNumberOfDataSets ( vtkMultiBlockDataSet* output, - const selectionInfo& + const partInfo& ); //- Reset data counters @@ -295,45 +328,42 @@ private: // Update information helper functions - //- Update the regions selected in the GUI - void updateSelectedRegions(); + //- Update the mesh parts selected in the GUI + void updateMeshPartsStatus(); //- Internal mesh info - void updateInformationInternalMesh(); + void updateInfoInternalMesh(); //- Lagrangian info - void updateInformationLagrangian(); + void updateInfoLagrangian(); //- Patch info - void updateInformationPatches(); + void updateInfoPatches(); //- Set info - void updateInformationSets(); + void updateInfoSets(); + + //- Zone info + void updateInfoZones(); //- Read zone names for zoneType from file wordList readZoneNames(const word& zoneType); - //- Zone info - void updateInformationZones(); - - //- Add to paraview array selection + //- Add objects of Type to paraview array selection template label addToSelection ( - vtkDataArraySelection *arraySelection, + vtkDataArraySelection*, const IOobjectList&, - const string& suffix = "" + const string& suffix=string::null ); //- Field info template class patchType, class meshType> - void updateInformationFields - ( - vtkDataArraySelection *fieldSelection - ); + void updateInfoFields(vtkDataArraySelection*); //- Lagrangian field info - void updateInformationLagrangianFields(); + void updateInfoLagrangianFields(); // Update helper functions @@ -341,118 +371,112 @@ private: //- Foam mesh void updateFoamMesh(); + //- Reduce memory footprint after conversion + void reduceMemory(); + //- 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 //- Add internal mesh/cell set meshes - void addVolumeMesh - ( - const fvMesh&, - vtkUnstructuredGrid*, - labelList& superCells - ); + vtkUnstructuredGrid* volumeVTKMesh(const fvMesh&, polyDecomp&); //- Add Lagrangian mesh - void addLagrangianMesh + vtkPolyData* lagrangianVTKMesh ( const fvMesh&, - vtkPolyData* + const word& cloudName ); //- Add patch mesh - void addPatchMesh - ( - const polyPatch&, - vtkPolyData* - ); + vtkPolyData* patchVTKMesh(const polyPatch&); //- Add face zone mesh - void addFaceZoneMesh + vtkPolyData* faceZoneVTKMesh ( const fvMesh&, - const labelList& faceLabels, - vtkPolyData* + const labelList& faceLabels ); //- Add point zone - void addPointZoneMesh + vtkPolyData* pointZoneVTKMesh ( const fvMesh&, - const labelList& pointLabels, - vtkPolyData* - ); - - //- Add cell set mesh - void addCellSetMesh - ( - const fvMesh&, - vtkUnstructuredGrid* + const labelList& pointLabels ); //- Add face set mesh - void addFaceSetMesh + vtkPolyData* faceSetVTKMesh ( const fvMesh&, - const faceSet&, - vtkPolyData* + const faceSet& ); //- Add point mesh - void addPointSetMesh + vtkPolyData* pointSetVTKMesh ( const fvMesh&, - const pointSet&, - vtkPolyData* + const pointSet& ); + // 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 template label addObjectsToSelection ( - vtkDataArraySelection* fieldSelection, - const IOobjectList& objects, - const string& suffix = string::null + vtkDataArraySelection*, + const IOobjectList&, + const string& suffix=string::null ); @@ -463,32 +487,42 @@ private: void convertVolFields ( const fvMesh&, - const volPointInterpolation& pInterp, + const volPointInterpolation&, const PtrList >&, - const IOobjectList& objects, - vtkDataArraySelection* fieldSelection, + const IOobjectList&, vtkMultiBlockDataSet* output ); - //- Volume field - all types except scalar + //- Volume field - all selected parts + template + void convertVolFieldBlock + ( + const GeometricField&, + const GeometricField&, + vtkMultiBlockDataSet* output, + const partInfo& selector, + const List& decompLst + ); + + //- Volume field template void convertVolField ( const GeometricField&, vtkMultiBlockDataSet* output, - const selectionInfo&, + const partInfo&, const label datasetNo, - labelList& superCells + const polyDecomp& ); //- Patch field template - void convertPatchFaceField + void convertPatchField ( const word& name, const Field&, vtkMultiBlockDataSet* output, - const selectionInfo&, + const partInfo&, const label datasetNo ); @@ -498,7 +532,7 @@ private: ( const GeometricField&, vtkMultiBlockDataSet* output, - const selectionInfo&, + const partInfo&, const label datasetNo, const fvMesh&, const labelList& faceLabels @@ -510,7 +544,7 @@ private: ( const GeometricField&, vtkMultiBlockDataSet* output, - const selectionInfo&, + const partInfo&, const label datasetNo, const fvMesh&, const faceSet& @@ -520,19 +554,18 @@ private: template void convertLagrangianFields ( - const fvMesh&, - const IOobjectList& objects, - vtkDataArraySelection *fieldSelection, - vtkMultiBlockDataSet* output + const IOobjectList&, + vtkMultiBlockDataSet* output, + const label datasetNo ); - //- Lagrangian field - all types except scalar + //- Lagrangian field template void convertLagrangianField ( const IOField&, vtkMultiBlockDataSet* output, - const selectionInfo&, + const partInfo&, const label datasetNo ); @@ -540,31 +573,42 @@ private: template void convertPointFields ( - const fvMesh& mesh, - const IOobjectList& objects, - vtkDataArraySelection *fieldSelection, + const fvMesh&, + const pointMesh&, + const IOobjectList&, vtkMultiBlockDataSet* output ); - //- Point fields - all types except scalar + //- Point field - all selected parts + template + void convertPointFieldBlock + ( + const GeometricField&, + vtkMultiBlockDataSet* output, + const partInfo& selector, + const List& + ); + + //- Point fields template void convertPointField ( - const GeometricField& ptf, - const GeometricField& tf, + const GeometricField&, + const GeometricField&, vtkMultiBlockDataSet* output, - const selectionInfo&, - const label datasetNo + const partInfo&, + const label datasetNo, + const polyDecomp& ); - //- Patch point field - all types except scalar + //- Patch point field template void convertPatchPointField ( const word& name, - const Field& tf, + const Field&, vtkMultiBlockDataSet* output, - const selectionInfo&, + const partInfo&, const label datasetNo ); @@ -574,28 +618,43 @@ private: //- Extract up to the first non-word characters inline static word getFirstWord(const char*); - //- Store the current selection(s) - static stringList getSelectedArrayEntries + //- Only keep what is listed in hashSet + static void pruneObjectList ( - vtkDataArraySelection* arraySelection, - const bool firstWord = false + IOobjectList&, + const wordHashSet& ); - //- Store the current selection(s) for a sub-selection + //- Retrieve the current selections + static wordHashSet getSelected(vtkDataArraySelection*); + + //- Retrieve a sub-list of the current selections + static wordHashSet getSelected + ( + vtkDataArraySelection*, + const partInfo& + ); + + //- Retrieve the current selections + static stringList getSelectedArrayEntries(vtkDataArraySelection*); + + //- Retrieve a sub-list of the current selections static stringList getSelectedArrayEntries ( - vtkDataArraySelection* arraySelection, - const selectionInfo&, - const bool firstWord = false + vtkDataArraySelection*, + const partInfo& ); //- Set selection(s) static void setSelectedArrayEntries ( - vtkDataArraySelection* arraySelection, - const stringList& selectedEntries + vtkDataArraySelection*, + const stringList& ); + //- Get the first word from the mesh parts selection + word getPartName(int); + //- Disallow default bitwise copy construct vtkPV3Foam(const vtkPV3Foam&); @@ -629,9 +688,13 @@ public: // Member Functions //- Update - void UpdateInformation(); + void updateInfo(); - void Update(vtkMultiBlockDataSet* output); + void Update + ( + vtkMultiBlockDataSet* output, + vtkMultiBlockDataSet* lagrangianOutput + ); //- Allocate and return a list of selected times // returns the count via the parameter @@ -643,10 +706,15 @@ public: //- Remove patch names from the display void removePatchNames(vtkRenderer* renderer); - //- set the runTime to the requested time - // sets to "constant" on error - bool setTime(const double& requestedTime); + //- set the runTime to the requested time, returns the timeIndex + // sets to "constant" on error and returns -1 + int setTime(const double& requestedTime); + //- The current time index + int timeIndex() const + { + return timeIndex_; + } // Access diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddToSelection.H b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddToSelection.H index 08a3162686..5648889ff0 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddToSelection.H +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddToSelection.H @@ -28,6 +28,7 @@ License #define vtkPV3FoamAddToSelection_H // FOAM includes +#include "IOobjectList.H" #include "SortableList.H" // VTK includes @@ -38,51 +39,26 @@ License template Foam::label Foam::vtkPV3Foam::addToSelection ( - vtkDataArraySelection *arraySelection, + vtkDataArraySelection *select, const IOobjectList& objectLst, const string& suffix ) { - IOobjectList objects(objectLst.lookupClass(Type::typeName)); + SortableList names(objectLst.names(Type::typeName)); - SortableList objectNames(objects.size()); - - label count = 0; - forAllConstIter(IOobjectList, objects, iter) + forAll(names, nameI) { - objectNames[count++] = iter()->name(); - } - - if (count) - { - objectNames.sort(); - - forAll (objectNames, objI) + if (suffix.size()) { - if (debug) - { - Info<<" addToSelection<" << Type::typeName << "> to GUI " - << ":" << objectNames[objI] << endl; - } - - if (suffix.size()) - { - arraySelection->AddArray - ( - (objectNames[objI] + suffix).c_str() - ); - } - else - { - arraySelection->AddArray - ( - objectNames[objI].c_str() - ); - } + select->AddArray((names[nameI] + suffix).c_str()); + } + else + { + select->AddArray(names[nameI].c_str()); } } - return count; + return names.size(); } diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertLagrangianFields.H b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertLagrangianFields.H deleted file mode 100644 index 0ccc3f81a0..0000000000 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertLagrangianFields.H +++ /dev/null @@ -1,139 +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 - -InClass - vtkPV3Foam - -\*---------------------------------------------------------------------------*/ - -#ifndef vtkPV3FoamConvertLagrangianFields_H -#define vtkPV3FoamConvertLagrangianFields_H - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -template -void Foam::vtkPV3Foam::convertLagrangianFields -( - const fvMesh& mesh, - const IOobjectList& objects, - vtkDataArraySelection* fieldSelection, - vtkMultiBlockDataSet* output -) -{ - const selectionInfo& selector = selectInfoLagrangian_; - const label datasetId = 0; - - if (!selector.size()) - { - return; - } - - IOobjectList fieldObjects - ( - objects.lookupClass - ( - IOField::typeName - ) - ); - - label nFields = fieldSelection->GetNumberOfArrays(); - - for (label i=0; iGetArraySetting(i)) - { - const word fieldName = fieldSelection->GetArrayName(i); - - if (fieldObjects.found(fieldName)) - { - IOField iotf - ( - IOobject - ( - fieldName, - mesh.time().timeName(), - "lagrangian"/cloudName_, - mesh, - IOobject::MUST_READ - ) - ); - - convertLagrangianField(iotf, output, selector, datasetId); - } - } - } -} - - -template -void Foam::vtkPV3Foam::convertLagrangianField -( - const IOField& tf, - vtkMultiBlockDataSet* output, - const selectionInfo& selector, - const label datasetNo -) -{ - const label nComp = pTraits::nComponents; - - vtkPolyData* vtkmesh = vtkPolyData::SafeDownCast - ( - GetDataSetFromBlock(output, selector, datasetNo) - ); - - vtkFloatArray *pointData = vtkFloatArray::New(); - pointData->SetNumberOfTuples(tf.size()); - pointData->SetNumberOfComponents(nComp); - pointData->Allocate(nComp*tf.size()); - pointData->SetName(tf.name().c_str()); - - if (debug) - { - Info<< "converting Lagrangian Field: " << tf.name() << nl - << "tf.size() = " << tf.size() << nl - << "nComp = " << nComp << endl; - } - - float vec[nComp]; - - forAll(tf, i) - { - for (direction d=0; dInsertTuple(i, vec); - } - - vtkmesh->GetPointData()->AddArray(pointData); - pointData->Delete(); -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertMesh.C b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertMesh.C deleted file mode 100644 index 33b5891f04..0000000000 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertMesh.C +++ /dev/null @@ -1,649 +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 "cellSet.H" -#include "faceSet.H" -#include "pointSet.H" -#include "fvMeshSubset.H" -#include "vtkPV3FoamReader.h" - -// VTK includes -#include "vtkDataArraySelection.h" -#include "vtkMultiBlockDataSet.h" -#include "vtkPolyData.h" -#include "vtkUnstructuredGrid.h" - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -void Foam::vtkPV3Foam::convertMeshVolume -( - vtkMultiBlockDataSet* output -) -{ - if (debug) - { - Info<< " Foam::vtkPV3Foam::convertMeshVolume" << endl; - printMemory(); - } - - const selectionInfo& selector = selectInfoVolume_; - const fvMesh& mesh = *meshPtr_; - - // Create the internal mesh and add as dataset 0 - for - ( - int regionId = selector.start(); - regionId < selector.end(); - ++regionId - ) - { - if (!selectedRegions_[regionId]) - { - continue; - } - - // word selectName = getFirstWord - // ( - // arraySelection->GetArrayName(regionId) - // ); - - if (debug) - { - Info<< "Creating VTK internalMesh" << endl; - } - - const label datasetId = 0; - - vtkUnstructuredGrid* vtkmesh = vtkUnstructuredGrid::New(); - addVolumeMesh(mesh, vtkmesh, superCells_); - - AddToBlock(output, selector, datasetId, vtkmesh, "internalMesh"); - selectedRegionDatasetIds_[regionId] = datasetId; - vtkmesh->Delete(); - } - - if (debug) - { - Info<< " Foam::vtkPV3Foam::convertMeshVolume" << endl; - printMemory(); - } -} - - -void Foam::vtkPV3Foam::convertMeshLagrangian -( - vtkMultiBlockDataSet* output -) -{ - if (debug) - { - Info<< " Foam::vtkPV3Foam::convertMeshLagrangian" << endl; - printMemory(); - } - - const selectionInfo& selector = selectInfoLagrangian_; - const fvMesh& mesh = *meshPtr_; - - // Create the Lagrangian mesh and add as dataset 0 - for - ( - int regionId = selector.start(); - regionId < selector.end(); - ++regionId - ) - { - if (!selectedRegions_[regionId]) - { - continue; - } - - if (debug) - { - Info<< "Creating VTK Lagrangian mesh" << endl; - } - - const label datasetId = 0; - - vtkPolyData* vtkmesh = vtkPolyData::New(); - addLagrangianMesh(mesh, vtkmesh); - - AddToBlock(output, selector, datasetId, vtkmesh, cloudName_); - selectedRegionDatasetIds_[regionId] = datasetId; - vtkmesh->Delete(); - } - if (debug) - { - Info<< " Foam::vtkPV3Foam::convertMeshLagrangian" << endl; - printMemory(); - } -} - - -void Foam::vtkPV3Foam::convertMeshPatches -( - vtkMultiBlockDataSet* output -) -{ - if (debug) - { - Info<< " Foam::vtkPV3Foam::convertMeshPatches" << endl; - printMemory(); - } - - const selectionInfo& selector = selectInfoPatches_; - vtkDataArraySelection* arraySelection = reader_->GetRegionSelection(); - - if (selector.size()) - { - const fvMesh& mesh = *meshPtr_; - const polyBoundaryMesh& patches = mesh.boundaryMesh(); - - // Create the patches and add as dataset ... - for - ( - int regionId = selector.start(); - regionId < selector.end(); - ++regionId - ) - { - if (!selectedRegions_[regionId]) - { - continue; - } - - word selectName = getFirstWord - ( - arraySelection->GetArrayName(regionId) - ); - - const label patchId = patches.findPatchID(selectName); - - if (debug) - { - Info<< "Creating VTK mesh for patch: " << selectName - << " region index: " << regionId << endl; - } - - const label datasetId = GetNumberOfDataSets(output, selector); - - vtkPolyData* vtkmesh = vtkPolyData::New(); - addPatchMesh - ( - patches[patchId], - vtkmesh - ); - - AddToBlock - ( - output, selector, datasetId, vtkmesh, - selectName + ":patch" - ); - selectedRegionDatasetIds_[regionId] = datasetId; - vtkmesh->Delete(); - } - } - - if (debug) - { - Info<< " Foam::vtkPV3Foam::convertMeshPatches" << endl; - printMemory(); - } -} - - -void Foam::vtkPV3Foam::convertMeshCellZones -( - vtkMultiBlockDataSet* output -) -{ - if (debug) - { - Info<< " Foam::vtkPV3Foam::convertMeshCellZones" << endl; - printMemory(); - } - - const selectionInfo& selector = selectInfoCellZones_; - const fvMesh& mesh = *meshPtr_; - - // Create the cell zone(s) and add as DataSet(CELLZONE, 0..n) - if (selector.size()) - { - const cellZoneMesh& czMesh = mesh.cellZones(); - - // use the zoneId directly instead of the name - for (int zoneI=0; zoneI < selector.size(); ++zoneI) - { - const int regionId = selector.start() + zoneI; - - if (!selectedRegions_[regionId]) - { - continue; - } - - if (debug) - { - Info<< "Creating VTK mesh for cellZone: " - << zoneI << endl; - } - - fvMeshSubset subsetter(mesh); - subsetter.setLargeCellSubset(czMesh[zoneI]); - - const label datasetId = GetNumberOfDataSets(output, selector); - - vtkUnstructuredGrid* vtkmesh = vtkUnstructuredGrid::New(); - - addVolumeMesh - ( - subsetter.subMesh(), - vtkmesh, - zoneSuperCells_[datasetId] - ); - - // renumber - superCells must contain global cell ids - inplaceRenumber - ( - subsetter.cellMap(), - zoneSuperCells_[datasetId] - ); - - AddToBlock - ( - output, selector, datasetId, vtkmesh, - czMesh.names()[zoneI] + ":cellZone" - ); - selectedRegionDatasetIds_[regionId] = datasetId; - vtkmesh->Delete(); - } - } - - if (debug) - { - Info<< " Foam::vtkPV3Foam::convertMeshCellZones" << endl; - printMemory(); - } -} - - -void Foam::vtkPV3Foam::convertMeshCellSets -( - vtkMultiBlockDataSet* output -) -{ - if (debug) - { - Info<< " Foam::vtkPV3Foam::convertMeshCellSets" << endl; - printMemory(); - } - - const selectionInfo& selector = selectInfoCellSets_; - vtkDataArraySelection* arraySelection = reader_->GetRegionSelection(); - - // Create the cell sets and add as dataset - if (selector.size()) - { - const fvMesh& mesh = *meshPtr_; - - for - ( - int regionId = selector.start(); - regionId < selector.end(); - ++regionId) - { - if (!selectedRegions_[regionId]) - { - continue; - } - - word selectName = getFirstWord - ( - arraySelection->GetArrayName(regionId) - ); - - if (debug) - { - Info<< "Creating VTK mesh for cellSet: " << selectName - << " region index: " << regionId << endl; - } - - const cellSet cSet(mesh, selectName); - fvMeshSubset subsetter(mesh); - subsetter.setLargeCellSubset(cSet); - - const label datasetId = GetNumberOfDataSets(output, selector); - - vtkUnstructuredGrid* vtkmesh = vtkUnstructuredGrid::New(); - - addVolumeMesh - ( - subsetter.subMesh(), - vtkmesh, - csetSuperCells_[datasetId] - ); - - // renumber - superCells must contain global cell ids - inplaceRenumber - ( - subsetter.cellMap(), - csetSuperCells_[datasetId] - ); - - AddToBlock - ( - output, selector, datasetId, vtkmesh, - selectName + ":cellSet" - ); - selectedRegionDatasetIds_[regionId] = datasetId; - vtkmesh->Delete(); - } - } - - if (debug) - { - Info<< " Foam::vtkPV3Foam::convertMeshCellSets" << endl; - printMemory(); - } -} - - -void Foam::vtkPV3Foam::convertMeshFaceZones -( - vtkMultiBlockDataSet* output -) -{ - if (debug) - { - Info<< " Foam::vtkPV3Foam::convertMeshFaceZones" << endl; - printMemory(); - } - - const selectionInfo& selector = selectInfoFaceZones_; - const fvMesh& mesh = *meshPtr_; - - // Create the cell zone(s) and add as datasets - if (selector.size()) - { - const faceZoneMesh& fzMesh = mesh.faceZones(); - - // use the zoneId directly instead of the name - for (int zoneI=0; zoneI < selector.size(); ++zoneI) - { - const int regionId = selector.start() + zoneI; - - if (!selectedRegions_[regionId]) - { - continue; - } - - if (debug) - { - Info<< "Creating VTK mesh for faceZone: " - << zoneI << endl; - } - - const label datasetId = GetNumberOfDataSets(output, selector); - - vtkPolyData* vtkmesh = vtkPolyData::New(); - - addFaceZoneMesh - ( - mesh, - fzMesh[zoneI], - vtkmesh - ); - - AddToBlock - ( - output, selector, datasetId, vtkmesh, - fzMesh.names()[zoneI] + ":faceZone" - ); - selectedRegionDatasetIds_[regionId] = datasetId; - vtkmesh->Delete(); - } - } - - if (debug) - { - Info<< " Foam::vtkPV3Foam::convertMeshFaceZones" << endl; - printMemory(); - } -} - - -void Foam::vtkPV3Foam::convertMeshFaceSets -( - vtkMultiBlockDataSet* output -) -{ - if (debug) - { - Info<< " Foam::vtkPV3Foam::convertMeshFaceSets" << endl; - printMemory(); - } - - const selectionInfo& selector = selectInfoFaceSets_; - vtkDataArraySelection* arraySelection = reader_->GetRegionSelection(); - - // Create the face sets and add as dataset - if (selector.size()) - { - const fvMesh& mesh = *meshPtr_; - - for - ( - int regionId = selector.start(); - regionId < selector.end(); - ++regionId - ) - { - if (!selectedRegions_[regionId]) - { - continue; - } - - word selectName = getFirstWord - ( - arraySelection->GetArrayName(regionId) - ); - - if (debug) - { - Info<< "Creating VTK mesh for faceSet: " << selectName - << " region index: " << regionId << endl; - } - - const faceSet fSet(mesh, selectName); - - const label datasetId = GetNumberOfDataSets(output, selector); - - vtkPolyData* vtkmesh = vtkPolyData::New(); - addFaceSetMesh - ( - mesh, - fSet, - vtkmesh - ); - - AddToBlock - ( - output, selector, datasetId, vtkmesh, - selectName + ":faceSet" - ); - selectedRegionDatasetIds_[regionId] = datasetId; - vtkmesh->Delete(); - } - } - - if (debug) - { - Info<< " Foam::vtkPV3Foam::convertMeshFaceSets" << endl; - printMemory(); - } -} - - -void Foam::vtkPV3Foam::convertMeshPointZones -( - vtkMultiBlockDataSet* output -) -{ - if (debug) - { - Info<< " Foam::vtkPV3Foam::convertMeshPointZones" << endl; - printMemory(); - } - - const selectionInfo& selector = selectInfoPointZones_; - const fvMesh& mesh = *meshPtr_; - - // Create the point sets and add as dataset - if (selector.size()) - { - const pointZoneMesh& pzMesh = mesh.pointZones(); - - // use the zoneId directly instead of the name - for (int zoneI=0; zoneI < selector.size(); ++zoneI) - { - const int regionId = selector.start() + zoneI; - - if (!selectedRegions_[regionId]) - { - continue; - } - - if (debug) - { - Info<< "Creating VTK mesh for pointZone: " - << zoneI << endl; - } - - const label datasetId = GetNumberOfDataSets(output, selector); - - vtkPolyData* vtkmesh = vtkPolyData::New(); - - addPointZoneMesh - ( - mesh, - pzMesh[zoneI], - vtkmesh - ); - - AddToBlock - ( - output, selector, datasetId, vtkmesh, - pzMesh.names()[zoneI] + ":pointZone" - ); - selectedRegionDatasetIds_[regionId] = datasetId; - vtkmesh->Delete(); - } - } - - if (debug) - { - Info<< " Foam::vtkPV3Foam::convertMeshPointZones" << endl; - printMemory(); - } -} - - - -void Foam::vtkPV3Foam::convertMeshPointSets -( - vtkMultiBlockDataSet* output -) -{ - if (debug) - { - Info<< " Foam::vtkPV3Foam::convertMeshPointSets" << endl; - printMemory(); - } - - const selectionInfo& selector = selectInfoPointSets_; - vtkDataArraySelection* arraySelection = reader_->GetRegionSelection(); - - // Create the point sets and add as dataset - if (selector.size()) - { - const fvMesh& mesh = *meshPtr_; - - for - ( - int regionId = selector.start(); - regionId < selector.end(); - ++regionId - ) - { - if (!selectedRegions_[regionId]) - { - continue; - } - - word selectName = getFirstWord - ( - arraySelection->GetArrayName(regionId) - ); - - - if (debug) - { - Info<< "Creating VTK mesh for pointSet: " << selectName - << " region index: " << regionId << endl; - } - - const pointSet pSet(mesh, selectName); - - const label datasetId = GetNumberOfDataSets(output, selector); - - vtkPolyData* vtkmesh = vtkPolyData::New(); - addPointSetMesh - ( - mesh, - pSet, - vtkmesh - ); - AddToBlock - ( - output, selector, datasetId, vtkmesh, - selectName + ":pointSet" - ); - selectedRegionDatasetIds_[regionId] = datasetId; - vtkmesh->Delete(); - } - } - - if (debug) - { - Info<< " Foam::vtkPV3Foam::convertMeshPointSets" << endl; - printMemory(); - } -} - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertPointFields.H b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertPointFields.H deleted file mode 100644 index d26a0eb365..0000000000 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertPointFields.H +++ /dev/null @@ -1,211 +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 - -InClass - vtkPV3Foam - -\*---------------------------------------------------------------------------*/ - -#ifndef vtkPV3FoamConvertPointFields_H -#define vtkPV3FoamConvertPointFields_H - -// Foam includes -#include "interpolatePointToCell.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -template -void Foam::vtkPV3Foam::convertPointFields -( - const fvMesh& mesh, - const IOobjectList& objects, - vtkDataArraySelection* fieldSelection, - vtkMultiBlockDataSet* output -) -{ - IOobjectList fieldObjects - ( - objects.lookupClass - ( - GeometricField::typeName - ) - ); - - label nSelectedFields = fieldSelection->GetNumberOfArrays(); - const polyBoundaryMesh& patches = mesh.boundaryMesh(); - - for (label i=0; iGetArraySetting(i)) - { - word fieldName = fieldSelection->GetArrayName(i); - - 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 - 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++; - } - } - } - } - } -} - - -template -void Foam::vtkPV3Foam::convertPointField -( - const GeometricField& ptf, - const GeometricField& tf, - vtkMultiBlockDataSet* output, - const selectionInfo& selector, - const label datasetNo -) -{ - const label nComp = pTraits::nComponents; - - vtkUnstructuredGrid* internalMesh = vtkUnstructuredGrid::SafeDownCast - ( - GetDataSetFromBlock(output, selector, datasetNo) - ); - - vtkFloatArray *pointData = vtkFloatArray::New(); - pointData->SetNumberOfTuples(ptf.size() + addPointCellLabels_.size()); - pointData->SetNumberOfComponents(nComp); - pointData->Allocate(nComp*ptf.size()); - pointData->SetName(tf.name().c_str()); - - float vec[nComp]; - - forAll(ptf, i) - { - for (direction d=0; dInsertTuple(i, vec); - } - - label i = ptf.size(); - - if (&tf != &GeometricField::null()) - { - forAll(addPointCellLabels_, api) - { - Type t = tf[addPointCellLabels_[api]]; - - for (direction d=0; dInsertTuple(i++, vec); - } - } - else - { - forAll(addPointCellLabels_, api) - { - Type t = interpolatePointToCell(ptf, addPointCellLabels_[api]); - - for (direction d=0; dInsertTuple(i++, vec); - } - } - - internalMesh->GetPointData()->AddArray(pointData); - pointData->Delete(); -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertVolFields.H b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertVolFields.H deleted file mode 100644 index 7543f58c9c..0000000000 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertVolFields.H +++ /dev/null @@ -1,416 +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 - -InClass - vtkPV3Foam - -\*---------------------------------------------------------------------------*/ - -#ifndef vtkPV3FoamConvertVolFields_H -#define vtkPV3FoamConvertVolFields_H - -// Foam includes -#include "emptyFvPatchField.H" -#include "wallPolyPatch.H" -#include "faceSet.H" -#include "vtkPV3FoamConvertPatchFaceField.H" -#include "vtkPV3FoamConvertPatchPointField.H" -#include "vtkPV3FoamConvertFaceField.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -template -void Foam::vtkPV3Foam::convertVolFields -( - const fvMesh& mesh, - const volPointInterpolation& pInterp, - const PtrList >& ppInterpList, - const IOobjectList& objects, - vtkDataArraySelection *fieldSelection, - vtkMultiBlockDataSet* output -) -{ - IOobjectList fieldObjects - ( - objects.lookupClass - ( - GeometricField::typeName - ) - ); - - label nFields = fieldSelection->GetNumberOfArrays(); - const polyBoundaryMesh& patches = mesh.boundaryMesh(); - - vtkDataArraySelection* arraySelector = reader_->GetRegionSelection(); - - for (label i=0; iGetArrayName(i); - - if - ( - !fieldSelection->GetArraySetting(i) - || !fieldObjects.found(fieldName)) - { - continue; - } - - if (debug) - { - Info<< "converting Foam volume field: " << fieldName - << endl; - } - - GeometricField tf - ( - IOobject - ( - fieldName, - mesh.time().timeName(), - mesh, - IOobject::MUST_READ - ), - mesh - ); - - tmp > tptf - ( - pInterp.interpolate(tf) - ); - - // Convert internal mesh - for - ( - int regionId = selectInfoVolume_.start(); - regionId < selectInfoVolume_.end(); - ++regionId - ) - { - if (selectedRegions_[regionId]) - { - convertVolField - ( - tf, - output, - selectInfoVolume_, - selectedRegionDatasetIds_[regionId], - superCells_ - ); - convertPointField - ( - tptf(), - tf, - output, - selectInfoVolume_, - selectedRegionDatasetIds_[regionId] - ); - } - } - - - // Convert patches - for - ( - int regionId = selectInfoPatches_.start(); - regionId < selectInfoPatches_.end(); - ++regionId - ) - { - if (!selectedRegions_[regionId]) - { - continue; - } - - word selectName = getFirstWord - ( - arraySelector->GetArrayName(regionId) - ); - - const label patchId = patches.findPatchID(selectName); - - const fvPatchField& ptf - ( - tf.boundaryField()[patchId] - ); - - if - ( - isType >(ptf) - || - ( - typeid(patches[patchId]) == typeid(wallPolyPatch) - && reader_->GetExtrapolateWalls() - ) - ) - { - fvPatch p - ( - ptf.patch().patch(), - tf.mesh().boundary() - ); - - convertPatchFaceField - ( - tf.name(), - fvPatchField(p, tf).patchInternalField()(), - output, - selectInfoPatches_, - selectedRegionDatasetIds_[regionId] - ); - } - else - { - convertPatchFaceField - ( - tf.name(), - ptf, - output, - selectInfoPatches_, - selectedRegionDatasetIds_[regionId] - ); - } - - convertPatchPointField - ( - tf.name(), - ppInterpList[patchId].faceToPointInterpolate(ptf)(), - output, - selectInfoPatches_, - selectedRegionDatasetIds_[regionId] - ); - } - - // Convert cell zones - for - ( - int regionId = selectInfoCellZones_.start(); - regionId < selectInfoCellZones_.end(); - ++regionId - ) - { - if (!selectedRegions_[regionId]) - { - continue; - } - - if (debug) - { - - word selectName = getFirstWord - ( - arraySelector->GetArrayName(regionId) - ); - - Info<< "wish to convert cellzone: " << selectName - << " regionId: " << regionId - << " volume field: " << fieldName - << endl; - } - - const label datasetId = - selectedRegionDatasetIds_[regionId]; - - convertVolField - ( - tf, - output, selectInfoCellZones_, datasetId, - zoneSuperCells_[datasetId] - ); - } - - // Convert cell sets - for - ( - int regionId = selectInfoCellSets_.start(); - regionId < selectInfoCellSets_.end(); - ++regionId - ) - { - if (!selectedRegions_[regionId]) - { - continue; - } - - if (debug) - { - word selectName = getFirstWord - ( - arraySelector->GetArrayName(regionId) - ); - - Info<< "wish to convert cellset: " << selectName - << " regionId: " << regionId - << " volume field: " << fieldName - << endl; - } - - const label datasetId = - selectedRegionDatasetIds_[regionId]; - - convertVolField - ( - tf, - output, selectInfoCellSets_, datasetId, - csetSuperCells_[datasetId] - ); - } - - // Convert face zones - for - ( - int regionId = selectInfoFaceZones_.start(); - regionId < selectInfoFaceZones_.end(); - ++regionId - ) - { - if (!selectedRegions_[regionId]) - { - continue; - } - - if (debug) - { - word selectName = getFirstWord - ( - arraySelector->GetArrayName(regionId) - ); - - Info<< "wish to convert facezone: " << selectName - << " regionId: " << regionId - << " volume field: " << fieldName - << endl; - } - - const faceZoneMesh& fzMesh = mesh.faceZones(); - const label zoneI = regionId - selectInfoFaceZones_.start(); - - const label datasetId = - selectedRegionDatasetIds_[regionId]; - - convertFaceField - ( - tf, - output, selectInfoFaceZones_, datasetId, - mesh, - fzMesh[zoneI] - ); - } - - // Convert face sets - for - ( - int regionId = selectInfoFaceSets_.start(); - regionId < selectInfoFaceSets_.end(); - ++regionId - ) - { - if (!selectedRegions_[regionId]) - { - continue; - } - - word selectName = getFirstWord - ( - arraySelector->GetArrayName(regionId) - ); - - if (debug) - { - Info<< "wish to convert faceset: " << selectName - << " regionId: " << regionId - << " volume field: " << fieldName - << endl; - } - - const faceSet fSet(mesh, selectName); - - const label datasetId = - selectedRegionDatasetIds_[regionId]; - - convertFaceField - ( - tf, - output, selectInfoFaceSets_, datasetId, - mesh, - fSet - ); - } - } -} - - -template -void Foam::vtkPV3Foam::convertVolField -( - const GeometricField& tf, - vtkMultiBlockDataSet* output, - const selectionInfo& selector, - const label datasetNo, - labelList& superCells -) -{ - const label nComp = pTraits::nComponents; - - vtkUnstructuredGrid* vtkmesh = vtkUnstructuredGrid::SafeDownCast - ( - GetDataSetFromBlock(output, selector, datasetNo) - ); - - vtkFloatArray* celldata = vtkFloatArray::New(); - celldata->SetNumberOfTuples(superCells.size()); - celldata->SetNumberOfComponents(nComp); - celldata->Allocate(nComp*superCells.size()); - celldata->SetName(tf.name().c_str()); - - if (debug) - { - Info<< "converting volField: " << tf.name() << nl - << "field size = " << tf.size() << nl - << "nTuples = " << superCells.size() << nl - << "nComp = " << nComp << endl; - } - - float vec[nComp]; - - forAll(superCells, scI) - { - const Type& t = tf[superCells[scI]]; - for (direction d=0; dInsertTuple(scI, vec); - } - - vtkmesh->GetCellData()->AddArray(celldata); - celldata->Delete(); -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertFaceField.H b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamFaceField.H similarity index 75% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertFaceField.H rename to applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamFaceField.H index 114aab667a..b3fdcacf32 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertFaceField.H +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamFaceField.H @@ -27,8 +27,8 @@ InClass \*---------------------------------------------------------------------------*/ -#ifndef vtkPV3FoamConvertFaceField_H -#define vtkPV3FoamConvertFaceField_H +#ifndef vtkPV3FoamFaceField_H +#define vtkPV3FoamFaceField_H // VTK includes #include "vtkCellData.h" @@ -42,31 +42,36 @@ void Foam::vtkPV3Foam::convertFaceField ( const GeometricField& tf, vtkMultiBlockDataSet* output, - const selectionInfo& selector, + const partInfo& selector, const label datasetNo, const fvMesh& mesh, const labelList& faceLabels ) { const label nComp = pTraits::nComponents; - - vtkPolyData* vtkmesh = vtkPolyData::SafeDownCast - ( - GetDataSetFromBlock(output, selector, datasetNo) - ); - const label nInternalFaces = mesh.nInternalFaces(); const labelList& faceOwner = mesh.faceOwner(); const labelList& faceNeigh = mesh.faceNeighbour(); vtkFloatArray *cellData = vtkFloatArray::New(); - cellData->SetNumberOfTuples(faceLabels.size()); - cellData->SetNumberOfComponents(nComp); - cellData->Allocate(nComp*faceLabels.size()); - cellData->SetName(tf.name().c_str()); + cellData->SetNumberOfTuples( faceLabels.size() ); + cellData->SetNumberOfComponents( nComp ); + cellData->Allocate( nComp*faceLabels.size() ); + cellData->SetName( tf.name().c_str() ); + + if (debug) + { + Info<< "convert convertFaceField: " + << tf.name() + << " size = " << tf.size() + << " nComp=" << nComp + << " nTuples = " << faceLabels.size() << endl; + } float vec[nComp]; + // for interior faces: average owner/neighbour + // for boundary faces: owner forAll(faceLabels, faceI) { const label faceNo = faceLabels[faceI]; @@ -91,7 +96,13 @@ void Foam::vtkPV3Foam::convertFaceField cellData->InsertTuple(faceI, vec); } - vtkmesh->GetCellData()->AddArray(cellData); + + vtkPolyData::SafeDownCast + ( + GetDataSetFromBlock(output, selector, datasetNo) + ) ->GetCellData() + ->AddArray(cellData); + cellData->Delete(); } @@ -101,31 +112,36 @@ void Foam::vtkPV3Foam::convertFaceField ( const GeometricField& tf, vtkMultiBlockDataSet* output, - const selectionInfo& selector, + const partInfo& selector, const label datasetNo, const fvMesh& mesh, const faceSet& fSet ) { const label nComp = pTraits::nComponents; - - vtkPolyData* vtkmesh = vtkPolyData::SafeDownCast - ( - GetDataSetFromBlock(output, selector, datasetNo) - ); - const label nInternalFaces = mesh.nInternalFaces(); const labelList& faceOwner = mesh.faceOwner(); const labelList& faceNeigh = mesh.faceNeighbour(); vtkFloatArray *cellData = vtkFloatArray::New(); - cellData->SetNumberOfTuples(fSet.size()); - cellData->SetNumberOfComponents(nComp); - cellData->Allocate(nComp*fSet.size()); - cellData->SetName(tf.name().c_str()); + cellData->SetNumberOfTuples( fSet.size() ); + cellData->SetNumberOfComponents( nComp ); + cellData->Allocate( nComp*fSet.size() ); + cellData->SetName( tf.name().c_str() ); + + if (debug) + { + Info<< "convert convertFaceField: " + << tf.name() + << " size = " << tf.size() + << " nComp=" << nComp + << " nTuples = " << fSet.size() << endl; + } float vec[nComp]; + // for interior faces: average owner/neighbour + // for boundary faces: owner label faceI = 0; forAllConstIter(faceSet, fSet, iter) { @@ -153,11 +169,16 @@ void Foam::vtkPV3Foam::convertFaceField ++faceI; } - vtkmesh->GetCellData()->AddArray(cellData); + + vtkPolyData::SafeDownCast + ( + GetDataSetFromBlock(output, selector, datasetNo) + ) ->GetCellData() + ->AddArray(cellData); + cellData->Delete(); } - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamFields.C b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamFields.C new file mode 100644 index 0000000000..bf5742e3a8 --- /dev/null +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamFields.C @@ -0,0 +1,319 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "IOobjectList.H" +#include "vtkPV3FoamReader.h" + +// VTK includes +#include "vtkDataArraySelection.h" +#include "vtkPolyData.h" +#include "vtkUnstructuredGrid.h" + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +#include "vtkPV3FoamVolFields.H" +#include "vtkPV3FoamPointFields.H" +#include "vtkPV3FoamLagrangianFields.H" + + +void Foam::vtkPV3Foam::pruneObjectList +( + IOobjectList& objects, + const wordHashSet& selected +) +{ + // hash all the selected field names + if (!selected.size()) + { + objects.clear(); + } + + // only keep selected fields + forAllIter(IOobjectList, objects, iter) + { + if (!selected.found(iter()->name())) + { + objects.erase(iter); + } + } +} + + +void Foam::vtkPV3Foam::convertVolFields +( + vtkMultiBlockDataSet* output +) +{ + wordHashSet selectedFields = getSelected + ( + reader_->GetVolFieldSelection() + ); + + if (!selectedFields.size()) + { + return; + } + + const fvMesh& mesh = *meshPtr_; + // Get objects (fields) for this time - only keep selected fields + IOobjectList objects(mesh, dbPtr_().timeName()); + pruneObjectList(objects, selectedFields); + + if (!objects.size()) + { + return; + } + + if (debug) + { + Info<< " Foam::vtkPV3Foam::convertVolFields" << nl + << "converting Foam volume fields" << endl; + forAllConstIter(IOobjectList, objects, iter) + { + Info<< " " << iter()->name() + << " == " << iter()->objectPath() << nl; + } + printMemory(); + } + + // Construct interpolation on the raw mesh + pointMesh pMesh(mesh); + volPointInterpolation pInterp(mesh, pMesh); + + PtrList > + ppInterpList(mesh.boundaryMesh().size()); + + forAll(ppInterpList, i) + { + ppInterpList.set + ( + i, + new PrimitivePatchInterpolation + ( + mesh.boundaryMesh()[i] + ) + ); + } + + + convertVolFields + ( + mesh, pInterp, ppInterpList, objects, output + ); + convertVolFields + ( + mesh, pInterp, ppInterpList, objects, output + ); + convertVolFields + ( + mesh, pInterp, ppInterpList, objects, output + ); + convertVolFields + ( + mesh, pInterp, ppInterpList, objects, output + ); + convertVolFields + ( + mesh, pInterp, ppInterpList, objects, output + ); + + if (debug) + { + Info<< " Foam::vtkPV3Foam::convertVolFields" << endl; + printMemory(); + } +} + + +void Foam::vtkPV3Foam::convertPointFields +( + vtkMultiBlockDataSet* output +) +{ + wordHashSet selectedFields = getSelected + ( + reader_->GetPointFieldSelection() + ); + + if (!selectedFields.size()) + { + return; + } + + const fvMesh& mesh = *meshPtr_; + // Get objects (fields) for this time - only keep selected fields + IOobjectList objects(mesh, dbPtr_().timeName()); + pruneObjectList(objects, selectedFields); + + if (!objects.size()) + { + return; + } + + if (debug) + { + Info<< " Foam::vtkPV3Foam::convertPointFields" << nl + << "converting Foam volume fields" << endl; + forAllConstIter(IOobjectList, objects, iter) + { + Info<< " " << iter()->name() + << " == " << iter()->objectPath() << nl; + } + printMemory(); + } + + // Construct interpolation on the raw mesh + pointMesh pMesh(mesh); + + + convertPointFields + ( + mesh, pMesh, objects, output + ); + convertPointFields + ( + mesh, pMesh, objects, output + ); + convertPointFields + ( + mesh, pMesh, objects, output + ); + convertPointFields + ( + mesh, pMesh, objects, output + ); + convertPointFields + ( + mesh, pMesh, objects, output + ); + + if (debug) + { + Info<< " Foam::vtkPV3Foam::convertPointFields" << endl; + printMemory(); + } +} + + +void Foam::vtkPV3Foam::convertLagrangianFields +( + vtkMultiBlockDataSet* output +) +{ + partInfo& selector = partInfoLagrangian_; + const fvMesh& mesh = *meshPtr_; + + wordHashSet selectedFields = getSelected + ( + reader_->GetLagrangianFieldSelection() + ); + + if (!selectedFields.size()) + { + return; + } + + if (debug) + { + Info<< " Foam::vtkPV3Foam::convertLagrangianFields" << endl; + printMemory(); + } + + for (int partId = selector.start(); partId < selector.end(); ++partId) + { + const word cloudName = getPartName(partId); + const label datasetNo = partDataset_[partId]; + + if (!partStatus_[partId] || datasetNo < 0) + { + continue; + } + + // Get the Lagrangian fields for this time and this cloud + // but only keep selected fields + IOobjectList objects + ( + mesh, + dbPtr_().timeName(), + "lagrangian"/cloudName + ); + pruneObjectList(objects, selectedFields); + + if (!objects.size()) + { + continue; + } + + if (debug) + { + Info<< "converting Foam lagrangian fields" << nl; + forAllConstIter(IOobjectList, objects, iter) + { + Info<< " " << iter()->name() + << " == " << iter()->objectPath() << nl; + } + } + + convertLagrangianFields