------------------------------------------------------------------------------
| 149 | |
| 150 | //------------------------------------------------------------------------------ |
| 151 | int vtkMFIXReader::RequestData(vtkInformation* vtkNotUsed(request), |
| 152 | vtkInformationVector** vtkNotUsed(inputVector), vtkInformationVector* outputVector) |
| 153 | { |
| 154 | vtkInformation* outInfo = outputVector->GetInformationObject(0); |
| 155 | vtkUnstructuredGrid* output = |
| 156 | vtkUnstructuredGrid::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())); |
| 157 | vtkDebugMacro(<< "Reading MFIX file"); |
| 158 | |
| 159 | // Save the time value in the output data information. |
| 160 | int length = outInfo->Length(vtkStreamingDemandDrivenPipeline::TIME_STEPS()); |
| 161 | double* steps = outInfo->Get(vtkStreamingDemandDrivenPipeline::TIME_STEPS()); |
| 162 | |
| 163 | if (outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP())) |
| 164 | { |
| 165 | // Get the requested time step. We only support requests of a single time |
| 166 | // step in this reader right now |
| 167 | double requestedTimeStep = outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()); |
| 168 | |
| 169 | // find the timestep with the closest value |
| 170 | int cnt = 0; |
| 171 | int closestStep = 0; |
| 172 | double minDist = -1; |
| 173 | for (cnt = 0; cnt < length; cnt++) |
| 174 | { |
| 175 | double tdist = (steps[cnt] - requestedTimeStep > requestedTimeStep - steps[cnt]) |
| 176 | ? steps[cnt] - requestedTimeStep |
| 177 | : requestedTimeStep - steps[cnt]; |
| 178 | if (minDist < 0 || tdist < minDist) |
| 179 | { |
| 180 | minDist = tdist; |
| 181 | closestStep = cnt; |
| 182 | } |
| 183 | } |
| 184 | this->CurrentTimeStep = closestStep; |
| 185 | } |
| 186 | else |
| 187 | { |
| 188 | this->CurrentTimeStep = this->TimeStep; |
| 189 | } |
| 190 | |
| 191 | this->MakeMesh(output); |
| 192 | output->GetInformation()->Set(vtkDataObject::DATA_TIME_STEP(), steps[this->CurrentTimeStep]); |
| 193 | return 1; |
| 194 | } |
| 195 | |
| 196 | //------------------------------------------------------------------------------ |
| 197 | void vtkMFIXReader::PrintSelf(ostream& os, vtkIndent indent) |
nothing calls this directly
no test coverage detected