----------------------------------------------------------------------------
| 201 | |
| 202 | //---------------------------------------------------------------------------- |
| 203 | int vtkPartitionedDataSetSource::RequestData( |
| 204 | vtkInformation*, vtkInformationVector**, vtkInformationVector* outputVector) |
| 205 | { |
| 206 | // We must meet these preconditions to continue this method |
| 207 | if (!this->GetParametricFunction()) |
| 208 | { |
| 209 | vtkLogF(WARNING, "RequestData aborted since ParametricFunction is missing"); |
| 210 | return 1; |
| 211 | } |
| 212 | |
| 213 | if (!this->RanksEnabledByDefault && this->Allocations.empty()) |
| 214 | { |
| 215 | return 1; |
| 216 | } |
| 217 | |
| 218 | auto outInfo = outputVector->GetInformationObject(0); |
| 219 | auto pds = vtkPartitionedDataSet::GetData(outInfo); |
| 220 | const int rank = outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER()); |
| 221 | const int numRanks = outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_NUMBER_OF_PIECES()); |
| 222 | |
| 223 | auto* function = this->GetParametricFunction(); |
| 224 | function->JoinVOff(); |
| 225 | function->JoinUOff(); |
| 226 | |
| 227 | vtkNew<vtkParametricFunctionSource> source; |
| 228 | source->SetOutputPointsPrecision(vtkAlgorithm::DOUBLE_PRECISION); |
| 229 | source->SetParametricFunction(function); |
| 230 | source->SetScalarModeToV(); |
| 231 | |
| 232 | // We set our default policy here |
| 233 | auto defaultAlloc = (this->RanksEnabledByDefault) ? NUM_PARTITIONS::MULTIPLE_PARTITIONS |
| 234 | : NUM_PARTITIONS::NO_PARTITIONS; |
| 235 | |
| 236 | std::vector<int> allocs(numRanks, defaultAlloc); |
| 237 | for (auto& kv : this->Allocations) |
| 238 | { |
| 239 | if (kv.first < static_cast<int>(allocs.size())) |
| 240 | { |
| 241 | allocs[kv.first] = kv.second; |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | const int numberOfPartitions = (this->NumberOfPartitions > 0) |
| 246 | ? this->NumberOfPartitions |
| 247 | : std::count(allocs.begin(), allocs.end(), NUM_PARTITIONS::MULTIPLE_PARTITIONS); |
| 248 | |
| 249 | if (numberOfPartitions <= 0) |
| 250 | { |
| 251 | return 1; |
| 252 | } |
| 253 | |
| 254 | const auto partsPerRank = ::GenerateAllocations(allocs, numberOfPartitions); |
| 255 | const auto range = ::GetRange(rank, partsPerRank); |
| 256 | |
| 257 | const double deltaV = function->GetMaximumV() / numberOfPartitions; |
| 258 | for (int idx = 0, partition = range.first; partition < range.second; ++partition, ++idx) |
| 259 | { |
| 260 | function->SetMinimumV(partition * deltaV); |
nothing calls this directly
no test coverage detected