------------------------------------------------------------------------------
| 302 | |
| 303 | //------------------------------------------------------------------------------ |
| 304 | void vtkAMRResampleFilter::TransferToCellCenters(vtkUniformGrid* g, vtkOverlappingAMR* amrds) |
| 305 | { |
| 306 | assert("pre: uniform grid is nullptr" && (g != nullptr)); |
| 307 | assert("pre: AMR data-structure is nullptr" && (amrds != nullptr)); |
| 308 | |
| 309 | // STEP 0: Get the first block so that we know the arrays |
| 310 | vtkUniformGrid* refGrid = this->GetReferenceGrid(amrds); |
| 311 | |
| 312 | // STEP 1: Get the cell-data of the reference grid |
| 313 | vtkCellData* CD = refGrid->GetCellData(); |
| 314 | assert("pre: Donor CellData is nullptr!" && (CD != nullptr)); |
| 315 | |
| 316 | // STEP 2: Get the cell data of the resampled grid |
| 317 | vtkCellData* fieldData = g->GetCellData(); |
| 318 | assert("pre: Target PointData is nullptr!" && (fieldData != nullptr)); |
| 319 | |
| 320 | // STEP 3: Initialize the fields on the resampled grid |
| 321 | this->InitializeFields(fieldData, g->GetNumberOfCells(), CD); |
| 322 | |
| 323 | if (fieldData->GetNumberOfArrays() == 0) |
| 324 | { |
| 325 | return; |
| 326 | } |
| 327 | |
| 328 | // TODO: this is a very naive implementation and should be optimized. However, |
| 329 | // mostly this filter is used to transfer the solution to the grid nodes and |
| 330 | // not on the cell nodes. |
| 331 | vtkIdType cellIdx = 0; |
| 332 | for (; cellIdx < g->GetNumberOfCells(); ++cellIdx) |
| 333 | { |
| 334 | double qPoint[3]; |
| 335 | this->ComputeCellCentroid(g, cellIdx, qPoint); |
| 336 | |
| 337 | unsigned int level = 0; |
| 338 | for (; level < amrds->GetNumberOfBlocks(level); ++level) |
| 339 | { |
| 340 | unsigned int dataIdx = 0; |
| 341 | for (; dataIdx < amrds->GetNumberOfBlocks(level); ++dataIdx) |
| 342 | { |
| 343 | int donorCellIdx = -1; |
| 344 | vtkUniformGrid* donorGrid = |
| 345 | vtkUniformGrid::SafeDownCast(amrds->GetDataSetAsCartesianGrid(level, dataIdx)); |
| 346 | if ((donorGrid != nullptr) && this->FoundDonor(qPoint, donorGrid, donorCellIdx)) |
| 347 | { |
| 348 | assert("pre: donorCellIdx is invalid" && (donorCellIdx >= 0) && |
| 349 | (donorCellIdx < donorGrid->GetNumberOfCells())); |
| 350 | CD = donorGrid->GetCellData(); |
| 351 | this->CopyData(fieldData, cellIdx, CD, donorCellIdx); |
| 352 | } // END if |
| 353 | } // END for all datasets |
| 354 | } // END for all levels |
| 355 | } // END for all cells |
| 356 | } |
| 357 | |
| 358 | //------------------------------------------------------------------------------ |
| 359 | bool vtkAMRResampleFilter::SearchForDonorGridAtLevel(double q[3], vtkOverlappingAMR* amrds, |
no test coverage detected