Currently this assumes your Boxes are cell-centered.
| 1453 | // Currently this assumes your Boxes are cell-centered. |
| 1454 | // |
| 1455 | void |
| 1456 | BoxArray::removeOverlap (bool simplify) |
| 1457 | { |
| 1458 | if (! ixType().cellCentered()) { |
| 1459 | amrex::Abort("BoxArray::removeOverlap() supports cell-centered only"); |
| 1460 | } |
| 1461 | |
| 1462 | if (crseRatio() != IntVect::TheUnitVector()) { |
| 1463 | amrex::Abort("BoxArray::removeOverlap() must have m_crse_ratio == 1"); |
| 1464 | } |
| 1465 | |
| 1466 | uniqify(); |
| 1467 | |
| 1468 | BARef::HashType& BoxHashMap = m_ref->hash; |
| 1469 | |
| 1470 | const Box EmptyBox; |
| 1471 | |
| 1472 | std::vector< std::pair<int,Box> > isects; |
| 1473 | // |
| 1474 | // Note that "size()" can increase in this loop!!! |
| 1475 | // |
| 1476 | #ifdef AMREX_MEM_PROFILING |
| 1477 | m_ref->updateMemoryUsage_box(-1); |
| 1478 | m_ref->updateMemoryUsage_hash(-1); |
| 1479 | Long total_hash_bytes_save = m_ref->total_hash_bytes; |
| 1480 | #endif |
| 1481 | |
| 1482 | BoxList bl_diff; |
| 1483 | |
| 1484 | for (int i = 0; i < size(); i++) |
| 1485 | { |
| 1486 | if (m_ref->m_abox[i].ok()) |
| 1487 | { |
| 1488 | intersections(m_ref->m_abox[i],isects); |
| 1489 | |
| 1490 | for (auto const& is: isects) |
| 1491 | { |
| 1492 | if (is.first == i) { continue; } |
| 1493 | |
| 1494 | Box& bx = m_ref->m_abox[is.first]; |
| 1495 | |
| 1496 | amrex::boxDiff(bl_diff, bx, is.second); |
| 1497 | |
| 1498 | bx = EmptyBox; |
| 1499 | |
| 1500 | for (const Box& b : bl_diff) |
| 1501 | { |
| 1502 | m_ref->m_abox.push_back(b); |
| 1503 | BoxHashMap[amrex::coarsen(b.smallEnd(),m_ref->crsn)].push_back(static_cast<int>(size()-1)); |
| 1504 | } |
| 1505 | } |
| 1506 | } |
| 1507 | } |
| 1508 | #ifdef AMREX_MEM_PROFILING |
| 1509 | m_ref->updateMemoryUsage_box(1); |
| 1510 | #endif |
| 1511 | // |
| 1512 | // We now have "holes" in our BoxArray. Make us good. |
no test coverage detected