1#ifndef AMREX_FABARRAY_UTILITY_H_
2#define AMREX_FABARRAY_UTILITY_H_
3#include <AMReX_Config.H>
14template <BaseFabType FAB,
class F>
15typename FAB::value_type
23template <BaseFabType FAB,
class F>
24typename FAB::value_type
25ReduceSum_host (FabArray<FAB>
const& fa, IntVect
const& nghost, F
const& f)
27 using value_type =
typename FAB::value_type;
31#pragma omp parallel if (!system::regtest_reduction) reduction(+:sm)
33 for (MFIter mfi(fa,
true); mfi.isValid(); ++mfi)
35 const Box& bx = mfi.growntilebox(nghost);
36 auto const& arr = fa.const_array(mfi);
48template <
class OP, BaseFabType FAB,
class F>
49std::conditional_t<std::is_same_v<OP,ReduceOpLogicalAnd> ||
50 std::is_same_v<OP,ReduceOpLogicalOr>,
51 int,
typename FAB::value_type>
52ReduceMF (FabArray<FAB>
const& fa, IntVect
const& nghost, F
const& f)
54 using T = std::conditional_t<std::is_same_v<OP,ReduceOpLogicalAnd> ||
55 std::is_same_v<OP,ReduceOpLogicalOr>,
56 int,
typename FAB::value_type>;
57 auto typ = fa.ixType();
58 auto const& ma = fa.const_arrays();
59 return ParReduce(TypeList<OP>{}, TypeList<T>{}, fa, nghost,
60 [=]
AMREX_GPU_DEVICE (
int box_no,
int i,
int j,
int k)
noexcept -> GpuTuple<T>
66template <
class OP, BaseFabType FAB1, BaseFabType FAB2,
class F>
67std::conditional_t<std::is_same_v<OP,ReduceOpLogicalAnd> ||
68 std::is_same_v<OP,ReduceOpLogicalOr>,
69 int,
typename FAB1::value_type>
70ReduceMF (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2, IntVect
const& nghost, F
const& f)
72 using T = std::conditional_t<std::is_same_v<OP,ReduceOpLogicalAnd> ||
73 std::is_same_v<OP,ReduceOpLogicalOr>,
74 int,
typename FAB1::value_type>;
75 auto typ = fa1.ixType();
76 auto const& ma1 = fa1.const_arrays();
77 auto const& ma2 = fa2.const_arrays();
78 return ParReduce(TypeList<OP>{}, TypeList<T>{}, fa1, nghost,
79 [=]
AMREX_GPU_DEVICE (
int box_no,
int i,
int j,
int k)
noexcept -> GpuTuple<T>
82 ma1[box_no], ma2[box_no])) };
86template <
class OP, BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
87std::conditional_t<std::is_same_v<OP,ReduceOpLogicalAnd> ||
88 std::is_same_v<OP,ReduceOpLogicalOr>,
89 int,
typename FAB1::value_type>
90ReduceMF (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
91 FabArray<FAB3>
const& fa3, IntVect
const& nghost, F
const& f)
93 using T = std::conditional_t<std::is_same_v<OP,ReduceOpLogicalAnd> ||
94 std::is_same_v<OP,ReduceOpLogicalOr>,
95 int,
typename FAB1::value_type>;
96 auto typ = fa1.ixType();
97 auto const& ma1 = fa1.const_arrays();
98 auto const& ma2 = fa2.const_arrays();
99 auto const& ma3 = fa3.const_arrays();
100 return ParReduce(TypeList<OP>{}, TypeList<T>{}, fa1, nghost,
101 [=]
AMREX_GPU_DEVICE (
int box_no,
int i,
int j,
int k)
noexcept -> GpuTuple<T>
104 ma1[box_no], ma2[box_no], ma3[box_no])) };
108template <BaseFabType FAB,
class F>
110typename FAB::value_type ReduceSum_host_wrapper (FabArray<FAB>
const& fa, IntVect
const& nghost, F&& f)
112 return ReduceSum_host(fa,nghost,std::forward<F>(f));
115template <BaseFabType FAB,
class F>
117typename FAB::value_type ReduceSum_host_wrapper (FabArray<FAB>
const& fa, IntVect
const& nghost, F&& f)
120 amrex::Abort(
"ReduceSum: Launch Region is off. Device lambda cannot be called by host.");
126template <BaseFabType FAB,
class F>
127typename FAB::value_type
131 return fudetail::ReduceMF<ReduceOpSum>(fa, nghost, std::forward<F>(f));
133 return fudetail::ReduceSum_host_wrapper(fa, nghost, std::forward<F>(f));
137template <BaseFabType FAB,
class F>
138typename FAB::value_type
141 return fudetail::ReduceSum_host(fa, nghost, std::forward<F>(f));
145template <BaseFabType FAB1, BaseFabType FAB2,
class F>
146typename FAB1::value_type
155template <BaseFabType FAB1, BaseFabType FAB2,
class F>
156typename FAB1::value_type
157ReduceSum_host (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
158 IntVect
const& nghost, F
const& f)
160 using value_type =
typename FAB1::value_type;
164#pragma omp parallel if (!system::regtest_reduction) reduction(+:sm)
166 for (MFIter mfi(fa1,
true); mfi.isValid(); ++mfi)
168 const Box& bx = mfi.growntilebox(nghost);
169 const auto& arr1 = fa1.const_array(mfi);
170 const auto& arr2 = fa2.const_array(mfi);
171 sm += f(bx, arr1, arr2);
182template <BaseFabType FAB1, BaseFabType FAB2,
class F>
184typename FAB1::value_type ReduceSum_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
185 IntVect
const& nghost, F&& f)
187 return ReduceSum_host(fa1,fa2,nghost,std::forward<F>(f));
190template <BaseFabType FAB1, BaseFabType FAB2,
class F>
192typename FAB1::value_type ReduceSum_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
193 IntVect
const& nghost, F&& f)
196 amrex::Abort(
"ReduceSum: Launch Region is off. Device lambda cannot be called by host.");
202template <BaseFabType FAB1, BaseFabType FAB2,
class F>
203typename FAB1::value_type
208 return fudetail::ReduceMF<ReduceOpSum>(fa1,fa2,nghost,std::forward<F>(f));
210 return fudetail::ReduceSum_host_wrapper(fa1,fa2,nghost, std::forward<F>(f));
214template <BaseFabType FAB1, BaseFabType FAB2,
class F>
215typename FAB1::value_type
216ReduceSum (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
219 return fudetail::ReduceSum_host(fa1,fa2,nghost,std::forward<F>(f));
223template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
224typename FAB1::value_type
233template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
234typename FAB1::value_type
235ReduceSum_host (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
236 FabArray<FAB3>
const& fa3, IntVect
const& nghost, F
const& f)
238 using value_type =
typename FAB1::value_type;
242#pragma omp parallel if (!system::regtest_reduction) reduction(+:sm)
244 for (MFIter mfi(fa1,
true); mfi.isValid(); ++mfi)
246 const Box& bx = mfi.growntilebox(nghost);
247 const auto& arr1 = fa1.const_array(mfi);
248 const auto& arr2 = fa2.const_array(mfi);
249 const auto& arr3 = fa3.const_array(mfi);
250 sm += f(bx, arr1, arr2, arr3);
261template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
263typename FAB1::value_type ReduceSum_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
264 FabArray<FAB3>
const& fa3, IntVect
const& nghost, F&& f)
266 return fudetail::ReduceSum_host(fa1,fa2,fa3,nghost,std::forward<F>(f));
269template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
271typename FAB1::value_type ReduceSum_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
272 FabArray<FAB3>
const& fa3, IntVect
const& nghost, F&& f)
275 amrex::Abort(
"ReduceSum: Launch Region is off. Device lambda cannot be called by host.");
281template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
282typename FAB1::value_type
287 return fudetail::ReduceMF<ReduceOpSum>(fa1,fa2,fa3,nghost,std::forward<F>(f));
289 return fudetail::ReduceSum_host_wrapper(fa1,fa2,fa3,nghost,std::forward<F>(f));
293template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
294typename FAB1::value_type
295ReduceSum (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
296 FabArray<FAB3>
const& fa3,
IntVect const& nghost,
F&& f)
298 return fudetail::ReduceSum_host(fa1,fa2,fa3,nghost,std::forward<F>(f));
302template <BaseFabType FAB,
class F>
303typename FAB::value_type
311template <BaseFabType FAB,
class F>
312typename FAB::value_type
313ReduceMin_host (FabArray<FAB>
const& fa, IntVect
const& nghost, F
const& f)
315 using value_type =
typename FAB::value_type;
316 value_type r = std::numeric_limits<value_type>::max();
319#pragma omp parallel reduction(min:r)
321 for (MFIter mfi(fa,
true); mfi.isValid(); ++mfi)
323 const Box& bx = mfi.growntilebox(nghost);
324 const auto& arr = fa.const_array(mfi);
325 r = std::min(r, f(bx, arr));
335template <BaseFabType FAB,
class F>
337typename FAB::value_type ReduceMin_host_wrapper (FabArray<FAB>
const& fa, IntVect
const& nghost, F&& f)
339 return ReduceMin_host(fa,nghost,std::forward<F>(f));
342template <BaseFabType FAB,
class F>
344typename FAB::value_type ReduceMin_host_wrapper (FabArray<FAB>
const& fa, IntVect
const& nghost, F&& f)
347 amrex::Abort(
"ReduceMin: Launch Region is off. Device lambda cannot be called by host.");
353template <BaseFabType FAB,
class F>
354typename FAB::value_type
358 return fudetail::ReduceMF<ReduceOpMin>(fa, nghost, std::forward<F>(f));
360 return fudetail::ReduceMin_host_wrapper(fa, nghost, std::forward<F>(f));
364template <BaseFabType FAB,
class F>
365typename FAB::value_type
368 return fudetail::ReduceMin_host(fa, nghost, std::forward<F>(f));
372template <BaseFabType FAB1, BaseFabType FAB2,
class F>
373typename FAB1::value_type
381template <BaseFabType FAB1, BaseFabType FAB2,
class F>
382typename FAB1::value_type
383ReduceMin_host (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
384 IntVect
const& nghost, F
const& f)
386 using value_type =
typename FAB1::value_type;
387 value_type r = std::numeric_limits<value_type>::max();
390#pragma omp parallel reduction(min:r)
392 for (MFIter mfi(fa1,
true); mfi.isValid(); ++mfi)
394 const Box& bx = mfi.growntilebox(nghost);
395 const auto& arr1 = fa1.const_array(mfi);
396 const auto& arr2 = fa2.const_array(mfi);
397 r = std::min(r, f(bx, arr1, arr2));
408template <BaseFabType FAB1, BaseFabType FAB2,
class F>
410typename FAB1::value_type ReduceMin_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
411 IntVect
const& nghost, F&& f)
413 return fudetail::ReduceMin_host(fa1,fa2,nghost,std::forward<F>(f));
416template <BaseFabType FAB1, BaseFabType FAB2,
class F>
418typename FAB1::value_type ReduceMin_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
419 IntVect
const& nghost, F&& f)
422 amrex::Abort(
"ReduceMin: Launch Region is off. Device lambda cannot be called by host.");
428template <BaseFabType FAB1, BaseFabType FAB2,
class F>
429typename FAB1::value_type
434 return fudetail::ReduceMF<ReduceOpMin>(fa1,fa2,nghost,std::forward<F>(f));
436 return fudetail::ReduceMin_host_wrapper(fa1,fa2,nghost,std::forward<F>(f));
440template <BaseFabType FAB1, BaseFabType FAB2,
class F>
441typename FAB1::value_type
442ReduceMin (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
445 return fudetail::ReduceMin_host(fa1,fa2,nghost,std::forward<F>(f));
449template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
450typename FAB1::value_type
459template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
460typename FAB1::value_type
461ReduceMin_host (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
462 FabArray<FAB3>
const& fa3, IntVect
const& nghost, F
const& f)
464 using value_type =
typename FAB1::value_type;
465 value_type r = std::numeric_limits<value_type>::max();
468#pragma omp parallel reduction(min:r)
470 for (MFIter mfi(fa1,
true); mfi.isValid(); ++mfi)
472 const Box& bx = mfi.growntilebox(nghost);
473 const auto& arr1 = fa1.const_array(mfi);
474 const auto& arr2 = fa2.const_array(mfi);
475 const auto& arr3 = fa3.const_array(mfi);
476 r = std::min(r, f(bx, arr1, arr2, arr3));
487template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
489typename FAB1::value_type ReduceMin_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
490 FabArray<FAB3>
const& fa3, IntVect
const& nghost, F&& f)
492 return fudetail::ReduceMin_host(fa1,fa2,fa3,nghost,std::forward<F>(f));
495template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
497typename FAB1::value_type ReduceMin_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
498 FabArray<FAB3>
const& fa3, IntVect
const& nghost, F&& f)
501 amrex::Abort(
"ReduceMin: Launch Region is off. Device lambda cannot be called by host.");
507template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
508typename FAB1::value_type
513 return fudetail::ReduceMF<ReduceOpMin>(fa1,fa2,fa3,nghost,std::forward<F>(f));
515 return fudetail::ReduceMin_host_wrapper(fa1,fa2,fa3,nghost,std::forward<F>(f));
519template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
520typename FAB1::value_type
521ReduceMin (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
522 FabArray<FAB3>
const& fa3,
IntVect const& nghost,
F&& f)
524 return fudetail::ReduceMin_host(fa1,fa2,fa3,nghost,std::forward<F>(f));
528template <BaseFabType FAB,
class F>
529typename FAB::value_type
537template <BaseFabType FAB,
class F>
538typename FAB::value_type
539ReduceMax_host (FabArray<FAB>
const& fa, IntVect
const& nghost, F
const& f)
541 using value_type =
typename FAB::value_type;
542 value_type r = std::numeric_limits<value_type>::lowest();
545#pragma omp parallel reduction(max:r)
547 for (MFIter mfi(fa,
true); mfi.isValid(); ++mfi)
549 const Box& bx = mfi.growntilebox(nghost);
550 const auto& arr = fa.const_array(mfi);
551 r = std::max(r, f(bx, arr));
562template <BaseFabType FAB,
class F>
564typename FAB::value_type ReduceMax_host_wrapper (FabArray<FAB>
const& fa, IntVect
const& nghost, F&& f)
566 return ReduceMax_host(fa,nghost,std::forward<F>(f));
569template <BaseFabType FAB,
class F>
571typename FAB::value_type ReduceMax_host_wrapper (FabArray<FAB>
const& fa, IntVect
const& nghost, F&& f)
574 amrex::Abort(
"ReduceMax: Launch Region is off. Device lambda cannot be called by host.");
580template <BaseFabType FAB,
class F>
581typename FAB::value_type
585 return fudetail::ReduceMF<ReduceOpMax>(fa,nghost,std::forward<F>(f));
587 return fudetail::ReduceMax_host_wrapper(fa,nghost,std::forward<F>(f));
591template <BaseFabType FAB,
class F>
592typename FAB::value_type
595 return fudetail::ReduceMax_host(fa,nghost,std::forward<F>(f));
599template <BaseFabType FAB1, BaseFabType FAB2,
class F>
600typename FAB1::value_type
608template <BaseFabType FAB1, BaseFabType FAB2,
class F>
609typename FAB1::value_type
610ReduceMax_host (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
611 IntVect
const& nghost, F
const& f)
613 using value_type =
typename FAB1::value_type;
614 value_type r = std::numeric_limits<value_type>::lowest();
617#pragma omp parallel reduction(max:r)
619 for (MFIter mfi(fa1,
true); mfi.isValid(); ++mfi)
621 const Box& bx = mfi.growntilebox(nghost);
622 const auto& arr1 = fa1.const_array(mfi);
623 const auto& arr2 = fa2.const_array(mfi);
624 r = std::max(r, f(bx, arr1, arr2));
635template <BaseFabType FAB1, BaseFabType FAB2,
class F>
637typename FAB1::value_type ReduceMax_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
638 IntVect
const& nghost, F&& f)
640 return ReduceMax_host(fa1,fa2,nghost,std::forward<F>(f));
643template <BaseFabType FAB1, BaseFabType FAB2,
class F>
645typename FAB1::value_type ReduceMax_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
646 IntVect
const& nghost, F&& f)
649 amrex::Abort(
"ReduceMax: Launch Region is off. Device lambda cannot be called by host.");
655template <BaseFabType FAB1, BaseFabType FAB2,
class F>
656typename FAB1::value_type
661 return fudetail::ReduceMF<ReduceOpMax>(fa1,fa2,nghost,std::forward<F>(f));
663 return fudetail::ReduceMax_host_wrapper(fa1,fa2,nghost,std::forward<F>(f));
667template <BaseFabType FAB1, BaseFabType FAB2,
class F>
668typename FAB1::value_type
669ReduceMax (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
672 return fudetail::ReduceMax_host(fa1,fa2,nghost,std::forward<F>(f));
676template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
677typename FAB1::value_type
686template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
687typename FAB1::value_type
688ReduceMax_host (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
689 FabArray<FAB3>
const& fa3, IntVect
const& nghost, F
const& f)
691 using value_type =
typename FAB1::value_type;
692 value_type r = std::numeric_limits<value_type>::lowest();
695#pragma omp parallel reduction(max:r)
697 for (MFIter mfi(fa1,
true); mfi.isValid(); ++mfi)
699 const Box& bx = mfi.growntilebox(nghost);
700 const auto& arr1 = fa1.const_array(mfi);
701 const auto& arr2 = fa2.const_array(mfi);
702 const auto& arr3 = fa3.const_array(mfi);
703 r = std::max(r, f(bx, arr1, arr2, arr3));
714template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
716typename FAB1::value_type ReduceMax_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
717 FabArray<FAB3>
const& fa3, IntVect
const& nghost, F&& f)
719 return fudetail::ReduceMax_host(fa1,fa2,fa3,nghost,std::forward<F>(f));
722template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
724typename FAB1::value_type ReduceMax_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
725 FabArray<FAB3>
const& fa3, IntVect
const& nghost, F&& f)
728 amrex::Abort(
"ReduceMax: Launch Region is off. Device lambda cannot be called by host.");
734template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
735typename FAB1::value_type
740 return fudetail::ReduceMF<ReduceOpMax>(fa1,fa2,fa3,nghost,std::forward<F>(f));
742 return fudetail::ReduceMax_host_wrapper(fa1,fa2,fa3,nghost,std::forward<F>(f));
746template <BaseFabType FAB1, BaseFabType FAB2, BaseFabType FAB3,
class F>
747typename FAB1::value_type
748ReduceMax (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
749 FabArray<FAB3>
const& fa3,
IntVect const& nghost,
F&& f)
751 return fudetail::ReduceMax_host(fa1,fa2,fa3,nghost,std::forward<F>(f));
755template <BaseFabType FAB,
class F>
764template <BaseFabType FAB,
class F>
766ReduceLogicalAnd_host (FabArray<FAB>
const& fa, IntVect
const& nghost, F
const& f)
771#pragma omp parallel reduction(&&:r)
773 for (MFIter mfi(fa,
true); mfi.isValid(); ++mfi)
775 const Box& bx = mfi.growntilebox(nghost);
776 const auto& arr = fa.const_array(mfi);
788template <BaseFabType FAB,
class F>
790bool ReduceLogicalAnd_host_wrapper (FabArray<FAB>
const& fa, IntVect
const& nghost, F&& f)
792 return ReduceLogicalAnd_host(fa,nghost,std::forward<F>(f));
795template <BaseFabType FAB,
class F>
797bool ReduceLogicalAnd_host_wrapper (FabArray<FAB>
const& fa, IntVect
const& nghost, F&& f)
800 amrex::Abort(
"ReduceLogicalAnd: Launch Region is off. Device lambda cannot be called by host.");
806template <BaseFabType FAB,
class F>
811 return fudetail::ReduceMF<ReduceOpLogicalAnd>(fa,nghost,std::forward<F>(f));
813 return fudetail::ReduceLogicalAnd_host_wrapper(fa,nghost,std::forward<F>(f));
817template <BaseFabType FAB,
class F>
821 return fudetail::ReduceLogicalAnd_host(fa,nghost,std::forward<F>(f));
825template <BaseFabType FAB1, BaseFabType FAB2,
class F>
835template <BaseFabType FAB1, BaseFabType FAB2,
class F>
837ReduceLogicalAnd_host (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
838 IntVect
const& nghost, F
const& f)
843#pragma omp parallel reduction(&&:r)
845 for (MFIter mfi(fa1,
true); mfi.isValid(); ++mfi)
847 const Box& bx = mfi.growntilebox(nghost);
848 const auto& arr1 = fa1.const_array(mfi);
849 const auto& arr2 = fa2.const_array(mfi);
850 r = r && f(bx, arr1, arr2);
861template <BaseFabType FAB1, BaseFabType FAB2,
class F>
863bool ReduceLogicalAnd_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
864 IntVect
const& nghost, F&& f)
866 return ReduceLogicalAnd_host(fa1,fa2,nghost,std::forward<F>(f));
869template <BaseFabType FAB1, BaseFabType FAB2,
class F>
871bool ReduceLogicalAnd_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
872 IntVect
const& nghost, F&& f)
875 amrex::Abort(
"ReduceLogicalAnd: Luanch Region is off. Device lambda cannot be called by host.");
881template <BaseFabType FAB1, BaseFabType FAB2,
class F>
887 return fudetail::ReduceMF<ReduceOpLogicalAnd>(fa1,fa2,nghost,std::forward<F>(f));
889 return fudetail::ReduceLogicalAnd_host_wrapper(fa1,fa2,nghost,std::forward<F>(f));
893template <BaseFabType FAB1, BaseFabType FAB2,
class F>
898 return fudetail::ReduceLogicalAnd_host(fa1,fa2,nghost,std::forward<F>(f));
902template <BaseFabType FAB,
class F>
911template <BaseFabType FAB,
class F>
913ReduceLogicalOr_host (FabArray<FAB>
const& fa, IntVect
const& nghost, F
const& f)
918#pragma omp parallel reduction(||:r)
920 for (MFIter mfi(fa,
true); mfi.isValid(); ++mfi)
922 const Box& bx = mfi.growntilebox(nghost);
923 const auto& arr = fa.const_array(mfi);
935template <BaseFabType FAB,
class F>
937bool ReduceLogicalOr_host_wrapper (FabArray<FAB>
const& fa, IntVect
const& nghost, F&& f)
939 return ReduceLogicalOr_host(fa,nghost,std::forward<F>(f));
942template <BaseFabType FAB,
class F>
944bool ReduceLogicalOr_host (FabArray<FAB>
const& fa, IntVect
const& nghost, F&& )
947 amrex::Abort(
"ReduceLogicalOr: Launch Region is off. Device lambda cannot be called by host.");
953template <BaseFabType FAB,
class F>
958 return fudetail::ReduceMF<ReduceOpLogicalOr>(fa,nghost,std::forward<F>(f));
960 return fudetail::ReduceLogicalOr_host_wrapper(fa,nghost,std::forward<F>(f));
964template <BaseFabType FAB,
class F>
968 return fudetail::ReduceLogicalOr_host(fa,nghost,std::forward<F>(f));
972template <BaseFabType FAB1, BaseFabType FAB2,
class F>
982template <BaseFabType FAB1, BaseFabType FAB2,
class F>
984ReduceLogicalOr_host (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
985 IntVect
const& nghost, F
const& f)
990#pragma omp parallel reduction(||:r)
992 for (MFIter mfi(fa1,
true); mfi.isValid(); ++mfi)
994 const Box& bx = mfi.growntilebox(nghost);
995 const auto& arr1 = fa1.const_array(mfi);
996 const auto& arr2 = fa2.const_array(mfi);
997 r = r || f(bx, arr1, arr2);
1008template <BaseFabType FAB1, BaseFabType FAB2,
class F>
1010bool ReduceLogicalOr_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
1011 IntVect
const& nghost, F&& f)
1013 return fudetail::ReduceLogicalOr_host(fa1,fa2,nghost,std::forward<F>(f));
1016template <BaseFabType FAB1, BaseFabType FAB2,
class F>
1018bool ReduceLogicalOr_host_wrapper (FabArray<FAB1>
const& fa1, FabArray<FAB2>
const& fa2,
1019 IntVect
const& nghost, F&& f)
1022 amrex::Abort(
"ReeuceLogicalOr: Launch Region is off. Device lambda cannot be called by host.");
1028template <BaseFabType FAB1, BaseFabType FAB2,
class F>
1034 return fudetail::ReduceMF<ReduceOpLogicalOr>(fa1,fa2,nghost,std::forward<F>(f));
1036 return fudetail::ReduceLogicalOr_host_wrapper(fa1,fa2,nghost,std::forward<F>(f));
1040template <BaseFabType FAB1, BaseFabType FAB2,
class F>
1045 return fudetail::ReduceLogicalOr_host(fa1,fa2,nghost,std::forward<F>(f));
1049template <BaseFabType FAB>
1058 int n = (comp >= 0) ? 1 : mf.
nComp();
1061 auto* dp = pv.
data();
1065 *dp = fab(cell, comp);
1067 for (
int i = 0; i < n; ++i) {
1068 dp[i] = fab(cell,i);
1085 <<
": " << *dp <<
'\n';
1087 std::ostringstream ss;
1089 for (
int i = 0; i < n-1; ++i)
1091 ss << dp[i] <<
", ";
1095 <<
": " << ss.view() <<
'\n';
1101template <BaseFabType FAB>
1105 Swap(dst,src,srccomp,dstcomp,numcomp,
IntVect(nghost));
1108template <BaseFabType FAB>
1115 bool explicit_swap =
true;
1117 if (srccomp == dstcomp && dstcomp == 0 && src.
nComp() == dst.
nComp() &&
1120 explicit_swap =
false;
1123 if (!explicit_swap) {
1125 std::swap(dst, src);
1130 auto const& dstma = dst.
arrays();
1131 auto const& srcma = src.
arrays();
1135 const auto tmp = dstma[box_no](i,j,k,n+dstcomp);
1136 dstma[box_no](i,j,k,n+dstcomp) = srcma[box_no](i,j,k,n+srccomp);
1137 srcma[box_no](i,j,k,n+srccomp) = tmp;
1146#pragma omp parallel if (Gpu::notInLaunchRegion())
1150 const Box& bx = mfi.growntilebox(nghost);
1152 auto sfab = src.
array(mfi);
1153 auto dfab = dst.
array(mfi);
1156 const auto tmp = dfab(i,j,k,n+dstcomp);
1157 dfab(i,j,k,n+dstcomp) = sfab(i,j,k,n+srccomp);
1158 sfab(i,j,k,n+srccomp) = tmp;
1166template <BaseFabType FAB>
1173template <BaseFabType FAB>
1179 auto const& dstfa = dst.
arrays();
1184 dstfa[box_no](i,j,k,n+dstcomp) -= srcfa[box_no](i,j,k,n+srccomp);
1193#pragma omp parallel if (Gpu::notInLaunchRegion())
1197 const Box& bx = mfi.growntilebox(nghost);
1200 auto const srcFab = src.
array(mfi);
1201 auto dstFab = dst.
array(mfi);
1204 dstFab(i,j,k,n+dstcomp) -= srcFab(i,j,k,n+srccomp);
1212template <BaseFabType FAB>
1219template <BaseFabType FAB>
1225 auto const& dstfa = dst.
arrays();
1230 dstfa[box_no](i,j,k,n+dstcomp) *= srcfa[box_no](i,j,k,n+srccomp);
1239#pragma omp parallel if (Gpu::notInLaunchRegion())
1243 const Box& bx = mfi.growntilebox(nghost);
1246 auto const srcFab = src.
array(mfi);
1247 auto dstFab = dst.
array(mfi);
1250 dstFab(i,j,k,n+dstcomp) *= srcFab(i,j,k,n+srccomp);
1258template <BaseFabType FAB>
1265template <BaseFabType FAB>
1271 auto const& dstfa = dst.
arrays();
1276 dstfa[box_no](i,j,k,n+dstcomp) /= srcfa[box_no](i,j,k,n+srccomp);
1285#pragma omp parallel if (Gpu::notInLaunchRegion())
1289 const Box& bx = mfi.growntilebox(nghost);
1292 auto const srcFab = src.
array(mfi);
1293 auto dstFab = dst.
array(mfi);
1296 dstFab(i,j,k,n+dstcomp) /= srcFab(i,j,k,n+srccomp);
1303template <BaseFabType FAB>
1310template <BaseFabType FAB>
1316 auto const& fabarr = fa.
arrays();
1320 fabarr[box_no](i,j,k,n+icomp) = std::abs(fabarr[box_no](i,j,k,n+icomp));
1329#pragma omp parallel if (Gpu::notInLaunchRegion())
1333 const Box& bx = mfi.growntilebox(nghost);
1336 auto const& fab = fa.
array(mfi);
1339 fab(i,j,k,n+icomp) = std::abs(fab(i,j,k,n+icomp));
1346template <BaseFabType FAB>
1361template <BaseFabType FAB>
1377template <BaseFabType FAB, BaseFabType IFAB>
1388template <BaseFabType FAB, BaseFabType IFAB>
1397 const int ncomp = fa.
nComp();
1401 auto const& fabarr = fa.
arrays();
1406 if (!ifabarr[box_no](i,j,k)) { fabarr[box_no](i,j,k,n) = 0; }
1415#pragma omp parallel if (Gpu::notInLaunchRegion())
1419 const Box& bx = mfi.tilebox();
1420 auto fab = fa.
array(mfi);
1421 auto const ifab = msk.
array(mfi);
1424 if (!ifab(i,j,k)) { fab(i,j,k,n) = 0; }
1435template <BaseFabType FAB>
1443 fa.
os_temp->ParallelCopy_finish();
1449template <BaseFabType FAB>
1452 int scomp,
int dcomp,
int ncomp)
1458 void*
pdst = dst[mfi].dataPtr(dcomp);
1459 void const* psrc = src[mfi].dataPtr(scomp);
1467template <BaseFabType FAB>
1474template <BaseFabType FAB>
1477 int scomp,
int dcomp,
int ncomp)
1483 void*
pdst = dst[mfi].dataPtr(dcomp);
1484 void const* psrc = src[mfi].dataPtr(scomp);
1492template <BaseFabType FAB>
1499template <BaseFabType FAB>
1502 typename FAB::value_type value)
1519 if (ma[box_no](i,j,k,comp) == value) {
1536 if (arr(i,j,k,comp) == value) {
1547 int const* tmp = aa.copyToHost();
1563 const Box& bx = mfi.growntilebox(nghost);
1567 if (fab(i,j,k,comp) == value) {
1578#if defined(AMREX_USE_OMP) && defined(_OPENMP) && (_OPENMP < 201307 || (defined(__NVCOMPILER) && __NVCOMPILER_MAJOR__ < 23))
1579#pragma omp critical (amrex_indexfromvalue)
1580#elif defined(AMREX_USE_OMP)
1581#pragma omp atomic capture
1588 if (old ==
false) { loc = priv_loc; }
1607template <BaseFabType FAB>
1608typename FAB::value_type
1610 IntVect const& nghost,
bool local =
false)
1613 BL_ASSERT(
x.DistributionMap() ==
y.DistributionMap());
1614 BL_ASSERT(
x.nGrowVect().allGE(nghost) &&
y.nGrowVect().allGE(nghost));
1618 using T =
typename FAB::value_type;
1622 auto const& xma =
x.const_arrays();
1623 auto const& yma =
y.const_arrays();
1628 auto const& xfab = xma[box_no];
1629 auto const& yfab = yma[box_no];
1630 for (
int n = 0; n < ncomp; ++n) {
1631 t += xfab(i,j,k,xcomp+n) * yfab(i,j,k,ycomp+n);
1639#pragma omp parallel if (!system::regtest_reduction) reduction(+:sm)
1643 Box const& bx = mfi.growntilebox(nghost);
1644 auto const& xfab =
x.const_array(mfi);
1645 auto const& yfab =
y.const_array(mfi);
1648 sm += xfab(i,j,k,xcomp+n) * yfab(i,j,k,ycomp+n);
1669template <BaseFabType FAB>
1670typename FAB::value_type
1677 using T =
typename FAB::value_type;
1681 auto const& xma =
x.const_arrays();
1686 auto const& xfab = xma[box_no];
1687 for (
int n = 0; n < ncomp; ++n) {
1688 auto v = xfab(i,j,k,xcomp+n);
1697#pragma omp parallel if (!system::regtest_reduction) reduction(+:sm)
1701 Box const& bx = mfi.growntilebox(nghost);
1702 auto const& xfab =
x.const_array(mfi);
1705 auto v = xfab(i,j,k,xcomp+n);
1730template <BaseFabType IFAB, BaseFabType FAB>
1731typename FAB::value_type
1736 BL_ASSERT(
x.boxArray() ==
y.boxArray() &&
x.boxArray() ==
mask.boxArray());
1737 BL_ASSERT(
x.DistributionMap() ==
y.DistributionMap() &&
x.DistributionMap() ==
mask.DistributionMap());
1738 BL_ASSERT(
x.nGrowVect().allGE(nghost) &&
y.nGrowVect().allGE(nghost) &&
1739 mask.nGrowVect().allGE(nghost));
1743 using T =
typename FAB::value_type;
1747 auto const& mma =
mask.const_arrays();
1748 auto const& xma =
x.const_arrays();
1749 auto const& yma =
y.const_arrays();
1754 auto m = T(mma[box_no](i,j,k));
1756 auto const& xfab = xma[box_no];
1757 auto const& yfab = yma[box_no];
1758 for (
int n = 0; n < ncomp; ++n) {
1759 t += xfab(i,j,k,xcomp+n) * yfab(i,j,k,ycomp+n);
1768#pragma omp parallel if (!system::regtest_reduction) reduction(+:sm)
1772 Box const& bx = mfi.growntilebox(nghost);
1773 auto const& mfab =
mask.const_array(mfi);
1774 auto const& xfab =
x.const_array(mfi);
1775 auto const& yfab =
y.const_array(mfi);
1778 auto m = T(mfab(i,j,k));
1779 sm += m * xfab(i,j,k,xcomp+n) * yfab(i,j,k,ycomp+n);
1801template <BaseFabType IFAB, BaseFabType FAB>
1802typename FAB::value_type
1804 IntVect const& nghost,
bool local =
false)
1808 BL_ASSERT(
x.nGrowVect().allGE(nghost) &&
mask.nGrowVect().allGE(nghost));
1812 using T =
typename FAB::value_type;
1816 auto const& mma =
mask.const_arrays();
1817 auto const& xma =
x.const_arrays();
1822 auto m = T(mma[box_no](i,j,k));
1824 auto const& xfab = xma[box_no];
1825 for (
int n = 0; n < ncomp; ++n) {
1826 auto v = xfab(i,j,k,xcomp+n);
1836#pragma omp parallel if (!system::regtest_reduction) reduction(+:sm)
1840 Box const& bx = mfi.growntilebox(nghost);
1841 auto const& mfab =
mask.const_array(mfi);
1842 auto const& xfab =
x.const_array(mfi);
1845 auto m = T(mfab(i,j,k));
1846 auto v = xfab(i,j,k,xcomp+n);
1860template <MultiFabLike MF>
1861void setVal (MF& dst,
typename MF::value_type val)
1867template <MultiFabLike MF>
1868void setBndry (MF& dst,
typename MF::value_type val,
int scomp,
int ncomp)
1870 dst.setBndry(val, scomp, ncomp);
1874template <MultiFabLike MF>
1875void Scale (MF& dst,
typename MF::value_type val,
int scomp,
int ncomp,
int nghost)
1877 dst.mult(val, scomp, ncomp, nghost);
1881template <MultiFabLike DMF, MultiFabLike SMF>
1882void LocalCopy (DMF& dst, SMF
const& src,
int scomp,
int dcomp,
1883 int ncomp,
IntVect const& nghost)
1885 amrex::Copy(dst, src, scomp, dcomp, ncomp, nghost);
1889template <MultiFabLike MF>
1890void LocalAdd (MF& dst, MF
const& src,
int scomp,
int dcomp,
1891 int ncomp,
IntVect const& nghost)
1893 amrex::Add(dst, src, scomp, dcomp, ncomp, nghost);
1897template <MultiFabLike MF>
1898void Saxpy (MF& dst,
typename MF::value_type a, MF
const& src,
int scomp,
int dcomp,
1899 int ncomp,
IntVect const& nghost)
1901 MF::Saxpy(dst, a, src, scomp, dcomp, ncomp, nghost);
1905template <MultiFabLike MF>
1906void Xpay (MF& dst,
typename MF::value_type a, MF
const& src,
int scomp,
int dcomp,
1907 int ncomp,
IntVect const& nghost)
1909 MF::Xpay(dst, a, src, scomp, dcomp, ncomp, nghost);
1913template <MultiFabLike MF>
1914void Saxpy_Xpay (MF& dst,
typename MF::value_type a_saxpy, MF
const& src_saxpy,
1915 typename MF::value_type a_xpay, MF
const& src_xpay,
int scomp,
int dcomp,
1916 int ncomp,
IntVect const& nghost)
1918 MF::Saxpy_Xpay(dst, a_saxpy, src_saxpy, a_xpay, src_xpay, scomp, dcomp, ncomp, nghost);
1922template <MultiFabLike MF>
1923void Saxpy_Saxpy (MF& dst1,
typename MF::value_type a1, MF
const& src1,
1924 MF& dst2,
typename MF::value_type a2, MF
const& src2,
int scomp,
int dcomp,
1925 int ncomp,
IntVect const& nghost)
1927 MF::Saxpy_Saxpy(dst1, a1, src1, dst2, a2, src2, scomp, dcomp, ncomp, nghost);
1931template <MultiFabLike MF>
1933 MF& dst2,
typename MF::value_type a2, MF
const& src,
int scomp,
int dcomp,
1934 int ncomp,
IntVect const& nghost)
1936 MF::Saypy_Saxpy(dst1, a1, dst2, a2, src, scomp, dcomp, ncomp, nghost);
1940template <MultiFabLike MF>
1942 typename MF::value_type a, MF
const& src_a,
int acomp,
1943 typename MF::value_type b, MF
const& src_b,
int bcomp,
1944 int dcomp,
int ncomp,
IntVect const& nghost)
1946 MF::LinComb(dst, a, src_a, acomp, b, src_b, bcomp, dcomp, ncomp, nghost);
1950template <MultiFabLike MF>
1956 dst.ParallelCopy(src, scomp, dcomp, ncomp, ng_src, ng_dst, period);
1959template <MultiFabLike MF>
1960[[nodiscard]]
typename MF::value_type
1964 return mf.norminf(scomp, ncomp, nghost, local);
1968template <MultiFabLike MF, std::
size_t N>
1971 for (
auto& mf: dst) {
1977template <MultiFabLike MF, std::
size_t N>
1980 for (
auto& mf : dst) {
1986template <MultiFabLike MF, std::
size_t N>
1990 for (
auto& mf : dst) {
1991 mf.
mult(val, scomp, ncomp, nghost);
1996template <MultiFabLike DMF, MultiFabLike SMF, std::
size_t N>
1998 int ncomp,
IntVect const& nghost)
2000 for (std::size_t i = 0; i < N; ++i) {
2001 amrex::Copy(dst[i], src[i], scomp, dcomp, ncomp, nghost);
2006template <MultiFabLike MF, std::
size_t N>
2008 int ncomp,
IntVect const& nghost)
2010 for (std::size_t i = 0; i < N; ++i) {
2011 amrex::Add(dst[i], src[i], scomp, dcomp, ncomp, nghost);
2016template <MultiFabLike MF, std::
size_t N>
2018 Array<MF,N> const& src,
int scomp,
int dcomp,
int ncomp,
2021 for (std::size_t i = 0; i < N; ++i) {
2022 MF::Saxpy(dst[i], a, src[i], scomp, dcomp, ncomp, nghost);
2027template <MultiFabLike MF, std::
size_t N>
2029 Array<MF,N> const& src,
int scomp,
int dcomp,
int ncomp,
2032 for (std::size_t i = 0; i < N; ++i) {
2033 MF::Xpay(dst[i], a, src[i], scomp, dcomp, ncomp, nghost);
2038template <MultiFabLike MF, std::
size_t N>
2040 typename MF::value_type a,
Array<MF,N> const& src_a,
int acomp,
2041 typename MF::value_type b,
Array<MF,N> const& src_b,
int bcomp,
2042 int dcomp,
int ncomp,
IntVect const& nghost)
2044 for (std::size_t i = 0; i < N; ++i) {
2045 MF::LinComb(dst[i], a, src_a[i], acomp, b, src_b[i], bcomp, dcomp, ncomp, nghost);
2050template <MultiFabLike MF, std::
size_t N>
2052 int scomp,
int dcomp,
int ncomp,
2057 for (std::size_t i = 0; i < N; ++i) {
2058 dst[i].ParallelCopy(src[i], scomp, dcomp, ncomp, ng_src, ng_dst, period);
2062template <MultiFabLike MF, std::
size_t N>
2063[[nodiscard]]
typename MF::value_type
2067 auto r =
typename MF::value_type(0);
2068 for (std::size_t i = 0; i < N; ++i) {
2069 auto tmp = mf[i].norminf(scomp, ncomp, nghost,
true);
2070 r = std::max(r,tmp);
2078template <MultiFabLike MF, std::
size_t N>
2082 return mf[0].nComp();
2085template <MultiFabLike MF, std::
size_t N>
2089 return mf[0].nGrowVect();
2092template <MultiFabLike MF, std::
size_t N>
2094[[nodiscard]] BoxArray
const&
2097 return mf[0].boxArray();
2100template <MultiFabLike MF, std::
size_t N>
2102[[nodiscard]] DistributionMapping
const&
2105 return mf[0].DistributionMap();
2116FabArray<BaseFab<int>>
2127 const std::vector<IntVect>& pshifts = period.
shiftIntVect();
2134#pragma omp parallel if (!run_on_gpu)
2137 std::vector< std::pair<int,Box> > isects;
2141 const Box& bx =
mask[mfi].box();
2142 auto const& arr =
mask.array(mfi);
2144 for (
const auto& iv : pshifts)
2147 for (
const auto& is : isects)
2149 Box const& b = is.second-iv;
2150 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
#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:1140
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
A collection of Boxes stored in an Array.
Definition AMReX_BoxArray.H:564
std::vector< std::pair< int, Box > > intersections(const Box &bx) const
Return intersections of Box and 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:216
__host__ __device__ bool ok() const noexcept
Checks if it is a proper BoxND (including a valid type).
Definition AMReX_Box.H:212
Calculates the distribution of FABs to MPI processes.
Definition AMReX_DistributionMapping.H:43
IntVect nGrowVect() const noexcept
Definition AMReX_FabArrayBase.H:80
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:86
const DistributionMapping & DistributionMap() const noexcept
Return constant reference to associated DistributionMapping.
Definition AMReX_FabArrayBase.H:131
@ ADD
Definition AMReX_FabArrayBase.H:394
int nComp() const noexcept
Return number of variables (aka components) associated with each point.
Definition AMReX_FabArrayBase.H:83
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:95
An Array of FortranArrayBox(FAB)-like Objects.
Definition AMReX_FabArray.H:344
void mult(value_type val, int comp, int num_comp, int nghost=0)
Definition AMReX_FabArray.H:2968
void setBndry(value_type val)
Set all values in the boundary region to val.
Definition AMReX_FabArray.H:2487
std::unique_ptr< FabArray< FAB > > os_temp
Definition AMReX_FabArray.H:1661
const FabFactory< FAB > & Factory() const noexcept
Definition AMReX_FabArray.H:442
void prefetchToHost(const MFIter &mfi) const noexcept
Definition AMReX_FabArray.H:541
MultiArray4< typename FabArray< FAB >::value_type > arrays() noexcept
Definition AMReX_FabArray.H:633
void prefetchToDevice(const MFIter &mfi) const noexcept
Definition AMReX_FabArray.H:551
Arena * arena() const noexcept
Definition AMReX_FabArray.H:445
MultiArray4< typename FabArray< FAB >::value_type const > const_arrays() const noexcept
Definition AMReX_FabArray.H:647
void setVal(value_type val)
Set all components in the entire region of each FAB to val.
Definition AMReX_FabArray.H:2705
Array4< typename FabArray< FAB >::value_type const > array(const MFIter &mfi) const noexcept
Definition AMReX_FabArray.H:561
bool hasEBFabFactory() const noexcept
Definition AMReX_FabArray.H:449
Array4< typename FabArray< FAB >::value_type const > const_array(const MFIter &mfi) const noexcept
Definition AMReX_FabArray.H:585
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 > grow(const BoxND< dim > &b, int i) noexcept
Grow BoxND in all directions by given amount.
Definition AMReX_Box.H:1289
std::array< T, N > Array
Definition AMReX_Array.H:26
void Sum(T &v, MPI_Comm comm)
Definition AMReX_ParallelReduce.H:221
void Max(KeyValuePair< K, V > &vi, MPI_Comm comm)
Definition AMReX_ParallelReduce.H:133
__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 &...)
This shuts up the compiler about unused variables.
Definition AMReX.H:139
__host__ __device__ BoxND< dim > makeSingleCellBox(int i, int j, int k, IndexTypeND< dim > typ=IndexTypeND< dim >::TheCellType())
Definition AMReX_Box.H:2152
int nComp(FabArrayBase const &fa)
Definition AMReX_FabArrayBase.cpp:2852
void Copy(FabArray< DFAB > &dst, FabArray< SFAB > const &src, int srccomp, int dstcomp, int numcomp, int nghost)
Definition AMReX_FabArray.H:180
void htod_memcpy(FabArray< FAB > &dst, FabArray< FAB > const &src, int scomp, int dcomp, int ncomp)
Definition AMReX_FabArrayUtility.H:1476
__host__ __device__ void Swap(T &t1, T &t2) noexcept
Definition AMReX_Algorithm.H:94
void OverrideSync_nowait(FabArray< FAB > &fa, FabArray< IFAB > const &msk, const Periodicity &period)
Definition AMReX_FabArrayUtility.H:1390
void Add(FabArray< FAB > &dst, FabArray< FAB > const &src, int srccomp, int dstcomp, int numcomp, int nghost)
Definition AMReX_FabArray.H:239
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
DistributionMapping const & DistributionMap(FabArrayBase const &fa)
Definition AMReX_FabArrayBase.cpp:2867
IntVect nGrowVect(FabArrayBase const &fa)
Definition AMReX_FabArrayBase.cpp:2857
void Scale(MF &dst, typename MF::value_type val, int scomp, int ncomp, int nghost)
dst *= val
Definition AMReX_FabArrayUtility.H:1875
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:1609
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:1914
void prefetchToDevice(FabArray< FAB > const &fa, const bool synchronous=true)
Definition AMReX_FabArrayUtility.H:1363
FAB::value_type ReduceMin(FabArray< FAB > const &fa, int nghost, F &&f)
Definition AMReX_FabArrayUtility.H:304
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)
Definition AMReX_FabArrayUtility.H:2117
void prefetchToHost(FabArray< FAB > const &fa, const bool synchronous=true)
Definition AMReX_FabArrayUtility.H:1348
bool isMFIterSafe(const FabArrayBase &x, const FabArrayBase &y)
Definition AMReX_MFIter.H:252
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:1923
IntVect indexFromValue(FabArray< FAB > const &mf, int comp, IntVect const &nghost, typename FAB::value_type value)
Definition AMReX_FabArrayUtility.H:1501
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:1941
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:1951
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:1932
void Multiply(FabArray< FAB > &dst, FabArray< FAB > const &src, int srccomp, int dstcomp, int numcomp, int nghost)
Definition AMReX_FabArrayUtility.H:1214
IntVectND< 3 > IntVect
IntVect is an alias for amrex::IntVectND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:33
void Abs(FabArray< FAB > &fa, int icomp, int numcomp, int nghost)
Definition AMReX_FabArrayUtility.H:1305
void OverrideSync_finish(FabArray< FAB > &fa)
Definition AMReX_FabArrayUtility.H:1437
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)
Definition AMReX_FabArrayUtility.H:1451
void LocalCopy(DMF &dst, SMF const &src, int scomp, int dcomp, int ncomp, IntVect const &nghost)
dst = src
Definition AMReX_FabArrayUtility.H:1882
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:1868
void printCell(FabArray< FAB > const &mf, const IntVect &cell, int comp=-1, const IntVect &ng=IntVect::TheZeroVector())
Definition AMReX_FabArrayUtility.H:1051
MF::value_type norminf(MF const &mf, int scomp, int ncomp, IntVect const &nghost, bool local=false)
Definition AMReX_FabArrayUtility.H:1961
bool ReduceLogicalOr(FabArray< FAB > const &fa, int nghost, F &&f)
Definition AMReX_FabArrayUtility.H:904
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:1906
void Abort(const std::string &msg)
Print out message to cerr and exit via abort().
Definition AMReX.cpp:241
const int[]
Definition AMReX_BLProfiler.cpp:1664
void OverrideSync(FabArray< FAB > &fa, FabArray< IFAB > const &msk, const Periodicity &period)
Definition AMReX_FabArrayUtility.H:1379
void Divide(FabArray< FAB > &dst, FabArray< FAB > const &src, int srccomp, int dstcomp, int numcomp, int nghost)
Definition AMReX_FabArrayUtility.H:1260
bool ReduceLogicalAnd(FabArray< FAB > const &fa, int nghost, F &&f)
Definition AMReX_FabArrayUtility.H:757
FAB::value_type ReduceMax(FabArray< FAB > const &fa, int nghost, F &&f)
Definition AMReX_FabArrayUtility.H:530
void Subtract(FabArray< FAB > &dst, FabArray< FAB > const &src, int srccomp, int dstcomp, int numcomp, int nghost)
Definition AMReX_FabArrayUtility.H:1168
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:1898
void LocalAdd(MF &dst, MF const &src, int scomp, int dcomp, int ncomp, IntVect const &nghost)
dst += src
Definition AMReX_FabArrayUtility.H:1890
BoxArray const & boxArray(FabArrayBase const &fa)
Definition AMReX_FabArrayBase.cpp:2862
FAB::value_type ReduceSum(FabArray< FAB > const &fa, int nghost, F &&f)
Definition AMReX_FabArrayUtility.H:16
void setVal(MF &dst, typename MF::value_type val)
dst = val
Definition AMReX_FabArrayUtility.H:1861
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:68
Definition AMReX_MFIter.H:20
Struct for holding types.
Definition AMReX_TypeList.H:13