Commit 768a7629 authored by David Partyka's avatar David Partyka
Browse files

BUG: Fixes so both outputs contain time.

Conflicts:

	Parallel/vtkWindBladeReader.cxx
parent 5081b717
...@@ -105,10 +105,6 @@ vtkWindBladeReader::vtkWindBladeReader() ...@@ -105,10 +105,6 @@ vtkWindBladeReader::vtkWindBladeReader()
this->DivideVariables->InsertNextValue("B-scale turbulence"); this->DivideVariables->InsertNextValue("B-scale turbulence");
this->DivideVariables->InsertNextValue("Oxygen"); this->DivideVariables->InsertNextValue("Oxygen");
// Two output require Modified() to be set causing RequestData done twice
// Keep track of which time through on a time step to save reloading data
this->RequestDataLoop = 0;
// Set rank and total number of processors // Set rank and total number of processors
this->MPIController = vtkMultiProcessController::GetGlobalController(); this->MPIController = vtkMultiProcessController::GetGlobalController();
...@@ -198,6 +194,7 @@ int vtkWindBladeReader::RequestInformation( ...@@ -198,6 +194,7 @@ int vtkWindBladeReader::RequestInformation(
vtkInformation* fieldInfo = outputVector->GetInformationObject(0); vtkInformation* fieldInfo = outputVector->GetInformationObject(0);
vtkStructuredGrid *field = vtkStructuredGrid::SafeDownCast( vtkStructuredGrid *field = vtkStructuredGrid::SafeDownCast(
fieldInfo->Get(vtkDataObject::DATA_OBJECT())); fieldInfo->Get(vtkDataObject::DATA_OBJECT()));
vtkInformation* bladeInfo = outputVector->GetInformationObject(1);
vtkUnstructuredGrid* blade = GetBladeOutput(); vtkUnstructuredGrid* blade = GetBladeOutput();
// Read global size and variable information from input file one time // Read global size and variable information from input file one time
...@@ -233,7 +230,7 @@ int vtkWindBladeReader::RequestInformation( ...@@ -233,7 +230,7 @@ int vtkWindBladeReader::RequestInformation(
// Create the rectilinear coordinate spacing for entire problem // Create the rectilinear coordinate spacing for entire problem
CreateCoordinates(); CreateCoordinates();
// Collect temporal information // Collect temporal information and attach to both output ports
this->TimeSteps = NULL; this->TimeSteps = NULL;
if (this->NumberOfTimeSteps > 0) { if (this->NumberOfTimeSteps > 0) {
...@@ -247,49 +244,41 @@ int vtkWindBladeReader::RequestInformation( ...@@ -247,49 +244,41 @@ int vtkWindBladeReader::RequestInformation(
// Tell the pipeline what steps are available // Tell the pipeline what steps are available
fieldInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(), fieldInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(),
this->TimeSteps, this->NumberOfTimeSteps); this->TimeSteps, this->NumberOfTimeSteps);
bladeInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(),
this->TimeSteps, this->NumberOfTimeSteps);
// Range is required to get GUI to show things // Range is required to get GUI to show things
double tRange[2]; double tRange[2];
tRange[0] = this->TimeSteps[0]; tRange[0] = this->TimeSteps[0];
tRange[1] = this->TimeSteps[this->NumberOfTimeSteps - 1]; tRange[1] = this->TimeSteps[this->NumberOfTimeSteps - 1];
fieldInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_RANGE(), tRange, 2); fieldInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_RANGE(), tRange, 2);
bladeInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_RANGE(), tRange, 2);
} else { } else {
fieldInfo->Remove(vtkStreamingDemandDrivenPipeline::TIME_STEPS()); fieldInfo->Remove(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
fieldInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(), fieldInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(),
this->TimeSteps, this->NumberOfTimeSteps); this->TimeSteps, this->NumberOfTimeSteps);
bladeInfo->Remove(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
bladeInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(),
this->TimeSteps, this->NumberOfTimeSteps);
} }
} }
return 1; return 1;
} }
//----------------------------------------------------------------------------
// RequestUpdateExtent asks the partitioning for this processor
// ParaView is doing the partitioning for this reader
//----------------------------------------------------------------------------
int vtkWindBladeReader::RequestUpdateExtent(
vtkInformation* vtkNotUsed(request),
vtkInformationVector** vtkNotUsed(inputVector),
vtkInformationVector* outputVector)
{
// If Modified is not set, blades do not turn
this->Modified();
return 1;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// RequestData populates the output object with data for rendering // RequestData populates the output object with data for rendering
// Using two output ports (one for fields and one for turbine blades) // Uses two output ports (one for fields and one for turbine blades).
// is not working as expected. Modified() must be set on the reader in
// order for the blade geometry to be updated. This means every RequestData
// for a time step will be called twice. To keep from reading field data
// twice, we use RequestDataLoop, so that the second time will set the
// data but not actually read in again.
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
int vtkWindBladeReader::RequestData( int vtkWindBladeReader::RequestData(
vtkInformation *vtkNotUsed(reqInfo), vtkInformation *vtkNotUsed(reqInfo),
vtkInformationVector **vtkNotUsed(inVector), vtkInformationVector **vtkNotUsed(inVector),
vtkInformationVector *outVector) vtkInformationVector *outVector)
{ {
int port = reqInfo->Get(vtkDemandDrivenPipeline::FROM_OUTPUT_PORT());
// Request data for field port
if (port == 0) {
// Get the information and output pointers // Get the information and output pointers
vtkInformation* fieldInfo = outVector->GetInformationObject(0); vtkInformation* fieldInfo = outVector->GetInformationObject(0);
vtkStructuredGrid *field = GetFieldOutput(); vtkStructuredGrid *field = GetFieldOutput();
...@@ -335,7 +324,6 @@ int vtkWindBladeReader::RequestData( ...@@ -335,7 +324,6 @@ int vtkWindBladeReader::RequestData(
timeStep++; timeStep++;
// Open the data file for time step if needed // Open the data file for time step if needed
if (this->RequestDataLoop == 0) {
ostringstream fileName; ostringstream fileName;
fileName << this->RootDirectory << Slash fileName << this->RootDirectory << Slash
<< this->DataDirectory << Slash << this->DataBaseName << this->DataDirectory << Slash << this->DataBaseName
...@@ -345,7 +333,6 @@ int vtkWindBladeReader::RequestData( ...@@ -345,7 +333,6 @@ int vtkWindBladeReader::RequestData(
cout << "Could not open file " << fileName.str() << endl; cout << "Could not open file " << fileName.str() << endl;
if (this->Rank == 0) if (this->Rank == 0)
cout << "Load file " << fileName.str() << endl; cout << "Load file " << fileName.str() << endl;
}
// Some variables depend on others, so force their loading // Some variables depend on others, so force their loading
for (int i = 0; i < this->DivideVariables->GetNumberOfTuples(); i++) for (int i = 0; i < this->DivideVariables->GetNumberOfTuples(); i++)
...@@ -355,10 +342,7 @@ int vtkWindBladeReader::RequestData( ...@@ -355,10 +342,7 @@ int vtkWindBladeReader::RequestData(
// Examine each file variable to see if it is selected and load // Examine each file variable to see if it is selected and load
for (int var = 0; var < this->NumberOfFileVariables; var++) { for (int var = 0; var < this->NumberOfFileVariables; var++) {
if (this->PointDataArraySelection->GetArraySetting(var)) { if (this->PointDataArraySelection->GetArraySetting(var)) {
if (this->RequestDataLoop == 0)
LoadVariableData(var); LoadVariableData(var);
field->GetPointData()->AddArray(this->data[var]); field->GetPointData()->AddArray(this->data[var]);
} }
} }
...@@ -366,19 +350,16 @@ int vtkWindBladeReader::RequestData( ...@@ -366,19 +350,16 @@ int vtkWindBladeReader::RequestData(
// Divide variables by Density if required // Divide variables by Density if required
for (int i = 0; i < this->DivideVariables->GetNumberOfTuples(); i++) for (int i = 0; i < this->DivideVariables->GetNumberOfTuples(); i++)
if (GetPointArrayStatus(this->DivideVariables->GetValue(i))) if (GetPointArrayStatus(this->DivideVariables->GetValue(i)))
if (this->RequestDataLoop == 0)
DivideByDensity(this->DivideVariables->GetValue(i)); DivideByDensity(this->DivideVariables->GetValue(i));
// Calculate pressure if requested // Calculate pressure if requested
if (GetPointArrayStatus("Pressure")) { if (GetPointArrayStatus("Pressure")) {
int pressure = this->PointDataArraySelection->GetArrayIndex("Pressure"); int pressure = this->PointDataArraySelection->GetArrayIndex("Pressure");
int prespre = this->PointDataArraySelection->GetArrayIndex("Pressure-Pre"); int pre = this->PointDataArraySelection->GetArrayIndex("Pressure-Pre");
int tempg = this->PointDataArraySelection->GetArrayIndex("tempg"); int tempg = this->PointDataArraySelection->GetArrayIndex("tempg");
int density = this->PointDataArraySelection->GetArrayIndex("Density"); int density = this->PointDataArraySelection->GetArrayIndex("Density");
if (this->RequestDataLoop == 0) CalculatePressure(pressure, pre, tempg, density);
CalculatePressure(pressure, prespre, tempg, density);
field->GetPointData()->AddArray(this->data[pressure]); field->GetPointData()->AddArray(this->data[pressure]);
field->GetPointData()->AddArray(this->data[pressure + 1]); field->GetPointData()->AddArray(this->data[pressure + 1]);
} }
...@@ -389,22 +370,44 @@ int vtkWindBladeReader::RequestData( ...@@ -389,22 +370,44 @@ int vtkWindBladeReader::RequestData(
int uvw = this->PointDataArraySelection->GetArrayIndex("UVW"); int uvw = this->PointDataArraySelection->GetArrayIndex("UVW");
int density = this->PointDataArraySelection->GetArrayIndex("Density"); int density = this->PointDataArraySelection->GetArrayIndex("Density");
if (this->RequestDataLoop == 0)
CalculateVorticity(vort, uvw, density); CalculateVorticity(vort, uvw, density);
field->GetPointData()->AddArray(this->data[vort]); field->GetPointData()->AddArray(this->data[vort]);
} }
// Load the second output
if (this->UseTurbineFile == 1 && this->Rank == 0)
LoadBladeData(timeStep);
// Close file after all data is read // Close file after all data is read
if (this->RequestDataLoop == 0) {
fclose(this->FilePtr); fclose(this->FilePtr);
this->RequestDataLoop = 1; }
} else {
this->RequestDataLoop = 0; // Request data is on blade
else if (port == 1) {
if (this->UseTurbineFile == 1 && this->Rank == 0) {
vtkInformation* bladeInfo = outVector->GetInformationObject(1);
vtkUnstructuredGrid* blade = GetBladeOutput();
// Collect the time step requested
double* requestedTimeSteps = NULL;
int numRequestedTimeSteps = 0;
vtkInformationDoubleVectorKey* timeKey =
static_cast<vtkInformationDoubleVectorKey*>
(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS());
if (bladeInfo->Has(timeKey)) {
numRequestedTimeSteps = bladeInfo->Length(timeKey);
requestedTimeSteps = bladeInfo->Get(timeKey);
}
// Actual time for the time step
double dTime = requestedTimeSteps[0];
blade->GetInformation()->Set(vtkDataObject::DATA_TIME_STEPS(), &dTime, 1);
// Index of the time step to request
int timeStep = 0;
while (timeStep < this->NumberOfTimeSteps &&
this->TimeSteps[timeStep] < dTime)
timeStep++;
LoadBladeData(timeStep);
}
} }
return 1; return 1;
} }
...@@ -1198,6 +1201,9 @@ void vtkWindBladeReader::SetupBladeData() ...@@ -1198,6 +1201,9 @@ void vtkWindBladeReader::SetupBladeData()
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void vtkWindBladeReader::LoadBladeData(int timeStep) void vtkWindBladeReader::LoadBladeData(int timeStep)
{ {
this->BPoints->Delete();
this->BPoints = vtkPoints::New();
// Open the file for this time step // Open the file for this time step
ostringstream fileName; ostringstream fileName;
fileName << this->RootDirectory << Slash fileName << this->RootDirectory << Slash
......
...@@ -161,8 +161,6 @@ protected: ...@@ -161,8 +161,6 @@ protected:
vtkStdString TurbineTowerName; // Name of tower file vtkStdString TurbineTowerName; // Name of tower file
vtkStdString TurbineBladeName; // Base name of time series blade data vtkStdString TurbineBladeName; // Base name of time series blade data
int RequestDataLoop; // Hack to deal with two output ports
// Selected field of interest // Selected field of interest
vtkDataArraySelection* PointDataArraySelection; vtkDataArraySelection* PointDataArraySelection;
...@@ -209,11 +207,6 @@ protected: ...@@ -209,11 +207,6 @@ protected:
vtkInformationVector** inputVector, vtkInformationVector** inputVector,
vtkInformationVector* outputVector); vtkInformationVector* outputVector);
virtual int RequestUpdateExtent(
vtkInformation* request,
vtkInformationVector** inputVector,
vtkInformationVector* outputVector);
static void SelectionCallback( static void SelectionCallback(
vtkObject *caller, vtkObject *caller,
unsigned long eid, unsigned long eid,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment