PV3FoamReader - remove old time-selection arrays

This commit is contained in:
Mark Olesen
2008-07-24 15:58:59 +02:00
parent fc6780cd23
commit af5674aca5
8 changed files with 100 additions and 346 deletions

View File

@ -1,7 +1,5 @@
#!/bin/sh
set -x
rm -r PV3FoamReader/Make
rm -rf PV3FoamReader/Make
wclean libso vtkPV3Foam

View File

@ -31,26 +31,6 @@
<TimeRangeInformationHelper/>
</DoubleVectorProperty>
<!-- Update GUI check box -->
<IntVectorProperty
name="UpdateGUI"
command="SetUpdateGUI"
number_of_elements="1"
default_values="0">
<BooleanDomain
name="bool"/>
</IntVectorProperty>
<!-- Cache mesh check box -->
<IntVectorProperty
name="CacheMesh"
command="SetCacheMesh"
number_of_elements="1"
default_values="1">
<BooleanDomain
name="bool"/>
</IntVectorProperty>
<!-- ExtrapolateWalls check box -->
<IntVectorProperty
name="ExtrapolateWalls"
@ -186,34 +166,25 @@
</ArraySelectionDomain>
</StringVectorProperty>
<!-- Available times array -->
<!-- PV3FOAM_TIMESELECTION must be defined when compiling vtkPV3Foam
might discard this in the future
<StringVectorProperty
name="TimeArrayInfo"
information_only="1">
<ArraySelectionInformationHelper
attribute_name="Time"/>
</StringVectorProperty>
<StringVectorProperty
name="TimeStatus"
command="SetTimeArrayStatus"
number_of_elements="0"
repeat_command="1"
number_of_elements_per_command="2"
element_types="2 0"
information_property="TimeArrayInfo">
<ArraySelectionDomain
name="array_list">
<RequiredProperties>
<Property name="TimeArrayInfo"
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>
PV3FOAM_TIMESELECTION
-->
<!-- Update GUI check box -->
<IntVectorProperty
name="UpdateGUI"
command="SetUpdateGUI"
number_of_elements="1"
default_values="0">
<BooleanDomain
name="bool"/>
</IntVectorProperty>
</SourceProxy>
</ProxyGroup>

View File

@ -21,32 +21,19 @@
// VTK includes
#include "vtkCallbackCommand.h"
#include "vtkCellArray.h"
#include "vtkCellData.h"
#include "vtkDataArraySelection.h"
#include "vtkDirectory.h"
#include "vtkDoubleArray.h"
#include "vtkErrorCode.h"
#include "vtkFloatArray.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkIntArray.h"
#include "vtkMultiBlockDataSet.h"
#include "vtkObjectFactory.h"
#include "vtkPoints.h"
#include "vtkRenderer.h"
#include "vtkSMRenderViewProxy.h"
#include "vtkStreamingDemandDrivenPipeline.h"
#include "vtkStringArray.h"
#include "vtkUnstructuredGrid.h"
#include "vtkUnstructuredGridAlgorithm.h"
#include "vtkAlgorithmOutput.h"
#include "vtkMultiBlockDataSet.h"
// Foam includes
#include "vtkPV3Foam.H"
vtkCxxRevisionMacro(vtkPV3FoamReader, "$Revision: 1.2$");
vtkCxxRevisionMacro(vtkPV3FoamReader, "$Revision: 1.5$");
vtkStandardNewMacro(vtkPV3FoamReader);
@ -60,17 +47,21 @@ vtkPV3FoamReader::vtkPV3FoamReader()
FileName = NULL;
foamData_ = NULL;
CacheMesh = 0;
UpdateGUI = 1;
UpdateGUIOld = 1;
TimeStep = 0;
TimeStepRange[0] = 0;
TimeStepRange[1] = 0;
CacheMesh = 0;
ExtrapolateWalls = 0;
IncludeSets = 0;
IncludeZones = 0;
ShowPatchNames = 0;
TimeSelection = vtkDataArraySelection::New();
UpdateGUI = 1;
UpdateGUIOld = 1;
RegionSelection = vtkDataArraySelection::New();
VolFieldSelection = vtkDataArraySelection::New();
PointFieldSelection = vtkDataArraySelection::New();
@ -85,11 +76,6 @@ vtkPV3FoamReader::vtkPV3FoamReader()
);
SelectionObserver->SetClientData(this);
TimeSelection->AddObserver
(
vtkCommand::ModifiedEvent,
this->SelectionObserver
);
RegionSelection->AddObserver
(
vtkCommand::ModifiedEvent,
@ -112,6 +98,7 @@ vtkPV3FoamReader::vtkPV3FoamReader()
);
}
vtkPV3FoamReader::~vtkPV3FoamReader()
{
vtkDebugMacro(<<"Deconstructor");
@ -126,7 +113,6 @@ vtkPV3FoamReader::~vtkPV3FoamReader()
delete [] FileName;
}
TimeSelection->RemoveObserver(this->SelectionObserver);
RegionSelection->RemoveObserver(this->SelectionObserver);
VolFieldSelection->RemoveObserver(this->SelectionObserver);
PointFieldSelection->RemoveObserver(this->SelectionObserver);
@ -134,7 +120,6 @@ vtkPV3FoamReader::~vtkPV3FoamReader()
SelectionObserver->Delete();
TimeSelection->Delete();
RegionSelection->Delete();
VolFieldSelection->Delete();
PointFieldSelection->Delete();
@ -152,7 +137,6 @@ int vtkPV3FoamReader::RequestInformation
{
vtkDebugMacro(<<"RequestInformation");
if (Foam::vtkPV3Foam::debug)
{
cout<<"REQUEST_INFORMATION\n";
@ -180,7 +164,7 @@ int vtkPV3FoamReader::RequestInformation
}
else
{
cout << "no output\n";
cout<< "no output\n";
}
this->GetExecutive()->GetOutputInformation(0)->Print(cout);
@ -189,7 +173,7 @@ int vtkPV3FoamReader::RequestInformation
cout<< "requestInfo with " << nInfo << " items:\n";
for (int i=0; i<nInfo; i++)
for (int i = 0; i < nInfo; ++i)
{
vtkInformation *info = outputVector->GetInformationObject(i);
info->Print(cout);
@ -230,7 +214,7 @@ int vtkPV3FoamReader::RequestInformation
timeRange[0] = timeSteps[0];
timeRange[1] = timeSteps[nTimeSteps-1];
if (Foam::vtkPV3Foam::debug)
if (Foam::vtkPV3Foam::debug > 1)
{
cout<<"nTimeSteps " << nTimeSteps << "\n";
cout<<"timeRange " << timeRange[0] << " to " << timeRange[1] << "\n";
@ -271,20 +255,15 @@ int vtkPV3FoamReader::RequestData
return 0;
}
if (Foam::vtkPV3Foam::debug)
{
int nInfo = outputVector->GetNumberOfInformationObjects();
if (Foam::vtkPV3Foam::debug)
{
cout<<"requestData with " << nInfo << " items\n";
}
for (int i=0; i<nInfo; i++)
cout<<"requestData with " << nInfo << " items\n";
for (int i = 0; i < nInfo; ++i)
{
vtkInformation *info = outputVector->GetInformationObject(i);
if (Foam::vtkPV3Foam::debug)
{
info->Print(cout);
}
info->Print(cout);
}
}
@ -330,7 +309,7 @@ int vtkPV3FoamReader::RequestData
}
else
{
cout << "no data_object\n";
cout<< "no data_object\n";
}
}
@ -447,67 +426,12 @@ void vtkPV3FoamReader::PrintSelf
}
vtkDataArraySelection* vtkPV3FoamReader::GetTimeSelection()
{
vtkDebugMacro(<<"GetTimeSelection");
return TimeSelection;
}
int vtkPV3FoamReader::GetNumberOfTimeArrays()
{
vtkDebugMacro(<<"GetNumberOf TimeArrays");
return TimeSelection->GetNumberOfArrays();
}
const char* vtkPV3FoamReader::GetTimeArrayName
(
int index
)
{
vtkDebugMacro(<<"GetTimeArrayName");
return TimeSelection->GetArrayName(index);
}
int vtkPV3FoamReader::GetTimeArrayStatus
(
const char* name
)
{
vtkDebugMacro(<<"GetTimeArrayStatus");
return TimeSelection->ArrayIsEnabled(name);
}
void vtkPV3FoamReader::SetTimeArrayStatus
(
const char* name,
int status
)
{
vtkDebugMacro(<<"SetTimeArrayStatus");
if (status)
{
TimeSelection->EnableArray(name);
}
else
{
TimeSelection->DisableArray(name);
}
}
// ----------------------------------------------------------------------
// Region selection list control
vtkDataArraySelection* vtkPV3FoamReader::GetRegionSelection()
{
vtkDebugMacro(<<"GetRegionSelection");
return RegionSelection;
}
@ -515,42 +439,29 @@ vtkDataArraySelection* vtkPV3FoamReader::GetRegionSelection()
int vtkPV3FoamReader::GetNumberOfRegionArrays()
{
vtkDebugMacro(<<"GetNumberOfRegionArrays");
return RegionSelection->GetNumberOfArrays();
}
const char* vtkPV3FoamReader::GetRegionArrayName
(
int index
)
const char* vtkPV3FoamReader::GetRegionArrayName(int index)
{
vtkDebugMacro(<<"GetRegionArrayName");
return RegionSelection->GetArrayName(index);
}
int vtkPV3FoamReader::GetRegionArrayStatus
(
const char* name
)
int vtkPV3FoamReader::GetRegionArrayStatus(const char* name)
{
vtkDebugMacro(<<"GetRegionArrayStatus");
return RegionSelection->ArrayIsEnabled(name);
}
void vtkPV3FoamReader::SetRegionArrayStatus
(
const char* name,
int status
)
void vtkPV3FoamReader::SetRegionArrayStatus(const char* name, int status)
{
vtkDebugMacro(<<"SetRegionArrayStatus");
if(status)
if (status)
{
RegionSelection->EnableArray(name);
}
@ -561,6 +472,9 @@ void vtkPV3FoamReader::SetRegionArrayStatus
}
// ----------------------------------------------------------------------
// volField selection list control
vtkDataArraySelection* vtkPV3FoamReader::GetVolFieldSelection()
{
vtkDebugMacro(<<"GetVolFieldSelection");
@ -577,10 +491,7 @@ int vtkPV3FoamReader::GetNumberOfVolFieldArrays()
}
const char* vtkPV3FoamReader::GetVolFieldArrayName
(
int index
)
const char* vtkPV3FoamReader::GetVolFieldArrayName(int index)
{
vtkDebugMacro(<<"GetVolFieldArrayName");
@ -588,10 +499,7 @@ const char* vtkPV3FoamReader::GetVolFieldArrayName
}
int vtkPV3FoamReader::GetVolFieldArrayStatus
(
const char* name
)
int vtkPV3FoamReader::GetVolFieldArrayStatus(const char* name)
{
vtkDebugMacro(<<"GetVolFieldArrayStatus");
@ -599,11 +507,7 @@ int vtkPV3FoamReader::GetVolFieldArrayStatus
}
void vtkPV3FoamReader::SetVolFieldArrayStatus
(
const char* name,
int status
)
void vtkPV3FoamReader::SetVolFieldArrayStatus(const char* name, int status)
{
vtkDebugMacro(<<"SetVolFieldArrayStatus");
@ -618,6 +522,9 @@ void vtkPV3FoamReader::SetVolFieldArrayStatus
}
// ----------------------------------------------------------------------
// pointField selection list control
vtkDataArraySelection* vtkPV3FoamReader::GetPointFieldSelection()
{
vtkDebugMacro(<<"GetPointFieldSelection");
@ -634,10 +541,7 @@ int vtkPV3FoamReader::GetNumberOfPointFieldArrays()
}
const char* vtkPV3FoamReader::GetPointFieldArrayName
(
int index
)
const char* vtkPV3FoamReader::GetPointFieldArrayName(int index)
{
vtkDebugMacro(<<"GetPointFieldArrayName");
@ -645,10 +549,7 @@ const char* vtkPV3FoamReader::GetPointFieldArrayName
}
int vtkPV3FoamReader::GetPointFieldArrayStatus
(
const char* name
)
int vtkPV3FoamReader::GetPointFieldArrayStatus(const char* name)
{
vtkDebugMacro(<<"GetPointFieldArrayStatus");
@ -656,11 +557,7 @@ int vtkPV3FoamReader::GetPointFieldArrayStatus
}
void vtkPV3FoamReader::SetPointFieldArrayStatus
(
const char* name,
int status
)
void vtkPV3FoamReader::SetPointFieldArrayStatus(const char* name, int status)
{
vtkDebugMacro(<<"SetPointFieldArrayStatus");
@ -675,6 +572,9 @@ void vtkPV3FoamReader::SetPointFieldArrayStatus
}
// ----------------------------------------------------------------------
// lagrangianField selection list control
vtkDataArraySelection* vtkPV3FoamReader::GetLagrangianFieldSelection()
{
vtkDebugMacro(<<"GetLagrangianFieldSelection");
@ -691,10 +591,7 @@ int vtkPV3FoamReader::GetNumberOfLagrangianFieldArrays()
}
const char* vtkPV3FoamReader::GetLagrangianFieldArrayName
(
int index
)
const char* vtkPV3FoamReader::GetLagrangianFieldArrayName(int index)
{
vtkDebugMacro(<<"GetLagrangianFieldArrayName");
@ -702,10 +599,7 @@ const char* vtkPV3FoamReader::GetLagrangianFieldArrayName
}
int vtkPV3FoamReader::GetLagrangianFieldArrayStatus
(
const char* name
)
int vtkPV3FoamReader::GetLagrangianFieldArrayStatus(const char* name)
{
vtkDebugMacro(<<"GetLagrangianFieldArrayStatus");
@ -731,6 +625,7 @@ void vtkPV3FoamReader::SetLagrangianFieldArrayStatus
}
}
// ----------------------------------------------------------------------
void vtkPV3FoamReader::SelectionModifiedCallback
(
@ -751,3 +646,4 @@ void vtkPV3FoamReader::SelectionModified()
Modified();
}
// ************************************************************************* //

View File

@ -14,11 +14,9 @@
=========================================================================*/
// .NAME vtkPV3FoamReader - reads a dataset in OpenFOAM format
// .SECTION Description
// vtkPV3FoamReader creates an multiblock dataset. It reads a controlDict
// file, mesh information, and time dependent data. The controlDict file
// contains timestep information. The polyMesh folders contain mesh information
// The time folders contain transient data for the cells Each folder can
// contain any number of data files.
// vtkPV3FoamReader creates an multiblock dataset.
// It uses the OpenFOAM infrastructure (fvMesh, etc) to
// handle mesh and field data.
#ifndef __vtkPV3FoamReader_h
#define __vtkPV3FoamReader_h
@ -66,6 +64,13 @@ public:
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);
// GUI update control
vtkSetMacro(UpdateGUI, int);
vtkGetMacro(UpdateGUI, int);
@ -86,24 +91,10 @@ public:
vtkSetMacro(IncludeZones, int);
vtkGetMacro(IncludeZones, int);
// FOAM patch names control
// FOAM display patch names control
vtkSetMacro(ShowPatchNames, int);
vtkGetMacro(ShowPatchNames, int);
// Time-step slider control
vtkSetMacro(TimeStep, int);
vtkGetMacro(TimeStep, int);
vtkSetVector2Macro(TimeStepRange, int);
vtkGetVector2Macro(TimeStepRange, int);
// Time selection list control
vtkDataArraySelection* GetTimeSelection();
int GetNumberOfTimeArrays();
const char* GetTimeArrayName(int index);
int GetTimeArrayStatus(const char* name);
void SetTimeArrayStatus(const char* name, int status);
// Region selection list control
vtkDataArraySelection* GetRegionSelection();
int GetNumberOfRegionArrays();
@ -121,16 +112,16 @@ public:
// pointField selection list control
vtkDataArraySelection* GetPointFieldSelection();
int GetNumberOfPointFieldArrays();
const char* GetPointFieldArrayName(int index);
int GetPointFieldArrayStatus(const char* name);
void SetPointFieldArrayStatus(const char* name, int status);
const char* GetPointFieldArrayName(int index);
// lagrangianField selection list control
vtkDataArraySelection* GetLagrangianFieldSelection();
int GetNumberOfLagrangianFieldArrays();
const char* GetLagrangianFieldArrayName(int index);
int GetLagrangianFieldArrayStatus(const char* name);
void SetLagrangianFieldArrayStatus(const char* name, int status);
const char* GetLagrangianFieldArrayName(int index);
// Callback registered with the SelectionObserver
// for all the selection lists
@ -182,7 +173,11 @@ private:
//- Remove patch names from the view
void removePatchNamesFromView();
int TimeStep;
int TimeStepRange[2];
int CacheMesh;
int ExtrapolateWalls;
int IncludeSets;
int IncludeZones;
@ -190,10 +185,7 @@ private:
int UpdateGUI;
int UpdateGUIOld;
int TimeStep;
int TimeStepRange[2];
vtkDataArraySelection* TimeSelection;
vtkDataArraySelection* RegionSelection;
vtkDataArraySelection* VolFieldSelection;
vtkDataArraySelection* PointFieldSelection;
@ -204,4 +196,8 @@ private:
//ETX
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,5 +1,4 @@
EXE_INC = \
/* -DPV3FOAM_TIMESELECTION */ \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \

View File

@ -172,38 +172,6 @@ void Foam::vtkPV3Foam::resetCounters()
}
void Foam::vtkPV3Foam::initializeTime()
{
#ifdef PV3FOAM_TIMESELECTION
Time& runTime = dbPtr_();
// Get times list
instantList times = runTime.times();
vtkDataArraySelection* arraySelection = reader_->GetTimeSelection();
// only execute this if there is a mismatch between
// the times available according to FOAM and according to VTK
int nArrays = arraySelection->GetNumberOfArrays();
if (nArrays && nArrays == times.size() - 1)
{
return;
}
// "constant" is implicit - skip it
// All the time selections are enabled by default
for (label timeI = 1; timeI < times.size(); ++timeI)
{
arraySelection->AddArray
(
times[timeI].name().c_str()
);
}
#endif /* PV3FOAM_TIMESELECTION */
}
bool Foam::vtkPV3Foam::setTime(const double& requestedTime)
{
if (debug)
@ -301,7 +269,7 @@ Foam::stringList Foam::vtkPV3Foam::getSelectedArrayEntries
if (debug)
{
Info << "selections(";
Info<< "selections(";
}
forAll (selections, elemI)
@ -322,7 +290,7 @@ Foam::stringList Foam::vtkPV3Foam::getSelectedArrayEntries
if (debug)
{
Info << " " << selections[nElem];
Info<< " " << selections[nElem];
}
++nElem;
@ -331,7 +299,7 @@ Foam::stringList Foam::vtkPV3Foam::getSelectedArrayEntries
if (debug)
{
Info << " )" << endl;
Info<< " )" << endl;
}
selections.setSize(nElem);
@ -351,7 +319,7 @@ Foam::stringList Foam::vtkPV3Foam::getSelectedArrayEntries
if (debug)
{
Info << "selections(";
Info<< "selections(";
}
for
@ -377,7 +345,7 @@ Foam::stringList Foam::vtkPV3Foam::getSelectedArrayEntries
if (debug)
{
Info << " " << selections[nElem];
Info<< " " << selections[nElem];
}
++nElem;
@ -386,7 +354,7 @@ Foam::stringList Foam::vtkPV3Foam::getSelectedArrayEntries
if (debug)
{
Info << " )" << endl;
Info<< " )" << endl;
}
@ -569,8 +537,6 @@ void Foam::vtkPV3Foam::UpdateInformation()
// Clear current region list/array
reader_->GetRegionSelection()->RemoveAllArrays();
initializeTime();
// Update region array
updateInformationInternalMesh();
@ -693,16 +659,13 @@ void Foam::vtkPV3Foam::Update
<< GetNumberOfDataSets(output, selectInfoPointSets_) << nl;
// traverse blocks:
int nBlocks = output->GetNumberOfBlocks();
Info << "nBlocks = " << nBlocks << endl;
cout<< "nBlocks = " << output->GetNumberOfBlocks() << "\n";
cout<< "done Update\n";
output_->Print(cout);
cout<< " has " << output_->GetNumberOfBlocks() << " blocks\n";
output_->GetInformation()->Print(cout);
cout <<"ShouldIReleaseData :" << output_->ShouldIReleaseData() << "\n";
cout<<"ShouldIReleaseData :" << output_->ShouldIReleaseData() << "\n";
}
}
@ -710,71 +673,13 @@ void Foam::vtkPV3Foam::Update
double* Foam::vtkPV3Foam::timeSteps(int& nTimeSteps)
{
int nTimes = 0;
double* ts = NULL;
double* tsteps = NULL;
if (dbPtr_.valid())
{
Time& runTime = dbPtr_();
instantList times = runTime.times();
#ifdef PV3FOAM_TIMESELECTION
List<bool> selected = List<bool>(times.size(), false);
vtkDataArraySelection* arraySelection = reader_->GetTimeSelection();
const label nSelectedTimes = arraySelection->GetNumberOfArrays();
for (int i = 0; i < nSelectedTimes; ++i)
{
// always skip "constant" time
const int timeI = i + 1;
if
(
arraySelection->GetArraySetting(i)
&& timeI < times.size()
)
{
if (debug > 1)
{
Info<<"timeSelection["
<< i
<<"] = "
<< arraySelection->GetArraySetting(i)
<< " is "
<< arraySelection->GetArrayName(i) << endl;
}
selected[timeI] = true;
++nTimes;
}
}
if (debug > 1)
{
Info<< "selected " << nTimes << " times ";
Info<< "found " << times.size() << " times: (";
forAll(times, timeI)
{
Info<< " " << times[timeI].value();
}
Info<< " )" << endl;
}
if (nTimes)
{
ts = new double[nTimes];
int stepI = 0;
forAll(selected, selectI)
{
if (selected[selectI])
{
ts[stepI] = times[selectI].value();
stepI++;
}
}
}
#else /* PV3FOAM_TIMESELECTION */
// always skip "constant" time, unless there are no other times
nTimes = times.size();
label timeI = 0;
@ -787,26 +692,25 @@ double* Foam::vtkPV3Foam::timeSteps(int& nTimeSteps)
if (nTimes)
{
ts = new double[nTimes];
tsteps = new double[nTimes];
for (label stepI = 0; stepI < nTimes; ++stepI, ++timeI)
{
ts[stepI] = times[timeI].value();
tsteps[stepI] = times[timeI].value();
}
}
#endif /* PV3FOAM_TIMESELECTION */
}
else
{
if (debug)
{
Info<< "no valid dbPtr:" <<endl;
cout<< "no valid dbPtr:\n";
}
}
// return vector length via the parameter
// vector length returned via the parameter
nTimeSteps = nTimes;
return ts;
return tsteps;
}

View File

@ -287,9 +287,6 @@ private:
//- Reset data counters
void resetCounters();
//- Get all the available times and select the latestTime
void initializeTime();
// Update information helper functions
//- Update the regions selected in the GUI

View File

@ -50,14 +50,7 @@ void Foam::vtkPV3Foam::updateFoamMesh()
Info<< "<beg> Foam::vtkPV3Foam::updateFoamMesh" << endl;
}
if
(
!reader_->GetCacheMesh()
#ifdef PV3FOAM_TIMESELECTION
// This is only useful if the times are individually selectable
|| reader_->GetTimeSelection()->GetArraySetting(0)
#endif
)
if (!reader_->GetCacheMesh())
{
delete meshPtr_;
meshPtr_ = NULL;