| 722 | } |
| 723 | |
| 724 | Real |
| 725 | MultiFab::min (int comp, int nghost, bool local) const |
| 726 | { |
| 727 | BL_PROFILE("MultiFab::min()"); |
| 728 | |
| 729 | BL_ASSERT(nghost >= 0 && n_grow.allGE(nghost)); |
| 730 | |
| 731 | Real mn = std::numeric_limits<Real>::max(); |
| 732 | |
| 733 | #ifdef AMREX_USE_EB |
| 734 | if ( this->hasEBFabFactory() ) |
| 735 | { |
| 736 | const auto& ebfactory = dynamic_cast<EBFArrayBoxFactory const&>(this->Factory()); |
| 737 | auto const& flags = ebfactory.getMultiEBCellFlagFab(); |
| 738 | #ifdef AMREX_USE_GPU |
| 739 | if (Gpu::inLaunchRegion()) { |
| 740 | auto const& flagsma = flags.const_arrays(); |
| 741 | auto const& ma = this->const_arrays(); |
| 742 | mn = ParReduce(TypeList<ReduceOpMin>{}, TypeList<Real>{}, *this, IntVect(nghost), |
| 743 | [=] AMREX_GPU_DEVICE (int box_no, int i, int j, int k) noexcept -> GpuTuple<Real> |
| 744 | { |
| 745 | if (flagsma[box_no](i,j,k).isCovered()) { |
| 746 | return AMREX_REAL_MAX; |
| 747 | } else { |
| 748 | return ma[box_no](i,j,k,comp); |
| 749 | } |
| 750 | }); |
| 751 | } else |
| 752 | #endif |
| 753 | { |
| 754 | #ifdef AMREX_USE_OMP |
| 755 | #pragma omp parallel reduction(min:mn) |
| 756 | #endif |
| 757 | for (MFIter mfi(*this,true); mfi.isValid(); ++mfi) { |
| 758 | Box const& bx = mfi.growntilebox(nghost); |
| 759 | if (flags[mfi].getType(bx) != FabType::covered) { |
| 760 | auto const& flag = flags.const_array(mfi); |
| 761 | auto const& a = this->const_array(mfi); |
| 762 | AMREX_LOOP_3D(bx, i, j, k, |
| 763 | { |
| 764 | if (!flag(i,j,k).isCovered()) { |
| 765 | mn = std::min(mn, a(i,j,k,comp)); |
| 766 | } |
| 767 | }); |
| 768 | } |
| 769 | } |
| 770 | } |
| 771 | } |
| 772 | else |
| 773 | #endif |
| 774 | { |
| 775 | #ifdef AMREX_USE_GPU |
| 776 | if (Gpu::inLaunchRegion()) { |
| 777 | auto const& ma = this->const_arrays(); |
| 778 | mn = ParReduce(TypeList<ReduceOpMin>{}, TypeList<Real>{}, *this, IntVect(nghost), |
| 779 | [=] AMREX_GPU_DEVICE (int box_no, int i, int j, int k) noexcept -> GpuTuple<Real> |
| 780 | { |
| 781 | return ma[box_no](i,j,k,comp); |
no test coverage detected