diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/PV3FoamReader_SM.xml b/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/PV3FoamReader_SM.xml index 07620fd849b9590f0c18a8e70d86dc868719bb7f..59c118281f5dc2979b31b9d7509d91c6a2dc83ff 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 @@ <ServerManagerConfiguration> - <ProxyGroup name="sources"> - <SourceProxy - - name="PV3FoamReader" - class="vtkPV3FoamReader"> - - <!-- File name - compulsory --> - <StringVectorProperty - name="FileName" - command="SetFileName" - number_of_elements="1"> - <FileListDomain - name="files"/> - </StringVectorProperty> - -<!-- Time info sent to animation controls (top of window) --> - - <DoubleVectorProperty - name="TimestepValues" - information_only="1"> - <TimeStepsInformationHelper/> - <Documentation> - Available timestep values. - </Documentation> - </DoubleVectorProperty> - - <DoubleVectorProperty - name="TimeRange" - information_only="1"> - <TimeRangeInformationHelper/> - </DoubleVectorProperty> - -<!-- ExtrapolateWalls check box --> - <IntVectorProperty - name="ExtrapolateWalls" - command="SetExtrapolateWalls" - number_of_elements="1" - default_values="0"> - <BooleanDomain - name="bool"/> - </IntVectorProperty> - -<!-- Include sets check box --> - <IntVectorProperty - name="IncludeSets" - command="SetIncludeSets" - number_of_elements="1" - default_values="0"> - <BooleanDomain - name="bool"/> - </IntVectorProperty> - -<!-- Include zones check box --> - <IntVectorProperty - name="IncludeZones" - command="SetIncludeZones" - number_of_elements="1" - default_values="0"> - <BooleanDomain - name="bool"/> - </IntVectorProperty> - -<!-- Show patch names check box --> - <IntVectorProperty - name="ShowPatchNames" - command="SetShowPatchNames" - number_of_elements="1" - default_values="0"> - <BooleanDomain name="bool"/> - </IntVectorProperty> - -<!-- Available regions array --> - <StringVectorProperty - name="RegionArrayInfo" - information_only="1"> - <ArraySelectionInformationHelper - attribute_name="Region"/> - </StringVectorProperty> - <StringVectorProperty - name="RegionStatus" - command="SetRegionArrayStatus" - number_of_elements="0" - repeat_command="1" - number_of_elements_per_command="2" - element_types="2 0" - information_property="RegionArrayInfo"> - <ArraySelectionDomain - name="array_list"> - <RequiredProperties> - <Property name="RegionArrayInfo" - function="ArrayList"/> - </RequiredProperties> - </ArraySelectionDomain> - </StringVectorProperty> - -<!-- Available volFields array --> - <StringVectorProperty - name="VolFieldArrayInfo" - information_only="1"> - <ArraySelectionInformationHelper - attribute_name="VolField"/> - </StringVectorProperty> - <StringVectorProperty - name="VolFieldStatus" - command="SetVolFieldArrayStatus" - number_of_elements="0" - repeat_command="1" - number_of_elements_per_command="2" - element_types="2 0" - information_property="VolFieldArrayInfo"> - <ArraySelectionDomain - name="array_list"> - <RequiredProperties> - <Property name="VolFieldArrayInfo" - function="ArrayList"/> - </RequiredProperties> - </ArraySelectionDomain> - </StringVectorProperty> - -<!-- Available pointFields array --> - <StringVectorProperty - name="PointFieldArrayInfo" - information_only="1"> - <ArraySelectionInformationHelper - attribute_name="PointField"/> - </StringVectorProperty> - <StringVectorProperty - name="PointFieldStatus" - command="SetPointFieldArrayStatus" - number_of_elements="0" - repeat_command="1" - number_of_elements_per_command="2" - element_types="2 0" - information_property="PointFieldArrayInfo"> - <ArraySelectionDomain - name="array_list"> - <RequiredProperties> - <Property name="PointFieldArrayInfo" - function="ArrayList"/> - </RequiredProperties> - </ArraySelectionDomain> - </StringVectorProperty> - -<!-- Available Lagrangian fields array --> - <StringVectorProperty - name="LagrangianFieldArrayInfo" - information_only="1"> - <ArraySelectionInformationHelper - attribute_name="LagrangianField"/> - </StringVectorProperty> - <StringVectorProperty - name="LagrangianFieldStatus" - command="SetLagrangianFieldArrayStatus" - number_of_elements="0" - repeat_command="1" - number_of_elements_per_command="2" - element_types="2 0" - information_property="LagrangianFieldArrayInfo"> - <ArraySelectionDomain - name="array_list"> - <RequiredProperties> - <Property name="LagrangianFieldArrayInfo" - function="ArrayList"/> - </RequiredProperties> - </ArraySelectionDomain> - </StringVectorProperty> - -<!-- Cache mesh check box --> - <IntVectorProperty - name="CacheMesh" - command="SetCacheMesh" - number_of_elements="1" - default_values="1"> - <BooleanDomain - name="bool"/> - </IntVectorProperty> - -<!-- Update GUI check box --> - <IntVectorProperty - name="UpdateGUI" - command="SetUpdateGUI" - number_of_elements="1" - default_values="0"> - <BooleanDomain - name="bool"/> - </IntVectorProperty> - - </SourceProxy> - </ProxyGroup> + <ProxyGroup name="sources"> + <SourceProxy + name="PV3FoamReader" + class="vtkPV3FoamReader"> + + <!-- File name - compulsory --> + <StringVectorProperty + name="FileName" + command="SetFileName" + number_of_elements="1" + animateable="0"> + <FileListDomain name="files"/> + <Documentation> + Specifies the filename for the OpenFOAM Reader. + </Documentation> + </StringVectorProperty> + + <!-- Send discrete time info to the animation panel --> + <DoubleVectorProperty + name="TimestepValues" + repeatable="1" + information_only="1"> + <TimeStepsInformationHelper/> + <Documentation> + Available timestep values. + </Documentation> + </DoubleVectorProperty> + + <!-- Send continuous time info to the animation panel --> + <DoubleVectorProperty + name="TimeRange" + information_only="1"> + <TimeRangeInformationHelper/> + </DoubleVectorProperty> + + <!-- Available Parts (volume, patches, lagrangian) array --> + <StringVectorProperty + name="PartArrayInfo" + information_only="1"> + <ArraySelectionInformationHelper attribute_name="Part"/> + </StringVectorProperty> + <StringVectorProperty + name="PartStatus" + label="Mesh Parts" + command="SetPartArrayStatus" + number_of_elements="0" + repeat_command="1" + number_of_elements_per_command="2" + element_types="2 0" + information_property="PartArrayInfo" + animateable="0"> + <ArraySelectionDomain name="array_list"> + <RequiredProperties> + <Property name="PartArrayInfo" function="ArrayList"/> + </RequiredProperties> + </ArraySelectionDomain> + </StringVectorProperty> + + <!-- Available volFields array --> + <StringVectorProperty + name="VolFieldArrayInfo" + information_only="1"> + <ArraySelectionInformationHelper attribute_name="VolField"/> + </StringVectorProperty> + <StringVectorProperty + name="VolFieldStatus" + label="Volume Fields" + command="SetVolFieldArrayStatus" + number_of_elements="0" + repeat_command="1" + number_of_elements_per_command="2" + element_types="2 0" + information_property="VolFieldArrayInfo" + animateable="0"> + <ArraySelectionDomain name="array_list"> + <RequiredProperties> + <Property name="VolFieldArrayInfo" function="ArrayList"/> + </RequiredProperties> + </ArraySelectionDomain> + </StringVectorProperty> + + <!-- Available Lagrangian fields array --> + <StringVectorProperty + name="LagrangianFieldArrayInfo" + information_only="1"> + <ArraySelectionInformationHelper attribute_name="LagrangianField"/> + </StringVectorProperty> + <StringVectorProperty + name="LagrangianFieldStatus" + label="Lagrangian Fields" + command="SetLagrangianFieldArrayStatus" + number_of_elements="0" + repeat_command="1" + number_of_elements_per_command="2" + element_types="2 0" + information_property="LagrangianFieldArrayInfo" + animateable="0"> + <ArraySelectionDomain name="array_list"> + <RequiredProperties> + <Property name="LagrangianFieldArrayInfo" function="ArrayList"/> + </RequiredProperties> + </ArraySelectionDomain> + </StringVectorProperty> + + <!-- Available pointFields array --> + <StringVectorProperty + name="PointFieldArrayInfo" + information_only="1"> + <ArraySelectionInformationHelper attribute_name="PointField"/> + </StringVectorProperty> + <StringVectorProperty + name="PointFieldStatus" + label="Point Fields" + command="SetPointFieldArrayStatus" + number_of_elements="0" + repeat_command="1" + number_of_elements_per_command="2" + element_types="2 0" + information_property="PointFieldArrayInfo" + animateable="0"> + <ArraySelectionDomain name="array_list"> + <RequiredProperties> + <Property name="PointFieldArrayInfo" function="ArrayList"/> + </RequiredProperties> + </ArraySelectionDomain> + </StringVectorProperty> + + <!-- Extrapolate Walls check-box --> + <IntVectorProperty + name="ExtrapolateWalls" + command="SetExtrapolateWalls" + number_of_elements="1" + default_values="0" + animateable="0"> + <BooleanDomain name="bool"/> + <Documentation> + Extrapolate internalField to wall and empty patches + </Documentation> + </IntVectorProperty> + + <!-- Include Sets check-box --> + <IntVectorProperty + name="IncludeSets" + command="SetIncludeSets" + number_of_elements="1" + default_values="0" + animateable="0"> + <Documentation> + Searches the polyMesh/sets/ directory + </Documentation> + <BooleanDomain name="bool"/> + </IntVectorProperty> + + <!-- Include Zones check-box --> + <IntVectorProperty + name="IncludeZones" + command="SetIncludeZones" + number_of_elements="1" + default_values="0" + animateable="0"> + <Documentation> + ZoneMesh information is used to find {cell,face,point}Zones. + The polyMesh/ directory is only checked on startup. + </Documentation> + <BooleanDomain name="bool"/> + </IntVectorProperty> + + <!-- Show Patch Names check-box --> + <IntVectorProperty + name="ShowPatchNames" + command="SetShowPatchNames" + number_of_elements="1" + default_values="0" + animateable="0"> + <BooleanDomain name="bool"/> + <Documentation> + Show patch names in render window. + </Documentation> + </IntVectorProperty> + + <!-- Cache Mesh check-box --> + <IntVectorProperty + name="CacheMesh" + command="SetCacheMesh" + number_of_elements="1" + default_values="1" + animateable="0"> + <BooleanDomain name="bool"/> + <Documentation> + Cache the fvMesh in memory. + </Documentation> + </IntVectorProperty> + + + <!-- Update GUI check box --> + <IntVectorProperty + name="UpdateGUI" + command="SetUpdateGUI" + number_of_elements="1" + default_values="0" + animateable="0"> + <BooleanDomain name="bool"/> + <Documentation> + A simple way cause a reader GUI modification. + </Documentation> + </IntVectorProperty> + + </SourceProxy> + </ProxyGroup> </ServerManagerConfiguration> diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.cxx b/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.cxx index 81885deee700655016c3a9afbbf36ea0d2f8bac1..70a6230bfe17dcf99d5085b866c3d3a25dc05f2e 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 (!foamData_) + if (Foam::vtkPV3Foam::debug) { - vtkDebugMacro("RequestInformation: creating foamData_"); - vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::SafeDownCast - ( - outInfo->Get(vtkMultiBlockDataSet::DATA_OBJECT()) - ); - - if (Foam::vtkPV3Foam::debug) + cout<<"RequestInformation with " << nInfo << " item(s)\n"; + for (int infoI = 0; infoI < nInfo; ++infoI) { - cout<< "constructed vtkPV3Foam with output: "; - output->Print(cout); + outputVector->GetInformationObject(infoI)->Print(cout); } + } + if (!foamData_) + { 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()) - ); - - if (Foam::vtkPV3Foam::debug) - { - vtkInformation* outputInfo = this->GetOutputPortInformation(0); - outputInfo->Print(cout); - - vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::SafeDownCast + outInfo->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); + vtkMultiBlockDataSet::DATA_OBJECT() + ) + ); - outInfo->Print(cout); - vtkMultiBlockDataSet* dobj = vtkMultiBlockDataSet::SafeDownCast + vtkMultiBlockDataSet* lagrangianOutput = vtkMultiBlockDataSet::SafeDownCast + ( + outputVector->GetInformationObject(1)->Get ( - 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); + } + +#else + + foamData_->Update(output, lagrangianOutput); + + if (ShowPatchNames) + { + addPatchNamesToView(); + } + else + { + removePatchNamesFromView(); } - UpdateGUIOld = GetUpdateGUI(); + +#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 8611884b519da42e8186240f73c11a5335d28179..fde87527de29c134526ee73c72909d1bd0fed8d9 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,34 +135,44 @@ public: protected: + //- Construct null vtkPV3FoamReader(); - ~vtkPV3FoamReader(); - char* FileName; + //- Destructor + ~vtkPV3FoamReader(); - virtual int RequestData + //- Return information about mesh, times, etc without loading anything + virtual int RequestInformation ( vtkInformation*, vtkInformationVector**, vtkInformationVector* ); - virtual int RequestInformation + //- Get the mesh/fields for a particular time + //- Destructor + virtual int RequestData ( vtkInformation*, vtkInformationVector**, vtkInformationVector* ); - // The observer to modify this object when the array selections - // are modified + //- 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 0a5e64ddf14feaed6766684c4c40e2315f661006..9699e3c71ebe3c4159b36ee2f5abb09d9730ab2e 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 8af700450c0e31c10a2a2544fae5603bd61b9992..10ccf691263ef8069171407b7f3aeb858a045a93 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" - +#include "vtkPV3FoamUpdateInfoFields.H" -void Foam::vtkPV3Foam::AddToBlock -( - vtkMultiBlockDataSet* output, - const selectionInfo& selector, - const label datasetNo, - vtkDataSet* dataset, - const string& blockName -) +void Foam::vtkPV3Foam::resetCounters() { - 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; - } + // Reset mesh part ids and sizes + partInfoVolume_.reset(); + partInfoPatches_.reset(); + partInfoLagrangian_.reset(); + partInfoCellZones_.reset(); + partInfoFaceZones_.reset(); + partInfoPointZones_.reset(); + partInfoCellSets_.reset(); + partInfoFaceSets_.reset(); + partInfoPointSets_.reset(); +} - if (!block) - { - block = vtkMultiBlockDataSet::New(); - output->SetBlock(blockNo, block); - block->Delete(); - } - if (block) +void Foam::vtkPV3Foam::reduceMemory() +{ + forAll(regionPolyDecomp_, i) { - 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() - ); - } + regionPolyDecomp_[i].clear(); } - - block->SetBlock(datasetNo, dataset); - - if (blockName.size()) + forAll(zonePolyDecomp_, i) { - block->GetMetaData(datasetNo)->Set - ( - vtkCompositeDataSet::NAME(), blockName.c_str() - ); + zonePolyDecomp_[i].clear(); } -} - - -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) + forAll(csetPolyDecomp_, i) { - return vtkDataSet::SafeDownCast(block->GetBlock(datasetNo)); + csetPolyDecomp_[i].clear(); } - 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) + if (!reader_->GetCacheMesh()) { - return block->GetNumberOfBlocks(); + delete meshPtr_; + meshPtr_ = NULL; } - - return 0; } -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(); -} -bool Foam::vtkPV3Foam::setTime(const double& requestedTime) +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<< "<beg> Foam::vtkPV3Foam::updateSelectedRegions" << endl; + Info<< "<beg> 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; - } - } - if (debug) - { - Info<< "<end> Foam::vtkPV3Foam::updateSelectedRegions" << 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; + Info<< " part[" << partId << "] = " + << partStatus_[partId] + << " : " << selection->GetArrayName(partId) << endl; } } - if (debug) { - Info<< " )" << endl; + Info<< "<end> Foam::vtkPV3Foam::updateMeshPartsStatus" << endl; } - - selections.setSize(nElem); - return selections; } - -void Foam::vtkPV3Foam::setSelectedArrayEntries -( - vtkDataArraySelection* arraySelection, - const stringList& selections -) -{ - if (debug > 1) - { - Info<< "<beg> 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; i<nEntries; i++) - { - string arrayName = arraySelection->GetArrayName(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<< "<end> 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,182 +280,189 @@ Foam::vtkPV3Foam::~vtkPV3Foam() Info<< "<end> 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<< "<beg> Foam::vtkPV3Foam::UpdateInformation" - << " [meshPtr=" << (meshPtr_ ? "set" : "NULL") << "] TimeStep=" - << reader_->GetTimeStep() << endl; + Info<< "<beg> 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<fvPatchField, volMesh> + // Update volume, point and lagrangian fields + updateInfoFields<fvPatchField, volMesh> ( reader_->GetVolFieldSelection() ); - - // Update pointField array - updateInformationFields<pointPatchField, pointMesh> + updateInfoFields<pointPatchField, pointMesh> ( reader_->GetPointFieldSelection() ); + updateInfoLagrangianFields(); + + if (debug) + { + Info<< "<end> Foam::vtkPV3Foam::updateInfo" << endl; + } + +} - // Update lagrangian field array - updateInformationLagrangianFields(); +void Foam::vtkPV3Foam::updateFoamMesh() +{ if (debug) { - Info<< "<end> Foam::vtkPV3Foam::UpdateInformation" << endl; + Info<< "<beg> 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<< "<end> Foam::vtkPV3Foam::updateFoamMesh" << endl; + printMemory(); + } } void Foam::vtkPV3Foam::Update ( - vtkMultiBlockDataSet* output + vtkMultiBlockDataSet* output, + vtkMultiBlockDataSet* lagrangianOutput ) { if (debug) { - cout<< "<beg> Foam::vtkPV3Foam::Update" << nl - <<"Update\n"; - output->Print(cout); + cout<< "<beg> 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); - 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); + convertVolFields(output); + convertPointFields(output); + convertLagrangianFields(lagrangianOutput); + reader_->UpdateProgress(0.95); - cout<<"ShouldIReleaseData :" << output->ShouldIReleaseData() << "\n"; - printMemory(); - } + // reclaim some memory + reduceMemory(); + reader_->UpdateProgress(1.0); meshChanged_ = fieldsChanged_ = false; } @@ -773,31 +517,28 @@ void Foam::vtkPV3Foam::addPatchNames(vtkRenderer* renderer) // Remove any patch names previously added to the renderer removePatchNames(renderer); - if (debug) - { - Info<< "<beg> Foam::vtkPV3Foam::addPatchNames" << endl; - } - - const polyBoundaryMesh& pbMesh = meshPtr_->boundaryMesh(); - - const selectionInfo& selector = selectInfoPatches_; - - // the currently selected patches, strip off any suffix - const stringList selectedPatches = getSelectedArrayEntries + // get the display patches, strip off any suffix + wordHashSet selectedPatches = getSelected ( - reader_->GetRegionSelection(), - selector, - true + reader_->GetPartSelection(), + partInfoPatches_ ); + if (!selectedPatches.size()) + { + return; + } + if (debug) { - Info<<"... add patches: " << selectedPatches << endl; + Info<< "<beg> Foam::vtkPV3Foam::addPatchNames" << nl + <<"... add patches: " << selectedPatches << endl; } + const polyBoundaryMesh& pbMesh = meshPtr_->boundaryMesh(); + // Find the total number of zones // Each zone will take the patch name - // Number of zones per patch ... zero zones should be skipped labelList nZones(pbMesh.size(), 0); @@ -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]) - { - isSelected = true; - break; - } + continue; } - if (isSelected) - { - const labelListList& edgeFaces = pp.edgeFaces(); - const vectorField& n = pp.faceNormals(); + const labelListList& edgeFaces = pp.edgeFaces(); + const vectorField& n = pp.faceNormals(); + + boolList featEdge(pp.nEdges(), false); - boolList featEdge(pp.nEdges(), false); + forAll(edgeFaces, edgeI) + { + const labelList& eFaces = edgeFaces[edgeI]; - forAll(edgeFaces, edgeI) + if (eFaces.size() != 2) { - 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; - } + 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(); + // Do topological analysis of patch, find disconnected regions + patchZones pZones(pp, featEdge); - labelList zoneNFaces(pZones.nZones(), 0); + nZones[patchI] = pZones.nZones(); - // Save start of information for current patch - label patchStart = zoneCentre.size(); + labelList zoneNFaces(pZones.nZones(), 0); - // Create storage for additional zone centres - forAll(zoneNFaces, zoneI) - { - zoneCentre.append(vector::zero); - } + // Save start of information for current patch + label patchStart = zoneCentre.size(); - // Do averaging per individual zone + // Create storage for additional zone centres + forAll(zoneNFaces, zoneI) + { + zoneCentre.append(vector::zero); + } - forAll(pp, faceI) - { - label zoneI = pZones[faceI]; - zoneCentre[patchStart+zoneI] += pp[faceI].centre(pp.points()); - zoneNFaces[zoneI]++; - } + // 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<nZones[patchI]; i++) - { - zoneCentre[patchStart + i] /= zoneNFaces[i]; - } + for (label i=0; i<nZones[patchI]; i++) + { + zoneCentre[patchStart + i] /= zoneNFaces[i]; } } + zoneCentre.shrink(); if (debug) @@ -948,24 +681,19 @@ void Foam::vtkPV3Foam::addPatchNames(vtkRenderer* renderer) if (debug) { - Info<< "<end> Foam::vtkPV3Foam::addPatchNames)" << endl; + Info<< "<end> 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 0fbed64bfacf3e4624d2bc05f0221605d4357b4f..ada85c137322fc457c615792384664c938e1f850 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: - - // Public data + // Private classes - //- 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: } }; + //- bookkeeping for polyhedral cell decomposition + // hide in extra pointMap (cellSet/cellZone) for now + class polyDecomp + { + labelList superCells_; + labelList addPointCellLabels_; + labelList pointMap_; -private: + public: - // Private data + polyDecomp() + {} - //BTX - //- Indices for datasets in vtkMultiBlockDataSet - enum - { - VOLUME = 0, // internal mesh - PATCHES = 1, // patches - LAGRANGIAN = 2, - CELLZONE = 3, - FACEZONE = 4, - POINTZONE = 5, - CELLSET = 6, - FACESET = 7, - POINTSET = 8 + //- 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,63 +248,50 @@ 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_; - - //- Selected regions - // [0] = internal mesh, then lagrangian, patches, zones, sets - boolList selectedRegions_; - - //- Selected regions indices in each respective block - labelList selectedRegionDatasetIds_; - - //- Labels of cell-centres used as additional points when decomposing - // polyhedra - labelList addPointCellLabels_; - - //- Label of original cell for decomposed cells - // - internal mesh - labelList superCells_; - - //- Label of original cell for decomposed cells - // - cellZone meshes - List<labelList> zoneSuperCells_; - - //- Label of original cell for decomposed cells - // - cellSet meshes - List<labelList> csetSuperCells_; - - //- List of patch names - List<vtkTextActor*> patchTextActorsPtrs_; + //- Number of meshes + // TODO - for info only - only set up to process ONE mesh + int nMesh_; + + //- The time index + int timeIndex_; + //- Track changes in mesh geometry + bool meshChanged_; - // Dataset sizes + //- Track changes in fields + bool fieldsChanged_; - //- Number of meshes - // TODO - for info only - only set up to process ONE mesh - int nMesh_; + //- Selected geometrical parts (internalMesh, patches, ...) + boolList partStatus_; - //- Cloud name to be processed - // TODO - currently only set up to process ONE cloud - word cloudName_; + //- Datasets corresponding to selected geometrical pieces + // a negative number indicates that no vtkmesh exists for this piece + labelList partDataset_; - //- The time index - int timeIndex_; + //- 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_; - //- Track changes in mesh geometry - bool meshChanged_; + //- Decomposed cells information (mesh regions) + // TODO: regions + List<polyDecomp> regionPolyDecomp_; - //- Track changes in fields - bool fieldsChanged_; + //- Decomposed cells information (cellZone meshes) + List<polyDecomp> zonePolyDecomp_; + //- Decomposed cells information (cellSet meshes) + List<polyDecomp> csetPolyDecomp_; + + //- List of patch names for rendering to window + List<vtkTextActor*> patchTextActorsPtrs_; // Private Member Functions @@ -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<class Type> label addToSelection ( - vtkDataArraySelection *arraySelection, + vtkDataArraySelection*, const IOobjectList&, - const string& suffix = "" + const string& suffix=string::null ); //- Field info template<template<class> 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<class GeoField> 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<PrimitivePatchInterpolation<primitivePatch> >&, - const IOobjectList& objects, - vtkDataArraySelection* fieldSelection, + const IOobjectList&, vtkMultiBlockDataSet* output ); - //- Volume field - all types except scalar + //- Volume field - all selected parts + template<class Type> + void convertVolFieldBlock + ( + const GeometricField<Type, fvPatchField, volMesh>&, + const GeometricField<Type, pointPatchField, pointMesh>&, + vtkMultiBlockDataSet* output, + const partInfo& selector, + const List<polyDecomp>& decompLst + ); + + //- Volume field template<class Type> void convertVolField ( const GeometricField<Type, fvPatchField, volMesh>&, vtkMultiBlockDataSet* output, - const selectionInfo&, + const partInfo&, const label datasetNo, - labelList& superCells + const polyDecomp& ); //- Patch field template<class Type> - void convertPatchFaceField + void convertPatchField ( const word& name, const Field<Type>&, vtkMultiBlockDataSet* output, - const selectionInfo&, + const partInfo&, const label datasetNo ); @@ -498,7 +532,7 @@ private: ( const GeometricField<Type, fvPatchField, volMesh>&, vtkMultiBlockDataSet* output, - const selectionInfo&, + const partInfo&, const label datasetNo, const fvMesh&, const labelList& faceLabels @@ -510,7 +544,7 @@ private: ( const GeometricField<Type, fvPatchField, volMesh>&, vtkMultiBlockDataSet* output, - const selectionInfo&, + const partInfo&, const label datasetNo, const fvMesh&, const faceSet& @@ -520,19 +554,18 @@ private: template<class Type> 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<class Type> void convertLagrangianField ( const IOField<Type>&, vtkMultiBlockDataSet* output, - const selectionInfo&, + const partInfo&, const label datasetNo ); @@ -540,31 +573,42 @@ private: template<class Type> 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<class Type> + void convertPointFieldBlock + ( + const GeometricField<Type, pointPatchField, pointMesh>&, + vtkMultiBlockDataSet* output, + const partInfo& selector, + const List<polyDecomp>& + ); + + //- Point fields template<class Type> void convertPointField ( - const GeometricField<Type, pointPatchField, pointMesh>& ptf, - const GeometricField<Type, fvPatchField, volMesh>& tf, + const GeometricField<Type, pointPatchField, pointMesh>&, + const GeometricField<Type, fvPatchField, volMesh>&, 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<class Type> void convertPatchPointField ( const word& name, - const Field<Type>& tf, + const Field<Type>&, 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 + ( + IOobjectList&, + const wordHashSet& + ); + + //- Retrieve the current selections + static wordHashSet getSelected(vtkDataArraySelection*); + + //- Retrieve a sub-list of the current selections + static wordHashSet getSelected ( - vtkDataArraySelection* arraySelection, - const bool firstWord = false + vtkDataArraySelection*, + const partInfo& ); - //- Store the current selection(s) for a sub-selection + //- 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 08a316268637a9e6c93a87804443a2410cb89127..5648889ff0ae4380531aa28e01bc2ea80cd11482 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<class Type> Foam::label Foam::vtkPV3Foam::addToSelection ( - vtkDataArraySelection *arraySelection, + vtkDataArraySelection *select, const IOobjectList& objectLst, const string& suffix ) { - IOobjectList objects(objectLst.lookupClass(Type::typeName)); + SortableList<word> names(objectLst.names(Type::typeName)); - SortableList<word> objectNames(objects.size()); - - label count = 0; - forAllConstIter(IOobjectList, objects, iter) - { - objectNames[count++] = iter()->name(); - } - - if (count) + forAll(names, nameI) { - 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 0ccc3f81a04536a507caf3d6cccc59c368a3dde0..0000000000000000000000000000000000000000 --- 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<class Type> -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<Type>::typeName - ) - ); - - label nFields = fieldSelection->GetNumberOfArrays(); - - for (label i=0; i<nFields; i++) - { - if (fieldSelection->GetArraySetting(i)) - { - const word fieldName = fieldSelection->GetArrayName(i); - - if (fieldObjects.found(fieldName)) - { - IOField<Type> iotf - ( - IOobject - ( - fieldName, - mesh.time().timeName(), - "lagrangian"/cloudName_, - mesh, - IOobject::MUST_READ - ) - ); - - convertLagrangianField(iotf, output, selector, datasetId); - } - } - } -} - - -template<class Type> -void Foam::vtkPV3Foam::convertLagrangianField -( - const IOField<Type>& tf, - vtkMultiBlockDataSet* output, - const selectionInfo& selector, - const label datasetNo -) -{ - const label nComp = pTraits<Type>::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 <Type>Field: " << tf.name() << nl - << "tf.size() = " << tf.size() << nl - << "nComp = " << nComp << endl; - } - - float vec[nComp]; - - forAll(tf, i) - { - for (direction d=0; d<nComp; d++) - { - vec[d] = component(tf[i], d); - } - - pointData->InsertTuple(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 33b5891f04689bd706c766900baf01216e372f96..0000000000000000000000000000000000000000 --- 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<< "<beg> 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<< "<end> Foam::vtkPV3Foam::convertMeshVolume" << endl; - printMemory(); - } -} - - -void Foam::vtkPV3Foam::convertMeshLagrangian -( - vtkMultiBlockDataSet* output -) -{ - if (debug) - { - Info<< "<beg> 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<< "<end> Foam::vtkPV3Foam::convertMeshLagrangian" << endl; - printMemory(); - } -} - - -void Foam::vtkPV3Foam::convertMeshPatches -( - vtkMultiBlockDataSet* output -) -{ - if (debug) - { - Info<< "<beg> 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<< "<end> Foam::vtkPV3Foam::convertMeshPatches" << endl; - printMemory(); - } -} - - -void Foam::vtkPV3Foam::convertMeshCellZones -( - vtkMultiBlockDataSet* output -) -{ - if (debug) - { - Info<< "<beg> Foam::vtkPV3Foam::convertMeshCellZones" << endl; - printMemory(); - } - - const selectionInfo& selector = selectInfoCellZones_; - const fvMesh& mesh = *meshPtr_; - - // Create the cell zone(s) and add as DataSet(CELLZONE, 0..n) - if (selector.size()) - { - const cellZoneMesh& czMesh = mesh.cellZones(); - - // use the zoneId directly instead of the name - for (int zoneI=0; zoneI < selector.size(); ++zoneI) - { - const int regionId = selector.start() + zoneI; - - if (!selectedRegions_[regionId]) - { - continue; - } - - if (debug) - { - Info<< "Creating VTK mesh for cellZone: " - << zoneI << endl; - } - - fvMeshSubset subsetter(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<< "<end> Foam::vtkPV3Foam::convertMeshCellZones" << endl; - printMemory(); - } -} - - -void Foam::vtkPV3Foam::convertMeshCellSets -( - vtkMultiBlockDataSet* output -) -{ - if (debug) - { - Info<< "<beg> Foam::vtkPV3Foam::convertMeshCellSets" << endl; - printMemory(); - } - - const selectionInfo& selector = selectInfoCellSets_; - vtkDataArraySelection* arraySelection = reader_->GetRegionSelection(); - - // Create the cell sets and add as dataset - if (selector.size()) - { - const fvMesh& mesh = *meshPtr_; - - for - ( - int regionId = selector.start(); - regionId < selector.end(); - ++regionId) - { - if (!selectedRegions_[regionId]) - { - continue; - } - - word selectName = getFirstWord - ( - arraySelection->GetArrayName(regionId) - ); - - if (debug) - { - Info<< "Creating VTK mesh for cellSet: " << selectName - << " region index: " << regionId << endl; - } - - const cellSet cSet(mesh, selectName); - fvMeshSubset subsetter(mesh); - subsetter.setLargeCellSubset(cSet); - - const label datasetId = GetNumberOfDataSets(output, selector); - - vtkUnstructuredGrid* vtkmesh = vtkUnstructuredGrid::New(); - - addVolumeMesh - ( - subsetter.subMesh(), - vtkmesh, - csetSuperCells_[datasetId] - ); - - // renumber - superCells must contain global cell ids - inplaceRenumber - ( - subsetter.cellMap(), - csetSuperCells_[datasetId] - ); - - AddToBlock - ( - output, selector, datasetId, vtkmesh, - selectName + ":cellSet" - ); - selectedRegionDatasetIds_[regionId] = datasetId; - vtkmesh->Delete(); - } - } - - if (debug) - { - Info<< "<end> Foam::vtkPV3Foam::convertMeshCellSets" << endl; - printMemory(); - } -} - - -void Foam::vtkPV3Foam::convertMeshFaceZones -( - vtkMultiBlockDataSet* output -) -{ - if (debug) - { - Info<< "<beg> 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<< "<end> Foam::vtkPV3Foam::convertMeshFaceZones" << endl; - printMemory(); - } -} - - -void Foam::vtkPV3Foam::convertMeshFaceSets -( - vtkMultiBlockDataSet* output -) -{ - if (debug) - { - Info<< "<beg> 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<< "<end> Foam::vtkPV3Foam::convertMeshFaceSets" << endl; - printMemory(); - } -} - - -void Foam::vtkPV3Foam::convertMeshPointZones -( - vtkMultiBlockDataSet* output -) -{ - if (debug) - { - Info<< "<beg> 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<< "<end> Foam::vtkPV3Foam::convertMeshPointZones" << endl; - printMemory(); - } -} - - - -void Foam::vtkPV3Foam::convertMeshPointSets -( - vtkMultiBlockDataSet* output -) -{ - if (debug) - { - Info<< "<beg> 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<< "<end> 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 d26a0eb3658b94478e185656e86ac9170240cc9d..0000000000000000000000000000000000000000 --- 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<class Type> -void Foam::vtkPV3Foam::convertPointFields -( - const fvMesh& mesh, - const IOobjectList& objects, - vtkDataArraySelection* fieldSelection, - vtkMultiBlockDataSet* output -) -{ - IOobjectList fieldObjects - ( - objects.lookupClass - ( - GeometricField<Type, pointPatchField, pointMesh>::typeName - ) - ); - - label nSelectedFields = fieldSelection->GetNumberOfArrays(); - const polyBoundaryMesh& patches = mesh.boundaryMesh(); - - for (label i=0; i<nSelectedFields; i++) - { - if (fieldSelection->GetArraySetting(i)) - { - word fieldName = fieldSelection->GetArrayName(i); - - if (fieldObjects.found(fieldName)) - { - - if (debug) - { - Info<< "Foam::vtkPV3Foam::convertPointFields : " << fieldName - << endl; - } - - pointMesh pMesh(mesh); - - GeometricField<Type, pointPatchField, pointMesh> 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<Type, fvPatchField, volMesh>::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<class Type> -void Foam::vtkPV3Foam::convertPointField -( - const GeometricField<Type, pointPatchField, pointMesh>& ptf, - const GeometricField<Type, fvPatchField, volMesh>& tf, - vtkMultiBlockDataSet* output, - const selectionInfo& selector, - const label datasetNo -) -{ - const label nComp = pTraits<Type>::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; d<nComp; d++) - { - vec[d] = component(ptf[i], d); - } - - pointData->InsertTuple(i, vec); - } - - label i = ptf.size(); - - if (&tf != &GeometricField<Type, fvPatchField, volMesh>::null()) - { - forAll(addPointCellLabels_, api) - { - Type t = tf[addPointCellLabels_[api]]; - - for (direction d=0; d<nComp; d++) - { - vec[d] = component(t, d); - } - - pointData->InsertTuple(i++, vec); - } - } - else - { - forAll(addPointCellLabels_, api) - { - Type t = interpolatePointToCell(ptf, addPointCellLabels_[api]); - - for (direction d=0; d<nComp; d++) - { - vec[d] = component(t, d); - } - - pointData->InsertTuple(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 7543f58c9c97e4c18e175a36dc5d82052ba06ebf..0000000000000000000000000000000000000000 --- 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<class Type> -void Foam::vtkPV3Foam::convertVolFields -( - const fvMesh& mesh, - const volPointInterpolation& pInterp, - const PtrList<PrimitivePatchInterpolation<primitivePatch> >& ppInterpList, - const IOobjectList& objects, - vtkDataArraySelection *fieldSelection, - vtkMultiBlockDataSet* output -) -{ - IOobjectList fieldObjects - ( - objects.lookupClass - ( - GeometricField<Type, fvPatchField, volMesh>::typeName - ) - ); - - label nFields = fieldSelection->GetNumberOfArrays(); - const polyBoundaryMesh& patches = mesh.boundaryMesh(); - - vtkDataArraySelection* arraySelector = reader_->GetRegionSelection(); - - for (label i=0; i<nFields; i++) - { - const word fieldName = fieldSelection->GetArrayName(i); - - if - ( - !fieldSelection->GetArraySetting(i) - || !fieldObjects.found(fieldName)) - { - continue; - } - - if (debug) - { - Info<< "converting Foam volume field: " << fieldName - << endl; - } - - GeometricField<Type, fvPatchField, volMesh> tf - ( - IOobject - ( - fieldName, - mesh.time().timeName(), - mesh, - IOobject::MUST_READ - ), - mesh - ); - - tmp<GeometricField<Type, pointPatchField, pointMesh> > 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<Type>& ptf - ( - tf.boundaryField()[patchId] - ); - - if - ( - isType<emptyFvPatchField<Type> >(ptf) - || - ( - typeid(patches[patchId]) == typeid(wallPolyPatch) - && reader_->GetExtrapolateWalls() - ) - ) - { - fvPatch p - ( - ptf.patch().patch(), - tf.mesh().boundary() - ); - - convertPatchFaceField - ( - tf.name(), - fvPatchField<Type>(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<class Type> -void Foam::vtkPV3Foam::convertVolField -( - const GeometricField<Type, fvPatchField, volMesh>& tf, - vtkMultiBlockDataSet* output, - const selectionInfo& selector, - const label datasetNo, - labelList& superCells -) -{ - const label nComp = pTraits<Type>::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 vol<Type>Field: " << 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; d<nComp; d++) - { - vec[d] = component(t, d); - } - - celldata->InsertTuple(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 114aab667a5f9347b799b53e8274f0495ede37c4..b3fdcacf329f0339e9ec8defe08f2a3d3310cc87 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<Type, fvPatchField, volMesh>& tf, vtkMultiBlockDataSet* output, - const selectionInfo& selector, + const partInfo& selector, const label datasetNo, const fvMesh& mesh, const labelList& faceLabels ) { const label nComp = pTraits<Type>::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<Type, fvPatchField, volMesh>& tf, vtkMultiBlockDataSet* output, - const selectionInfo& selector, + const partInfo& selector, const label datasetNo, const fvMesh& mesh, const faceSet& fSet ) { const label nComp = pTraits<Type>::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 0000000000000000000000000000000000000000..bf5742e3a8671751db6527f789283ee78f00f65f --- /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<< "<beg> 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<PrimitivePatchInterpolation<primitivePatch> > + ppInterpList(mesh.boundaryMesh().size()); + + forAll(ppInterpList, i) + { + ppInterpList.set + ( + i, + new PrimitivePatchInterpolation<primitivePatch> + ( + mesh.boundaryMesh()[i] + ) + ); + } + + + convertVolFields<scalar> + ( + mesh, pInterp, ppInterpList, objects, output + ); + convertVolFields<vector> + ( + mesh, pInterp, ppInterpList, objects, output + ); + convertVolFields<sphericalTensor> + ( + mesh, pInterp, ppInterpList, objects, output + ); + convertVolFields<symmTensor> + ( + mesh, pInterp, ppInterpList, objects, output + ); + convertVolFields<tensor> + ( + mesh, pInterp, ppInterpList, objects, output + ); + + if (debug) + { + Info<< "<end> 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<< "<beg> 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<scalar> + ( + mesh, pMesh, objects, output + ); + convertPointFields<vector> + ( + mesh, pMesh, objects, output + ); + convertPointFields<sphericalTensor> + ( + mesh, pMesh, objects, output + ); + convertPointFields<symmTensor> + ( + mesh, pMesh, objects, output + ); + convertPointFields<tensor> + ( + mesh, pMesh, objects, output + ); + + if (debug) + { + Info<< "<end> 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<< "<beg> 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<label> + ( + objects, output, datasetNo + ); + convertLagrangianFields<scalar> + ( + objects, output, datasetNo + ); + convertLagrangianFields<vector> + ( + objects, output, datasetNo + ); + convertLagrangianFields<sphericalTensor> + ( + objects, output, datasetNo + ); + convertLagrangianFields<symmTensor> + ( + objects, output, datasetNo + ); + convertLagrangianFields<tensor> + ( + objects, output, datasetNo + ); + } + + if (debug) + { + Info<< "<end> Foam::vtkPV3Foam::convertLagrangianFields" << endl; + printMemory(); + } +} + + +// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertPatchPointField.H b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamLagrangianFields.H similarity index 60% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertPatchPointField.H rename to applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamLagrangianFields.H index a793958218a2084299fc9a4fd50b85bb9d9078f4..c0bc91e82fa56fc0dbf70f9ddadde9a426eacd88 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertPatchPointField.H +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamLagrangianFields.H @@ -27,54 +27,81 @@ InClass \*---------------------------------------------------------------------------*/ -#ifndef vtkPV3FoamConvertPatchPointField_H -#define vtkPV3FoamConvertPatchPointField_H - -// VTK includes -#include "vtkPointData.h" +#ifndef vtkPV3FoamLagrangianFields_H +#define vtkPV3FoamLagrangianFields_H // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // template<class Type> -void Foam::vtkPV3Foam::convertPatchPointField +void Foam::vtkPV3Foam::convertLagrangianFields ( - const word& name, - const Field<Type>& pptf, + const IOobjectList& objects, vtkMultiBlockDataSet* output, - const selectionInfo& selector, const label datasetNo ) { - const label nComp = pTraits<Type>::nComponents; + const partInfo& selector = partInfoLagrangian_; - vtkPolyData* vtkmesh = vtkPolyData::SafeDownCast - ( - GetDataSetFromBlock(output, selector, datasetNo) - ); + forAllConstIter(IOobjectList, objects, iter) + { + // restrict to this IOField<Type> + if (iter()->headerClassName() == IOField<Type>::typeName) + { + IOField<Type> tf(*iter()); + convertLagrangianField(tf, output, selector, datasetNo); + } + } +} + + +template<class Type> +void Foam::vtkPV3Foam::convertLagrangianField +( + const IOField<Type>& tf, + vtkMultiBlockDataSet* output, + const partInfo& selector, + const label datasetNo +) +{ + const label nComp = pTraits<Type>::nComponents; vtkFloatArray *pointData = vtkFloatArray::New(); - pointData->SetNumberOfTuples(pptf.size()); - pointData->SetNumberOfComponents(nComp); - pointData->Allocate(nComp*pptf.size()); - pointData->SetName(name.c_str()); + pointData->SetNumberOfTuples( tf.size() ); + pointData->SetNumberOfComponents( nComp ); + pointData->Allocate( nComp*tf.size() ); + pointData->SetName( tf.name().c_str() ); - float vec[nComp]; + if (debug) + { + Info<< "convert LagrangianField: " + << tf.name() + << " size = " << tf.size() + << " nComp=" << nComp + << " nTuples = " << tf.size() << endl; + } - forAll(pptf, i) + float vec[nComp]; + forAll(tf, i) { + const Type& t = tf[i]; for (direction d=0; d<nComp; d++) { - vec[d] = component(pptf[i], d); + vec[d] = component(t, d); } pointData->InsertTuple(i, vec); } - vtkmesh->GetPointData()->AddArray(pointData); + + vtkPolyData::SafeDownCast + ( + GetDataSetFromBlock(output, selector, datasetNo) + ) ->GetPointData() + ->AddArray(pointData); + pointData->Delete(); } - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMesh.C b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMesh.C new file mode 100644 index 0000000000000000000000000000000000000000..8539bca001ce85a70819c92cdefb85cfeaad790b --- /dev/null +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMesh.C @@ -0,0 +1,623 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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, + int& blockNo +) +{ + partInfo& selector = partInfoVolume_; + selector.block(blockNo); // set output block + label datasetNo = 0; // restart at dataset 0 + const fvMesh& mesh = *meshPtr_; + + // resize for decomposed polyhedra + regionPolyDecomp_.setSize(selector.size()); + + if (debug) + { + Info<< "<beg> Foam::vtkPV3Foam::convertMeshVolume" << endl; + printMemory(); + } + + // Convert the internalMesh + // TODO: multiple mesh regions + for (int partId = selector.start(); partId < selector.end(); ++partId) + { + const word partName = "internalMesh"; + + if (!partStatus_[partId]) + { + continue; + } + + vtkUnstructuredGrid* vtkmesh = volumeVTKMesh + ( + mesh, + regionPolyDecomp_[datasetNo] + ); + + if (vtkmesh) + { + AddToBlock(output, vtkmesh, selector, datasetNo, partName); + vtkmesh->Delete(); + + partDataset_[partId] = datasetNo++; + } + } + + // anything added? + if (datasetNo) + { + ++blockNo; + } + + if (debug) + { + Info<< "<end> Foam::vtkPV3Foam::convertMeshVolume" << endl; + printMemory(); + } +} + + +void Foam::vtkPV3Foam::convertMeshLagrangian +( + vtkMultiBlockDataSet* output, + int& blockNo +) +{ + partInfo& selector = partInfoLagrangian_; + selector.block(blockNo); // set output block + label datasetNo = 0; // restart at dataset 0 + const fvMesh& mesh = *meshPtr_; + + if (debug) + { + Info<< "<beg> Foam::vtkPV3Foam::convertMeshLagrangian" << endl; + printMemory(); + } + + for (int partId = selector.start(); partId < selector.end(); ++partId) + { + const word cloudName = getPartName(partId); + + if (!partStatus_[partId]) + { + continue; + } + + vtkPolyData* vtkmesh = lagrangianVTKMesh(mesh, cloudName); + + if (vtkmesh) + { + AddToBlock(output, vtkmesh, selector, datasetNo, cloudName); + vtkmesh->Delete(); + + partDataset_[partId] = datasetNo++; + } + } + + // anything added? + if (datasetNo) + { + ++blockNo; + } + + if (debug) + { + Info<< "<end> Foam::vtkPV3Foam::convertMeshLagrangian" << endl; + printMemory(); + } +} + + +void Foam::vtkPV3Foam::convertMeshPatches +( + vtkMultiBlockDataSet* output, + int& blockNo +) +{ + partInfo& selector = partInfoPatches_; + selector.block(blockNo); // set output block + label datasetNo = 0; // restart at dataset 0 + const fvMesh& mesh = *meshPtr_; + const polyBoundaryMesh& patches = mesh.boundaryMesh(); + + if (debug) + { + Info<< "<beg> Foam::vtkPV3Foam::convertMeshPatches" << endl; + printMemory(); + } + + for (int partId = selector.start(); partId < selector.end(); ++partId) + { + const word patchName = getPartName(partId); + const label patchId = patches.findPatchID(patchName); + + if (!partStatus_[partId] || patchId < 0) + { + continue; + } + + if (debug) + { + Info<< "Creating VTK mesh for patch[" << patchId <<"] " + << patchName << endl; + } + + vtkPolyData* vtkmesh = patchVTKMesh(patches[patchId]); + + if (vtkmesh) + { + AddToBlock(output, vtkmesh, selector, datasetNo, patchName); + vtkmesh->Delete(); + + partDataset_[partId] = datasetNo++; + } + } + + // anything added? + if (datasetNo) + { + ++blockNo; + } + + if (debug) + { + Info<< "<end> Foam::vtkPV3Foam::convertMeshPatches" << endl; + printMemory(); + } +} + + +void Foam::vtkPV3Foam::convertMeshCellZones +( + vtkMultiBlockDataSet* output, + int& blockNo +) +{ + partInfo& selector = partInfoCellZones_; + selector.block(blockNo); // set output block + label datasetNo = 0; // restart at dataset 0 + const fvMesh& mesh = *meshPtr_; + + // resize for decomposed polyhedra + zonePolyDecomp_.setSize(selector.size()); + + if (!selector.size()) + { + return; + } + + if (debug) + { + Info<< "<beg> Foam::vtkPV3Foam::convertMeshCellZones" << endl; + printMemory(); + } + + const cellZoneMesh& zMesh = mesh.cellZones(); + + for (int partId = selector.start(); partId < selector.end(); ++partId) + { + const word zoneName = getPartName(partId); + const label zoneId = zMesh.findZoneID(zoneName); + + if (!partStatus_[partId] || zoneId < 0) + { + continue; + } + + if (debug) + { + Info<< "Creating VTK mesh for cellZone[" << zoneId << "] " + << zoneName << endl; + } + + fvMeshSubset subsetter(mesh); + subsetter.setLargeCellSubset(zMesh[zoneId]); + + vtkUnstructuredGrid* vtkmesh = volumeVTKMesh + ( + subsetter.subMesh(), + zonePolyDecomp_[datasetNo] + ); + + if (vtkmesh) + { + // superCells + addPointCellLabels must contain global cell ids + inplaceRenumber + ( + subsetter.cellMap(), + zonePolyDecomp_[datasetNo].superCells() + ); + inplaceRenumber + ( + subsetter.cellMap(), + zonePolyDecomp_[datasetNo].addPointCellLabels() + ); + + // copy pointMap as well, otherwise pointFields fail + zonePolyDecomp_[datasetNo].pointMap() = subsetter.pointMap(); + + AddToBlock(output, vtkmesh, selector, datasetNo, zoneName); + vtkmesh->Delete(); + + partDataset_[partId] = datasetNo++; + } + } + + // anything added? + if (datasetNo) + { + ++blockNo; + } + + if (debug) + { + Info<< "<end> Foam::vtkPV3Foam::convertMeshCellZones" << endl; + printMemory(); + } +} + + +void Foam::vtkPV3Foam::convertMeshCellSets +( + vtkMultiBlockDataSet* output, + int& blockNo +) +{ + partInfo& selector = partInfoCellSets_; + selector.block(blockNo); // set output block + label datasetNo = 0; // restart at dataset 0 + const fvMesh& mesh = *meshPtr_; + + // resize for decomposed polyhedra + csetPolyDecomp_.setSize(selector.size()); + + if (debug) + { + Info<< "<beg> Foam::vtkPV3Foam::convertMeshCellSets" << endl; + printMemory(); + } + + for (int partId = selector.start(); partId < selector.end(); ++partId) + { + const word partName = getPartName(partId); + + if (!partStatus_[partId]) + { + continue; + } + + if (debug) + { + Info<< "Creating VTK mesh for cellSet=" << partName << endl; + } + + const cellSet cSet(mesh, partName); + fvMeshSubset subsetter(mesh); + subsetter.setLargeCellSubset(cSet); + + vtkUnstructuredGrid* vtkmesh = volumeVTKMesh + ( + subsetter.subMesh(), + csetPolyDecomp_[datasetNo] + ); + + if (vtkmesh) + { + // superCells + addPointCellLabels must contain global cell ids + inplaceRenumber + ( + subsetter.cellMap(), + csetPolyDecomp_[datasetNo].superCells() + ); + inplaceRenumber + ( + subsetter.cellMap(), + csetPolyDecomp_[datasetNo].addPointCellLabels() + ); + + // copy pointMap as well, otherwise pointFields fail + csetPolyDecomp_[datasetNo].pointMap() = subsetter.pointMap(); + + AddToBlock(output, vtkmesh, selector, datasetNo, partName); + vtkmesh->Delete(); + + partDataset_[partId] = datasetNo++; + } + } + + // anything added? + if (datasetNo) + { + ++blockNo; + } + + if (debug) + { + Info<< "<end> Foam::vtkPV3Foam::convertMeshCellSets" << endl; + printMemory(); + } +} + + +void Foam::vtkPV3Foam::convertMeshFaceZones +( + vtkMultiBlockDataSet* output, + int& blockNo +) +{ + partInfo& selector = partInfoFaceZones_; + selector.block(blockNo); // set output block + label datasetNo = 0; // restart at dataset 0 + const fvMesh& mesh = *meshPtr_; + + if (!selector.size()) + { + return; + } + + if (debug) + { + Info<< "<beg> Foam::vtkPV3Foam::convertMeshFaceZones" << endl; + printMemory(); + } + + const faceZoneMesh& zMesh = mesh.faceZones(); + + for (int partId = selector.start(); partId < selector.end(); ++partId) + { + const word zoneName = getPartName(partId); + const label zoneId = zMesh.findZoneID(zoneName); + + if (!partStatus_[partId] || zoneId < 0) + { + continue; + } + + if (debug) + { + Info<< "Creating VTKmesh for faceZone[" << zoneId << "] " + << zoneName << endl; + } + + vtkPolyData* vtkmesh = faceZoneVTKMesh(mesh, zMesh[zoneId]); + if (vtkmesh) + { + AddToBlock(output, vtkmesh, selector, datasetNo, zoneName); + vtkmesh->Delete(); + + partDataset_[partId] = datasetNo++; + } + } + + // anything added? + if (datasetNo) + { + ++blockNo; + } + + if (debug) + { + Info<< "<end> Foam::vtkPV3Foam::convertMeshFaceZones" << endl; + printMemory(); + } +} + + +void Foam::vtkPV3Foam::convertMeshFaceSets +( + vtkMultiBlockDataSet* output, + int& blockNo +) +{ + partInfo& selector = partInfoFaceSets_; + selector.block(blockNo); // set output block + label datasetNo = 0; // restart at dataset 0 + const fvMesh& mesh = *meshPtr_; + + if (debug) + { + Info<< "<beg> Foam::vtkPV3Foam::convertMeshFaceSets" << endl; + printMemory(); + } + + for (int partId = selector.start(); partId < selector.end(); ++partId) + { + const word partName = getPartName(partId); + + if (!partStatus_[partId]) + { + continue; + } + + if (debug) + { + Info<< "Creating VTK mesh for faceSet=" << partName << endl; + } + + const faceSet fSet(mesh, partName); + + vtkPolyData* vtkmesh = faceSetVTKMesh(mesh, fSet); + if (vtkmesh) + { + AddToBlock(output, vtkmesh, selector, datasetNo, partName); + vtkmesh->Delete(); + + partDataset_[partId] = datasetNo++; + } + } + + // anything added? + if (datasetNo) + { + ++blockNo; + } + + if (debug) + { + Info<< "<end> Foam::vtkPV3Foam::convertMeshFaceSets" << endl; + printMemory(); + } +} + + +void Foam::vtkPV3Foam::convertMeshPointZones +( + vtkMultiBlockDataSet* output, + int& blockNo +) +{ + partInfo& selector = partInfoPointZones_; + selector.block(blockNo); // set output block + label datasetNo = 0; // restart at dataset 0 + + if (debug) + { + Info<< "<beg> Foam::vtkPV3Foam::convertMeshPointZones" << endl; + printMemory(); + } + + const fvMesh& mesh = *meshPtr_; + + if (selector.size()) + { + const pointZoneMesh& zMesh = mesh.pointZones(); + + for (int partId = selector.start(); partId < selector.end(); ++partId) + { + word zoneName = getPartName(partId); + label zoneId = zMesh.findZoneID(zoneName); + + if (!partStatus_[partId] || zoneId < 0) + { + continue; + } + + vtkPolyData* vtkmesh = pointZoneVTKMesh(mesh, zMesh[zoneId]); + if (vtkmesh) + { + AddToBlock(output, vtkmesh, selector, datasetNo, zoneName); + vtkmesh->Delete(); + + partDataset_[partId] = datasetNo++; + } + } + } + + // anything added? + if (datasetNo) + { + ++blockNo; + } + + if (debug) + { + Info<< "<end> Foam::vtkPV3Foam::convertMeshPointZones" << endl; + printMemory(); + } +} + + + +void Foam::vtkPV3Foam::convertMeshPointSets +( + vtkMultiBlockDataSet* output, + int& blockNo +) +{ + partInfo& selector = partInfoPointSets_; + selector.block(blockNo); // set output block + label datasetNo = 0; // restart at dataset 0 + const fvMesh& mesh = *meshPtr_; + + if (debug) + { + Info<< "<beg> Foam::vtkPV3Foam::convertMeshPointSets" << endl; + printMemory(); + } + + for (int partId = selector.start(); partId < selector.end(); ++partId) + { + word partName = getPartName(partId); + + if (!partStatus_[partId]) + { + continue; + } + + if (debug) + { + Info<< "Creating VTK mesh for pointSet=" << partName << endl; + } + + const pointSet pSet(mesh, partName); + + vtkPolyData* vtkmesh = pointSetVTKMesh(mesh, pSet); + if (vtkmesh) + { + AddToBlock(output, vtkmesh, selector, datasetNo, partName); + vtkmesh->Delete(); + + partDataset_[partId] = datasetNo++; + } + } + + // anything added? + if (datasetNo) + { + ++blockNo; + } + + if (debug) + { + Info<< "<end> Foam::vtkPV3Foam::convertMeshPointSets" << endl; + printMemory(); + } +} + +// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddLagrangianMesh.C b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshLagrangian.C similarity index 55% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddLagrangianMesh.C rename to applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshLagrangian.C index d4463109a9cf82f8596884c1ac67a9527d15e9a2..d1b0492235c56aa1d63717439bba31f062a4b650 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddLagrangianMesh.C +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshLagrangian.C @@ -31,81 +31,68 @@ Description // Foam includes #include "Cloud.H" #include "fvMesh.H" -#include "passiveParticle.H" -#include "vtkPV3FoamInsertNextPoint.H" #include "IOobjectList.H" +#include "passiveParticle.H" +#include "vtkPV3FoamPoints.H" // VTK includes -#include "vtkCellArray.h" +#include "vtkPoints.h" #include "vtkPolyData.h" -#include "vtkUnstructuredGrid.h" // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::vtkPV3Foam::addLagrangianMesh +vtkPolyData* Foam::vtkPV3Foam::lagrangianVTKMesh ( const fvMesh& mesh, - vtkPolyData *vtkmesh + const word& cloudName ) { + vtkPolyData* vtkmesh = NULL; + if (debug) { - Info<< "<beg> Foam::vtkPV3Foam::addLagrangianMesh - timePath " - << mesh.time().timePath()/"lagrangian" << endl; + Info<< "<beg> Foam::vtkPV3Foam::lagrangianVTKMesh - timePath " + << mesh.time().timePath()/"lagrangian"/cloudName << endl; printMemory(); } - fileNameList cloudDirs + IOobjectList sprayObjs ( - readDir(mesh.time().timePath()/"lagrangian", fileName::DIRECTORY) + mesh, + mesh.time().timeName(), + "lagrangian"/cloudName ); - if (debug && cloudDirs.size()) + IOobject* positionsPtr = sprayObjs.lookup("positions"); + if (positionsPtr) { - Info<< "... check cloudDirs: " << cloudDirs << endl; - } - - bool foundCloud = false; - forAll(cloudDirs, i) - { - IOobjectList sprayObjs - ( - mesh, - mesh.time().timeName(), - "lagrangian"/cloudDirs[i] - ); - - IOobject* positionsPtr = sprayObjs.lookup("positions"); + Cloud<passiveParticle> parcels(mesh, cloudName, false); - if (positionsPtr && !foundCloud) + if (debug) { - foundCloud = true; - - Cloud<passiveParticle> parcels(mesh, cloudDirs[i], false); - - if (debug) - { - Info<< "cloud with " << parcels.size() << " parcels" << endl; - } - - vtkPoints* vtkpoints = vtkPoints::New(); - vtkpoints->Allocate(parcels.size()); + Info<< "cloud with " << parcels.size() << " parcels" << endl; + } - forAllConstIter(Cloud<passiveParticle>, parcels, elmnt) - { - vtkPV3FoamInsertNextPoint(vtkpoints, elmnt().position()); - } + vtkmesh = vtkPolyData::New(); + vtkPoints* vtkpoints = vtkPoints::New(); + vtkpoints->Allocate( parcels.size() ); - vtkmesh->SetPoints(vtkpoints); - vtkpoints->Delete(); + forAllConstIter(Cloud<passiveParticle>, parcels, iter) + { + vtkPV3FoamInsertNextPoint(vtkpoints, iter().position()); } + + vtkmesh->SetPoints(vtkpoints); + vtkpoints->Delete(); } if (debug) { - Info<< "<end> Foam::vtkPV3Foam::addLagrangianMesh" << endl; + Info<< "<end> Foam::vtkPV3Foam::lagrangianVTKMesh" << endl; printMemory(); } + + return vtkmesh; } diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddPatchMesh.C b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshPatch.C similarity index 84% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddPatchMesh.C rename to applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshPatch.C index 7c8a586ebabd084c9fd96147edb51c00239b11ba..bacaa0f63d01724660e68655768b7033f7e21903 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddPatchMesh.C +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshPatch.C @@ -31,7 +31,7 @@ Description // Foam includes #include "polyPatch.H" #include "primitivePatch.H" -#include "vtkPV3FoamInsertNextPoint.H" +#include "vtkPV3FoamPoints.H" // VTK includes #include "vtkCellArray.h" @@ -40,15 +40,16 @@ Description // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::vtkPV3Foam::addPatchMesh +vtkPolyData* Foam::vtkPV3Foam::patchVTKMesh ( - const polyPatch& p, - vtkPolyData *vtkmesh + const polyPatch& p ) { + vtkPolyData* vtkmesh = vtkPolyData::New(); + if (debug) { - Info<< "<beg> Foam::vtkPV3Foam::addPatchMesh - " << p.name() << endl; + Info<< "<beg> Foam::vtkPV3Foam::patchVTKMesh - " << p.name() << endl; printMemory(); } @@ -56,7 +57,7 @@ void Foam::vtkPV3Foam::addPatchMesh const Foam::pointField& points = p.localPoints(); vtkPoints *vtkpoints = vtkPoints::New(); - vtkpoints->Allocate(points.size()); + vtkpoints->Allocate( points.size() ); forAll(points, i) { vtkPV3FoamInsertNextPoint(vtkpoints, points[i]); @@ -69,14 +70,14 @@ void Foam::vtkPV3Foam::addPatchMesh // Add faces as polygons const faceList& faces = p.localFaces(); - vtkCellArray * vtkcells = vtkCellArray::New(); - vtkcells->Allocate(faces.size()); + vtkCellArray* vtkcells = vtkCellArray::New(); + vtkcells->Allocate( faces.size() ); forAll(faces, faceI) { const face& f = faces[faceI]; vtkIdType nodeIds[f.size()]; - forAll (f, fp) + forAll(f, fp) { nodeIds[fp] = f[fp]; } @@ -88,9 +89,11 @@ void Foam::vtkPV3Foam::addPatchMesh if (debug) { - Info<< "<end> Foam::vtkPV3Foam::addPatchMesh - " << p.name() << endl; + Info<< "<end> Foam::vtkPV3Foam::patchVTKMesh - " << p.name() << endl; printMemory(); } + + return vtkmesh; } diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddSetMesh.C b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshSet.C similarity index 80% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddSetMesh.C rename to applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshSet.C index 18835fe427f38c36d7a9aa1ac13f6a47af54fb9b..c64c3ec692d8235890ad655a51a1e3be73b0b243 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddSetMesh.C +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshSet.C @@ -31,7 +31,7 @@ Description // Foam includes #include "faceSet.H" #include "pointSet.H" -#include "vtkPV3FoamInsertNextPoint.H" +#include "vtkPV3FoamPoints.H" // VTK includes #include "vtkPoints.h" @@ -40,16 +40,17 @@ Description // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::vtkPV3Foam::addFaceSetMesh +vtkPolyData* Foam::vtkPV3Foam::faceSetVTKMesh ( const fvMesh& mesh, - const faceSet& fSet, - vtkPolyData* vtkmesh + const faceSet& fSet ) { + vtkPolyData* vtkmesh = vtkPolyData::New(); + if (debug) { - Info<< "<beg> Foam::vtkPV3Foam::addFaceSetMesh" << endl; + Info<< "<beg> Foam::vtkPV3Foam::faceSetVTKMesh" << endl; printMemory(); } @@ -65,13 +66,13 @@ void Foam::vtkPV3Foam::addFaceSetMesh primitiveFacePatch p(patchFaces, mesh.points()); - // The balance of this routine should be identical to addPatchMesh + // The balance of this routine should be identical to patchVTKMesh // Convert Foam mesh vertices to VTK const pointField& points = p.localPoints(); vtkPoints *vtkpoints = vtkPoints::New(); - vtkpoints->Allocate(points.size()); + vtkpoints->Allocate( points.size() ); forAll(points, i) { vtkPV3FoamInsertNextPoint(vtkpoints, points[i]); @@ -83,13 +84,14 @@ void Foam::vtkPV3Foam::addFaceSetMesh const faceList& faces = p.localFaces(); vtkCellArray* vtkcells = vtkCellArray::New(); - vtkcells->Allocate(p.size()); + vtkcells->Allocate( faces.size() ); + forAll(faces, faceI) { const face& f = faces[faceI]; vtkIdType nodeIds[f.size()]; - forAll (f, fp) + forAll(f, fp) { nodeIds[fp] = f[fp]; } @@ -101,29 +103,32 @@ void Foam::vtkPV3Foam::addFaceSetMesh if (debug) { - Info<< "<end> Foam::vtkPV3Foam::addFaceSetMesh" << endl; + Info<< "<end> Foam::vtkPV3Foam::faceSetVTKMesh" << endl; printMemory(); } + + return vtkmesh; } -void Foam::vtkPV3Foam::addPointSetMesh +vtkPolyData* Foam::vtkPV3Foam::pointSetVTKMesh ( const fvMesh& mesh, - const pointSet& pSet, - vtkPolyData* vtkmesh + const pointSet& pSet ) { + vtkPolyData* vtkmesh = vtkPolyData::New(); + if (debug) { - Info<< "<beg> Foam::vtkPV3Foam::addPointSetMesh" << endl; + Info<< "<beg> Foam::vtkPV3Foam::pointSetVTKMesh" << endl; printMemory(); } const pointField& meshPoints = mesh.points(); vtkPoints *vtkpoints = vtkPoints::New(); - vtkpoints->Allocate(pSet.size()); + vtkpoints->Allocate( pSet.size() ); forAllConstIter(pointSet, pSet, iter) { @@ -135,9 +140,12 @@ void Foam::vtkPV3Foam::addPointSetMesh if (debug) { - Info<< "<end> Foam::vtkPV3Foam::addPointSetMesh" << endl; + Info<< "<end> Foam::vtkPV3Foam::pointSetVTKMesh" << endl; printMemory(); } + + return vtkmesh; } + // ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddVolumeMesh.C b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshVolume.C similarity index 84% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddVolumeMesh.C rename to applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshVolume.C index 292fb8d2a0964cd6f75582ea356d67b59e00dbae..05e15827251e9873c9e1d8b0d02c1a34e71ab09f 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddVolumeMesh.C +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshVolume.C @@ -26,35 +26,30 @@ Description \*---------------------------------------------------------------------------*/ -#ifndef vtkPV3FoamAddVolumeMesh_H -#define vtkPV3FoamAddVolumeMesh_H - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - #include "vtkPV3Foam.H" // Foam includes #include "fvMesh.H" #include "cellModeller.H" -#include "vtkPV3FoamInsertNextPoint.H" +#include "vtkPV3FoamPoints.H" // VTK includes #include "vtkCellArray.h" #include "vtkUnstructuredGrid.h" - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::vtkPV3Foam::addVolumeMesh +vtkUnstructuredGrid* Foam::vtkPV3Foam::volumeVTKMesh ( const fvMesh& mesh, - vtkUnstructuredGrid* vtkmesh, - labelList& superCells + polyDecomp& decompInfo ) { + vtkUnstructuredGrid* vtkmesh = vtkUnstructuredGrid::New(); + if (debug) { - Info<< "<beg> Foam::vtkPV3Foam::addVolumeMesh" << endl; + Info<< "<beg> Foam::vtkPV3Foam::volumeVTKMesh" << endl; printMemory(); } @@ -64,6 +59,9 @@ void Foam::vtkPV3Foam::addVolumeMesh // Number of additional cells generated by the decomposition of polyhedra label nAddCells = 0; + labelList& superCells = decompInfo.superCells(); + labelList& addPointCellLabels = decompInfo.addPointCellLabels(); + const cellModel& tet = *(cellModeller::lookup("tet")); const cellModel& pyr = *(cellModeller::lookup("pyr")); const cellModel& prism = *(cellModeller::lookup("prism")); @@ -117,17 +115,17 @@ void Foam::vtkPV3Foam::addVolumeMesh // Set size of additional point addressing array // (from added point to original cell) - addPointCellLabels_.setSize(nAddPoints); + addPointCellLabels.setSize(nAddPoints); // Set size of additional cells mapping array // (from added cell to original cell) if (debug) { - Info<<"mesh.nCells() = " << mesh.nCells() << nl - <<"mesh.nPoints() = " << mesh.nPoints() << nl - <<"nAddCells = " << nAddCells << nl - <<"nAddPoints = " << nAddPoints << endl; + Info<<" mesh nCells = " << mesh.nCells() << nl + <<" nPoints = " << mesh.nPoints() << nl + <<" nAddCells = " << nAddCells << nl + <<" nAddPoints = " << nAddPoints << endl; } superCells.setSize(mesh.nCells() + nAddCells); @@ -139,7 +137,7 @@ void Foam::vtkPV3Foam::addVolumeMesh // Convert Foam mesh vertices to VTK vtkPoints *vtkpoints = vtkPoints::New(); - vtkpoints->Allocate(mesh.nPoints() + nAddPoints); + vtkpoints->Allocate( mesh.nPoints() + nAddPoints ); const Foam::pointField& points = mesh.points(); @@ -154,21 +152,21 @@ void Foam::vtkPV3Foam::addVolumeMesh Info<< "... converting cells" << endl; } - vtkmesh->Allocate(mesh.nCells() + nAddCells); + vtkmesh->Allocate( mesh.nCells() + nAddCells ); // Set counters for additional points and additional cells - label api = 0, aci = 0; + label addPointI = 0, addCellI = 0; // Create storage for points - needed for mapping from Foam to VTK // data types - max 'order' = hex = 8 points vtkIdType nodeIds[8]; - forAll(cellShapes, celli) + forAll(cellShapes, cellI) { - const cellShape& cellShape = cellShapes[celli]; + const cellShape& cellShape = cellShapes[cellI]; const cellModel& cellModel = cellShape.model(); - superCells[aci++] = celli; + superCells[addCellI++] = cellI; if (cellModel == tet) { @@ -265,16 +263,16 @@ void Foam::vtkPV3Foam::addVolumeMesh // Polyhedral cell. Decompose into tets + prisms. // Mapping from additional point to cell - addPointCellLabels_[api] = celli; + addPointCellLabels[addPointI] = cellI; // Insert the new vertex from the cell-centre - label newVertexLabel = mesh.nPoints() + api; - vtkPV3FoamInsertNextPoint(vtkpoints, mesh.C()[celli]); + label newVertexLabel = mesh.nPoints() + addPointI; + vtkPV3FoamInsertNextPoint(vtkpoints, mesh.C()[cellI]); // Whether to insert cell in place of original or not. bool substituteCell = true; - const labelList& cFaces = mesh.cells()[celli]; + const labelList& cFaces = mesh.cells()[cellI]; forAll(cFaces, cFaceI) { @@ -293,13 +291,13 @@ void Foam::vtkPV3Foam::addVolumeMesh if (substituteCell) { - thisCellI = celli; + thisCellI = cellI; substituteCell = false; } else { - thisCellI = mesh.nCells() + aci; - superCells[aci++] = celli; + thisCellI = mesh.nCells() + addCellI; + superCells[addCellI++] = cellI; } nodeIds[0] = f[0]; @@ -323,13 +321,13 @@ void Foam::vtkPV3Foam::addVolumeMesh if (substituteCell) { - thisCellI = celli; + thisCellI = cellI; substituteCell = false; } else { - thisCellI = mesh.nCells() + aci; - superCells[aci++] = celli; + thisCellI = mesh.nCells() + addCellI; + superCells[addCellI++] = cellI; } nodeIds[0] = f[0]; @@ -345,7 +343,7 @@ void Foam::vtkPV3Foam::addVolumeMesh } } - api++; + addPointI++; } } @@ -354,14 +352,11 @@ void Foam::vtkPV3Foam::addVolumeMesh if (debug) { - Info<< "<end> Foam::vtkPV3Foam::addVolumeMesh" << endl; + Info<< "<end> Foam::vtkPV3Foam::volumeVTKMesh" << endl; printMemory(); } -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif + return vtkmesh; +} // ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddZoneMesh.C b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshZone.C similarity index 76% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddZoneMesh.C rename to applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshZone.C index 9c52624f0f9ad7019d92e70a3fceb1718e3de5cc..12533e44bc8939c734a8a82362057e662a214a42 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddZoneMesh.C +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshZone.C @@ -29,7 +29,7 @@ Description #include "vtkPV3Foam.H" // Foam includes -#include "vtkPV3FoamInsertNextPoint.H" +#include "vtkPV3FoamPoints.H" // VTK includes #include "vtkPoints.h" @@ -39,20 +39,21 @@ Description // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::vtkPV3Foam::addFaceZoneMesh +vtkPolyData* Foam::vtkPV3Foam::faceZoneVTKMesh ( const fvMesh& mesh, - const labelList& faceLabels, - vtkPolyData* vtkmesh + const labelList& faceLabels ) { + vtkPolyData* vtkmesh = vtkPolyData::New(); + if (debug) { - Info<< "<beg> Foam::vtkPV3Foam::addFaceZoneMesh" << endl; + Info<< "<beg> Foam::vtkPV3Foam::faceZoneVTKMesh" << endl; printMemory(); } - // Construct primitivePatch of faces in fSet. + // Construct primitivePatch of faces in faceZone const faceList& meshFaces = mesh.faces(); faceList patchFaces(faceLabels.size()); @@ -63,31 +64,34 @@ void Foam::vtkPV3Foam::addFaceZoneMesh primitiveFacePatch p(patchFaces, mesh.points()); - // The balance of this routine should be identical to addPatchMesh + // The balance of this routine should be identical to patchVTKMesh // Convert Foam mesh vertices to VTK const pointField& points = p.localPoints(); - vtkPoints *vtkpoints = vtkPoints::New(); - vtkpoints->Allocate(p.size()); + vtkPoints* vtkpoints = vtkPoints::New(); + vtkpoints->Allocate( points.size() ); forAll(points, i) { vtkPV3FoamInsertNextPoint(vtkpoints, points[i]); } + vtkmesh->SetPoints(vtkpoints); vtkpoints->Delete(); + // Add faces as polygons const faceList& faces = p.localFaces(); vtkCellArray* vtkcells = vtkCellArray::New(); - vtkcells->Allocate(points.size()); + vtkcells->Allocate( faces.size() ); + forAll(faces, faceI) { const face& f = faces[faceI]; vtkIdType nodeIds[f.size()]; - forAll (f, fp) + forAll(f, fp) { nodeIds[fp] = f[fp]; } @@ -99,30 +103,33 @@ void Foam::vtkPV3Foam::addFaceZoneMesh if (debug) { - Info<< "<end> Foam::vtkPV3Foam::addFaceZoneMesh" << endl; + Info<< "<end> Foam::vtkPV3Foam::faceZoneVTKMesh" << endl; printMemory(); } + + return vtkmesh; } -void Foam::vtkPV3Foam::addPointZoneMesh +vtkPolyData* Foam::vtkPV3Foam::pointZoneVTKMesh ( const fvMesh& mesh, - const labelList& pointLabels, - vtkPolyData* vtkmesh + const labelList& pointLabels ) { + vtkPolyData* vtkmesh = vtkPolyData::New(); + if (debug) { - Info<< "<beg> Foam::vtkPV3Foam::addPointZoneMesh" << endl; + Info<< "<beg> Foam::vtkPV3Foam::pointZoneVTKMesh" << endl; printMemory(); } const pointField& meshPoints = mesh.points(); vtkPoints *vtkpoints = vtkPoints::New(); - vtkpoints->Allocate(pointLabels.size()); + vtkpoints->Allocate( pointLabels.size() ); forAll(pointLabels, pointI) { @@ -134,9 +141,11 @@ void Foam::vtkPV3Foam::addPointZoneMesh if (debug) { - Info<< "<beg> Foam::vtkPV3Foam::addPointZoneMesh" << endl; + Info<< "<beg> Foam::vtkPV3Foam::pointZoneVTKMesh" << endl; printMemory(); } + + return vtkmesh; } // ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertPatchFaceField.H b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamPatchField.H similarity index 60% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertPatchFaceField.H rename to applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamPatchField.H index af0fde5e21db913a599b06f0438ab3edb555fd4c..ee4d3b7dcb58ef376524eedce2581fd62ba68246 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamConvertPatchFaceField.H +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamPatchField.H @@ -27,42 +27,37 @@ InClass \*---------------------------------------------------------------------------*/ -#ifndef vtkPV3FoamConvertPatchFaceField_H -#define vtkPV3FoamConvertPatchFaceField_H +#ifndef vtkPV3FoamPatchField_H +#define vtkPV3FoamPatchField_H // VTK includes #include "vtkCellData.h" #include "vtkFloatArray.h" #include "vtkMultiBlockDataSet.h" +#include "vtkPointData.h" #include "vtkPolyData.h" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // template<class Type> -void Foam::vtkPV3Foam::convertPatchFaceField +void Foam::vtkPV3Foam::convertPatchField ( const word& name, const Field<Type>& ptf, vtkMultiBlockDataSet* output, - const selectionInfo& selector, + const partInfo& selector, const label datasetNo ) { const label nComp = pTraits<Type>::nComponents; - vtkPolyData* vtkmesh = vtkPolyData::SafeDownCast - ( - GetDataSetFromBlock(output, selector, datasetNo) - ); - - vtkFloatArray *cellData = vtkFloatArray::New(); - cellData->SetNumberOfTuples(ptf.size()); - cellData->SetNumberOfComponents(nComp); - cellData->Allocate(nComp*ptf.size()); - cellData->SetName(name.c_str()); + vtkFloatArray* cellData = vtkFloatArray::New(); + cellData->SetNumberOfTuples( ptf.size() ); + cellData->SetNumberOfComponents( nComp ); + cellData->Allocate( nComp*ptf.size() ); + cellData->SetName( name.c_str() ); float vec[nComp]; - forAll(ptf, i) { const Type& t = ptf[i]; @@ -70,15 +65,59 @@ void Foam::vtkPV3Foam::convertPatchFaceField { vec[d] = component(t, d); } - cellData->InsertTuple(i, vec); } - vtkmesh->GetCellData()->AddArray(cellData); + vtkPolyData::SafeDownCast + ( + GetDataSetFromBlock(output, selector, datasetNo) + ) ->GetCellData() + ->AddArray(cellData); + cellData->Delete(); } +// as above, but with PointData() +template<class Type> +void Foam::vtkPV3Foam::convertPatchPointField +( + const word& name, + const Field<Type>& pptf, + vtkMultiBlockDataSet* output, + const partInfo& selector, + const label datasetNo +) +{ + const label nComp = pTraits<Type>::nComponents; + + vtkFloatArray *pointData = vtkFloatArray::New(); + pointData->SetNumberOfTuples( pptf.size() ); + pointData->SetNumberOfComponents( nComp ); + pointData->Allocate( nComp*pptf.size() ); + pointData->SetName( name.c_str() ); + + float vec[nComp]; + forAll(pptf, i) + { + const Type& t = pptf[i]; + for (direction d=0; d<nComp; d++) + { + vec[d] = component(t, d); + } + + pointData->InsertTuple(i, vec); + } + + vtkPolyData::SafeDownCast + ( + GetDataSetFromBlock(output, selector, datasetNo) + ) ->GetPointData() + ->AddArray(pointData); + + pointData->Delete(); +} + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamPointFields.H b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamPointFields.H new file mode 100644 index 0000000000000000000000000000000000000000..9493bce3210aa53e833d0181a54bae1e5655169b --- /dev/null +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamPointFields.H @@ -0,0 +1,277 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 vtkPV3FoamPointFields_H +#define vtkPV3FoamPointFields_H + +// Foam includes +#include "interpolatePointToCell.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template<class Type> +void Foam::vtkPV3Foam::convertPointFields +( + const fvMesh& mesh, + const pointMesh& pMesh, + const IOobjectList& objects, + vtkMultiBlockDataSet* output +) +{ + const polyBoundaryMesh& patches = mesh.boundaryMesh(); + + forAllConstIter(IOobjectList, objects, iter) + { + const word& fieldName = iter()->name(); + // restrict to this GeometricField<Type, ...> + if + ( + iter()->headerClassName() + != GeometricField<Type, pointPatchField, pointMesh>::typeName + ) + { + continue; + } + + if (debug) + { + Info<< "Foam::vtkPV3Foam::convertPointFields : " + << fieldName << endl; + } + + GeometricField<Type, pointPatchField, pointMesh> ptf + ( + *iter(), + pMesh + ); + + + // Convert activated internalMesh regions + convertPointFieldBlock + ( + ptf, + output, + partInfoVolume_, + regionPolyDecomp_ + ); + + // Convert activated cellZones + convertPointFieldBlock + ( + ptf, + output, + partInfoCellZones_, + zonePolyDecomp_ + ); + + // Convert activated cellSets + convertPointFieldBlock + ( + ptf, + output, + partInfoCellSets_, + csetPolyDecomp_ + ); + + + // + // Convert patches - if activated + // + for + ( + int partId = partInfoPatches_.start(); + partId < partInfoPatches_.end(); + ++partId + ) + { + const word patchName = getPartName(partId); + const label datasetNo = partDataset_[partId]; + const label patchId = patches.findPatchID(patchName); + + if (!partStatus_[partId] || datasetNo < 0 || patchId < 0) + { + continue; + } + + convertPatchPointField + ( + fieldName, + ptf.boundaryField()[patchId].patchInternalField()(), + output, + partInfoPatches_, + datasetNo + ); + } + } +} + + + +template<class Type> +void Foam::vtkPV3Foam::convertPointFieldBlock +( + const GeometricField<Type, pointPatchField, pointMesh>& ptf, + vtkMultiBlockDataSet* output, + const partInfo& selector, + const List<polyDecomp>& decompLst +) +{ + for (int partId = selector.start(); partId < selector.end(); ++partId) + { + const label datasetNo = partDataset_[partId]; + + if (datasetNo >= 0 && partStatus_[partId]) + { + convertPointField + ( + ptf, + GeometricField<Type, fvPatchField, volMesh>::null(), + output, + selector, + datasetNo, + decompLst[datasetNo] + ); + } + } +} + + + +template<class Type> +void Foam::vtkPV3Foam::convertPointField +( + const GeometricField<Type, pointPatchField, pointMesh>& ptf, + const GeometricField<Type, fvPatchField, volMesh>& tf, + vtkMultiBlockDataSet* output, + const partInfo& selector, + const label datasetNo, + const polyDecomp& decomp +) +{ + const label nComp = pTraits<Type>::nComponents; + const labelList& addPointCellLabels = decomp.addPointCellLabels(); + const labelList& pointMap = decomp.pointMap(); + + // use a pointMap or address directly into mesh + label nPoints; + if (pointMap.size()) + { + nPoints = pointMap.size(); + } + else + { + nPoints = ptf.size(); + } + + vtkFloatArray *pointData = vtkFloatArray::New(); + pointData->SetNumberOfTuples( nPoints + addPointCellLabels.size() ); + pointData->SetNumberOfComponents( nComp ); + pointData->Allocate( nComp*(nPoints + addPointCellLabels.size()) ); + pointData->SetName( tf.name().c_str() ); + + + if (debug) + { + Info<< "convert convertPointField: " + << tf.name() + << " size = " << nPoints + << " nComp=" << nComp + << " nTuples = " << (nPoints + addPointCellLabels.size()) + << endl; + } + + float vec[nComp]; + + if (pointMap.size()) + { + forAll(pointMap, i) + { + const Type& t = ptf[pointMap[i]]; + for (direction d=0; d<nComp; d++) + { + vec[d] = component(t, d); + } + pointData->InsertTuple(i, vec); + } + } + else + { + forAll(ptf, i) + { + const Type& t = ptf[i]; + for (direction d=0; d<nComp; d++) + { + vec[d] = component(t, d); + } + pointData->InsertTuple(i, vec); + } + } + + // continue insertion from here + label i = nPoints; + + if (&tf != &GeometricField<Type, fvPatchField, volMesh>::null()) + { + forAll(addPointCellLabels, apI) + { + const Type& t = tf[addPointCellLabels[apI]]; + for (direction d=0; d<nComp; d++) + { + vec[d] = component(t, d); + } + pointData->InsertTuple(i++, vec); + } + } + else + { + forAll(addPointCellLabels, apI) + { + Type t = interpolatePointToCell(ptf, addPointCellLabels[apI]); + for (direction d=0; d<nComp; d++) + { + vec[d] = component(t, d); + } + pointData->InsertTuple(i++, vec); + } + } + + vtkUnstructuredGrid::SafeDownCast + ( + GetDataSetFromBlock(output, selector, datasetNo) + ) ->GetPointData() + ->AddArray(pointData); + + pointData->Delete(); +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamInsertNextPoint.H b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamPoints.H similarity index 72% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamInsertNextPoint.H rename to applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamPoints.H index a7bab440d3ec8f936fe9d7ad8c8e99365d6b8091..101fb8d62b24109d90b66c355baf0cd7ce5a7646 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamInsertNextPoint.H +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamPoints.H @@ -27,8 +27,8 @@ InClass \*---------------------------------------------------------------------------*/ -#ifndef vtkPV3FoamInsertNextPoint_H -#define vtkPV3FoamInsertNextPoint_H +#ifndef vtkPV3FoamPoints_H +#define vtkPV3FoamPoints_H // VTK includes #include "vtkPoints.h" @@ -44,6 +44,34 @@ inline void vtkPV3FoamInsertNextPoint points->InsertNextPoint(p.x(), p.y(), p.z()); } +#if 0 +// this should be faster, but didn't get it working ... +inline void vtkPV3FoamSetPoint +( + vtkPoints *points, + const Foam::label id, + const Foam::point& p +) +{ + points->SetPoint(id, p.x(), p.y(), p.z()); +} + + +// Convert Foam mesh vertices to VTK +inline vtkPoints* vtkPV3FoamVTKPoints(const Foam::pointField& points) +{ + vtkPoints *vtkpoints = vtkPoints::New(); + vtkpoints->SetNumberOfPoints(points.size()); + forAll(points, i) + { + const Foam::point& p = points[i]; + vtkpoints->SetPoint(i, p.x(), p.y(), p.z()); + } + + return vtkpoints; +} + +#endif // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdate.C b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdate.C deleted file mode 100644 index 8f4a83c43f356baca208f25941ff04767191ec7f..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdate.C +++ /dev/null @@ -1,291 +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 "IOobjectList.H" -#include "vtkPV3FoamReader.h" - -// VTK includes -#include "vtkDataArraySelection.h" -#include "vtkPolyData.h" -#include "vtkUnstructuredGrid.h" - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -#include "vtkPV3FoamConvertVolFields.H" -#include "vtkPV3FoamConvertPointFields.H" -#include "vtkPV3FoamConvertLagrangianFields.H" - -void Foam::vtkPV3Foam::updateFoamMesh() -{ - if (debug) - { - Info<< "<beg> 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<< "<end> Foam::vtkPV3Foam::updateFoamMesh" << endl; - printMemory(); - } -} - - -void Foam::vtkPV3Foam::updateVolFields -( - vtkMultiBlockDataSet* output -) -{ - if (debug) - { - Info<< "<beg> Foam::vtkPV3Foam::updateVolFields" << endl; - printMemory(); - } - - const fvMesh& mesh = *meshPtr_; - - // Construct interpolation on the raw mesh - pointMesh pMesh(mesh); - - // Search for list of objects for this time - IOobjectList objects(mesh, dbPtr_().timeName()); - - vtkDataArraySelection* arraySelection = reader_->GetVolFieldSelection(); - - // Convert volume fields - if (debug) - { - Info<< "converting Foam volume fields" << endl; - } - - volPointInterpolation pInterp(mesh, pMesh); - - PtrList<PrimitivePatchInterpolation<primitivePatch> > - ppInterpList(mesh.boundaryMesh().size()); - - forAll(ppInterpList, i) - { - ppInterpList.set - ( - i, - new PrimitivePatchInterpolation<primitivePatch> - ( - mesh.boundaryMesh()[i] - ) - ); - } -/* - convertVolFields<Foam::label> - ( - mesh, pInterp, objects, arraySelection, output - ); -*/ - convertVolFields<Foam::scalar> - ( - mesh, pInterp, ppInterpList, objects, arraySelection, output - ); - convertVolFields<Foam::vector> - ( - mesh, pInterp, ppInterpList, objects, arraySelection, output - ); - convertVolFields<Foam::sphericalTensor> - ( - mesh, pInterp, ppInterpList, objects, arraySelection, output - ); - convertVolFields<Foam::symmTensor> - ( - mesh, pInterp, ppInterpList, objects, arraySelection, output - ); - convertVolFields<Foam::tensor> - ( - mesh, pInterp, ppInterpList, objects, arraySelection, output - ); - - if (debug) - { - Info<< "<end> Foam::vtkPV3Foam::updateVolFields" << endl; - printMemory(); - } -} - - -void Foam::vtkPV3Foam::updatePointFields -( - vtkMultiBlockDataSet* output -) -{ - if (debug) - { - Info<< "<beg> Foam::vtkPV3Foam::updatePointFields" << endl; - printMemory(); - } - - const fvMesh& mesh = *meshPtr_; - - // Search for list of objects for this time - IOobjectList objects(mesh, dbPtr_().timeName()); - - vtkDataArraySelection* arraySelection = reader_->GetPointFieldSelection(); - -/* - convertPointFields<Foam::label> - ( - mesh, objects, arraySelection, output - ); -*/ - convertPointFields<Foam::scalar> - ( - mesh, objects, arraySelection, output - ); - convertPointFields<Foam::vector> - ( - mesh, objects, arraySelection, output - ); - convertPointFields<Foam::sphericalTensor> - ( - mesh, objects, arraySelection, output - ); - convertPointFields<Foam::symmTensor> - ( - mesh, objects, arraySelection, output - ); - convertPointFields<Foam::tensor> - ( - mesh, objects, arraySelection, output - ); - - if (debug) - { - Info<< "<end> Foam::vtkPV3Foam::updatePointFields" << endl; - printMemory(); - } -} - - -void Foam::vtkPV3Foam::updateLagrangianFields -( - vtkMultiBlockDataSet* output -) -{ - if (debug) - { - Info<< "<beg> Foam::vtkPV3Foam::updateLagrangianFields" << endl; - printMemory(); - } - - const fvMesh& mesh = *meshPtr_; - - // Search for list of objects for this time - //- TODO - currently hard-coded to ONE cloud - IOobjectList objects - ( - mesh, - dbPtr_().timeName(), - "lagrangian"/cloudName_ - ); - - vtkDataArraySelection* arraySelection = - reader_->GetLagrangianFieldSelection(); - - // Convert Lagrangian fields - if (debug) - { - Info<< "converting Foam Lagrangian fields" << endl; - } - - convertLagrangianFields<Foam::label> - ( - mesh, objects, arraySelection, output - ); - - convertLagrangianFields<Foam::scalar> - ( - mesh, objects, arraySelection, output - ); - convertLagrangianFields<Foam::vector> - ( - mesh, objects, arraySelection, output - ); - convertLagrangianFields<Foam::sphericalTensor> - ( - mesh, objects, arraySelection, output - ); - convertLagrangianFields<Foam::symmTensor> - ( - mesh, objects, arraySelection, output - ); - convertLagrangianFields<Foam::tensor> - ( - mesh, objects, arraySelection, output - ); - - if (debug) - { - Info<< "<end> Foam::vtkPV3Foam::updateLagrangianFields" << endl; - printMemory(); - } -} - - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInformation.C b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfo.C similarity index 58% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInformation.C rename to applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfo.C index 031d8aad58ddf8115c49002fbbfb767e654fef45..1c00a04a8573edf498772061a60d081b95e06a1c 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInformation.C +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfo.C @@ -38,7 +38,7 @@ License // local headers #include "vtkPV3FoamAddToSelection.H" -#include "vtkPV3FoamUpdateInformationFields.H" +#include "vtkPV3FoamUpdateInfoFields.H" // VTK includes #include "vtkDataArraySelection.h" @@ -107,7 +107,7 @@ Foam::wordList Foam::vtkPV3Foam::readZoneNames(const word& zoneType) zonesEntries zones(ioObj); zoneNames.setSize(zones.size()); - forAll (zones, zoneI) + forAll(zones, zoneI) { zoneNames[zoneI] = zones[zoneI].keyword(); } @@ -117,115 +117,100 @@ Foam::wordList Foam::vtkPV3Foam::readZoneNames(const word& zoneType) } -void Foam::vtkPV3Foam::updateInformationInternalMesh() +void Foam::vtkPV3Foam::updateInfoInternalMesh() { if (debug) { - Info<< "<beg> Foam::vtkPV3Foam::updateInformationInternalMesh" << endl; + Info<< "<beg> Foam::vtkPV3Foam::updateInfoInternalMesh" << endl; } - vtkDataArraySelection* arraySelection = reader_->GetRegionSelection(); + vtkDataArraySelection* partSelection = reader_->GetPartSelection(); // Determine number of meshes available HashTable<const fvMesh*> meshObjects = dbPtr_().lookupClass<const fvMesh>(); nMesh_ = meshObjects.size(); - // Determine regions (internal mesh and patches...) + // Determine mesh parts (internalMesh, patches...) //- Add internal mesh as first entry - selectInfoVolume_ = arraySelection->GetNumberOfArrays(); - arraySelection->AddArray("internalMesh"); - selectInfoVolume_ += 1; + partInfoVolume_ = partSelection->GetNumberOfArrays(); + partSelection->AddArray("internalMesh"); + partInfoVolume_ += 1; if (debug) { // just for debug info - getSelectedArrayEntries(arraySelection); + getSelectedArrayEntries(partSelection); - Info<< "<end> Foam::vtkPV3Foam::updateInformationInternalMesh" << endl; + Info<< "<end> Foam::vtkPV3Foam::updateInfoInternalMesh" << endl; } } -void Foam::vtkPV3Foam::updateInformationLagrangian() +void Foam::vtkPV3Foam::updateInfoLagrangian() { if (debug) { - Info<< "<beg> Foam::vtkPV3Foam::updateInformationLagrangian" << nl + Info<< "<beg> Foam::vtkPV3Foam::updateInfoLagrangian" << nl << " " << dbPtr_->timePath()/"lagrangian" << endl; } - vtkDataArraySelection* arraySelection = reader_->GetRegionSelection(); - // Search for list of lagrangian objects for this time fileNameList cloudDirs ( readDir(dbPtr_->timePath()/"lagrangian", fileName::DIRECTORY) ); - selectInfoLagrangian_ = arraySelection->GetNumberOfArrays(); + vtkDataArraySelection* partSelection = reader_->GetPartSelection(); + partInfoLagrangian_ = partSelection->GetNumberOfArrays(); - if (cloudDirs.size()) + int nClouds = 0; + forAll(cloudDirs, cloudI) { - arraySelection->AddArray("lagrangian"); - selectInfoLagrangian_ += 1; - - Info<< "... added cloudDirs\n"; + // Add cloud to GUI list + partSelection->AddArray + ( + (cloudDirs[cloudI] + " - lagrangian").c_str() + ); - if (cloudDirs.size() > 1) - { - WarningIn("void Foam::vtkPV3Foam::updateInformationLagrangian()") - << "Multiple lagrangian clouds identified. Currently only able " - << "to process ONE cloud: " << cloudDirs[0] - << endl; - } - // Set cloud name to first cloud found - // TODO - multiple clouds - cloudName_ = cloudDirs[0]; - } - else - { - if (debug) - { - Info<< "... no clouds identified in " <<nl - << " " <<dbPtr_->timePath()/"lagrangian" << endl; - } + ++nClouds; } + partInfoLagrangian_ += nClouds; + if (debug) { // just for debug info - getSelectedArrayEntries(arraySelection); + getSelectedArrayEntries(partSelection); - Info<< "<end> Foam::vtkPV3Foam::updateInformationLagrangian" << endl; + Info<< "<end> Foam::vtkPV3Foam::updateInfoLagrangian" << endl; } } -void Foam::vtkPV3Foam::updateInformationPatches() +void Foam::vtkPV3Foam::updateInfoPatches() { if (debug) { - Info<< "<beg> Foam::vtkPV3Foam::updateInformationPatches" + Info<< "<beg> Foam::vtkPV3Foam::updateInfoPatches" << " [meshPtr=" << (meshPtr_ ? "set" : "NULL") << "]" << endl; } - vtkDataArraySelection *arraySelection = reader_->GetRegionSelection(); - selectInfoPatches_ = arraySelection->GetNumberOfArrays(); + vtkDataArraySelection* partSelection = reader_->GetPartSelection(); + partInfoPatches_ = partSelection->GetNumberOfArrays(); int nPatches = 0; - if (meshPtr_) { const polyBoundaryMesh& patches = meshPtr_->boundaryMesh(); - forAll (patches, patchI) + forAll(patches, patchI) { const polyPatch& pp = patches[patchI]; if (pp.size()) { - // Add patch to GUI region list - arraySelection->AddArray + // Add patch to GUI list + partSelection->AddArray ( (pp.name() + " - patch").c_str() ); @@ -251,8 +236,8 @@ void Foam::vtkPV3Foam::updateInformationPatches() ) ); - // Start regions at patches - forAll (patchEntries, entryI) + // Add (non-zero) patches to the list of mesh parts + forAll(patchEntries, entryI) { label nFaces ( @@ -262,8 +247,8 @@ void Foam::vtkPV3Foam::updateInformationPatches() // Valid patch if nFace > 0 if (nFaces) { - // Add patch to GUI region list - arraySelection->AddArray + // Add patch to GUI list + partSelection->AddArray ( (patchEntries[entryI].keyword() + " - patch").c_str() ); @@ -273,28 +258,32 @@ void Foam::vtkPV3Foam::updateInformationPatches() } } - selectInfoPatches_ += nPatches; + partInfoPatches_ += nPatches; if (debug) { // just for debug info - getSelectedArrayEntries(arraySelection); + getSelectedArrayEntries(partSelection); - Info<< "<end> Foam::vtkPV3Foam::updateInformationPatches" << endl; + Info<< "<end> Foam::vtkPV3Foam::updateInfoPatches" << endl; } } -void Foam::vtkPV3Foam::updateInformationZones() +void Foam::vtkPV3Foam::updateInfoZones() { + if (!reader_->GetIncludeZones()) + { + return; + } + if (debug) { - Info<< "<beg> Foam::vtkPV3Foam::updateInformationZones" + Info<< "<beg> Foam::vtkPV3Foam::updateInfoZones" << " [meshPtr=" << (meshPtr_ ? "set" : "NULL") << "]" << endl; } - vtkDataArraySelection *arraySelection = reader_->GetRegionSelection(); - + vtkDataArraySelection* partSelection = reader_->GetPartSelection(); wordList namesLst; // @@ -309,13 +298,12 @@ void Foam::vtkPV3Foam::updateInformationZones() namesLst = readZoneNames("cellZones"); } - selectInfoCellZones_ = arraySelection->GetNumberOfArrays(); - forAll (namesLst, elemI) + partInfoCellZones_ = partSelection->GetNumberOfArrays(); + forAll(namesLst, elemI) { - arraySelection->AddArray((namesLst[elemI] + " - cellZone").c_str()); + partSelection->AddArray((namesLst[elemI] + " - cellZone").c_str()); } - selectInfoCellZones_ += namesLst.size(); - zoneSuperCells_.setSize(selectInfoCellZones_.size()); + partInfoCellZones_ += namesLst.size(); // @@ -330,12 +318,15 @@ void Foam::vtkPV3Foam::updateInformationZones() namesLst = readZoneNames("faceZones"); } - selectInfoFaceZones_ = arraySelection->GetNumberOfArrays(); - forAll (namesLst, elemI) + partInfoFaceZones_ = partSelection->GetNumberOfArrays(); + forAll(namesLst, elemI) { - arraySelection->AddArray((namesLst[elemI] + " - faceZone").c_str()); + partSelection->AddArray + ( + (namesLst[elemI] + " - faceZone").c_str() + ); } - selectInfoFaceZones_ += namesLst.size(); + partInfoFaceZones_ += namesLst.size(); // @@ -350,32 +341,40 @@ void Foam::vtkPV3Foam::updateInformationZones() namesLst = readZoneNames("pointZones"); } - selectInfoPointZones_ = arraySelection->GetNumberOfArrays(); - forAll (namesLst, elemI) + partInfoPointZones_ = partSelection->GetNumberOfArrays(); + forAll(namesLst, elemI) { - arraySelection->AddArray((namesLst[elemI] + " - pointZone").c_str()); + partSelection->AddArray + ( + (namesLst[elemI] + " - pointZone").c_str() + ); } - selectInfoPointZones_ += namesLst.size(); + partInfoPointZones_ += namesLst.size(); if (debug) { // just for debug info - getSelectedArrayEntries(arraySelection); + getSelectedArrayEntries(partSelection); - Info<< "<end> Foam::vtkPV3Foam::updateInformationZones" << endl; + Info<< "<end> Foam::vtkPV3Foam::updateInfoZones" << endl; } } -void Foam::vtkPV3Foam::updateInformationSets() +void Foam::vtkPV3Foam::updateInfoSets() { + if (!reader_->GetIncludeSets()) + { + return; + } + if (debug) { - Info<< "<beg> Foam::vtkPV3Foam::updateInformationSets" << endl; + Info<< "<beg> Foam::vtkPV3Foam::updateInfoSets" << endl; } - vtkDataArraySelection *arraySelection = reader_->GetRegionSelection(); + vtkDataArraySelection* partSelection = reader_->GetPartSelection(); // Add names of sets IOobjectList objects @@ -386,27 +385,26 @@ void Foam::vtkPV3Foam::updateInformationSets() ); - selectInfoCellSets_ = arraySelection->GetNumberOfArrays(); - selectInfoCellSets_ += addToSelection<cellSet> + partInfoCellSets_ = partSelection->GetNumberOfArrays(); + partInfoCellSets_ += addToSelection<cellSet> ( - arraySelection, + partSelection, objects, " - cellSet" ); - csetSuperCells_.setSize(selectInfoCellSets_.size()); - selectInfoFaceSets_ = arraySelection->GetNumberOfArrays(); - selectInfoFaceSets_ += addToSelection<faceSet> + partInfoFaceSets_ = partSelection->GetNumberOfArrays(); + partInfoFaceSets_ += addToSelection<faceSet> ( - arraySelection, + partSelection, objects, " - faceSet" ); - selectInfoPointSets_ = arraySelection->GetNumberOfArrays(); - selectInfoPointSets_ += addToSelection<pointSet> + partInfoPointSets_ = partSelection->GetNumberOfArrays(); + partInfoPointSets_ += addToSelection<pointSet> ( - arraySelection, + partSelection, objects, " - pointSet" ); @@ -414,85 +412,92 @@ void Foam::vtkPV3Foam::updateInformationSets() if (debug) { // just for debug info - getSelectedArrayEntries(arraySelection); + getSelectedArrayEntries(partSelection); - Info<< "<end> Foam::vtkPV3Foam::updateInformationSets" << endl; + Info<< "<end> Foam::vtkPV3Foam::updateInfoSets" << endl; } } -void Foam::vtkPV3Foam::updateInformationLagrangianFields() +void Foam::vtkPV3Foam::updateInfoLagrangianFields() { if (debug) { - Info<< "<beg> Foam::vtkPV3Foam::updateInformationLagrangianFields" + Info<< "<beg> Foam::vtkPV3Foam::updateInfoLagrangianFields" << endl; } - vtkDataArraySelection *arraySelection = + vtkDataArraySelection *fieldSelection = reader_->GetLagrangianFieldSelection(); - // preserve the currently selected values - const stringList selectedEntries = getSelectedArrayEntries - ( - arraySelection - ); - arraySelection->RemoveAllArrays(); + // preserve the enabled selections + stringList enabledEntries = getSelectedArrayEntries(fieldSelection); + fieldSelection->RemoveAllArrays(); + + // + // TODO - currently only get fields from ONE cloud + // have to decide if the second set of fields get mixed in + // or dealt with separately + + const partInfo& selector = partInfoLagrangian_; + int partId = selector.start(); + + if (!selector.size() || partId < 0) + { + return; + } + + word cloudName = getPartName(partId); - // TODO - currently hard-coded to ONE cloud IOobjectList objects ( dbPtr_(), dbPtr_().timeName(), - "lagrangian"/cloudName_ + "lagrangian"/cloudName ); addToSelection<IOField<label> > ( - arraySelection, + fieldSelection, objects ); addToSelection<IOField<scalar> > ( - arraySelection, + fieldSelection, objects ); addToSelection<IOField<vector> > ( - arraySelection, + fieldSelection, objects ); addToSelection<IOField<sphericalTensor> > ( - arraySelection, + fieldSelection, + objects ); addToSelection<IOField<symmTensor> > ( - arraySelection, + fieldSelection, objects ); addToSelection<IOField<tensor> > ( - arraySelection, + fieldSelection, objects ); - // restore the currently enabled values - setSelectedArrayEntries - ( - arraySelection, - selectedEntries - ); + // restore the enabled selections + setSelectedArrayEntries(fieldSelection, enabledEntries); if (debug) { - Info<< "<end> Foam::vtkPV3Foam::updateInformationLagrangianFields - " + Info<< "<end> Foam::vtkPV3Foam::updateInfoLagrangianFields - " << "lagrangian objects.size() = " << objects.size() << endl; } } // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - // ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInformationFields.H b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfoFields.H similarity index 67% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInformationFields.H rename to applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfoFields.H index b9d7df9fa55d5235806785fcd07f838b7b7c5943..bd18d66d944640a02ad8fdc30bad1333d7117b28 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInformationFields.H +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfoFields.H @@ -27,95 +27,78 @@ InClass \*---------------------------------------------------------------------------*/ -#ifndef vtkPV3FoamUpdateInformationFields_H -#define vtkPV3FoamUpdateInformationFields_H +#ifndef vtkPV3FoamUpdateInfoFields_H +#define vtkPV3FoamUpdateInfoFields_H // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // template<template<class> class patchType, class meshType> -void Foam::vtkPV3Foam::updateInformationFields +void Foam::vtkPV3Foam::updateInfoFields ( - vtkDataArraySelection *arraySelection + vtkDataArraySelection *select ) { if (debug) { - Info<< "<beg> Foam::vtkPV3Foam::updateInformationFields" << endl; + Info<< "<beg> Foam::vtkPV3Foam::updateInfoFields" << endl; } - stringList selectedEntries; + stringList enabledEntries; // enable 'p' and 'U' on the first call - if (arraySelection->GetNumberOfArrays() == 0 && !meshPtr_) + if (select->GetNumberOfArrays() == 0 && !meshPtr_) { - selectedEntries.setSize(2); - selectedEntries[0] = "p"; - selectedEntries[1] = "U"; + enabledEntries.setSize(2); + enabledEntries[0] = "p"; + enabledEntries[1] = "U"; } else { - // preserve the currently selected values - selectedEntries = getSelectedArrayEntries - ( - arraySelection - ); + // preserve the enabled selections + enabledEntries = getSelectedArrayEntries(select); } - arraySelection->RemoveAllArrays(); + select->RemoveAllArrays(); // Search for list of objects for this time IOobjectList objects(dbPtr_(), dbPtr_().timeName()); - // Populate the GUI volume/point field arrays //- Add volume fields to GUI -/* - addToSelection<GeometricField<label, patchType, meshType> > - ( - arraySelection, - objects - ); -*/ addToSelection<GeometricField<scalar, patchType, meshType> > ( - arraySelection, + select, objects ); addToSelection<GeometricField<vector, patchType, meshType> > ( - arraySelection, + select, objects ); addToSelection<GeometricField<sphericalTensor, patchType, meshType> > ( - arraySelection, + select, objects ); addToSelection<GeometricField<symmTensor, patchType, meshType> > ( - arraySelection, + select, objects ); addToSelection<GeometricField<tensor, patchType, meshType> > ( - arraySelection, + select, objects ); - // restore the currently enabled values - setSelectedArrayEntries - ( - arraySelection, - selectedEntries - ); + // restore the enabled selections + setSelectedArrayEntries(select, enabledEntries); if (debug) { - Info<< "<end> Foam::vtkPV3Foam::updateInformationFields" << endl; + Info<< "<end> Foam::vtkPV3Foam::updateInfoFields" << endl; } } - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif - // ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUtilities.C b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUtilities.C new file mode 100644 index 0000000000000000000000000000000000000000..e09d83e5e2c7cb87293917d267b8255ffef70159 --- /dev/null +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUtilities.C @@ -0,0 +1,341 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 + Misc helper methods and utilities + +\*---------------------------------------------------------------------------*/ + +#include "vtkPV3Foam.H" +#include "vtkPV3FoamReader.h" + +// Foam includes +#include "fvMesh.H" +#include "Time.H" +#include "IFstream.H" + +// VTK includes +#include "vtkDataArraySelection.h" +#include "vtkDataSet.h" +#include "vtkMultiBlockDataSet.h" +#include "vtkInformation.h" + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::vtkPV3Foam::AddToBlock +( + vtkMultiBlockDataSet* output, + vtkDataSet* dataset, + const partInfo& selector, + const label datasetNo, + const string& datasetName +) +{ + const int blockNo = selector.block(); + + vtkDataObject* blockDO = output->GetBlock(blockNo); + vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO); + + if (!block) + { + if (blockDO) + { + FatalErrorIn("Foam::vtkPV3Foam::AddToBlock") + << "Block already has a vtkDataSet assigned to it" + << endl; + return; + } + + block = vtkMultiBlockDataSet::New(); + output->SetBlock(blockNo, block); + block->Delete(); + } + + if (debug) + { + Info<< "block[" << blockNo << "] has " + << block->GetNumberOfBlocks() + << " datasets prior to adding set " << datasetNo + << " with name: " << datasetName << endl; + } + + block->SetBlock(datasetNo, dataset); + + // name the block when assigning dataset 0 + if (datasetNo == 0) + { + output->GetMetaData(blockNo)->Set + ( + vtkCompositeDataSet::NAME(), + selector.name() + ); + } + + if (datasetName.size()) + { + block->GetMetaData(datasetNo)->Set + ( + vtkCompositeDataSet::NAME(), + datasetName.c_str() + ); + } +} + + +vtkDataSet* Foam::vtkPV3Foam::GetDataSetFromBlock +( + vtkMultiBlockDataSet* output, + const partInfo& 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; +} + + +// ununsed at the moment +Foam::label Foam::vtkPV3Foam::GetNumberOfDataSets +( + vtkMultiBlockDataSet* output, + const partInfo& selector +) +{ + const int blockNo = selector.block(); + + vtkDataObject* blockDO = output->GetBlock(blockNo); + vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO); + if (block) + { + return block->GetNumberOfBlocks(); + } + + return 0; +} + + +Foam::word Foam::vtkPV3Foam::getPartName(int partId) +{ + return getFirstWord(reader_->GetPartArrayName(partId)); +} + + +Foam::wordHashSet Foam::vtkPV3Foam::getSelected +( + vtkDataArraySelection* select +) +{ + int nElem = select->GetNumberOfArrays(); + wordHashSet selections(2*nElem); + + for (int elemI=0; elemI < nElem; ++elemI) + { + if (select->GetArraySetting(elemI)) + { + selections.insert(getFirstWord(select->GetArrayName(elemI))); + } + } + + return selections; +} + + +Foam::wordHashSet Foam::vtkPV3Foam::getSelected +( + vtkDataArraySelection* select, + const partInfo& selector +) +{ + int nElem = select->GetNumberOfArrays(); + wordHashSet selections(2*nElem); + + for (int elemI = selector.start(); elemI < selector.end(); ++elemI) + { + if (select->GetArraySetting(elemI)) + { + selections.insert(getFirstWord(select->GetArrayName(elemI))); + } + } + + return selections; +} + + +Foam::stringList Foam::vtkPV3Foam::getSelectedArrayEntries +( + vtkDataArraySelection* select +) +{ + stringList selections(select->GetNumberOfArrays()); + label nElem = 0; + + forAll(selections, elemI) + { + if (select->GetArraySetting(elemI)) + { + selections[nElem++] = select->GetArrayName(elemI); + } + } + selections.setSize(nElem); + + + if (debug) + { + label nElem = select->GetNumberOfArrays(); + Info<< "available("; + for (int elemI = 0; elemI < nElem; ++elemI) + { + Info<< " \"" << select->GetArrayName(elemI) << "\""; + } + Info<< " )\nselected("; + + forAll(selections, elemI) + { + Info<< " " << selections[elemI]; + } + Info<< " )\n"; + } + + return selections; +} + + +Foam::stringList Foam::vtkPV3Foam::getSelectedArrayEntries +( + vtkDataArraySelection* select, + const partInfo& selector +) +{ + stringList selections(selector.size()); + label nElem = 0; + + for (int elemI = selector.start(); elemI < selector.end(); ++elemI) + { + if (select->GetArraySetting(elemI)) + { + selections[nElem++] = select->GetArrayName(elemI); + } + } + selections.setSize(nElem); + + + if (debug) + { + Info<< "available("; + for (int elemI = selector.start(); elemI < selector.end(); ++elemI) + { + Info<< " \"" << select->GetArrayName(elemI) << "\""; + } + Info<< " )\nselected("; + + forAll(selections, elemI) + { + Info<< " " << selections[elemI]; + } + Info<< " )\n"; + } + + return selections; +} + + +void Foam::vtkPV3Foam::setSelectedArrayEntries +( + vtkDataArraySelection* select, + const stringList& selections +) +{ + const int nElem = select->GetNumberOfArrays(); + select->DisableAllArrays(); + + // Loop through entries, setting values from selectedEntries + for (int elemI=0; elemI < nElem; ++elemI) + { + string arrayName(select->GetArrayName(elemI)); + + forAll(selections, elemI) + { + if (selections[elemI] == arrayName) + { + select->EnableArray(arrayName.c_str()); + break; + } + } + } +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +// 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/vtkPV3FoamVolFields.H b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamVolFields.H new file mode 100644 index 0000000000000000000000000000000000000000..a15b314706a24e48ffbbf73d7bd77a8492a7328c --- /dev/null +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamVolFields.H @@ -0,0 +1,354 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 vtkPV3FoamVolFields_H +#define vtkPV3FoamVolFields_H + +// Foam includes +#include "emptyFvPatchField.H" +#include "wallPolyPatch.H" +#include "faceSet.H" +#include "vtkPV3FoamFaceField.H" +#include "vtkPV3FoamPatchField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template<class Type> +void Foam::vtkPV3Foam::convertVolFields +( + const fvMesh& mesh, + const volPointInterpolation& pInterp, + const PtrList<PrimitivePatchInterpolation<primitivePatch> >& ppInterpList, + const IOobjectList& objects, + vtkMultiBlockDataSet* output +) +{ + const polyBoundaryMesh& patches = mesh.boundaryMesh(); + + forAllConstIter(IOobjectList, objects, iter) + { + // restrict to GeometricField<Type, ...> + if + ( + iter()->headerClassName() + != GeometricField<Type, fvPatchField, volMesh>::typeName + ) + { + continue; + } + + GeometricField<Type, fvPatchField, volMesh> tf + ( + *iter(), + mesh + ); + + tmp<GeometricField<Type, pointPatchField, pointMesh> > tptf + ( + pInterp.interpolate(tf) + ); + + + // Convert activated internalMesh regions + convertVolFieldBlock + ( + tf, + tptf(), + output, + partInfoVolume_, + regionPolyDecomp_ + ); + + // Convert activated cellZones + convertVolFieldBlock + ( + tf, + tptf(), + output, + partInfoCellZones_, + zonePolyDecomp_ + ); + + // Convert activated cellSets + convertVolFieldBlock + ( + tf, + tptf(), + output, + partInfoCellSets_, + csetPolyDecomp_ + ); + + + // + // Convert patches - if activated + // + for + ( + int partId = partInfoPatches_.start(); + partId < partInfoPatches_.end(); + ++partId + ) + { + const word patchName = getPartName(partId); + const label datasetNo = partDataset_[partId]; + const label patchId = patches.findPatchID(patchName); + + if (!partStatus_[partId] || datasetNo < 0 || patchId < 0) + { + continue; + } + + const fvPatchField<Type>& ptf = tf.boundaryField()[patchId]; + + if + ( + isType<emptyFvPatchField<Type> >(ptf) + || + ( + typeid(patches[patchId]) == typeid(wallPolyPatch) + && reader_->GetExtrapolateWalls() + ) + ) + { + fvPatch p(ptf.patch().patch(), tf.mesh().boundary()); + + tmp<Field<Type> > tpptf + ( + fvPatchField<Type>(p, tf).patchInternalField() + ); + + convertPatchField + ( + tf.name(), + tpptf(), + output, + partInfoPatches_, + datasetNo + ); + + convertPatchPointField + ( + tf.name(), + ppInterpList[patchId].faceToPointInterpolate(tpptf)(), + output, + partInfoPatches_, + datasetNo + ); + } + else + { + convertPatchField + ( + tf.name(), + ptf, + output, + partInfoPatches_, + datasetNo + ); + + convertPatchPointField + ( + tf.name(), + ppInterpList[patchId].faceToPointInterpolate(ptf)(), + output, + partInfoPatches_, + datasetNo + ); + } + } + + // + // Convert face zones - if activated + // + for + ( + int partId = partInfoFaceZones_.start(); + partId < partInfoFaceZones_.end(); + ++partId + ) + { + const word zoneName = getPartName(partId); + const label datasetNo = partDataset_[partId]; + + if (!partStatus_[partId] || datasetNo < 0) + { + continue; + } + + const faceZoneMesh& zMesh = mesh.faceZones(); + const label zoneId = zMesh.findZoneID(zoneName); + + if (zoneId < 0) + { + continue; + } + + convertFaceField + ( + tf, + output, + partInfoFaceZones_, + datasetNo, + mesh, + zMesh[zoneId] + ); + + // TODO: points + } + + // + // Convert face sets - if activated + // + for + ( + int partId = partInfoFaceSets_.start(); + partId < partInfoFaceSets_.end(); + ++partId + ) + { + const word selectName = getPartName(partId); + const label datasetNo = partDataset_[partId]; + + if (!partStatus_[partId] || datasetNo < 0) + { + continue; + } + + const faceSet fSet(mesh, selectName); + + convertFaceField + ( + tf, + output, + partInfoFaceSets_, + datasetNo, + mesh, + fSet + ); + + // TODO: points + } + } +} + +template<class Type> +void Foam::vtkPV3Foam::convertVolFieldBlock +( + const GeometricField<Type, fvPatchField, volMesh>& tf, + const GeometricField<Type, pointPatchField, pointMesh>& ptf, + vtkMultiBlockDataSet* output, + const partInfo& selector, + const List<polyDecomp>& decompLst +) +{ + for (int partId = selector.start(); partId < selector.end(); ++partId) + { + const label datasetNo = partDataset_[partId]; + + if (datasetNo >= 0 && partStatus_[partId]) + { + convertVolField + ( + tf, + output, + selector, + datasetNo, + decompLst[datasetNo] + ); + + convertPointField + ( + ptf, + tf, + output, + selector, + datasetNo, + decompLst[datasetNo] + ); + } + } +} + + + +template<class Type> +void Foam::vtkPV3Foam::convertVolField +( + const GeometricField<Type, fvPatchField, volMesh>& tf, + vtkMultiBlockDataSet* output, + const partInfo& selector, + const label datasetNo, + const polyDecomp& decompInfo +) +{ + const label nComp = pTraits<Type>::nComponents; + const labelList& superCells = decompInfo.superCells(); + + 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<< "convert volField: " + << tf.name() + << " size = " << tf.size() + << " nComp=" << nComp + << " nTuples = " << superCells.size() << endl; + } + + float vec[nComp]; + forAll(superCells, i) + { + const Type& t = tf[superCells[i]]; + for (direction d=0; d<nComp; d++) + { + vec[d] = component(t, d); + } + celldata->InsertTuple(i, vec); + } + + vtkUnstructuredGrid::SafeDownCast + ( + GetDataSetFromBlock(output, selector, datasetNo) + ) ->GetCellData() + ->AddArray(celldata); + + celldata->Delete(); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/autoMesh/autoHexMesh/meshRefinement/meshRefinement.H b/src/autoMesh/autoHexMesh/meshRefinement/meshRefinement.H index d27eaae413946987954c4a168144fe67b1d64849..012ef08d00691d25ab9b73d29b07306fe6e226f0 100644 --- a/src/autoMesh/autoHexMesh/meshRefinement/meshRefinement.H +++ b/src/autoMesh/autoHexMesh/meshRefinement/meshRefinement.H @@ -570,7 +570,9 @@ public: // region and split them. autoPtr<mapPolyMesh> dupNonManifoldPoints(); - //- Create baffle for every internal face where ownPatch != -1 + //- Create baffle for every internal face where ownPatch != -1. + // External faces get repatched according to ownPatch (neiPatch + // should be -1 for these) autoPtr<mapPolyMesh> createBaffles ( const labelList& ownPatch, diff --git a/src/meshTools/searchableSurface/searchableSphere.C b/src/meshTools/searchableSurface/searchableSphere.C index 039be46749d05d74d07824334faf587672464df9..47abfbfff51d6f03546f30d0c2b6d748a9101abb 100644 --- a/src/meshTools/searchableSurface/searchableSphere.C +++ b/src/meshTools/searchableSurface/searchableSphere.C @@ -233,10 +233,9 @@ void Foam::searchableSphere::findLineAll { info.setSize(start.size()); - pointIndexHit near, far; - forAll(start, i) { + pointIndexHit near, far; findLineAll(start[i], end[i], near, far); if (near.hit()) @@ -260,6 +259,10 @@ void Foam::searchableSphere::findLineAll info[i].setSize(1); info[i][0] = far; } + else + { + info[i].clear(); + } } } }