| 1572 | //---------------------------------------------------------------------------- |
| 1573 | template <class GridDataSetT> |
| 1574 | ::LinkMap ComputeLinkMapForStructuredData( |
| 1575 | const diy::Master& master, std::vector<GridDataSetT*>& inputs, int outputGhostLevels) |
| 1576 | { |
| 1577 | using BlockType = typename ::DataSetTypeToBlockTypeConverter<GridDataSetT>::BlockType; |
| 1578 | using BlockStructureType = typename BlockType::BlockStructureType; |
| 1579 | |
| 1580 | ::LinkMap linkMap(inputs.size()); |
| 1581 | |
| 1582 | for (int localId = 0; localId < static_cast<int>(inputs.size()); ++localId) |
| 1583 | { |
| 1584 | // Getting block structures sent by other blocks |
| 1585 | BlockType* block = master.block<BlockType>(localId); |
| 1586 | ::BlockMapType<BlockStructureType>& blockStructures = block->BlockStructures; |
| 1587 | |
| 1588 | auto& input = inputs[localId]; |
| 1589 | const ::ExtentType& localExtent = block->Information.Extent; |
| 1590 | |
| 1591 | // If I am myself empty, I get rid of everything and skip. |
| 1592 | if (localExtent[0] > localExtent[1] || localExtent[2] > localExtent[3] || |
| 1593 | localExtent[4] > localExtent[5]) |
| 1594 | { |
| 1595 | blockStructures.clear(); |
| 1596 | continue; |
| 1597 | } |
| 1598 | |
| 1599 | int dim = input->GetDataDimension(); |
| 1600 | |
| 1601 | auto& localLinks = linkMap[localId]; |
| 1602 | |
| 1603 | BlockStructureType localBlockStructure(input, block->Information); |
| 1604 | |
| 1605 | for (auto it = blockStructures.begin(); it != blockStructures.end();) |
| 1606 | { |
| 1607 | BlockStructureType& blockStructure = it->second; |
| 1608 | |
| 1609 | // We synchronize extents, i.e. we shift the extent of current block neighbor |
| 1610 | // so it is described relative to current block. |
| 1611 | if (!::SynchronizeGridExtents(localBlockStructure, blockStructure)) |
| 1612 | { |
| 1613 | // We end up here if extents cannot be fitted together |
| 1614 | it = blockStructures.erase(it); |
| 1615 | continue; |
| 1616 | } |
| 1617 | |
| 1618 | unsigned char& adjacencyMask = blockStructure.AdjacencyMask; |
| 1619 | unsigned char overlapMask; |
| 1620 | |
| 1621 | // We compute the adjacency mask and the extent. |
| 1622 | ::ComputeAdjacencyAndOverlapMasks( |
| 1623 | localExtent, blockStructure.ShiftedExtent, adjacencyMask, overlapMask); |
| 1624 | |
| 1625 | ::ExtentType& neighborShiftedExtentWithNewGhosts = blockStructure.ShiftedExtentWithNewGhosts; |
| 1626 | neighborShiftedExtentWithNewGhosts = blockStructure.ShiftedExtent; |
| 1627 | |
| 1628 | // We compute the adjacency mask and the extent. |
| 1629 | // We update our neighbor's block extent with ghost layers given spatial adjacency. |
| 1630 | ::LinkGrid<BlockType>(blockStructures, it, block->Information, localLinks, adjacencyMask, |
| 1631 | overlapMask, outputGhostLevels, dim); |
no test coverage detected