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 (FabArray<FAB>
const& fa, IntVect
const& nghost, 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 && src.
nComp() == dst.
nComp() &&
1360 explicit_swap =
false;
1363 if (!explicit_swap) {
1365 std::swap(dst, src);
1370 auto const& dstma = dst.
arrays();
1371 auto const& srcma = src.
arrays();
1375 const auto tmp = dstma[box_no](i,j,k,n+dstcomp);
1376 dstma[box_no](i,j,k,n+dstcomp) = srcma[box_no](i,j,k,n+srccomp);
1377 srcma[box_no](i,j,k,n+srccomp) = tmp;
1386#pragma omp parallel if (Gpu::notInLaunchRegion())
1390 const Box& bx = mfi.growntilebox(nghost);
1392 auto sfab = src.
array(mfi);
1393 auto dfab = dst.
array(mfi);
1396 const auto tmp = dfab(i,j,k,n+dstcomp);
1397 dfab(i,j,k,n+dstcomp) = sfab(i,j,k,n+srccomp);
1398 sfab(i,j,k,n+srccomp) = tmp;
1407template <BaseFabType FAB>
1415template <BaseFabType FAB>
1421 auto const& dstfa = dst.
arrays();
1426 dstfa[box_no](i,j,k,n+dstcomp) -= srcfa[box_no](i,j,k,n+srccomp);
1435#pragma omp parallel if (Gpu::notInLaunchRegion())
1439 const Box& bx = mfi.growntilebox(nghost);
1442 auto const srcFab = src.
array(mfi);
1443 auto dstFab = dst.
array(mfi);
1446 dstFab(i,j,k,n+dstcomp) -= srcFab(i,j,k,n+srccomp);
1455template <BaseFabType FAB>
1463template <BaseFabType FAB>
1469 auto const& dstfa = dst.
arrays();
1474 dstfa[box_no](i,j,k,n+dstcomp) *= srcfa[box_no](i,j,k,n+srccomp);
1483#pragma omp parallel if (Gpu::notInLaunchRegion())
1487 const Box& bx = mfi.growntilebox(nghost);
1490 auto const srcFab = src.
array(mfi);
1491 auto dstFab = dst.
array(mfi);
1494 dstFab(i,j,k,n+dstcomp) *= srcFab(i,j,k,n+srccomp);
1503template <BaseFabType FAB>
1511template <BaseFabType FAB>
1517 auto const& dstfa = dst.
arrays();
1522 dstfa[box_no](i,j,k,n+dstcomp) /= srcfa[box_no](i,j,k,n+srccomp);
1531#pragma omp parallel if (Gpu::notInLaunchRegion())
1535 const Box& bx = mfi.growntilebox(nghost);
1538 auto const srcFab = src.
array(mfi);
1539 auto dstFab = dst.
array(mfi);
1542 dstFab(i,j,k,n+dstcomp) /= srcFab(i,j,k,n+srccomp);
1550template <BaseFabType FAB>
1558template <BaseFabType FAB>
1564 auto const& fabarr = fa.
arrays();
1568 fabarr[box_no](i,j,k,n+icomp) = std::abs(fabarr[box_no](i,j,k,n+icomp));
1577#pragma omp parallel if (Gpu::notInLaunchRegion())
1581 const Box& bx = mfi.growntilebox(nghost);
1584 auto const& fab = fa.
array(mfi);
1587 fab(i,j,k,n+icomp) = std::abs(fab(i,j,k,n+icomp));
1601template <BaseFabType FAB>
1623template <BaseFabType FAB>
1645template <BaseFabType FAB, BaseFabType IFAB>
1657template <BaseFabType FAB, BaseFabType IFAB>
1666 const int ncomp = fa.
nComp();
1670 auto const& fabarr = fa.
arrays();
1675 if (!ifabarr[box_no](i,j,k)) { fabarr[box_no](i,j,k,n) = 0; }
1684#pragma omp parallel if (Gpu::notInLaunchRegion())
1688 const Box& bx = mfi.tilebox();
1689 auto fab = fa.
array(mfi);
1690 auto const ifab = msk.
array(mfi);
1693 if (!ifab(i,j,k)) { fab(i,j,k,n) = 0; }
1705template <BaseFabType FAB>
1713 fa.
os_temp->ParallelCopy_finish();
1720template <BaseFabType FAB>
1723 int scomp,
int dcomp,
int ncomp)
1729 void*
pdst = dst[mfi].dataPtr(dcomp);
1730 void const* psrc = src[mfi].dataPtr(scomp);
1739template <BaseFabType FAB>
1747template <BaseFabType FAB>
1750 int scomp,
int dcomp,
int ncomp)
1756 void*
pdst = dst[mfi].dataPtr(dcomp);
1757 void const* psrc = src[mfi].dataPtr(scomp);
1766template <BaseFabType FAB>
1781template <BaseFabType FAB>
1784 typename FAB::value_type value)
1801 if (ma[box_no](i,j,k,comp) == value) {
1818 if (arr(i,j,k,comp) == value) {
1829 int const* tmp = aa.copyToHost();
1845 const Box& bx = mfi.growntilebox(nghost);
1849 if (fab(i,j,k,comp) == value) {
1860#if defined(AMREX_USE_OMP) && defined(_OPENMP) && (_OPENMP < 201307 || (defined(__NVCOMPILER) && __NVCOMPILER_MAJOR__ < 23))
1861#pragma omp critical (amrex_indexfromvalue)
1862#elif defined(AMREX_USE_OMP)
1863#pragma omp atomic capture
1870 if (old ==
false) { loc = priv_loc; }
1889template <BaseFabType FAB>
1890typename FAB::value_type
1892 IntVect const& nghost,
bool local =
false)
1895 BL_ASSERT(
x.DistributionMap() ==
y.DistributionMap());
1896 BL_ASSERT(
x.nGrowVect().allGE(nghost) &&
y.nGrowVect().allGE(nghost));
1900 using T =
typename FAB::value_type;
1904 auto const& xma =
x.const_arrays();
1905 auto const& yma =
y.const_arrays();
1910 auto const& xfab = xma[box_no];
1911 auto const& yfab = yma[box_no];
1912 for (
int n = 0; n < ncomp; ++n) {
1913 t += xfab(i,j,k,xcomp+n) * yfab(i,j,k,ycomp+n);
1921#pragma omp parallel if (!system::regtest_reduction) reduction(+:sm)
1925 Box const& bx = mfi.growntilebox(nghost);
1926 auto const& xfab =
x.const_array(mfi);
1927 auto const& yfab =
y.const_array(mfi);
1930 sm += xfab(i,j,k,xcomp+n) * yfab(i,j,k,ycomp+n);
1951template <BaseFabType FAB>
1952typename FAB::value_type
1959 using T =
typename FAB::value_type;
1963 auto const& xma =
x.const_arrays();
1968 auto const& xfab = xma[box_no];
1969 for (
int n = 0; n < ncomp; ++n) {
1970 auto v = xfab(i,j,k,xcomp+n);
1979#pragma omp parallel if (!system::regtest_reduction) reduction(+:sm)
1983 Box const& bx = mfi.growntilebox(nghost);
1984 auto const& xfab =
x.const_array(mfi);
1987 auto v = xfab(i,j,k,xcomp+n);
2012template <BaseFabType IFAB, BaseFabType FAB>
2013typename FAB::value_type
2018 BL_ASSERT(
x.boxArray() ==
y.boxArray() &&
x.boxArray() ==
mask.boxArray());
2019 BL_ASSERT(
x.DistributionMap() ==
y.DistributionMap() &&
x.DistributionMap() ==
mask.DistributionMap());
2020 BL_ASSERT(
x.nGrowVect().allGE(nghost) &&
y.nGrowVect().allGE(nghost) &&
2021 mask.nGrowVect().allGE(nghost));
2025 using T =
typename FAB::value_type;
2029 auto const& mma =
mask.const_arrays();
2030 auto const& xma =
x.const_arrays();
2031 auto const& yma =
y.const_arrays();
2036 auto m = T(mma[box_no](i,j,k));
2038 auto const& xfab = xma[box_no];
2039 auto const& yfab = yma[box_no];
2040 for (
int n = 0; n < ncomp; ++n) {
2041 t += xfab(i,j,k,xcomp+n) * yfab(i,j,k,ycomp+n);
2050#pragma omp parallel if (!system::regtest_reduction) reduction(+:sm)
2054 Box const& bx = mfi.growntilebox(nghost);
2055 auto const& mfab =
mask.const_array(mfi);
2056 auto const& xfab =
x.const_array(mfi);
2057 auto const& yfab =
y.const_array(mfi);
2060 auto m = T(mfab(i,j,k));
2061 sm += m * xfab(i,j,k,xcomp+n) * yfab(i,j,k,ycomp+n);
2083template <BaseFabType IFAB, BaseFabType FAB>
2084typename FAB::value_type
2086 IntVect const& nghost,
bool local =
false)
2090 BL_ASSERT(
x.nGrowVect().allGE(nghost) &&
mask.nGrowVect().allGE(nghost));
2094 using T =
typename FAB::value_type;
2098 auto const& mma =
mask.const_arrays();
2099 auto const& xma =
x.const_arrays();
2104 auto m = T(mma[box_no](i,j,k));
2106 auto const& xfab = xma[box_no];
2107 for (
int n = 0; n < ncomp; ++n) {
2108 auto v = xfab(i,j,k,xcomp+n);
2118#pragma omp parallel if (!system::regtest_reduction) reduction(+:sm)
2122 Box const& bx = mfi.growntilebox(nghost);
2123 auto const& mfab =
mask.const_array(mfi);
2124 auto const& xfab =
x.const_array(mfi);
2127 auto m = T(mfab(i,j,k));
2128 auto v = xfab(i,j,k,xcomp+n);
2142template <MultiFabLike MF>
2143void setVal (MF& dst,
typename MF::value_type val)
2149template <MultiFabLike MF>
2150void setBndry (MF& dst,
typename MF::value_type val,
int scomp,
int ncomp)
2152 dst.setBndry(val, scomp, ncomp);
2156template <MultiFabLike MF>
2157void Scale (MF& dst,
typename MF::value_type val,
int scomp,
int ncomp,
int nghost)
2159 dst.mult(val, scomp, ncomp, nghost);
2163template <MultiFabLike DMF, MultiFabLike SMF>
2164void LocalCopy (DMF& dst, SMF
const& src,
int scomp,
int dcomp,
2165 int ncomp,
IntVect const& nghost)
2167 amrex::Copy(dst, src, scomp, dcomp, ncomp, nghost);
2171template <MultiFabLike MF>
2172void LocalAdd (MF& dst, MF
const& src,
int scomp,
int dcomp,
2173 int ncomp,
IntVect const& nghost)
2175 amrex::Add(dst, src, scomp, dcomp, ncomp, nghost);
2179template <MultiFabLike MF>
2180void Saxpy (MF& dst,
typename MF::value_type a, MF
const& src,
int scomp,
int dcomp,
2181 int ncomp,
IntVect const& nghost)
2183 MF::Saxpy(dst, a, src, scomp, dcomp, ncomp, nghost);
2187template <MultiFabLike MF>
2188void Xpay (MF& dst,
typename MF::value_type a, MF
const& src,
int scomp,
int dcomp,
2189 int ncomp,
IntVect const& nghost)
2191 MF::Xpay(dst, a, src, scomp, dcomp, ncomp, nghost);
2195template <MultiFabLike MF>
2196void Saxpy_Xpay (MF& dst,
typename MF::value_type a_saxpy, MF
const& src_saxpy,
2197 typename MF::value_type a_xpay, MF
const& src_xpay,
int scomp,
int dcomp,
2198 int ncomp,
IntVect const& nghost)
2200 MF::Saxpy_Xpay(dst, a_saxpy, src_saxpy, a_xpay, src_xpay, scomp, dcomp, ncomp, nghost);
2204template <MultiFabLike MF>
2205void Saxpy_Saxpy (MF& dst1,
typename MF::value_type a1, MF
const& src1,
2206 MF& dst2,
typename MF::value_type a2, MF
const& src2,
int scomp,
int dcomp,
2207 int ncomp,
IntVect const& nghost)
2209 MF::Saxpy_Saxpy(dst1, a1, src1, dst2, a2, src2, scomp, dcomp, ncomp, nghost);
2213template <MultiFabLike MF>
2215 MF& dst2,
typename MF::value_type a2, MF
const& src,
int scomp,
int dcomp,
2216 int ncomp,
IntVect const& nghost)
2218 MF::Saypy_Saxpy(dst1, a1, dst2, a2, src, scomp, dcomp, ncomp, nghost);
2222template <MultiFabLike MF>
2224 typename MF::value_type a, MF
const& src_a,
int acomp,
2225 typename MF::value_type b, MF
const& src_b,
int bcomp,
2226 int dcomp,
int ncomp,
IntVect const& nghost)
2228 MF::LinComb(dst, a, src_a, acomp, b, src_b, bcomp, dcomp, ncomp, nghost);
2232template <MultiFabLike MF>
2238 dst.ParallelCopy(src, scomp, dcomp, ncomp, ng_src, ng_dst, period);
2242template <MultiFabLike MF>
2243[[nodiscard]]
typename MF::value_type
2247 return mf.norminf(scomp, ncomp, nghost, local);
2251template <MultiFabLike MF, std::
size_t N>
2254 for (
auto& mf: dst) {
2260template <MultiFabLike MF, std::
size_t N>
2263 for (
auto& mf : dst) {
2269template <MultiFabLike MF, std::
size_t N>
2273 for (
auto& mf : dst) {
2274 mf.
mult(val, scomp, ncomp, nghost);
2279template <MultiFabLike DMF, MultiFabLike SMF, std::
size_t N>
2281 int ncomp,
IntVect const& nghost)
2283 for (std::size_t i = 0; i < N; ++i) {
2284 amrex::Copy(dst[i], src[i], scomp, dcomp, ncomp, nghost);
2289template <MultiFabLike MF, std::
size_t N>
2291 int ncomp,
IntVect const& nghost)
2293 for (std::size_t i = 0; i < N; ++i) {
2294 amrex::Add(dst[i], src[i], scomp, dcomp, ncomp, nghost);
2299template <MultiFabLike MF, std::
size_t N>
2301 Array<MF,N> const& src,
int scomp,
int dcomp,
int ncomp,
2304 for (std::size_t i = 0; i < N; ++i) {
2305 MF::Saxpy(dst[i], a, src[i], scomp, dcomp, ncomp, nghost);
2310template <MultiFabLike MF, std::
size_t N>
2312 Array<MF,N> const& src,
int scomp,
int dcomp,
int ncomp,
2315 for (std::size_t i = 0; i < N; ++i) {
2316 MF::Xpay(dst[i], a, src[i], scomp, dcomp, ncomp, nghost);
2321template <MultiFabLike MF, std::
size_t N>
2323 typename MF::value_type a,
Array<MF,N> const& src_a,
int acomp,
2324 typename MF::value_type b,
Array<MF,N> const& src_b,
int bcomp,
2325 int dcomp,
int ncomp,
IntVect const& nghost)
2327 for (std::size_t i = 0; i < N; ++i) {
2328 MF::LinComb(dst[i], a, src_a[i], acomp, b, src_b[i], bcomp, dcomp, ncomp, nghost);
2333template <MultiFabLike MF, std::
size_t N>
2335 int scomp,
int dcomp,
int ncomp,
2340 for (std::size_t i = 0; i < N; ++i) {
2341 dst[i].ParallelCopy(src[i], scomp, dcomp, ncomp, ng_src, ng_dst, period);
2346template <MultiFabLike MF, std::
size_t N>
2347[[nodiscard]]
typename MF::value_type
2351 auto r =
typename MF::value_type(0);
2352 for (std::size_t i = 0; i < N; ++i) {
2353 auto tmp = mf[i].norminf(scomp, ncomp, nghost,
true);
2354 r = std::max(r,tmp);
2363template <MultiFabLike MF, std::
size_t N>
2367 return mf[0].nComp();
2371template <MultiFabLike MF, std::
size_t N>
2375 return mf[0].nGrowVect();
2379template <MultiFabLike MF, std::
size_t N>
2381[[nodiscard]] BoxArray
const&
2384 return mf[0].boxArray();
2388template <MultiFabLike MF, std::
size_t N>
2390[[nodiscard]] DistributionMapping
const&
2393 return mf[0].DistributionMap();
2404FabArray<BaseFab<int>>
2415 const std::vector<IntVect>& pshifts = period.
shiftIntVect();
2422#pragma omp parallel if (!run_on_gpu)
2425 std::vector< std::pair<int,Box> > isects;
2429 const Box& bx =
mask[mfi].box();
2430 auto const& arr =
mask.array(mfi);
2432 for (
const auto& iv : pshifts)
2435 for (
const auto& is : isects)
2437 Box const& b = is.second-iv;
2438 if (iv == 0 && b == bx) {
continue; }
#define BL_PROFILE(a)
Definition AMReX_BLProfiler.H:551
#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:1130
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:676
std::vector< std::pair< int, Box > > intersections(const Box &bx) const
Return all intersections of bx with this BoxArray.
Definition AMReX_BoxArray.cpp:1186
__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:2705
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:3213
void setBndry(value_type val)
Set all values in the boundary region to val.
Definition AMReX_FabArray.H:2732
std::unique_ptr< FabArray< FAB > > os_temp
Definition AMReX_FabArray.H:1906
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:2950
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:98
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:172
Dynamically allocated vector for trivially copyable data.
Definition AMReX_PODVector.H:308
T * data() noexcept
Definition AMReX_PODVector.H:666
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
void Sum(Gpu::DeviceVector< T > &v, MPI_Comm comm)
Definition AMReX_GpuParallelReduce.H:34
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:1749
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:1659
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:2157
BoxArray const & boxArray(FabArrayBase const &fa)
Convenience wrapper that forwards to fa.boxArray().
Definition AMReX_FabArrayBase.cpp:2862
DistributionMapping const & DistributionMap(FabArrayBase const &fa)
Convenience wrapper that forwards to fa.DistributionMap().
Definition AMReX_FabArrayBase.cpp:2867
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:1891
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:2196
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:1625
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:2405
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:1603
bool isMFIterSafe(const FabArrayBase &x, const FabArrayBase &y)
Definition AMReX_MFIter.H:252
int nComp(FabArrayBase const &fa)
Convenience wrapper that forwards to fa.nComp().
Definition AMReX_FabArrayBase.cpp:2852
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:2205
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:1783
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:2223
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:2233
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:2214
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:1457
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:1552
void OverrideSync_finish(FabArray< FAB > &fa)
Finish the current masked OverrideSync_nowait() operation.
Definition AMReX_FabArrayUtility.H:1707
void single_task(L &&f) noexcept
Definition AMReX_GpuLaunchFunctsC.H:1239
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:1722
IntVect nGrowVect(FabArrayBase const &fa)
Convenience wrapper that forwards to fa.nGrowVect().
Definition AMReX_FabArrayBase.cpp:2857
void LocalCopy(DMF &dst, SMF const &src, int scomp, int dcomp, int ncomp, IntVect const &nghost)
dst = src
Definition AMReX_FabArrayUtility.H:2164
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:2150
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:2244
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:2188
void Abort(const std::string &msg)
Print a fatal-error message to stderr and abort execution.
Definition AMReX.cpp:241
const int[]
Definition AMReX_BLProfiler.cpp:1664
void OverrideSync(FabArray< FAB > &fa, FabArray< IFAB > const &msk, const Periodicity &period)
Synchronize shared nodal values using an owner mask.
Definition AMReX_FabArrayUtility.H:1647
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:1505
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:1409
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:2180
void LocalAdd(MF &dst, MF const &src, int scomp, int dcomp, int ncomp, IntVect const &nghost)
dst += src
Definition AMReX_FabArrayUtility.H:2172
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:2143
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
Definition AMReX_MFIter.H:20
Struct for holding types.
Definition AMReX_TypeList.H:13