PV3FoamReader fix

- using a filter such as clip-plane on a multi-port source causes
  inconsistent UPDATE_TIME_STEPS() on each port. This looks like a
  VTK/Paraview bug to me.
  Workaround: check both ports and take the first one that has a value
  different than the last time set.
This commit is contained in:
Mark Olesen
2009-03-23 14:53:14 +01:00
parent b2eb605962
commit 549c78f9fe
4 changed files with 82 additions and 37 deletions

View File

@ -52,8 +52,7 @@ vtkPV3FoamReader::vtkPV3FoamReader()
// Add second output for the Lagrangian // Add second output for the Lagrangian
this->SetNumberOfOutputPorts(2); this->SetNumberOfOutputPorts(2);
vtkMultiBlockDataSet *lagrangian; vtkMultiBlockDataSet *lagrangian = vtkMultiBlockDataSet::New();
lagrangian = vtkMultiBlockDataSet::New();
lagrangian->ReleaseData(); lagrangian->ReleaseData();
this->GetExecutive()->SetOutputData(1, lagrangian); this->GetExecutive()->SetOutputData(1, lagrangian);
@ -204,9 +203,9 @@ int vtkPV3FoamReader::RequestInformation
); );
} }
double timeRange[2];
if (nTimeSteps) if (nTimeSteps)
{ {
double timeRange[2];
timeRange[0] = timeSteps[0]; timeRange[0] = timeSteps[0];
timeRange[1] = timeSteps[nTimeSteps-1]; timeRange[1] = timeSteps[nTimeSteps-1];
@ -273,19 +272,53 @@ int vtkPV3FoamReader::RequestData
} }
} }
// take port0 as the lead for other outputs // Get the requested time step.
vtkInformation *outInfo = outputVector->GetInformationObject(0); // We only support requests for a single time step
int nRequestTime = 0;
double requestTime[nInfo];
// taking port0 as the lead for other outputs would be nice, but fails when
// a filter is added - we need to check everything
// but since PREVIOUS_UPDATE_TIME_STEPS() is protected, relay the logic
// to the vtkPV3Foam::setTime() method
for (int infoI = 0; infoI < nInfo; ++infoI)
{
vtkInformation *outInfo = outputVector->GetInformationObject(infoI);
if
(
outInfo->Has
(
vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS()
)
&& outInfo->Length
(
vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS()
) >= 1
)
{
requestTime[nRequestTime++] = outInfo->Get
(
vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS()
)[0];
}
}
if (nRequestTime)
{
foamData_->setTime(nRequestTime, requestTime);
}
vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::SafeDownCast vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::SafeDownCast
( (
outInfo->Get outputVector->GetInformationObject(0)->Get
( (
vtkMultiBlockDataSet::DATA_OBJECT() vtkMultiBlockDataSet::DATA_OBJECT()
) )
); );
vtkMultiBlockDataSet* lagrangianOutput = vtkMultiBlockDataSet::SafeDownCast vtkMultiBlockDataSet* lagrangianOutput = vtkMultiBlockDataSet::SafeDownCast
( (
outputVector->GetInformationObject(1)->Get outputVector->GetInformationObject(1)->Get
@ -294,24 +327,6 @@ int vtkPV3FoamReader::RequestData
) )
); );
if (outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS()))
{
// Get the requested time step.
// We only support requests for a single time step
int nRequestedTimeSteps = outInfo->Length
(
vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS()
);
if (nRequestedTimeSteps >= 1)
{
double *requestedTimeSteps = outInfo->Get
(
vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS()
);
foamData_->setTime(requestedTimeSteps[0]);
}
}
if (Foam::vtkPV3Foam::debug) if (Foam::vtkPV3Foam::debug)
{ {

View File

@ -90,12 +90,21 @@ void Foam::vtkPV3Foam::reduceMemory()
int Foam::vtkPV3Foam::setTime(const double& requestedTime) int Foam::vtkPV3Foam::setTime(int nRequest, const double requestTimes[])
{ {
if (debug) if (debug)
{ {
Info<< "<beg> Foam::vtkPV3Foam::setTime(" << requestedTime << ")" Info<< "<beg> Foam::vtkPV3Foam::setTime(";
<< endl; for (int requestI = 0; requestI < nRequest; ++requestI)
{
if (requestI)
{
Info<< ", ";
}
Info<< requestTimes[requestI];
}
Info << ") - previousIndex = " << timeIndex_ << endl;
} }
Time& runTime = dbPtr_(); Time& runTime = dbPtr_();
@ -103,12 +112,26 @@ int Foam::vtkPV3Foam::setTime(const double& requestedTime)
// Get times list // Get times list
instantList Times = runTime.times(); instantList Times = runTime.times();
int nearestIndex = Time::findClosestTimeIndex(Times, requestedTime); int nearestIndex = timeIndex_;
for (int requestI = 0; requestI < nRequest; ++requestI)
{
int index = Time::findClosestTimeIndex(Times, requestTimes[requestI]);
if (index >= 0 && index != timeIndex_)
{
nearestIndex = index;
break;
}
}
if (nearestIndex < 0) if (nearestIndex < 0)
{ {
nearestIndex = 0; nearestIndex = 0;
} }
// see what has changed // see what has changed
if (timeIndex_ != nearestIndex) if (timeIndex_ != nearestIndex)
{ {
@ -138,10 +161,11 @@ int Foam::vtkPV3Foam::setTime(const double& requestedTime)
if (debug) if (debug)
{ {
Info<< "<end> Foam::vtkPV3Foam::setTime() - selected time " Info<< "<end> Foam::vtkPV3Foam::setTime() - selectedTime="
<< Times[nearestIndex].name() << " index=" << nearestIndex << Times[nearestIndex].name() << " index=" << timeIndex_
<< " meshChanged=" << meshChanged_ << "/" << Times.size()
<< " fieldsChanged=" << fieldsChanged_ << endl; << " meshChanged=" << Switch(meshChanged_)
<< " fieldsChanged=" << Switch(fieldsChanged_) << endl;
} }
return nearestIndex; return nearestIndex;

View File

@ -133,6 +133,7 @@ class vtkPV3Foam
return block_; return block_;
} }
//- Assign block number, return previous value
int block(int blockNo) int block(int blockNo)
{ {
int prev = block_; int prev = block_;
@ -718,9 +719,11 @@ public:
//- Remove patch names from the display //- Remove patch names from the display
void removePatchNames(vtkRenderer* renderer); void removePatchNames(vtkRenderer* renderer);
//- set the runTime to the requested time, returns the timeIndex //- set the runTime to the first plausible request time,
// sets to "constant" on error and returns -1 // returns the timeIndex
int setTime(const double& requestedTime); // sets to "constant" on error
int setTime(int count, const double requestTimes[]);
//- The current time index //- The current time index
int timeIndex() const int timeIndex() const

View File

@ -40,7 +40,10 @@ void Foam::vtkPV3Foam::updateInfoFields
{ {
if (debug) if (debug)
{ {
Info<< "<beg> Foam::vtkPV3Foam::updateInfoFields" << endl; Info<< "<beg> Foam::vtkPV3Foam::updateInfoFields <"
<< meshType::Mesh::typeName
<< "> [meshPtr=" << (meshPtr_ ? "set" : "NULL") << "]"
<< endl;
} }
stringList enabledEntries; stringList enabledEntries;