Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
AMReX_FabArrayUtility.H File Reference

Reduction helpers and utility algorithms for FabArray objects. More...

#include <AMReX_Config.H>
#include <AMReX_Concepts.H>
#include <AMReX_FabArray.H>
#include <AMReX_LayoutData.H>
#include <AMReX_Print.H>
#include <AMReX_ParReduce.H>
#include <limits>

Go to the source code of this file.

Namespaces

namespace  amrex
 

Functions

template<BaseFabType FAB, class F >
FAB::value_type amrex::ReduceSum (FabArray< FAB > const &fa, int nghost, F &&f)
 Sum a user-defined quantity over locally owned data, including nghost cells.
 
template<BaseFabType FAB, class F >
FAB::value_type amrex::ReduceSum (FabArray< FAB > const &fa, IntVect const &nghost, F &&f)
 Sum a user-defined quantity over locally owned data, including nghost.
 
template<BaseFabType FAB1, BaseFabType FAB2, class F >
FAB1::value_type amrex::ReduceSum (FabArray< FAB1 > const &fa1, FabArray< FAB2 > const &fa2, int nghost, F &&f)
 Sum a functor over two FabArrays with the same BoxArray and DistributionMapping.
 
template<BaseFabType FAB1, BaseFabType FAB2, class F >
FAB1::value_type amrex::ReduceSum (FabArray< FAB1 > const &fa1, FabArray< FAB2 > const &fa2, IntVect const &nghost, F &&f)
 Sum a functor over two FabArrays with per-direction ghost-cell widths.
 
template<BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3, class F >
FAB1::value_type amrex::ReduceSum (FabArray< FAB1 > const &fa1, FabArray< FAB2 > const &fa2, FabArray< FAB3 > const &fa3, int nghost, F &&f)
 Sum a functor over three FabArrays with the same layout.
 
template<BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3, class F >
FAB1::value_type amrex::ReduceSum (FabArray< FAB1 > const &fa1, FabArray< FAB2 > const &fa2, FabArray< FAB3 > const &fa3, IntVect const &nghost, F &&f)
 Sum a functor over three FabArrays with per-direction ghost-cell widths.
 
template<BaseFabType FAB, class F >
FAB::value_type amrex::ReduceMin (FabArray< FAB > const &fa, int nghost, F &&f)
 Compute the rank-local minimum of a functor, including nghost cells.
 
template<BaseFabType FAB, class F >
FAB::value_type amrex::ReduceMin (FabArray< FAB > const &fa, IntVect const &nghost, F &&f)
 Compute the rank-local minimum of a functor with per-direction ghost widths.
 
template<BaseFabType FAB1, BaseFabType FAB2, class F >
FAB1::value_type amrex::ReduceMin (FabArray< FAB1 > const &fa1, FabArray< FAB2 > const &fa2, int nghost, F &&f)
 Compute the minimum of a functor that touches two FabArrays grown by nghost.
 
template<BaseFabType FAB1, BaseFabType FAB2, class F >
FAB1::value_type amrex::ReduceMin (FabArray< FAB1 > const &fa1, FabArray< FAB2 > const &fa2, IntVect const &nghost, F &&f)
 Compute the minimum of a functor that touches two FabArrays grown by nghost.
 
template<BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3, class F >
FAB1::value_type amrex::ReduceMin (FabArray< FAB1 > const &fa1, FabArray< FAB2 > const &fa2, FabArray< FAB3 > const &fa3, int nghost, F &&f)
 Convenience overload of ReduceMin for three FabArrays with a uniform ghost width.
 
template<BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3, class F >
FAB1::value_type amrex::ReduceMin (FabArray< FAB1 > const &fa1, FabArray< FAB2 > const &fa2, FabArray< FAB3 > const &fa3, IntVect const &nghost, F &&f)
 Compute the minimum of a functor that touches three FabArrays with per-direction ghost cells.
 
template<BaseFabType FAB, class F >
FAB::value_type amrex::ReduceMax (FabArray< FAB > const &fa, int nghost, F &&f)
 Compute the rank-local maximum of a functor, including nghost cells.
 
template<BaseFabType FAB, class F >
FAB::value_type amrex::ReduceMax (FabArray< FAB > const &fa, IntVect const &nghost, F &&f)
 Compute the rank-local maximum of a functor with per-direction ghost widths.
 
template<BaseFabType FAB1, BaseFabType FAB2, class F >
FAB1::value_type amrex::ReduceMax (FabArray< FAB1 > const &fa1, FabArray< FAB2 > const &fa2, int nghost, F &&f)
 Convenience overload of ReduceMax for two FabArrays with uniform ghost cells.
 
template<BaseFabType FAB1, BaseFabType FAB2, class F >
FAB1::value_type amrex::ReduceMax (FabArray< FAB1 > const &fa1, FabArray< FAB2 > const &fa2, IntVect const &nghost, F &&f)
 Compute the maximum of a functor that touches two FabArrays grown by nghost.
 
template<BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3, class F >
FAB1::value_type amrex::ReduceMax (FabArray< FAB1 > const &fa1, FabArray< FAB2 > const &fa2, FabArray< FAB3 > const &fa3, int nghost, F &&f)
 Convenience overload of ReduceMax for three FabArrays with a uniform ghost width.
 
template<BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3, class F >
FAB1::value_type amrex::ReduceMax (FabArray< FAB1 > const &fa1, FabArray< FAB2 > const &fa2, FabArray< FAB3 > const &fa3, IntVect const &nghost, F &&f)
 Compute the maximum of a functor that touches three FabArrays with per-direction ghost cells.
 
template<BaseFabType FAB, class F >
bool amrex::ReduceLogicalAnd (FabArray< FAB > const &fa, int nghost, F &&f)
 Return the logical AND of predicate results over locally owned data.
 
template<BaseFabType FAB, class F >
bool amrex::ReduceLogicalAnd (FabArray< FAB > const &fa, IntVect const &nghost, F &&f)
 Return the logical AND of predicate results over locally owned data.
 
template<BaseFabType FAB1, BaseFabType FAB2, class F >
bool amrex::ReduceLogicalAnd (FabArray< FAB1 > const &fa1, FabArray< FAB2 > const &fa2, int nghost, F &&f)
 Convenience overload of ReduceLogicalAnd for two FabArrays with uniform ghost cells.
 
template<BaseFabType FAB1, BaseFabType FAB2, class F >
bool amrex::ReduceLogicalAnd (FabArray< FAB1 > const &fa1, FabArray< FAB2 > const &fa2, IntVect const &nghost, F &&f)
 Two-Fab logical AND reduction with per-direction ghost cells.
 
template<BaseFabType FAB, class F >
bool amrex::ReduceLogicalOr (FabArray< FAB > const &fa, int nghost, F &&f)
 Return the logical OR of predicate results over locally owned data.
 
template<BaseFabType FAB, class F >
bool amrex::ReduceLogicalOr (FabArray< FAB > const &fa, IntVect const &nghost, F &&f)
 Return the logical OR of predicate results over locally owned data.
 
template<BaseFabType FAB1, BaseFabType FAB2, class F >
bool amrex::ReduceLogicalOr (FabArray< FAB1 > const &fa1, FabArray< FAB2 > const &fa2, int nghost, F &&f)
 Convenience overload of ReduceLogicalOr for two FabArrays with uniform ghost cells.
 
template<BaseFabType FAB1, BaseFabType FAB2, class F >
bool amrex::ReduceLogicalOr (FabArray< FAB1 > const &fa1, FabArray< FAB2 > const &fa2, IntVect const &nghost, F &&f)
 Two-Fab logical OR reduction with per-direction ghost cells.
 
template<BaseFabType FAB>
void amrex::printCell (FabArray< FAB > const &mf, const IntVect &cell, int comp=-1, const IntVect &ng=IntVect::TheZeroVector())
 Print the value(s) stored at a specific cell of a FabArray.
 
template<BaseFabType FAB>
void amrex::Swap (FabArray< FAB > &dst, FabArray< FAB > &src, int srccomp, int dstcomp, int numcomp, int nghost)
 Swap a component subset (with uniform ghost cells) between two FabArrays.
 
template<BaseFabType FAB>
void amrex::Swap (FabArray< FAB > &dst, FabArray< FAB > &src, int srccomp, int dstcomp, int numcomp, const IntVect &nghost)
 Swap a component subset (with per-direction ghost cells) between two FabArrays.
 
template<BaseFabType FAB>
void amrex::Subtract (FabArray< FAB > &dst, FabArray< FAB > const &src, int srccomp, int dstcomp, int numcomp, int nghost)
 Apply dst(dstcomp+n) -= src(srccomp+n) using a uniform ghost width.
 
template<BaseFabType FAB>
void amrex::Subtract (FabArray< FAB > &dst, FabArray< FAB > const &src, int srccomp, int dstcomp, int numcomp, const IntVect &nghost)
 Apply dst(dstcomp+n) -= src(srccomp+n) using per-direction ghost widths.
 
template<BaseFabType FAB>
void amrex::Multiply (FabArray< FAB > &dst, FabArray< FAB > const &src, int srccomp, int dstcomp, int numcomp, int nghost)
 Apply dst(dstcomp+n) *= src(srccomp+n) using a uniform ghost width.
 
template<BaseFabType FAB>
void amrex::Multiply (FabArray< FAB > &dst, FabArray< FAB > const &src, int srccomp, int dstcomp, int numcomp, const IntVect &nghost)
 Apply dst(dstcomp+n) *= src(srccomp+n) using per-direction ghost widths.
 
template<BaseFabType FAB>
void amrex::Divide (FabArray< FAB > &dst, FabArray< FAB > const &src, int srccomp, int dstcomp, int numcomp, int nghost)
 Apply dst(dstcomp+n) /= src(srccomp+n) using a uniform ghost width.
 
template<BaseFabType FAB>
void amrex::Divide (FabArray< FAB > &dst, FabArray< FAB > const &src, int srccomp, int dstcomp, int numcomp, const IntVect &nghost)
 Apply dst(dstcomp+n) /= src(srccomp+n) using per-direction ghost widths.
 
template<BaseFabType FAB>
void amrex::Abs (FabArray< FAB > &fa, int icomp, int numcomp, int nghost)
 Replace selected components by their absolute values using a uniform ghost width.
 
template<BaseFabType FAB>
void amrex::Abs (FabArray< FAB > &fa, int icomp, int numcomp, const IntVect &nghost)
 Replace selected components by their absolute values using per-direction ghost widths.
 
template<BaseFabType FAB>
void amrex::prefetchToHost (FabArray< FAB > const &fa, const bool synchronous=true)
 Request that managed-memory FAB data be prefetched to the host, where supported.
 
template<BaseFabType FAB>
void amrex::prefetchToDevice (FabArray< FAB > const &fa, const bool synchronous=true)
 Request that managed-memory FAB data be prefetched to the device, where supported.
 
template<BaseFabType FAB, BaseFabType IFAB>
void amrex::OverrideSync (FabArray< FAB > &fa, FabArray< IFAB > const &msk, const Periodicity &period)
 Synchronize shared nodal values using an owner mask.
 
template<BaseFabType FAB, BaseFabType IFAB>
void amrex::OverrideSync_nowait (FabArray< FAB > &fa, FabArray< IFAB > const &msk, const Periodicity &period)
 Start the masked OverrideSync operation; call OverrideSync_finish() to complete it.
 
template<BaseFabType FAB>
void amrex::OverrideSync_finish (FabArray< FAB > &fa)
 Finish the current masked OverrideSync_nowait() operation.
 
template<BaseFabType FAB>
void amrex::dtoh_memcpy (FabArray< FAB > &dst, FabArray< FAB > const &src, int scomp, int dcomp, int ncomp)
 Copy selected components of each local FAB, ghost cells included, device-to-host.
 
template<BaseFabType FAB>
void amrex::dtoh_memcpy (FabArray< FAB > &dst, FabArray< FAB > const &src)
 Copy all components of each local FAB, ghost cells included, device-to-host.
 
template<BaseFabType FAB>
void amrex::htod_memcpy (FabArray< FAB > &dst, FabArray< FAB > const &src, int scomp, int dcomp, int ncomp)
 Copy selected components of each local FAB, ghost cells included, host-to-device.
 
template<BaseFabType FAB>
void amrex::htod_memcpy (FabArray< FAB > &dst, FabArray< FAB > const &src)
 Copy all components of each local FAB, ghost cells included, host-to-device.
 
template<BaseFabType FAB>
IntVect amrex::indexFromValue (FabArray< FAB > const &mf, int comp, IntVect const &nghost, typename FAB::value_type value)
 Return the index of an arbitrary cell at which component comp equals value.
 
template<BaseFabType FAB>
FAB::value_type amrex::Dot (FabArray< FAB > const &x, int xcomp, FabArray< FAB > const &y, int ycomp, int ncomp, IntVect const &nghost, bool local=false)
 Compute dot products of two FabArrays.
 
template<BaseFabType FAB>
FAB::value_type amrex::Dot (FabArray< FAB > const &x, int xcomp, int ncomp, IntVect const &nghost, bool local=false)
 Compute dot product of FabArray with itself.
 
template<BaseFabType IFAB, BaseFabType FAB>
FAB::value_type amrex::Dot (FabArray< IFAB > const &mask, FabArray< FAB > const &x, int xcomp, FabArray< FAB > const &y, int ycomp, int ncomp, IntVect const &nghost, bool local=false)
 Compute dot product of two FabArrays in region that mask is true.
 
template<BaseFabType IFAB, BaseFabType FAB>
FAB::value_type amrex::Dot (FabArray< IFAB > const &mask, FabArray< FAB > const &x, int xcomp, int ncomp, IntVect const &nghost, bool local=false)
 Compute dot product of FabArray with itself in region that mask is true.
 
template<MultiFabLike MF>
void amrex::setVal (MF &dst, typename MF::value_type val)
 dst = val
 
template<MultiFabLike MF>
void amrex::setBndry (MF &dst, typename MF::value_type val, int scomp, int ncomp)
 dst = val in ghost cells.
 
template<MultiFabLike MF>
void amrex::Scale (MF &dst, typename MF::value_type val, int scomp, int ncomp, int nghost)
 dst *= val
 
template<MultiFabLike DMF, MultiFabLike SMF>
void amrex::LocalCopy (DMF &dst, SMF const &src, int scomp, int dcomp, int ncomp, IntVect const &nghost)
 dst = src
 
template<MultiFabLike MF>
void amrex::LocalAdd (MF &dst, MF const &src, int scomp, int dcomp, int ncomp, IntVect const &nghost)
 dst += src
 
template<MultiFabLike MF>
void amrex::Saxpy (MF &dst, typename MF::value_type a, MF const &src, int scomp, int dcomp, int ncomp, IntVect const &nghost)
 dst += a * src
 
template<MultiFabLike MF>
void amrex::Xpay (MF &dst, typename MF::value_type a, MF const &src, int scomp, int dcomp, int ncomp, IntVect const &nghost)
 dst = src + a * dst
 
template<MultiFabLike MF>
void amrex::Saxpy_Xpay (MF &dst, typename MF::value_type a_saxpy, MF const &src_saxpy, typename MF::value_type a_xpay, MF const &src_xpay, int scomp, int dcomp, int ncomp, IntVect const &nghost)
 dst += a_saxpy * src_saxpy followed by dst = src_xpay + a_xpay * dst
 
template<MultiFabLike MF>
void amrex::Saxpy_Saxpy (MF &dst1, typename MF::value_type a1, MF const &src1, MF &dst2, typename MF::value_type a2, MF const &src2, int scomp, int dcomp, int ncomp, IntVect const &nghost)
 dst1 += a1 * src1 followed by dst2 += a2 * src2
 
template<MultiFabLike MF>
void amrex::Saypy_Saxpy (MF &dst1, typename MF::value_type a1, MF &dst2, typename MF::value_type a2, MF const &src, int scomp, int dcomp, int ncomp, IntVect const &nghost)
 dst1 += a1 * dst2 followed by dst2 += a2 * src
 
template<MultiFabLike MF>
void amrex::LinComb (MF &dst, typename MF::value_type a, MF const &src_a, int acomp, typename MF::value_type b, MF const &src_b, int bcomp, int dcomp, int ncomp, IntVect const &nghost)
 dst = a*src_a + b*src_b
 
template<MultiFabLike MF>
void amrex::ParallelCopy (MF &dst, MF const &src, int scomp, int dcomp, int ncomp, IntVect const &ng_src=IntVect(0), IntVect const &ng_dst=IntVect(0), Periodicity const &period=Periodicity::NonPeriodic())
 dst = src w/ MPI communication
 
template<MultiFabLike MF>
MF::value_type amrex::norminf (MF const &mf, int scomp, int ncomp, IntVect const &nghost, bool local=false)
 Return the infinity norm, with an MPI maximum unless local is true.
 
template<MultiFabLike MF, std::size_t N>
void amrex::setVal (Array< MF, N > &dst, typename MF::value_type val)
 dst = val
 
template<MultiFabLike MF, std::size_t N>
void amrex::setBndry (Array< MF, N > &dst, typename MF::value_type val, int scomp, int ncomp)
 dst = val in ghost cells.
 
template<MultiFabLike MF, std::size_t N>
void amrex::Scale (Array< MF, N > &dst, typename MF::value_type val, int scomp, int ncomp, int nghost)
 dst *= val
 
template<MultiFabLike DMF, MultiFabLike SMF, std::size_t N>
void amrex::LocalCopy (Array< DMF, N > &dst, Array< SMF, N > const &src, int scomp, int dcomp, int ncomp, IntVect const &nghost)
 dst = src
 
template<MultiFabLike MF, std::size_t N>
void amrex::LocalAdd (Array< MF, N > &dst, Array< MF, N > const &src, int scomp, int dcomp, int ncomp, IntVect const &nghost)
 dst += src
 
template<MultiFabLike MF, std::size_t N>
void amrex::Saxpy (Array< MF, N > &dst, typename MF::value_type a, Array< MF, N > const &src, int scomp, int dcomp, int ncomp, IntVect const &nghost)
 dst += a * src
 
template<MultiFabLike MF, std::size_t N>
void amrex::Xpay (Array< MF, N > &dst, typename MF::value_type a, Array< MF, N > const &src, int scomp, int dcomp, int ncomp, IntVect const &nghost)
 dst = src + a * dst
 
template<MultiFabLike MF, std::size_t N>
void amrex::LinComb (Array< MF, N > &dst, typename MF::value_type a, Array< MF, N > const &src_a, int acomp, typename MF::value_type b, Array< MF, N > const &src_b, int bcomp, int dcomp, int ncomp, IntVect const &nghost)
 dst = a*src_a + b*src_b
 
template<MultiFabLike MF, std::size_t N>
void amrex::ParallelCopy (Array< MF, N > &dst, Array< MF, N > const &src, int scomp, int dcomp, int ncomp, IntVect const &ng_src=IntVect(0), IntVect const &ng_dst=IntVect(0), Periodicity const &period=Periodicity::NonPeriodic())
 dst = src w/ MPI communication
 
template<MultiFabLike MF, std::size_t N>
MF::value_type amrex::norminf (Array< MF, N > const &mf, int scomp, int ncomp, IntVect const &nghost, bool local=false)
 Return the maximum infinity norm across the array and, unless local is true, across MPI ranks.
 
template<MultiFabLike MF, std::size_t N>
requires (N > 0)
int amrex::nComp (Array< MF, N > const &mf)
 Return the component count of the first FabArray in mf.
 
template<MultiFabLike MF, std::size_t N>
requires (N > 0)
IntVect amrex::nGrowVect (Array< MF, N > const &mf)
 Return the grow vector of the first FabArray in mf.
 
template<MultiFabLike MF, std::size_t N>
requires (N > 0)
BoxArray const & amrex::boxArray (Array< MF, N > const &mf)
 Return the BoxArray of the first FabArray in mf.
 
template<MultiFabLike MF, std::size_t N>
requires (N > 0)
DistributionMapping const & amrex::DistributionMap (Array< MF, N > const &mf)
 Return the DistributionMapping of the first FabArray in mf.
 
template<class FAB >
FabArray< BaseFab< int > > amrex::OverlapMask (FabArray< FAB > const &fa, IntVect const &nghost, Periodicity const &period)
 Return the number of overlapping grown FAB regions at each point.
 

Detailed Description

Reduction helpers and utility algorithms for FabArray objects.