1#ifndef AMREX_FABARRAY_UTILITY_H_
2#define AMREX_FABARRAY_UTILITY_H_
3#include <AMReX_Config.H>
31template <BaseFabType FAB,
class F>
32typename FAB::value_type
40template <BaseFabType FAB,
class F>
41typename FAB::value_type
42ReduceSum_host (FabArray<FAB>
const& fa, IntVect
const& nghost, F
const& f)
44 using value_type =
typename FAB::value_type;
48#pragma omp parallel if (!system::regtest_reduction) reduction(+:sm)
50 for (MFIter mfi(fa,
true); mfi.isValid(); ++mfi)
52 const Box& bx = mfi.growntilebox(nghost);
53 auto const& arr = fa.const_array(mfi);
65template <
class OP, BaseFabType FAB,
class F>
66std::conditional_t<std::is_same_v<OP,ReduceOpLogicalAnd> ||
67 std::is_same_v<OP,ReduceOpLogicalOr>,
68 int,
typename FAB::value_type>
69ReduceMF (FabArray<FAB>
const& fa, IntVect
const& nghost, F
const& f)
71 using T = std::conditional_t<std::is_same_v<OP,ReduceOpLogicalAnd> ||
72 std::is_same_v<OP,ReduceOpLogicalOr>,
73 int,
typename FAB::value_type>;
74 auto typ = fa.ixType();
75 auto const& ma = fa.const_arrays();
76 return ParReduce(TypeList<OP>{}, TypeList<T>{}, fa, nghost,
77 [=]
AMREX_GPU_DEVICE (
int box_no,
int i,
int j,
int k)
noexcept -> GpuTuple<T>
83template <
class OP, BaseFabType FAB1, BaseFabType FAB2,
class F>
84std::conditional_t<std::is_same_v<OP,ReduceOpLogicalAnd> ||
85 std::is_same_v<OP,ReduceOpLogicalOr>,
86 int,
typename FAB1::value_type>
87ReduceMF (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2, IntVect
const& nghost, F
const& f)
89 using T = std::conditional_t<std::is_same_v<OP,ReduceOpLogicalAnd> ||
90 std::is_same_v<OP,ReduceOpLogicalOr>,
91 int,
typename FAB1::value_type>;
92 auto typ = fa1.ixType();
93 auto const& ma1 = fa1.const_arrays();
94 auto const& ma2 = fa2.const_arrays();
95 return ParReduce(TypeList<OP>{}, TypeList<T>{}, fa1, nghost,
96 [=]
AMREX_GPU_DEVICE (
int box_no,
int i,
int j,
int k)
noexcept -> GpuTuple<T>
99 ma1[box_no], ma2[box_no])) };
103template <
class OP, BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
104std::conditional_t<std::is_same_v<OP,ReduceOpLogicalAnd> ||
105 std::is_same_v<OP,ReduceOpLogicalOr>,
106 int,
typename FAB1::value_type>
107ReduceMF (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
108 FabArray<FAB3>
const& fa3, IntVect
const& nghost, F
const& f)
110 using T = std::conditional_t<std::is_same_v<OP,ReduceOpLogicalAnd> ||
111 std::is_same_v<OP,ReduceOpLogicalOr>,
112 int,
typename FAB1::value_type>;
113 auto typ = fa1.ixType();
114 auto const& ma1 = fa1.const_arrays();
115 auto const& ma2 = fa2.const_arrays();
116 auto const& ma3 = fa3.const_arrays();
117 return ParReduce(TypeList<OP>{}, TypeList<T>{}, fa1, nghost,
118 [=]
AMREX_GPU_DEVICE (
int box_no,
int i,
int j,
int k)
noexcept -> GpuTuple<T>
121 ma1[box_no], ma2[box_no], ma3[box_no])) };
125template <BaseFabType FAB,
class F>
127typename FAB::value_type ReduceSum_host_wrapper (FabArray<FAB>
const& fa, IntVect
const& nghost, F&& f)
129 return ReduceSum_host(fa,nghost,std::forward<F>(f));
132template <BaseFabType FAB,
class F>
134typename FAB::value_type ReduceSum_host_wrapper (FabArray<FAB>
const& fa, IntVect
const& nghost, F&& f)
137 amrex::Abort(
"ReduceSum: Launch Region is off. Device lambda cannot be called by host.");
151template <BaseFabType FAB,
class F>
152typename FAB::value_type
156 return fudetail::ReduceMF<ReduceOpSum>(fa, nghost, std::forward<F>(f));
158 return fudetail::ReduceSum_host_wrapper(fa, nghost, std::forward<F>(f));
170template <BaseFabType FAB,
class F>
171typename FAB::value_type
174 return fudetail::ReduceSum_host(fa, nghost, std::forward<F>(f));
186template <BaseFabType FAB1, BaseFabType FAB2,
class F>
187typename FAB1::value_type
196template <BaseFabType FAB1, BaseFabType FAB2,
class F>
197typename FAB1::value_type
198ReduceSum_host (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
199 IntVect
const& nghost, F
const& f)
201 using value_type =
typename FAB1::value_type;
205#pragma omp parallel if (!system::regtest_reduction) reduction(+:sm)
207 for (MFIter mfi(fa1,
true); mfi.isValid(); ++mfi)
209 const Box& bx = mfi.growntilebox(nghost);
210 const auto& arr1 = fa1.const_array(mfi);
211 const auto& arr2 = fa2.const_array(mfi);
212 sm += f(bx, arr1, arr2);
223template <BaseFabType FAB1, BaseFabType FAB2,
class F>
225typename FAB1::value_type ReduceSum_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
226 IntVect
const& nghost, F&& f)
228 return ReduceSum_host(fa1,fa2,nghost,std::forward<F>(f));
231template <BaseFabType FAB1, BaseFabType FAB2,
class F>
233typename FAB1::value_type ReduceSum_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
234 IntVect
const& nghost, F&& f)
237 amrex::Abort(
"ReduceSum: Launch Region is off. Device lambda cannot be called by host.");
251template <BaseFabType FAB1, BaseFabType FAB2,
class F>
252typename FAB1::value_type
257 return fudetail::ReduceMF<ReduceOpSum>(fa1,fa2,nghost,std::forward<F>(f));
259 return fudetail::ReduceSum_host_wrapper(fa1,fa2,nghost, std::forward<F>(f));
271template <BaseFabType FAB1, BaseFabType FAB2,
class F>
272typename FAB1::value_type
273ReduceSum (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
276 return fudetail::ReduceSum_host(fa1,fa2,nghost,std::forward<F>(f));
289template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
290typename FAB1::value_type
299template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
300typename FAB1::value_type
301ReduceSum_host (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
302 FabArray<FAB3>
const& fa3, IntVect
const& nghost, F
const& f)
304 using value_type =
typename FAB1::value_type;
308#pragma omp parallel if (!system::regtest_reduction) reduction(+:sm)
310 for (MFIter mfi(fa1,
true); mfi.isValid(); ++mfi)
312 const Box& bx = mfi.growntilebox(nghost);
313 const auto& arr1 = fa1.const_array(mfi);
314 const auto& arr2 = fa2.const_array(mfi);
315 const auto& arr3 = fa3.const_array(mfi);
316 sm += f(bx, arr1, arr2, arr3);
327template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
329typename FAB1::value_type ReduceSum_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
330 FabArray<FAB3>
const& fa3, IntVect
const& nghost, F&& f)
332 return fudetail::ReduceSum_host(fa1,fa2,fa3,nghost,std::forward<F>(f));
335template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
337typename FAB1::value_type ReduceSum_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
338 FabArray<FAB3>
const& fa3, IntVect
const& nghost, F&& f)
341 amrex::Abort(
"ReduceSum: Launch Region is off. Device lambda cannot be called by host.");
356template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
357typename FAB1::value_type
362 return fudetail::ReduceMF<ReduceOpSum>(fa1,fa2,fa3,nghost,std::forward<F>(f));
364 return fudetail::ReduceSum_host_wrapper(fa1,fa2,fa3,nghost,std::forward<F>(f));
377template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
378typename FAB1::value_type
379ReduceSum (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
380 FabArray<FAB3>
const& fa3,
IntVect const& nghost,
F&& f)
382 return fudetail::ReduceSum_host(fa1,fa2,fa3,nghost,std::forward<F>(f));
397template <BaseFabType FAB,
class F>
398typename FAB::value_type
406template <BaseFabType FAB,
class F>
407typename FAB::value_type
408ReduceMin_host (FabArray<FAB>
const& fa, IntVect
const& nghost, F
const& f)
410 using value_type =
typename FAB::value_type;
411 value_type r = std::numeric_limits<value_type>::max();
414#pragma omp parallel reduction(min:r)
416 for (MFIter mfi(fa,
true); mfi.isValid(); ++mfi)
418 const Box& bx = mfi.growntilebox(nghost);
419 const auto& arr = fa.const_array(mfi);
420 r = std::min(r, f(bx, arr));
430template <BaseFabType FAB,
class F>
432typename FAB::value_type ReduceMin_host_wrapper (FabArray<FAB>
const& fa, IntVect
const& nghost, F&& f)
434 return ReduceMin_host(fa,nghost,std::forward<F>(f));
437template <BaseFabType FAB,
class F>
439typename FAB::value_type ReduceMin_host_wrapper (FabArray<FAB>
const& fa, IntVect
const& nghost, F&& f)
442 amrex::Abort(
"ReduceMin: Launch Region is off. Device lambda cannot be called by host.");
455template <BaseFabType FAB,
class F>
456typename FAB::value_type
460 return fudetail::ReduceMF<ReduceOpMin>(fa, nghost, std::forward<F>(f));
462 return fudetail::ReduceMin_host_wrapper(fa, nghost, std::forward<F>(f));
473template <BaseFabType FAB,
class F>
474typename FAB::value_type
477 return fudetail::ReduceMin_host(fa, nghost, std::forward<F>(f));
489template <BaseFabType FAB1, BaseFabType FAB2,
class F>
490typename FAB1::value_type
498template <BaseFabType FAB1, BaseFabType FAB2,
class F>
499typename FAB1::value_type
500ReduceMin_host (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
501 IntVect
const& nghost, F
const& f)
503 using value_type =
typename FAB1::value_type;
504 value_type r = std::numeric_limits<value_type>::max();
507#pragma omp parallel reduction(min:r)
509 for (MFIter mfi(fa1,
true); mfi.isValid(); ++mfi)
511 const Box& bx = mfi.growntilebox(nghost);
512 const auto& arr1 = fa1.const_array(mfi);
513 const auto& arr2 = fa2.const_array(mfi);
514 r = std::min(r, f(bx, arr1, arr2));
525template <BaseFabType FAB1, BaseFabType FAB2,
class F>
527typename FAB1::value_type ReduceMin_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
528 IntVect
const& nghost, F&& f)
530 return fudetail::ReduceMin_host(fa1,fa2,nghost,std::forward<F>(f));
533template <BaseFabType FAB1, BaseFabType FAB2,
class F>
535typename FAB1::value_type ReduceMin_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
536 IntVect
const& nghost, F&& f)
539 amrex::Abort(
"ReduceMin: Launch Region is off. Device lambda cannot be called by host.");
553template <BaseFabType FAB1, BaseFabType FAB2,
class F>
554typename FAB1::value_type
559 return fudetail::ReduceMF<ReduceOpMin>(fa1,fa2,nghost,std::forward<F>(f));
561 return fudetail::ReduceMin_host_wrapper(fa1,fa2,nghost,std::forward<F>(f));
568template <BaseFabType FAB1, BaseFabType FAB2,
class F>
569typename FAB1::value_type
570ReduceMin (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
573 return fudetail::ReduceMin_host(fa1,fa2,nghost,std::forward<F>(f));
580template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
581typename FAB1::value_type
590template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
591typename FAB1::value_type
592ReduceMin_host (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
593 FabArray<FAB3>
const& fa3, IntVect
const& nghost, F
const& f)
595 using value_type =
typename FAB1::value_type;
596 value_type r = std::numeric_limits<value_type>::max();
599#pragma omp parallel reduction(min:r)
601 for (MFIter mfi(fa1,
true); mfi.isValid(); ++mfi)
603 const Box& bx = mfi.growntilebox(nghost);
604 const auto& arr1 = fa1.const_array(mfi);
605 const auto& arr2 = fa2.const_array(mfi);
606 const auto& arr3 = fa3.const_array(mfi);
607 r = std::min(r, f(bx, arr1, arr2, arr3));
618template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
620typename FAB1::value_type ReduceMin_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
621 FabArray<FAB3>
const& fa3, IntVect
const& nghost, F&& f)
623 return fudetail::ReduceMin_host(fa1,fa2,fa3,nghost,std::forward<F>(f));
626template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
628typename FAB1::value_type ReduceMin_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
629 FabArray<FAB3>
const& fa3, IntVect
const& nghost, F&& f)
632 amrex::Abort(
"ReduceMin: Launch Region is off. Device lambda cannot be called by host.");
641template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
642typename FAB1::value_type
647 return fudetail::ReduceMF<ReduceOpMin>(fa1,fa2,fa3,nghost,std::forward<F>(f));
649 return fudetail::ReduceMin_host_wrapper(fa1,fa2,fa3,nghost,std::forward<F>(f));
656template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
657typename FAB1::value_type
658ReduceMin (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
659 FabArray<FAB3>
const& fa3,
IntVect const& nghost,
F&& f)
661 return fudetail::ReduceMin_host(fa1,fa2,fa3,nghost,std::forward<F>(f));
672template <BaseFabType FAB,
class F>
673typename FAB::value_type
681template <BaseFabType FAB,
class F>
682typename FAB::value_type
683ReduceMax_host (FabArray<FAB>
const& fa, IntVect
const& nghost, F
const& f)
685 using value_type =
typename FAB::value_type;
686 value_type r = std::numeric_limits<value_type>::lowest();
689#pragma omp parallel reduction(max:r)
691 for (MFIter mfi(fa,
true); mfi.isValid(); ++mfi)
693 const Box& bx = mfi.growntilebox(nghost);
694 const auto& arr = fa.const_array(mfi);
695 r = std::max(r, f(bx, arr));
706template <BaseFabType FAB,
class F>
708typename FAB::value_type ReduceMax_host_wrapper (FabArray<FAB>
const& fa, IntVect
const& nghost, F&& f)
710 return ReduceMax_host(fa,nghost,std::forward<F>(f));
713template <BaseFabType FAB,
class F>
715typename FAB::value_type ReduceMax_host_wrapper (FabArray<FAB>
const& fa, IntVect
const& nghost, F&& f)
718 amrex::Abort(
"ReduceMax: Launch Region is off. Device lambda cannot be called by host.");
727template <BaseFabType FAB,
class F>
728typename FAB::value_type
732 return fudetail::ReduceMF<ReduceOpMax>(fa,nghost,std::forward<F>(f));
734 return fudetail::ReduceMax_host_wrapper(fa,nghost,std::forward<F>(f));
741template <BaseFabType FAB,
class F>
742typename FAB::value_type
745 return fudetail::ReduceMax_host(fa,nghost,std::forward<F>(f));
752template <BaseFabType FAB1, BaseFabType FAB2,
class F>
753typename FAB1::value_type
761template <BaseFabType FAB1, BaseFabType FAB2,
class F>
762typename FAB1::value_type
763ReduceMax_host (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
764 IntVect
const& nghost, F
const& f)
766 using value_type =
typename FAB1::value_type;
767 value_type r = std::numeric_limits<value_type>::lowest();
770#pragma omp parallel reduction(max:r)
772 for (MFIter mfi(fa1,
true); mfi.isValid(); ++mfi)
774 const Box& bx = mfi.growntilebox(nghost);
775 const auto& arr1 = fa1.const_array(mfi);
776 const auto& arr2 = fa2.const_array(mfi);
777 r = std::max(r, f(bx, arr1, arr2));
788template <BaseFabType FAB1, BaseFabType FAB2,
class F>
790typename FAB1::value_type ReduceMax_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
791 IntVect
const& nghost, F&& f)
793 return ReduceMax_host(fa1,fa2,nghost,std::forward<F>(f));
796template <BaseFabType FAB1, BaseFabType FAB2,
class F>
798typename FAB1::value_type ReduceMax_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
799 IntVect
const& nghost, F&& f)
802 amrex::Abort(
"ReduceMax: Launch Region is off. Device lambda cannot be called by host.");
811template <BaseFabType FAB1, BaseFabType FAB2,
class F>
812typename FAB1::value_type
817 return fudetail::ReduceMF<ReduceOpMax>(fa1,fa2,nghost,std::forward<F>(f));
819 return fudetail::ReduceMax_host_wrapper(fa1,fa2,nghost,std::forward<F>(f));
826template <BaseFabType FAB1, BaseFabType FAB2,
class F>
827typename FAB1::value_type
828ReduceMax (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
831 return fudetail::ReduceMax_host(fa1,fa2,nghost,std::forward<F>(f));
838template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
839typename FAB1::value_type
848template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
849typename FAB1::value_type
850ReduceMax_host (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
851 FabArray<FAB3>
const& fa3, IntVect
const& nghost, F
const& f)
853 using value_type =
typename FAB1::value_type;
854 value_type r = std::numeric_limits<value_type>::lowest();
857#pragma omp parallel reduction(max:r)
859 for (MFIter mfi(fa1,
true); mfi.isValid(); ++mfi)
861 const Box& bx = mfi.growntilebox(nghost);
862 const auto& arr1 = fa1.const_array(mfi);
863 const auto& arr2 = fa2.const_array(mfi);
864 const auto& arr3 = fa3.const_array(mfi);
865 r = std::max(r, f(bx, arr1, arr2, arr3));
876template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
878typename FAB1::value_type ReduceMax_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
879 FabArray<FAB3>
const& fa3, IntVect
const& nghost, F&& f)
881 return fudetail::ReduceMax_host(fa1,fa2,fa3,nghost,std::forward<F>(f));
884template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
886typename FAB1::value_type ReduceMax_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
887 FabArray<FAB3>
const& fa3, IntVect
const& nghost, F&& f)
890 amrex::Abort(
"ReduceMax: Launch Region is off. Device lambda cannot be called by host.");
899template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
900typename FAB1::value_type
905 return fudetail::ReduceMF<ReduceOpMax>(fa1,fa2,fa3,nghost,std::forward<F>(f));
907 return fudetail::ReduceMax_host_wrapper(fa1,fa2,fa3,nghost,std::forward<F>(f));
914template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
915typename FAB1::value_type
916ReduceMax (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
917 FabArray<FAB3>
const& fa3,
IntVect const& nghost,
F&& f)
919 return fudetail::ReduceMax_host(fa1,fa2,fa3,nghost,std::forward<F>(f));
930template <BaseFabType FAB,
class F>
939template <BaseFabType FAB,
class F>
941ReduceLogicalAnd_host (FabArray<FAB>
const& fa, IntVect
const& nghost, F
const& f)
946#pragma omp parallel reduction(&&:r)
948 for (MFIter mfi(fa,
true); mfi.isValid(); ++mfi)
950 const Box& bx = mfi.growntilebox(nghost);
951 const auto& arr = fa.const_array(mfi);
963template <BaseFabType FAB,
class F>
965bool ReduceLogicalAnd_host_wrapper (FabArray<FAB>
const& fa, IntVect
const& nghost, F&& f)
967 return ReduceLogicalAnd_host(fa,nghost,std::forward<F>(f));
970template <BaseFabType FAB,
class F>
972bool ReduceLogicalAnd_host_wrapper (FabArray<FAB>
const& fa, IntVect
const& nghost, F&& f)
975 amrex::Abort(
"ReduceLogicalAnd: Launch Region is off. Device lambda cannot be called by host.");
984template <BaseFabType FAB,
class F>
989 return fudetail::ReduceMF<ReduceOpLogicalAnd>(fa,nghost,std::forward<F>(f));
991 return fudetail::ReduceLogicalAnd_host_wrapper(fa,nghost,std::forward<F>(f));
998template <BaseFabType FAB,
class F>
1002 return fudetail::ReduceLogicalAnd_host(fa,nghost,std::forward<F>(f));
1009template <BaseFabType FAB1, BaseFabType FAB2,
class F>
1019template <BaseFabType FAB1, BaseFabType FAB2,
class F>
1021ReduceLogicalAnd_host (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
1022 IntVect
const& nghost, F
const& f)
1027#pragma omp parallel reduction(&&:r)
1029 for (MFIter mfi(fa1,
true); mfi.isValid(); ++mfi)
1031 const Box& bx = mfi.growntilebox(nghost);
1032 const auto& arr1 = fa1.const_array(mfi);
1033 const auto& arr2 = fa2.const_array(mfi);
1034 r = r && f(bx, arr1, arr2);
1045template <BaseFabType FAB1, BaseFabType FAB2,
class F>
1047bool ReduceLogicalAnd_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
1048 IntVect
const& nghost, F&& f)
1050 return ReduceLogicalAnd_host(fa1,fa2,nghost,std::forward<F>(f));
1053template <BaseFabType FAB1, BaseFabType FAB2,
class F>
1055bool ReduceLogicalAnd_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
1056 IntVect
const& nghost, F&& f)
1059 amrex::Abort(
"ReduceLogicalAnd: Luanch Region is off. Device lambda cannot be called by host.");
1068template <BaseFabType FAB1, BaseFabType FAB2,
class F>
1074 return fudetail::ReduceMF<ReduceOpLogicalAnd>(fa1,fa2,nghost,std::forward<F>(f));
1076 return fudetail::ReduceLogicalAnd_host_wrapper(fa1,fa2,nghost,std::forward<F>(f));
1083template <BaseFabType FAB1, BaseFabType FAB2,
class F>
1088 return fudetail::ReduceLogicalAnd_host(fa1,fa2,nghost,std::forward<F>(f));
1099template <BaseFabType FAB,
class F>
1108template <BaseFabType FAB,
class F>
1110ReduceLogicalOr_host (FabArray<FAB>
const& fa, IntVect
const& nghost, F
const& f)
1115#pragma omp parallel reduction(||:r)
1117 for (MFIter mfi(fa,
true); mfi.isValid(); ++mfi)
1119 const Box& bx = mfi.growntilebox(nghost);
1120 const auto& arr = fa.const_array(mfi);
1121 r = r || f(bx, arr);
1132template <BaseFabType FAB,
class F>
1134bool ReduceLogicalOr_host_wrapper (FabArray<FAB>
const& fa, IntVect
const& nghost, F&& f)
1136 return ReduceLogicalOr_host(fa,nghost,std::forward<F>(f));
1139template <BaseFabType FAB,
class F>
1141bool ReduceLogicalOr_host_wrapper (FabArray<FAB>
const& fa, IntVect
const& nghost, F&& f)
1144 amrex::Abort(
"ReduceLogicalOr: Launch Region is off. Device lambda cannot be called by host.");
1153template <BaseFabType FAB,
class F>
1158 return fudetail::ReduceMF<ReduceOpLogicalOr>(fa,nghost,std::forward<F>(f));
1160 return fudetail::ReduceLogicalOr_host_wrapper(fa,nghost,std::forward<F>(f));
1167template <BaseFabType FAB,
class F>
1171 return fudetail::ReduceLogicalOr_host(fa,nghost,std::forward<F>(f));
1178template <BaseFabType FAB1, BaseFabType FAB2,
class F>
1188template <BaseFabType FAB1, BaseFabType FAB2,
class F>
1190ReduceLogicalOr_host (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
1191 IntVect
const& nghost, F
const& f)
1196#pragma omp parallel reduction(||:r)
1198 for (MFIter mfi(fa1,
true); mfi.isValid(); ++mfi)
1200 const Box& bx = mfi.growntilebox(nghost);
1201 const auto& arr1 = fa1.const_array(mfi);
1202 const auto& arr2 = fa2.const_array(mfi);
1203 r = r || f(bx, arr1, arr2);
1214template <BaseFabType FAB1, BaseFabType FAB2,
class F>
1216bool ReduceLogicalOr_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
1217 IntVect
const& nghost, F&& f)
1219 return fudetail::ReduceLogicalOr_host(fa1,fa2,nghost,std::forward<F>(f));
1222template <BaseFabType FAB1, BaseFabType FAB2,
class F>
1224bool ReduceLogicalOr_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
1225 IntVect
const& nghost, F&& f)
1228 amrex::Abort(
"ReeuceLogicalOr: Launch Region is off. Device lambda cannot be called by host.");
1237template <BaseFabType FAB1, BaseFabType FAB2,
class F>
1243 return fudetail::ReduceMF<ReduceOpLogicalOr>(fa1,fa2,nghost,std::forward<F>(f));
1245 return fudetail::ReduceLogicalOr_host_wrapper(fa1,fa2,nghost,std::forward<F>(f));
1252template <BaseFabType FAB1, BaseFabType FAB2,
class F>
1257 return fudetail::ReduceLogicalOr_host(fa1,fa2,nghost,std::forward<F>(f));
1269template <BaseFabType FAB>
1278 int n = (comp >= 0) ? 1 : mf.
nComp();
1281 auto* dp = pv.
data();
1285 *dp = fab(cell, comp);
1287 for (
int i = 0; i < n; ++i) {
1288 dp[i] = fab(cell,i);
1305 <<
": " << *dp <<
'\n';
1307 std::ostringstream ss;
1309 for (
int i = 0; i < n-1; ++i)
1311 ss << dp[i] <<
", ";
1315 <<
": " << ss.view() <<
'\n';
1331template <BaseFabType FAB>
1335 Swap(dst,src,srccomp,dstcomp,numcomp,
IntVect(nghost));
1348template <BaseFabType FAB>
1355 bool explicit_swap =
true;
1357 if (srccomp == dstcomp && dstcomp == 0 && numcomp == src.
nComp() &&
1361 explicit_swap =
false;
1364 if (!explicit_swap) {
1366 std::swap(dst, src);
1371 auto const& dstma = dst.
arrays();
1372 auto const& srcma = src.
arrays();
1376 const auto tmp = dstma[box_no](i,j,k,n+dstcomp);
1377 dstma[box_no](i,j,k,n+dstcomp) = srcma[box_no](i,j,k,n+srccomp);
1378 srcma[box_no](i,j,k,n+srccomp) = tmp;
1387#pragma omp parallel if (Gpu::notInLaunchRegion())
1391 const Box& bx = mfi.growntilebox(nghost);
1393 auto sfab = src.
array(mfi);
1394 auto dfab = dst.
array(mfi);
1397 const auto tmp = dfab(i,j,k,n+dstcomp);
1398 dfab(i,j,k,n+dstcomp) = sfab(i,j,k,n+srccomp);
1399 sfab(i,j,k,n+srccomp) = tmp;
1408template <BaseFabType FAB>
1416template <BaseFabType FAB>
1422 auto const& dstfa = dst.
arrays();
1427 dstfa[box_no](i,j,k,n+dstcomp) -= srcfa[box_no](i,j,k,n+srccomp);
1436#pragma omp parallel if (Gpu::notInLaunchRegion())
1440 const Box& bx = mfi.growntilebox(nghost);
1443 auto const srcFab = src.
array(mfi);
1444 auto dstFab = dst.
array(mfi);
1447 dstFab(i,j,k,n+dstcomp) -= srcFab(i,j,k,n+srccomp);
1456template <BaseFabType FAB>
1464template <BaseFabType FAB>
1470 auto const& dstfa = dst.
arrays();
1475 dstfa[box_no](i,j,k,n+dstcomp) *= srcfa[box_no](i,j,k,n+srccomp);
1484#pragma omp parallel if (Gpu::notInLaunchRegion())
1488 const Box& bx = mfi.growntilebox(nghost);
1491 auto const srcFab = src.
array(mfi);
1492 auto dstFab = dst.
array(mfi);
1495 dstFab(i,j,k,n+dstcomp) *= srcFab(i,j,k,n+srccomp);
1504template <BaseFabType FAB>
1512template <BaseFabType FAB>
1518 auto const& dstfa = dst.
arrays();
1523 dstfa[box_no](i,j,k,n+dstcomp) /= srcfa[box_no](i,j,k,n+srccomp);
1532#pragma omp parallel if (Gpu::notInLaunchRegion())
1536 const Box& bx = mfi.growntilebox(nghost);
1539 auto const srcFab = src.
array(mfi);
1540 auto dstFab = dst.
array(mfi);
1543 dstFab(i,j,k,n+dstcomp) /= srcFab(i,j,k,n+srccomp);
1551template <BaseFabType FAB>
1559template <BaseFabType FAB>
1565 auto const& fabarr = fa.
arrays();
1569 fabarr[box_no](i,j,k,n+icomp) = std::abs(fabarr[box_no](i,j,k,n+icomp));
1578#pragma omp parallel if (Gpu::notInLaunchRegion())
1582 const Box& bx = mfi.growntilebox(nghost);
1585 auto const& fab = fa.
array(mfi);
1588 fab(i,j,k,n+icomp) = std::abs(fab(i,j,k,n+icomp));
1602template <BaseFabType FAB>
1624template <BaseFabType FAB>
1646template <BaseFabType FAB, BaseFabType IFAB>
1658template <BaseFabType FAB, BaseFabType IFAB>
1667 const int ncomp = fa.
nComp();
1671 auto const& fabarr = fa.
arrays();
1676 if (!ifabarr[box_no](i,j,k)) { fabarr[box_no](i,j,k,n) = 0; }
1685#pragma omp parallel if (Gpu::notInLaunchRegion())
1689 const Box& bx = mfi.tilebox();
1690 auto fab = fa.
array(mfi);
1691 auto const ifab = msk.
array(mfi);
1694 if (!ifab(i,j,k)) { fab(i,j,k,n) = 0; }
1708template <BaseFabType FAB>
1716 fa.
os_temp->ParallelCopy_finish();
1723template <BaseFabType FAB>
1726 int scomp,
int dcomp,
int ncomp)
1732 void*
pdst = dst[mfi].dataPtr(dcomp);
1733 void const* psrc = src[mfi].dataPtr(scomp);
1742template <BaseFabType FAB>
1750template <BaseFabType FAB>
1753 int scomp,
int dcomp,
int ncomp)
1759 void*
pdst = dst[mfi].dataPtr(dcomp);
1760 void const* psrc = src[mfi].dataPtr(scomp);
1769template <BaseFabType FAB>
1783template <BaseFabType FAB>
1786 typename FAB::value_type value)
1793 constexpr int nofind = std::numeric_limits<int>::lowest();
1806 if (ma[box_no](i,j,k,comp) == value) {
1825 if (arr(i,j,k,comp) == value) {
1836 int const* tmp = aa.copyToHost();
1852 const Box& bx = mfi.growntilebox(nghost);
1856 if (fab(i,j,k,comp) == value) {
1867#if defined(AMREX_USE_OMP) && defined(_OPENMP) && (_OPENMP < 201307 || (defined(__NVCOMPILER) && __NVCOMPILER_MAJOR__ < 23))
1868#pragma omp critical (amrex_indexfromvalue)
1869#elif defined(AMREX_USE_OMP)
1870#pragma omp atomic capture
1877 if (old ==
false) { loc = priv_loc; }
1896template <BaseFabType FAB>
1897typename FAB::value_type
1899 IntVect const& nghost,
bool local =
false)
1902 BL_ASSERT(
x.DistributionMap() ==
y.DistributionMap());
1903 BL_ASSERT(
x.nGrowVect().allGE(nghost) &&
y.nGrowVect().allGE(nghost));
1907 using T =
typename FAB::value_type;
1911 auto const& xma =
x.const_arrays();
1912 auto const& yma =
y.const_arrays();
1917 auto const& xfab = xma[box_no];
1918 auto const& yfab = yma[box_no];
1919 for (
int n = 0; n < ncomp; ++n) {
1920 t += xfab(i,j,k,xcomp+n) * yfab(i,j,k,ycomp+n);
1928#pragma omp parallel if (!system::regtest_reduction) reduction(+:sm)
1932 Box const& bx = mfi.growntilebox(nghost);
1933 auto const& xfab =
x.const_array(mfi);
1934 auto const& yfab =
y.const_array(mfi);
1937 sm += xfab(i,j,k,xcomp+n) * yfab(i,j,k,ycomp+n);
1958template <BaseFabType FAB>
1959typename FAB::value_type
1966 using T =
typename FAB::value_type;
1970 auto const& xma =
x.const_arrays();
1975 auto const& xfab = xma[box_no];
1976 for (
int n = 0; n < ncomp; ++n) {
1977 auto v = xfab(i,j,k,xcomp+n);
1986#pragma omp parallel if (!system::regtest_reduction) reduction(+:sm)
1990 Box const& bx = mfi.growntilebox(nghost);
1991 auto const& xfab =
x.const_array(mfi);
1994 auto v = xfab(i,j,k,xcomp+n);
2026template <BaseFabType MFAB, BaseFabType FAB>
2027typename FAB::value_type
2032 BL_ASSERT(
x.boxArray() ==
y.boxArray() &&
x.boxArray() ==
mask.boxArray());
2033 BL_ASSERT(
x.DistributionMap() ==
y.DistributionMap() &&
x.DistributionMap() ==
mask.DistributionMap());
2034 BL_ASSERT(
x.nGrowVect().allGE(nghost) &&
y.nGrowVect().allGE(nghost) &&
2035 mask.nGrowVect().allGE(nghost));
2039 using T =
typename FAB::value_type;
2043 auto const& mma =
mask.const_arrays();
2044 auto const& xma =
x.const_arrays();
2045 auto const& yma =
y.const_arrays();
2050 auto m = T(mma[box_no](i,j,k));
2052 auto const& xfab = xma[box_no];
2053 auto const& yfab = yma[box_no];
2054 for (
int n = 0; n < ncomp; ++n) {
2055 t += xfab(i,j,k,xcomp+n) * yfab(i,j,k,ycomp+n);
2064#pragma omp parallel if (!system::regtest_reduction) reduction(+:sm)
2068 Box const& bx = mfi.growntilebox(nghost);
2069 auto const& mfab =
mask.const_array(mfi);
2070 auto const& xfab =
x.const_array(mfi);
2071 auto const& yfab =
y.const_array(mfi);
2074 auto m = T(mfab(i,j,k));
2075 sm += m * xfab(i,j,k,xcomp+n) * yfab(i,j,k,ycomp+n);
2101template <BaseFabType MFAB, BaseFabType FAB>
2102typename FAB::value_type
2104 IntVect const& nghost,
bool local =
false)
2108 BL_ASSERT(
x.nGrowVect().allGE(nghost) &&
mask.nGrowVect().allGE(nghost));
2112 using T =
typename FAB::value_type;
2116 auto const& mma =
mask.const_arrays();
2117 auto const& xma =
x.const_arrays();
2122 auto m = T(mma[box_no](i,j,k));
2124 auto const& xfab = xma[box_no];
2125 for (
int n = 0; n < ncomp; ++n) {
2126 auto v = xfab(i,j,k,xcomp+n);
2136#pragma omp parallel if (!system::regtest_reduction) reduction(+:sm)
2140 Box const& bx = mfi.growntilebox(nghost);
2141 auto const& mfab =
mask.const_array(mfi);
2142 auto const& xfab =
x.const_array(mfi);
2145 auto m = T(mfab(i,j,k));
2146 auto v = xfab(i,j,k,xcomp+n);
2160template <MultiFabLike MF>
2161void setVal (MF& dst,
typename MF::value_type val)
2167template <MultiFabLike MF>
2168void setBndry (MF& dst,
typename MF::value_type val,
int scomp,
int ncomp)
2170 dst.setBndry(val, scomp, ncomp);
2174template <MultiFabLike MF>
2175void Scale (MF& dst,
typename MF::value_type val,
int scomp,
int ncomp,
int nghost)
2177 dst.mult(val, scomp, ncomp, nghost);
2181template <MultiFabLike DMF, MultiFabLike SMF>
2182void LocalCopy (DMF& dst, SMF
const& src,
int scomp,
int dcomp,
2183 int ncomp,
IntVect const& nghost)
2185 amrex::Copy(dst, src, scomp, dcomp, ncomp, nghost);
2189template <MultiFabLike MF>
2190void LocalAdd (MF& dst, MF
const& src,
int scomp,
int dcomp,
2191 int ncomp,
IntVect const& nghost)
2193 amrex::Add(dst, src, scomp, dcomp, ncomp, nghost);
2197template <MultiFabLike MF>
2198void Saxpy (MF& dst,
typename MF::value_type a, MF
const& src,
int scomp,
int dcomp,
2199 int ncomp,
IntVect const& nghost)
2201 MF::Saxpy(dst, a, src, scomp, dcomp, ncomp, nghost);
2205template <MultiFabLike MF>
2206void Xpay (MF& dst,
typename MF::value_type a, MF
const& src,
int scomp,
int dcomp,
2207 int ncomp,
IntVect const& nghost)
2209 MF::Xpay(dst, a, src, scomp, dcomp, ncomp, nghost);
2213template <MultiFabLike MF>
2214void Saxpy_Xpay (MF& dst,
typename MF::value_type a_saxpy, MF
const& src_saxpy,
2215 typename MF::value_type a_xpay, MF
const& src_xpay,
int scomp,
int dcomp,
2216 int ncomp,
IntVect const& nghost)
2218 MF::Saxpy_Xpay(dst, a_saxpy, src_saxpy, a_xpay, src_xpay, scomp, dcomp, ncomp, nghost);
2222template <MultiFabLike MF>
2223void Saxpy_Saxpy (MF& dst1,
typename MF::value_type a1, MF
const& src1,
2224 MF& dst2,
typename MF::value_type a2, MF
const& src2,
int scomp,
int dcomp,
2225 int ncomp,
IntVect const& nghost)
2227 MF::Saxpy_Saxpy(dst1, a1, src1, dst2, a2, src2, scomp, dcomp, ncomp, nghost);
2231template <MultiFabLike MF>
2233 MF& dst2,
typename MF::value_type a2, MF
const& src,
int scomp,
int dcomp,
2234 int ncomp,
IntVect const& nghost)
2236 MF::Saypy_Saxpy(dst1, a1, dst2, a2, src, scomp, dcomp, ncomp, nghost);
2240template <MultiFabLike MF>
2242 typename MF::value_type a, MF
const& src_a,
int acomp,
2243 typename MF::value_type b, MF
const& src_b,
int bcomp,
2244 int dcomp,
int ncomp,
IntVect const& nghost)
2246 MF::LinComb(dst, a, src_a, acomp, b, src_b, bcomp, dcomp, ncomp, nghost);
2250template <MultiFabLike MF>
2256 dst.ParallelCopy(src, scomp, dcomp, ncomp, ng_src, ng_dst, period);
2260template <MultiFabLike MF>
2261[[nodiscard]]
typename MF::value_type
2265 return mf.norminf(scomp, ncomp, nghost, local);
2269template <MultiFabLike MF, std::
size_t N>
2272 for (
auto& mf: dst) {
2278template <MultiFabLike MF, std::
size_t N>
2281 for (
auto& mf : dst) {
2287template <MultiFabLike MF, std::
size_t N>
2291 for (
auto& mf : dst) {
2292 mf.
mult(val, scomp, ncomp, nghost);
2297template <MultiFabLike DMF, MultiFabLike SMF, std::
size_t N>
2299 int ncomp,
IntVect const& nghost)
2301 for (std::size_t i = 0; i < N; ++i) {
2302 amrex::Copy(dst[i], src[i], scomp, dcomp, ncomp, nghost);
2307template <MultiFabLike MF, std::
size_t N>
2309 int ncomp,
IntVect const& nghost)
2311 for (std::size_t i = 0; i < N; ++i) {
2312 amrex::Add(dst[i], src[i], scomp, dcomp, ncomp, nghost);
2317template <MultiFabLike MF, std::
size_t N>
2319 Array<MF,N> const& src,
int scomp,
int dcomp,
int ncomp,
2322 for (std::size_t i = 0; i < N; ++i) {
2323 MF::Saxpy(dst[i], a, src[i], scomp, dcomp, ncomp, nghost);
2328template <MultiFabLike MF, std::
size_t N>
2330 Array<MF,N> const& src,
int scomp,
int dcomp,
int ncomp,
2333 for (std::size_t i = 0; i < N; ++i) {
2334 MF::Xpay(dst[i], a, src[i], scomp, dcomp, ncomp, nghost);
2339template <MultiFabLike MF, std::
size_t N>
2341 typename MF::value_type a,
Array<MF,N> const& src_a,
int acomp,
2342 typename MF::value_type b,
Array<MF,N> const& src_b,
int bcomp,
2343 int dcomp,
int ncomp,
IntVect const& nghost)
2345 for (std::size_t i = 0; i < N; ++i) {
2346 MF::LinComb(dst[i], a, src_a[i], acomp, b, src_b[i], bcomp, dcomp, ncomp, nghost);
2351template <MultiFabLike MF, std::
size_t N>
2353 int scomp,
int dcomp,
int ncomp,
2358 for (std::size_t i = 0; i < N; ++i) {
2359 dst[i].ParallelCopy(src[i], scomp, dcomp, ncomp, ng_src, ng_dst, period);
2364template <MultiFabLike MF, std::
size_t N>
2365[[nodiscard]]
typename MF::value_type
2369 auto r =
typename MF::value_type(0);
2370 for (std::size_t i = 0; i < N; ++i) {
2371 auto tmp = mf[i].norminf(scomp, ncomp, nghost,
true);
2372 r = std::max(r,tmp);
2381template <MultiFabLike MF, std::
size_t N>
2385 return mf[0].nComp();
2389template <MultiFabLike MF, std::
size_t N>
2393 return mf[0].nGrowVect();
2397template <MultiFabLike MF, std::
size_t N>
2399[[nodiscard]] BoxArray
const&
2402 return mf[0].boxArray();
2406template <MultiFabLike MF, std::
size_t N>
2408[[nodiscard]] DistributionMapping
const&
2411 return mf[0].DistributionMap();
2422FabArray<BaseFab<int>>
2433 const std::vector<IntVect>& pshifts = period.
shiftIntVect();
2440#pragma omp parallel if (!run_on_gpu)
2443 std::vector< std::pair<int,Box> > isects;
2447 const Box& bx =
mask[mfi].box();
2448 auto const& arr =
mask.array(mfi);
2450 for (
const auto& iv : pshifts)
2453 for (
const auto& is : isects)
2455 Box const& b = is.second-iv;
2456 if (iv == 0 && b == bx) {
continue; }
#define BL_PROFILE(a)
Definition AMReX_BLProfiler.H:562
#define BL_ASSERT(EX)
Definition AMReX_BLassert.H:39
#define AMREX_ASSERT_WITH_MESSAGE(EX, MSG)
Definition AMReX_BLassert.H:37
#define AMREX_ASSERT(EX)
Definition AMReX_BLassert.H:38
Distributed container of FAB objects plus copy and fill utilities.
#define AMREX_HOST_DEVICE_PARALLEL_FOR_4D(...)
Definition AMReX_GpuLaunchMacrosC.nolint.H:111
#define AMREX_GPU_DEVICE
Definition AMReX_GpuQualifiers.H:18
#define AMREX_GPU_HOST_DEVICE
Definition AMReX_GpuQualifiers.H:20
Real * pdst
Definition AMReX_HypreMLABecLap.cpp:1132
Array4< int const > mask
Definition AMReX_InterpFaceRegister.cpp:93
#define AMREX_LOOP_3D(bx, i, j, k, block)
Definition AMReX_Loop.nolint.H:4
#define AMREX_LOOP_4D(bx, ncomp, i, j, k, n, block)
Definition AMReX_Loop.nolint.H:16
#define AMREX_D_TERM(a, b, c)
Definition AMReX_SPACE.H:172
#define AMREX_D_DECL(a, b, c)
Definition AMReX_SPACE.H:171
Print on all processors of the default communicator.
Definition AMReX_Print.H:113
virtual bool isManaged() const
Check whether it is managed GPU memory.
Definition AMReX_Arena.cpp:88
virtual bool isDevice() const
Check whether it is non-managed GPU device memory.
Definition AMReX_Arena.cpp:100
Reference-counted collection of Boxes.
Definition AMReX_BoxArray.H:681
std::vector< std::pair< int, Box > > intersections(const Box &bx) const
Return all intersections of bx with this BoxArray.
Definition AMReX_BoxArray.cpp:1202
__host__ __device__ bool contains(const IntVectND< dim > &p) const noexcept
Return true if argument is contained within BoxND.
Definition AMReX_Box.H:233
__host__ __device__ bool ok() const noexcept
Return true if high bounds are >= low bounds and the index type is valid.
Definition AMReX_Box.H:229
Calculates the distribution of FABs to MPI processes.
Definition AMReX_DistributionMapping.H:51
IntVect nGrowVect() const noexcept
Definition AMReX_FabArrayBase.H:85
bool isFusingCandidate() const noexcept
Is this a good candidate for kernel fusing?
Definition AMReX_FabArrayBase.cpp:2713
IndexType ixType() const noexcept
Return index type.
Definition AMReX_FabArrayBase.H:91
const DistributionMapping & DistributionMap() const noexcept
Return constant reference to associated DistributionMapping.
Definition AMReX_FabArrayBase.H:135
@ ADD
Definition AMReX_FabArrayBase.H:411
int nComp() const noexcept
Return number of variables (aka components) associated with each point.
Definition AMReX_FabArrayBase.H:88
const BoxArray & boxArray() const noexcept
Return a constant reference to the BoxArray that defines the valid region associated with this FabArr...
Definition AMReX_FabArrayBase.H:100
An Array of FortranArrayBox(FAB)-like Objects.
Definition AMReX_FabArray.H:356
void mult(value_type val, int comp, int num_comp, int nghost=0)
Definition AMReX_FabArray.H:3248
void setBndry(value_type val)
Set all values in the boundary region to val.
Definition AMReX_FabArray.H:2767
std::unique_ptr< FabArray< FAB > > os_temp
Definition AMReX_FabArray.H:1917
const FabFactory< FAB > & Factory() const noexcept
Factory used to create FAB instances for this FabArray.
Definition AMReX_FabArray.H:471
void prefetchToHost(const MFIter &mfi) const noexcept
Request that the FAB selected by iterator mfi be prefetched to host memory, where supported.
Definition AMReX_FabArray.H:592
MultiArray4< typename FabArray< FAB >::value_type > arrays() noexcept
Build, if needed, and return mutable Array4 views for local FABs.
Definition AMReX_FabArray.H:713
void prefetchToDevice(const MFIter &mfi) const noexcept
Request that the FAB selected by iterator mfi be prefetched to device memory, where supported.
Definition AMReX_FabArray.H:608
Arena * arena() const noexcept
Arena configured for allocations by this FabArray.
Definition AMReX_FabArray.H:480
MultiArray4< typename FabArray< FAB >::value_type const > const_arrays() const noexcept
Read-only convenience wrapper equivalent to arrays() const.
Definition AMReX_FabArray.H:731
void setVal(value_type val)
Set all components in the entire region of each FAB to val.
Definition AMReX_FabArray.H:2985
Array4< typename FabArray< FAB >::value_type const > array(const MFIter &mfi) const noexcept
Read-only Array4 view for the FAB referenced by iterator mfi.
Definition AMReX_FabArray.H:621
bool hasEBFabFactory() const noexcept
Return whether this FabArray uses an EBFArrayBoxFactory.
Definition AMReX_FabArray.H:493
Array4< typename FabArray< FAB >::value_type const > const_array(const MFIter &mfi) const noexcept
Synonym for array(const MFIter&) that highlights read-only semantics.
Definition AMReX_FabArray.H:649
GPU-compatible tuple.
Definition AMReX_Tuple.H:104
Definition AMReX_GpuBuffer.H:24
T const * data() const noexcept
Definition AMReX_GpuBuffer.H:51
__host__ __device__ bool cellCentered() const noexcept
True if the IndexTypeND is CELL based in all directions.
Definition AMReX_IndexType.H:102
__host__ __device__ constexpr bool allGT(const IntVectND< dim > &rhs) const noexcept
Returns true if this is greater than argument for all components. NOTE: This is NOT a strict weak ord...
Definition AMReX_IntVect.H:517
__host__ static __device__ constexpr IntVectND< dim > TheZeroVector() noexcept
This static member function returns a reference to a constant IntVectND object, all of whose dim argu...
Definition AMReX_IntVect.H:771
__host__ static __device__ constexpr IntVectND< dim > TheMinVector() noexcept
Definition AMReX_IntVect.H:819
Iterator for looping ever tiles and boxes of amrex::FabArray based containers.
Definition AMReX_MFIter.H:88
bool isValid() const noexcept
Is the iterator valid i.e. is it associated with a FAB?
Definition AMReX_MFIter.H:176
Dynamically allocated vector for trivially copyable data.
Definition AMReX_PODVector.H:308
T * data() noexcept
Definition AMReX_PODVector.H:672
This provides length of period for periodic domains. 0 means it is not periodic in that direction....
Definition AMReX_Periodicity.H:17
static const Periodicity & NonPeriodic() noexcept
Definition AMReX_Periodicity.cpp:52
std::vector< IntVect > shiftIntVect(IntVect const &nghost=IntVect(0)) const
Definition AMReX_Periodicity.cpp:8
Print & SetPrecision(int p)
Definition AMReX_Print.H:86
This class is a thin wrapper around std::vector. Unlike vector, Vector::operator[] provides bound che...
Definition AMReX_Vector.H:29
__host__ __device__ BoxND< dim > makeSingleCellBox(int i, int j, int k, IndexTypeND< dim > typ=IndexTypeND< dim >::TheCellType())
Create a single-cell box at coordinates (i,j,k).
Definition AMReX_Box.H:2458
__host__ __device__ BoxND< dim > grow(const BoxND< dim > &b, int i) noexcept
Return a copy of b grown uniformly by i cells in every direction.
Definition AMReX_Box.H:1326
std::array< T, N > Array
Definition AMReX_Array.H:31
Arena * The_Async_Arena()
Definition AMReX_Arena.cpp:825
void Sum(Gpu::DeviceVector< T > &v, MPI_Comm comm)
Definition AMReX_GpuParallelReduce.H:37
void Max(KeyValuePair< K, V > &vi, MPI_Comm comm)
Definition AMReX_ParallelReduce.H:133
__host__ __device__ void Swap(T &t1, T &t2) noexcept
Definition AMReX_Algorithm.H:108
__host__ __device__ AMREX_FORCE_INLINE T Exch(T *address, T val) noexcept
Definition AMReX_GpuAtomic.H:487
__host__ __device__ AMREX_FORCE_INLINE void AddNoRet(T *sum, T value) noexcept
Definition AMReX_GpuAtomic.H:283
void streamSynchronize() noexcept
Definition AMReX_GpuDevice.H:310
void dtoh_memcpy_async(void *p_h, const void *p_d, const std::size_t sz) noexcept
Definition AMReX_GpuDevice.H:435
bool inLaunchRegion() noexcept
Definition AMReX_GpuControl.H:88
bool inNoSyncRegion() noexcept
Definition AMReX_GpuControl.H:148
void htod_memcpy_async(void *p_d, const void *p_h, const std::size_t sz) noexcept
Definition AMReX_GpuDevice.H:421
MPI_Comm CommunicatorSub() noexcept
sub-communicator for current frame
Definition AMReX_ParallelContext.H:70
Definition AMReX_Amr.cpp:50
__host__ __device__ void ignore_unused(const Ts &...)
No-op helper that marks variables as intentionally unused.
Definition AMReX.H:259
void Copy(FabArray< DFAB > &dst, FabArray< SFAB > const &src, int srccomp, int dstcomp, int numcomp, int nghost)
Definition AMReX_FabArray.H:192
void 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.
Definition AMReX_FabArrayUtility.H:1752
void OverrideSync_nowait(FabArray< FAB > &fa, FabArray< IFAB > const &msk, const Periodicity &period)
Start the masked OverrideSync operation; call OverrideSync_finish() to complete it.
Definition AMReX_FabArrayUtility.H:1660
void Add(FabArray< FAB > &dst, FabArray< FAB > const &src, int srccomp, int dstcomp, int numcomp, int nghost)
Definition AMReX_FabArray.H:251
ReduceData< Ts... >::Type ParReduce(TypeList< Ops... > operation_list, TypeList< Ts... > type_list, FabArray< FAB > const &fa, IntVect const &nghost, F &&f)
Parallel reduce for MultiFab/FabArray. The reduce result is local and it's the user's responsibility ...
Definition AMReX_ParReduce.H:48
void Scale(MF &dst, typename MF::value_type val, int scomp, int ncomp, int nghost)
dst *= val
Definition AMReX_FabArrayUtility.H:2175
BoxArray const & boxArray(FabArrayBase const &fa)
Convenience wrapper that forwards to fa.boxArray().
Definition AMReX_FabArrayBase.cpp:2870
DistributionMapping const & DistributionMap(FabArrayBase const &fa)
Convenience wrapper that forwards to fa.DistributionMap().
Definition AMReX_FabArrayBase.cpp:2875
FAB::value_type 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.
Definition AMReX_FabArrayUtility.H:1898
void 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
Definition AMReX_FabArrayUtility.H:2214
void prefetchToDevice(FabArray< FAB > const &fa, const bool synchronous=true)
Request that managed-memory FAB data be prefetched to the device, where supported.
Definition AMReX_FabArrayUtility.H:1626
FAB::value_type ReduceMin(FabArray< FAB > const &fa, int nghost, F &&f)
Compute the rank-local minimum of a functor, including nghost cells.
Definition AMReX_FabArrayUtility.H:399
void ParallelFor(TypeList< CTOs... > ctos, std::array< int, sizeof...(CTOs)> const &runtime_options, T N, F &&f)
Definition AMReX_CTOParallelForImpl.H:202
FabArray< BaseFab< int > > OverlapMask(FabArray< FAB > const &fa, IntVect const &nghost, Periodicity const &period)
Return the number of overlapping grown FAB regions at each point.
Definition AMReX_FabArrayUtility.H:2423
void prefetchToHost(FabArray< FAB > const &fa, const bool synchronous=true)
Request that managed-memory FAB data be prefetched to the host, where supported.
Definition AMReX_FabArrayUtility.H:1604
bool isMFIterSafe(const FabArrayBase &x, const FabArrayBase &y)
Definition AMReX_MFIter.H:256
int nComp(FabArrayBase const &fa)
Convenience wrapper that forwards to fa.nComp().
Definition AMReX_FabArrayBase.cpp:2860
void 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
Definition AMReX_FabArrayUtility.H:2223
IntVect 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.
Definition AMReX_FabArrayUtility.H:1785
void 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
Definition AMReX_FabArrayUtility.H:2241
void 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
Definition AMReX_FabArrayUtility.H:2251
void 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
Definition AMReX_FabArrayUtility.H:2232
void 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.
Definition AMReX_FabArrayUtility.H:1458
IntVectND< 3 > IntVect
IntVect is an alias for amrex::IntVectND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:38
void Abs(FabArray< FAB > &fa, int icomp, int numcomp, int nghost)
Replace selected components by their absolute values using a uniform ghost width.
Definition AMReX_FabArrayUtility.H:1553
void OverrideSync_finish(FabArray< FAB > &fa)
Finish the current masked OverrideSync_nowait() operation.
Definition AMReX_FabArrayUtility.H:1710
void single_task(L &&f) noexcept
Definition AMReX_GpuLaunchFunctsC.H:1245
void 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.
Definition AMReX_FabArrayUtility.H:1725
IntVect nGrowVect(FabArrayBase const &fa)
Convenience wrapper that forwards to fa.nGrowVect().
Definition AMReX_FabArrayBase.cpp:2865
void LocalCopy(DMF &dst, SMF const &src, int scomp, int dcomp, int ncomp, IntVect const &nghost)
dst = src
Definition AMReX_FabArrayUtility.H:2182
bool TilingIfNotGPU() noexcept
Definition AMReX_MFIter.H:12
void setBndry(MF &dst, typename MF::value_type val, int scomp, int ncomp)
dst = val in ghost cells.
Definition AMReX_FabArrayUtility.H:2168
void 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.
Definition AMReX_FabArrayUtility.H:1271
MF::value_type 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.
Definition AMReX_FabArrayUtility.H:2262
bool ReduceLogicalOr(FabArray< FAB > const &fa, int nghost, F &&f)
Return the logical OR of predicate results over locally owned data.
Definition AMReX_FabArrayUtility.H:1101
void LoopConcurrentOnCpu(Dim3 lo, Dim3 hi, F const &f) noexcept
Definition AMReX_Loop.H:388
void Xpay(MF &dst, typename MF::value_type a, MF const &src, int scomp, int dcomp, int ncomp, IntVect const &nghost)
dst = src + a * dst
Definition AMReX_FabArrayUtility.H:2206
void Abort(const std::string &msg)
Print a fatal-error message to stderr and abort execution.
Definition AMReX.cpp:242
const int[]
Definition AMReX_BLProfiler.cpp:1665
void OverrideSync(FabArray< FAB > &fa, FabArray< IFAB > const &msk, const Periodicity &period)
Synchronize shared nodal values using an owner mask.
Definition AMReX_FabArrayUtility.H:1648
void 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.
Definition AMReX_FabArrayUtility.H:1506
bool ReduceLogicalAnd(FabArray< FAB > const &fa, int nghost, F &&f)
Return the logical AND of predicate results over locally owned data.
Definition AMReX_FabArrayUtility.H:932
FAB::value_type ReduceMax(FabArray< FAB > const &fa, int nghost, F &&f)
Compute the rank-local maximum of a functor, including nghost cells.
Definition AMReX_FabArrayUtility.H:674
void 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.
Definition AMReX_FabArrayUtility.H:1410
void Saxpy(MF &dst, typename MF::value_type a, MF const &src, int scomp, int dcomp, int ncomp, IntVect const &nghost)
dst += a * src
Definition AMReX_FabArrayUtility.H:2198
void LocalAdd(MF &dst, MF const &src, int scomp, int dcomp, int ncomp, IntVect const &nghost)
dst += src
Definition AMReX_FabArrayUtility.H:2190
FAB::value_type ReduceSum(FabArray< FAB > const &fa, int nghost, F &&f)
Sum a user-defined quantity over locally owned data, including nghost cells.
Definition AMReX_FabArrayUtility.H:33
void setVal(MF &dst, typename MF::value_type val)
dst = val
Definition AMReX_FabArrayUtility.H:2161
Definition AMReX_TagParallelFor.H:58
Array4< T > dfab
Definition AMReX_TagParallelFor.H:59
Definition AMReX_TypeTraits.H:94
FabArray memory allocation information.
Definition AMReX_FabArray.H:73
MFInfo & SetArena(Arena *ar) noexcept
Select the Arena used for FAB storage.
Definition AMReX_FabArray.H:87
Definition AMReX_MFIter.H:20
Struct for holding types.
Definition AMReX_TypeList.H:13