------------------------------------------------------------------------------
| 231 | |
| 232 | //------------------------------------------------------------------------------ |
| 233 | int vtkHyperTreeGridRedistribute::ProcessComposite(vtkDataObject* input, vtkDataObject* output) |
| 234 | { |
| 235 | auto inPds = vtkPartitionedDataSet::SafeDownCast(input); |
| 236 | auto inHTG = vtkHyperTreeGrid::SafeDownCast(input); |
| 237 | auto inComposite = vtkCompositeDataSet::SafeDownCast(input); |
| 238 | auto outComposite = vtkCompositeDataSet::SafeDownCast(output); |
| 239 | |
| 240 | int result = 1; |
| 241 | if (inPds || inHTG) |
| 242 | { |
| 243 | result |= this->ProcessBlock(input, output); |
| 244 | } |
| 245 | else if (inComposite && outComposite) |
| 246 | { |
| 247 | outComposite->CopyStructure(inComposite); |
| 248 | |
| 249 | auto outputRange = vtk::Range(outComposite, vtk::CompositeDataSetOptions::None); |
| 250 | auto inputRange = vtk::Range(inComposite, vtk::CompositeDataSetOptions::None); |
| 251 | for (auto inIt = inputRange.begin(), outIt = outputRange.begin(); inIt != inputRange.end(); |
| 252 | ++inIt, ++outIt) |
| 253 | { |
| 254 | // Make sure type is shared among ranks. |
| 255 | // Some ranks may not have a non-null dataset, so they don't know what type to instantiate |
| 256 | constexpr int INVALID_TYPE = -1; |
| 257 | int typeOut = INVALID_TYPE; |
| 258 | int typeIn = *inIt ? inIt->GetDataObjectType() : INVALID_TYPE; |
| 259 | this->Controller->AllReduce(&typeIn, &typeOut, 1, vtkCommunicator::MAX_OP); |
| 260 | |
| 261 | if (typeOut == INVALID_TYPE) |
| 262 | { |
| 263 | *outIt = nullptr; |
| 264 | continue; |
| 265 | } |
| 266 | if (!*inIt) |
| 267 | { |
| 268 | *inIt = vtkSmartPointer<vtkDataObject>::Take(vtkDataObjectTypes::NewDataObject(typeOut)); |
| 269 | } |
| 270 | |
| 271 | *outIt = vtkSmartPointer<vtkDataObject>::Take(inIt->NewInstance()); |
| 272 | |
| 273 | auto inputComposite = vtkCompositeDataSet::SafeDownCast(*inIt); |
| 274 | auto outputComposite = vtkCompositeDataSet::SafeDownCast(*outIt); |
| 275 | |
| 276 | bool isComposite = inputComposite != nullptr; |
| 277 | bool isPDS = inIt->GetDataObjectType() == VTK_PARTITIONED_DATA_SET; |
| 278 | |
| 279 | if (isComposite && !isPDS) |
| 280 | { |
| 281 | if (!outputComposite) |
| 282 | { |
| 283 | vtkErrorMacro(<< "Found no composite output data object"); |
| 284 | result = 0; |
| 285 | continue; |
| 286 | } |
| 287 | // Composite but not PartitionedDS: recurse over the composite structure |
| 288 | result |= this->ProcessComposite(inputComposite, outputComposite); |
| 289 | } |
| 290 | else |
no test coverage detected