------------------------------------------------------------------------------
| 339 | |
| 340 | //------------------------------------------------------------------------------ |
| 341 | void vtkStructuredAMRGridConnectivity::InitializeGhostData(int gridID) |
| 342 | { |
| 343 | assert("pre: gridID is out-of-bounds!" && (gridID >= 0) && |
| 344 | (gridID < static_cast<int>(this->NumberOfGrids))); |
| 345 | assert("pre: Grid has no registered point data!" && (this->GridPointData[gridID] != nullptr)); |
| 346 | assert("pre: Grid has no registered cell data!" && (this->GridCellData[gridID] != nullptr)); |
| 347 | |
| 348 | // STEP 0: Get the ghosted grid extent |
| 349 | int ghostedExtent[6]; |
| 350 | this->GetGhostedExtent(gridID, ghostedExtent); |
| 351 | |
| 352 | // STEP 1: Get the number of nodes/cells in the ghosted extent |
| 353 | int numNodes = vtkStructuredData::GetNumberOfPoints(ghostedExtent, this->DataDescription); |
| 354 | int numCells = vtkStructuredData::GetNumberOfCells(ghostedExtent, this->DataDescription); |
| 355 | |
| 356 | // NOTE: For AMR we currently only support uniform AMR, so there is no need |
| 357 | // to allocate the GhostedGridPoints |
| 358 | |
| 359 | // STEP 2: Allocate point data, if node-centered is true |
| 360 | if (this->GetNodeCentered()) |
| 361 | { |
| 362 | assert("pre: GhostedPointData vector has not been properly allocated!" && |
| 363 | (this->NumberOfGrids == this->GhostedGridPointData.size())); |
| 364 | |
| 365 | this->GhostedGridPointData[gridID] = vtkPointData::New(); |
| 366 | vtkPointData* PD = this->GridPointData[gridID]; |
| 367 | for (int array = 0; array < PD->GetNumberOfArrays(); ++array) |
| 368 | { |
| 369 | int dataType = PD->GetArray(array)->GetDataType(); |
| 370 | vtkDataArray* dataArray = vtkDataArray::CreateDataArray(dataType); |
| 371 | assert("Cannot create data array" && (dataArray != nullptr)); |
| 372 | |
| 373 | dataArray->SetName(PD->GetArray(array)->GetName()); |
| 374 | dataArray->SetNumberOfComponents(PD->GetArray(array)->GetNumberOfComponents()); |
| 375 | dataArray->SetNumberOfTuples(numNodes); |
| 376 | |
| 377 | this->GhostedGridPointData[gridID]->AddArray(dataArray); |
| 378 | dataArray->Delete(); |
| 379 | } // END for all node arrays |
| 380 | } // END if node-centered data-set |
| 381 | |
| 382 | // STEP 3: Allocate cell data |
| 383 | if (this->GetCellCentered()) |
| 384 | { |
| 385 | assert("pre: GhostedCellData vector has not been properly allocated!" && |
| 386 | (this->NumberOfGrids == this->GhostedGridCellData.size())); |
| 387 | this->GhostedGridCellData[gridID] = vtkCellData::New(); |
| 388 | vtkCellData* CD = this->GridCellData[gridID]; |
| 389 | for (int array = 0; array < CD->GetNumberOfArrays(); ++array) |
| 390 | { |
| 391 | int dataType = CD->GetArray(array)->GetDataType(); |
| 392 | vtkDataArray* dataArray = vtkDataArray::CreateDataArray(dataType); |
| 393 | assert("Cannot create data array" && (dataArray != nullptr)); |
| 394 | |
| 395 | dataArray->SetName(CD->GetArray(array)->GetName()); |
| 396 | dataArray->SetNumberOfComponents(CD->GetArray(array)->GetNumberOfComponents()); |
| 397 | dataArray->SetNumberOfTuples(numCells); |
| 398 |
no test coverage detected