Block-Structured AMR Software Framework
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
AMReX_NonLocalBC.H
Go to the documentation of this file.
1#ifndef AMREX_NONLOCAL_BC_H_
2#define AMREX_NONLOCAL_BC_H_
3#include <AMReX_Config.H>
4#include <AMReX_TypeTraits.H>
5#include <AMReX_FabArray.H>
6#include <AMReX_FArrayBox.H>
7
8namespace amrex::NonLocalBC {
9
11// [concept.IndexMapping]
12//
13
15template <typename T, typename... Args>
16using Inverse_t = decltype(std::declval<T>().Inverse(std::declval<Args>()...));
17
19template <typename T>
20struct HasInverseMemFn : IsDetectedExact<Dim3, Inverse_t, T, Dim3> {};
21
24template <class IndexMap>
26 : Conjunction<IsCallableR<Dim3, IndexMap&, const Dim3&>,
27 HasInverseMemFn<const IndexMap&>> {};
28
30// [IndexMapping.MultiBlockIndexMapping]
31//
32
44
51 [[nodiscard]] AMREX_GPU_HOST_DEVICE Dim3 operator()(Dim3 i) const noexcept {
52 int iv[3]{i.x, i.y, i.z};
53 int iv_new[3]{};
54 for (int d = 0; d < AMREX_SPACEDIM; ++d) {
55 iv_new[d] = sign[d] * (iv[permutation[d]] - offset[d]);
56 }
57 return {iv_new[0], iv_new[1], iv_new[2]};
58 }
59
66 [[nodiscard]] AMREX_GPU_HOST_DEVICE Dim3 Inverse(Dim3 i) const noexcept {
67 int iv_new[3]{i.x, i.y, i.z};
68 int iv[3]{};
69 for (int d = 0; d < AMREX_SPACEDIM; ++d) {
70 AMREX_ASSERT(sign[d] == 1 || sign[d] == -1);
71 iv[permutation[d]] = iv_new[d] * sign[d] + offset[d];
72 }
73 return {iv[0], iv[1], iv[2]};
74 }
75
76 [[nodiscard]] IndexType operator()(IndexType it) const noexcept {
77 return IndexType{IntVect{AMREX_D_DECL(it[permutation[0]], it[permutation[1]], it[permutation[2]])}};
78 }
79
80 [[nodiscard]] IndexType Inverse(IndexType it) const noexcept {
81 IntVect inverse_permutation;
82 for (int i = 0; i < AMREX_SPACEDIM; ++i) {
83 inverse_permutation[permutation[i]] = i;
84 }
85 return IndexType{IntVect{AMREX_D_DECL(it[inverse_permutation[0]], it[inverse_permutation[1]], it[inverse_permutation[2]])}};
86 }
87};
88
100template <typename DTOS>
101std::enable_if_t<IsCallableR<Dim3, DTOS, Dim3>::value, IntVect>
102Apply(DTOS const& dtos, const IntVect& iv)
103{
104 Dim3 i = dtos(iv.dim3());
105 return IntVect{AMREX_D_DECL(i.x, i.y, i.z)};
106}
107
116template <typename DTOS>
117std::enable_if_t<IsCallableR<Dim3, DTOS, Dim3>::value && !IsCallableR<IndexType, DTOS, IndexType>::value, Box>
118Image (DTOS const& dtos, const Box& box)
119{
120 IntVect mapped_smallEnd = Apply(dtos, box.smallEnd());
121 IntVect mapped_bigEnd = Apply(dtos, box.bigEnd());
122 IntVect smallEnd;
123 IntVect bigEnd;
124 for (int d = 0; d < AMREX_SPACEDIM; ++d) {
125 smallEnd[d] = std::min(mapped_smallEnd[d], mapped_bigEnd[d]);
126 bigEnd[d] = std::max(mapped_smallEnd[d], mapped_bigEnd[d]);
127 }
128 return Box{smallEnd, bigEnd, box.ixType()};
129}
130
139template <typename DTOS>
140std::enable_if_t<IsCallableR<Dim3, DTOS, Dim3>::value && IsCallableR<IndexType, DTOS, IndexType>::value, Box>
141Image (DTOS const& dtos, const Box& box)
142{
143 // "Forget" the index type mapping and invoke Image without changing the index type.
144 Box srcbox = Image([&dtos](Dim3 d) { return dtos(d); }, box);
145 // Fix the index type of the resulting box
146 srcbox.setType(dtos(box.ixType()));
147 return srcbox;
148}
149
161template <typename DTOS>
162std::enable_if_t<HasInverseMemFn<DTOS>::value, IntVect>
163ApplyInverse(DTOS const& dtos, const IntVect& iv)
164{
165 return Apply([&dtos](Dim3 i) { return dtos.Inverse(i); }, iv);
166}
167
176template <typename DTOS>
177std::enable_if_t<HasInverseMemFn<DTOS>::value && !IsCallableR<IndexType, DTOS, IndexType>::value, Box>
178InverseImage (DTOS const& dtos, const Box& box)
179{
180 return Image([&dtos](Dim3 i) { return dtos.Inverse(i); }, box);
181}
182
191template <typename DTOS>
192std::enable_if_t<HasInverseMemFn<DTOS>::value && IsCallableR<IndexType, DTOS, IndexType>::value, Box>
193InverseImage (DTOS const& dtos, const Box& box)
194{
195 return Image([&dtos](auto&& i) { return dtos.Inverse(i); }, box);
196}
197
199static_assert(IsIndexMapping<MultiBlockIndexMapping>(), // NOLINT(bugprone-throw-keyword-missing)
200 "MultiBlockIndexMapping is expected to satisfy IndexMapping");
201
203// [class.MultiBlockCommMetaData]
204//
205
212
216 template <typename DTOS,
217 typename = std::enable_if_t<IsIndexMapping<DTOS>::value>>
218 MultiBlockCommMetaData(const FabArrayBase& dst, const Box& dstbox, const FabArrayBase& src,
219 const IntVect& ngrow, DTOS const& dtos);
220
224 template <typename DTOS,
225 typename = std::enable_if_t<IsIndexMapping<DTOS>::value>>
227 const Box& dstbox, const BoxArray& srcba,
228 const DistributionMapping& srcdm, const IntVect& ngrow, DTOS const& dtos);
229
231
256 template <typename DTOS>
257 std::enable_if_t<IsIndexMapping<DTOS>::value>
258 define(const BoxArray& dstba, const DistributionMapping& dstdm, const Box& dstbox,
259 const BoxArray& srcba, const DistributionMapping& srcdm, const IntVect& ngrow,
260 DTOS const& dtos);
261};
262
264// [concept.FabProjection]
265//
266
268template <typename P, typename FAB>
270 : IsCallableR<typename FAB::value_type, P, Array4<const typename FAB::value_type>, Dim3, int>
271{};
272
274// [FabProjection.Identity]
275// [IndexMapping.Identity]
276
280struct Identity {
282 constexpr Dim3 operator()(Dim3 i) const noexcept { return i; }
284 [[nodiscard]] static constexpr Dim3 Inverse(Dim3 i) noexcept { return i; }
285
287 template <typename T>
288 constexpr T operator()(Array4<const T> array, Dim3 i, int comp = 0) const
289 noexcept(noexcept(array(i.x, i.y, i.z, comp))) {
290 return array(i.x, i.y, i.z, comp);
291 }
292
294 constexpr int operator()(int i) const noexcept { return i; }
295};
296static constexpr Identity identity{};
297
298static_assert(sizeof(Identity) == 1 );
299static_assert(std::is_trivially_default_constructible_v<Identity> );
300static_assert(std::is_trivially_copy_assignable_v<Identity> );
301static_assert(std::is_trivially_copy_constructible_v<Identity> );
302static_assert(IsIndexMapping<Identity>() ); // NOLINT(bugprone-throw-keyword-missing)
303static_assert(IsFabProjection<Identity, FArrayBox>() ); // NOLINT(bugprone-throw-keyword-missing)
304
306// [FabProjection.MapComponents]
307
314template <typename Base, typename Map = Identity> struct MapComponents {
315 static_assert(IsCallable<Base, Array4<const Real>, Dim3, int>::value,
316 "Base needs to be a callable function: (Array4<const T>, Dim3, i) -> auto.");
317
319 "Map needs to be a callable function: int -> int.");
320
321 Base base;
322 Map map;
323
324 template <typename T,
325 typename = std::enable_if_t<IsCallable<Base, Array4<const T>, Dim3, int>::value>,
326 typename = std::enable_if_t<IsCallableR<int, Map, int>::value>>
327 constexpr decltype(auto) operator()(Array4<const T> array, Dim3 i, int comp) const
328 noexcept(noexcept(base(array, i, map(comp)))) {
329 return base(array, i, map(comp));
330 }
331};
332
333static_assert(std::is_trivially_copy_assignable<MapComponents<Identity>>() ); // NOLINT(bugprone-throw-keyword-missing)
334static_assert(std::is_trivially_copy_constructible<MapComponents<Identity>>() ); // NOLINT(bugprone-throw-keyword-missing)
335static_assert(IsFabProjection<MapComponents<Identity>, FArrayBox>() ); // NOLINT(bugprone-throw-keyword-missing)
336
338// [FabProjection.MapComponents.SwapComponents]
339
345template <int I, int J> struct SwapComponents {
346 static_assert(I >= 0 && J >= 0, "I >= 0 && J >= 0");
347
351 constexpr int operator()(int i) const noexcept {
352 const int map[2] = {I, J};
353 return i == I || i == J ? map[std::size_t(i == I)] : i;
354 }
355};
356
357template <int I> struct SwapComponents<I, -1> {
358 static_assert(I >= 0, "I >= 0");
359
360 int J;
361 constexpr int operator()(int i) const noexcept {
362 const int map[2] = {I, J};
363 return i == I || i == J ? map[std::size_t(i == I)] : i;
364 }
365};
366
367template <int J> struct SwapComponents<-1, J> {
368 static_assert(J >= 0, "J >= 0");
369
370 int I;
371 constexpr int operator()(int i) const noexcept {
372 const int map[2] = {I, J};
373 return i == I || i == J ? map[std::size_t(i == I)] : i;
374 }
375};
376
377template <> struct SwapComponents<-1, -1> {
378 int I;
379 int J;
380 constexpr int operator()(int i) const noexcept {
381 const int map[2] = {I, J};
382 return i == I || i == J ? map[std::size_t(i == I)] : i;
383 }
384};
385
387
388template <int I, int J> static constexpr SwapComponents<I, J> swap_indices{};
389
390static_assert(sizeof(SwapComponents<0, 1>) == 1 );
391static_assert(sizeof(DynamicSwapComponents) == 2 * sizeof(int) );
392static_assert(sizeof(SwapComponents<0, -1>) == sizeof(int) );
393static_assert(sizeof(SwapComponents<-1, 1>) == sizeof(int) );
394static_assert(std::is_trivially_default_constructible<MapComponents<Identity, SwapComponents<0, 1>>>() ); // NOLINT(bugprone-throw-keyword-missing)
395static_assert(std::is_trivially_copy_assignable<MapComponents<Identity, SwapComponents<0, 1>>>() ); // NOLINT(bugprone-throw-keyword-missing)
396static_assert(std::is_trivially_copy_constructible<MapComponents<Identity, SwapComponents<0, 1>>>() ); // NOLINT(bugprone-throw-keyword-missing)
397static_assert(IsFabProjection<MapComponents<Identity, SwapComponents<0, 1>>, FArrayBox>() ); // NOLINT(bugprone-throw-keyword-missing)
398
399static_assert(swap_indices<0, 1>(0) == 1 );
400static_assert(swap_indices<0, 1>(1) == 0 );
401static_assert(swap_indices<0, 1>(2) == 2 );
402static_assert(DynamicSwapComponents{0, 1}(0) == 1 );
403static_assert(DynamicSwapComponents{0, 1}(1) == 0 );
404static_assert(DynamicSwapComponents{0, 1}(2) == 2 );
405
407// [class.CommData]
408// [class.CommHandler]
409
435
436#ifdef AMREX_USE_MPI
438void PrepareCommBuffers(CommData& comm, const FabArrayBase::MapOfCopyComTagContainers& cctc,
439 int n_components, std::size_t object_size, std::size_t align);
440
442void PostRecvs(CommData& recv, int mpi_tag);
443
445void PostSends(CommData& send, int mpi_tag);
446#endif
447
448
453#ifdef AMREX_USE_MPI
454 int mpi_tag{};
457#endif
458};
459
461// [concept.DataPacking]
462//
463template <typename... Args>
464using PrepareSendBuffers_t = decltype(PrepareSendBuffers(std::declval<Args>()...));
465
466template <typename... Args>
467using PrepareRecvBuffers_t = decltype(PrepareRecvBuffers(std::declval<Args>()...));
468
469template <typename... Args>
470using PackSendBuffers_t = decltype(PackSendBuffers(std::declval<Args>()...));
471
472template <typename... Args>
473using UnpackRecvBuffers_t = decltype(UnpackRecvBuffers(std::declval<Args>()...));
474
475template <typename... Args>
476using LocalCopy_t = decltype(LocalCopy(std::declval<Args>()...));
477
479#if defined(AMREX_USE_CUDA) && defined(_WIN32)
480template <typename DP, typename FAB> struct IsDataPacking : std::true_type {};
481#else
482template <typename DP, typename FAB>
485 IsDetected<LocalCopy_t, DP&, FabArray<FAB>&, const FabArray<FAB>&, const FabArrayBase::CopyComTagsContainer&>
486#ifdef AMREX_USE_MPI
487 ,IsDetected<PrepareSendBuffers_t, DP&, FabArray<FAB>&, const FabArray<FAB>&, CommData&, const FabArrayBase::MapOfCopyComTagContainers&>,
488 IsDetected<PrepareRecvBuffers_t, DP&, FabArray<FAB>&, const FabArray<FAB>&, CommData&, const FabArrayBase::MapOfCopyComTagContainers&>,
489 IsDetected<PackSendBuffers_t, DP&, const FabArray<FAB>&, CommData&>,
490 IsDetected<UnpackRecvBuffers_t, DP&, FabArray<FAB>&, CommData&>
491#endif
492 > {};
493#endif
494
495template <class FAB, class DTOS = Identity, class Proj = Identity>
496std::enable_if_t<IsBaseFab<FAB>() && IsCallableR<Dim3, DTOS, Dim3>() && IsFabProjection<Proj, FAB>()>
497local_copy_cpu (FabArray<FAB>& dest, const FabArray<FAB>& src, int dcomp, int scomp, int ncomp,
498 FabArrayBase::CopyComTagsContainer const& local_tags, DTOS const& dtos = DTOS{},
499 Proj const& proj = Proj{}) noexcept;
500
501template <class FAB, class DTOS = Identity, class Proj = Identity>
502std::enable_if_t<IsBaseFab<FAB>() && IsCallableR<Dim3, DTOS, Dim3>() && IsFabProjection<Proj, FAB>()>
503unpack_recv_buffer_cpu (FabArray<FAB>& mf, int dcomp, int ncomp, Vector<char*> const& recv_data,
504 Vector<std::size_t> const& recv_size,
506 DTOS const& dtos = DTOS{}, Proj const& proj = Proj{}) noexcept;
507
508#ifdef AMREX_USE_GPU
509template <class FAB, class DTOS = Identity, class Proj = Identity>
510std::enable_if_t<IsBaseFab<FAB>() && IsCallableR<Dim3, DTOS, Dim3>() && IsFabProjection<Proj, FAB>()>
511local_copy_gpu (FabArray<FAB>& dest, const FabArray<FAB>& src, int dcomp, int scomp, int ncomp,
512 FabArrayBase::CopyComTagsContainer const& local_tags, DTOS const& dtos = DTOS{},
513 Proj const& proj = Proj{}) noexcept;
514
515template <class FAB, class DTOS = Identity, class Proj = Identity>
516std::enable_if_t<IsBaseFab<FAB>() && IsCallableR<Dim3, DTOS, Dim3>() && IsFabProjection<Proj, FAB>()>
517unpack_recv_buffer_gpu (FabArray<FAB>& mf, int scomp, int ncomp,
518 Vector<char*> const& recv_data,
519 Vector<std::size_t> const& recv_size,
521 DTOS const& dtos = DTOS{}, Proj const& proj = Proj{});
522#endif
523
525// [DataPacking.PackComponents]
526//
527// PackComponents is the simplest data packing policy.
528// This provides us with sane default behaviour that we can use when defining new
529// data packing policies.
530
537
539template <typename FAB>
540std::enable_if_t<IsBaseFab<FAB>::value>
541LocalCopy (const PackComponents& components, FabArray<FAB>& dest, const FabArray<FAB>& src,
542 const FabArrayBase::CopyComTagsContainer& local_tags) {
543#ifdef AMREX_USE_GPU
544 if (Gpu::inLaunchRegion()) {
545 local_copy_gpu(dest, src, components.dest_component, components.src_component,
546 components.n_components, local_tags);
547 } else
548#endif
549 {
550 local_copy_cpu(dest, src, components.dest_component, components.src_component,
551 components.n_components, local_tags);
552 }
553}
554
555#ifdef AMREX_USE_MPI
557template <typename FAB>
558std::enable_if_t<IsBaseFab<FAB>::value>
559PrepareSendBuffers (const PackComponents& components, FabArray<FAB>& dest, const FabArray<FAB>& src,
561 using T = typename FAB::value_type;
562 ignore_unused(dest, src);
563 PrepareCommBuffers(comm, cctc, components.n_components, sizeof(T), alignof(T));
564}
565
567template <typename FAB>
568std::enable_if_t<IsBaseFab<FAB>::value>
569PrepareRecvBuffers (const PackComponents& components, FabArray<FAB>& dest, const FabArray<FAB>& src,
571 using T = typename FAB::value_type;
572 ignore_unused(dest, src);
573 PrepareCommBuffers(comm, cctc, components.n_components, sizeof(T), alignof(T));
574}
575
577template <typename FAB>
578std::enable_if_t<IsBaseFab<FAB>::value>
579PackSendBuffers (const PackComponents& components, const FabArray<FAB>& src, CommData& send) {
580#ifdef AMREX_USE_GPU
581 if (Gpu::inLaunchRegion()) {
583 send.data, send.size, send.cctc);
584 } else
585#endif // AMREX_USE_GPU
586 {
588 send.data, send.size, send.cctc);
589 }
590}
591
593template <typename FAB>
594std::enable_if_t<IsBaseFab<FAB>::value>
595UnpackRecvBuffers (const PackComponents& components, FabArray<FAB>& dest, const CommData& recv) {
596#ifdef AMREX_USE_GPU
597 if (Gpu::inLaunchRegion()) {
598 unpack_recv_buffer_gpu(dest, components.dest_component, components.n_components, recv.data,
599 recv.size, recv.cctc);
600 } else
601#endif // AMREX_USE_GPU
602 {
603 unpack_recv_buffer_cpu(dest, components.dest_component, components.n_components, recv.data,
604 recv.size, recv.cctc);
605 }
606}
607#endif // AMREX_USE_MPI
608
609static_assert(IsDataPacking<PackComponents, FArrayBox>(), // NOLINT(bugprone-throw-keyword-missing)
610 "PackComponents is expected to satisfy the concept DataPacking.");
611
613// [DataPacking.ApplyDtosAndProjectionOnReciever]
614//
618template <typename DTOS = Identity, typename FabProj = Identity>
620 constexpr ApplyDtosAndProjectionOnReciever() = default;
621 constexpr ApplyDtosAndProjectionOnReciever(const PackComponents& components, DTOS dtos_ = DTOS{}, FabProj proj_ = FabProj{})
622 : PackComponents(components), dtos(std::move(dtos_)), proj(std::move(proj_)) {}
623
624 DTOS dtos;
625 FabProj proj;
626
627 static_assert(IsCallableR<Dim3, DTOS, Dim3>(), "DTOS needs to be a callable: Dim3 -> Dim3");
628 static_assert(IsFabProjection<FabProj, FArrayBox>(), "FabProj needs to be at least a projection on FArrayBox.");
629};
630
632template <typename FAB, typename DTOS, typename FabProj>
633std::enable_if_t<IsBaseFab<FAB>::value>
635 const FabArray<FAB>& src, const FabArrayBase::CopyComTagsContainer& local_tags) {
636 static_assert(IsFabProjection<FabProj, FAB>(), "FabProj needs to be a projection for given FAB type.");
637#ifdef AMREX_USE_GPU
638 if (Gpu::inLaunchRegion()) {
639 local_copy_gpu(dest, src, packing.dest_component, packing.src_component,
640 packing.n_components, local_tags, packing.dtos, packing.proj);
641 } else
642#endif
643 {
644 local_copy_cpu(dest, src, packing.dest_component, packing.src_component,
645 packing.n_components, local_tags, packing.dtos, packing.proj);
646 }
647}
648
649#ifdef AMREX_USE_MPI
651template <typename FAB, typename DTOS, typename FabProj>
652std::enable_if_t<IsBaseFab<FAB>::value>
654 FabArray<FAB>& dest, const CommData& recv) {
655 // If FAB is not FArrayBox we have not checked for the correct types yet.
656 static_assert(IsFabProjection<FabProj, FAB>(), "FabProj needs to be a projection for given FAB type.");
657#ifdef AMREX_USE_GPU
658 if (Gpu::inLaunchRegion()) {
659 unpack_recv_buffer_gpu(dest, packing.dest_component, packing.n_components, recv.data,
660 recv.size, recv.cctc, packing.dtos, packing.proj);
661 } else
662#endif // AMREX_USE_GPU
663 {
664 unpack_recv_buffer_cpu(dest, packing.dest_component, packing.n_components, recv.data,
665 recv.size, recv.cctc, packing.dtos, packing.proj);
666 }
667}
668#endif // AMREX_USE_MPI
669
670static_assert(IsDataPacking<ApplyDtosAndProjectionOnReciever<>, FArrayBox>(), // NOLINT(bugprone-throw-keyword-missing)
671 "ApplyDtosAndProjectionOnReciever<> is expected to satisfy the DataPacking concept.");
672
674// [ParallelCopy_nowait]
675
676static constexpr struct NoLocalCopy {} no_local_copy{};
677static constexpr struct DoLocalCopy {} do_local_copy{};
678
700template <typename FAB, typename DataPacking,
701 typename = std::enable_if_t<IsBaseFab<FAB>::value>,
702 typename = std::enable_if_t<IsDataPacking<DataPacking, FAB>::value>>
703#ifdef AMREX_USE_MPI
706 const FabArrayBase::CommMetaData& cmd, const DataPacking& data_packing) {
707 CommHandler handler{};
708 if (ParallelContext::NProcsSub() == 1) {
709 return handler;
710 }
711 //
712 // Do this before prematurely exiting if running in parallel.
713 // Otherwise sequence numbers will not match across MPI processes.
714 //
716
717 if (cmd.m_RcvTags && !(cmd.m_RcvTags->empty())) {
718 PrepareRecvBuffers(data_packing, dest, src, handler.recv, *cmd.m_RcvTags);
719 PostRecvs(handler.recv, handler.mpi_tag);
720 }
721
722 if (cmd.m_SndTags && !(cmd.m_SndTags->empty())) {
723 PrepareSendBuffers(data_packing, dest, src, handler.send, *cmd.m_SndTags);
724 PackSendBuffers(data_packing, src, handler.send);
725 PostSends(handler.send, handler.mpi_tag);
726 }
727 return handler;
728}
729#else
730CommHandler ParallelCopy_nowait (NoLocalCopy, FabArray<FAB>&, const FabArray<FAB>&,
731 const FabArrayBase::CommMetaData&, const DataPacking&) {
732 return CommHandler{};
733}
734#endif
735
757template <typename FAB, typename DataPacking,
758 typename = std::enable_if_t<IsBaseFab<FAB>::value>,
759 typename = std::enable_if_t<IsDataPacking<DataPacking, FAB>::value>>
760#ifdef AMREX_USE_MPI
762#endif
763CommHandler
765 const FabArrayBase::CommMetaData& cmd, const DataPacking& data_packing) {
766 CommHandler comm = ParallelCopy_nowait(no_local_copy, dest, src, cmd, data_packing);
767 // Eagerly do the local work and hope for some overlap with communication
768 if (cmd.m_LocTags && !cmd.m_LocTags->empty()) {
769 LocalCopy(data_packing, dest, src, *cmd.m_LocTags);
770 }
771 return comm;
772}
774// [ParallelCopy_finish]
775
794template <typename FAB, typename DataPacking>
795std::enable_if_t<IsBaseFab<FAB>() && IsDataPacking<DataPacking, FAB>()>
796#ifdef AMREX_USE_MPI
798 const FabArrayBase::CommMetaData& cmd, const DataPacking& data_packing) {
799 // If any FabArray is empty we have nothing to do.
800 if (dest.empty()) {
801 return;
802 }
803 // Return if nothing do
804 if (ParallelContext::NProcsSub() == 1) {
805 return;
806 }
807 // Unpack receives
808 if (cmd.m_RcvTags && !(cmd.m_RcvTags->empty())) {
810#ifdef AMREX_DEBUG
811 if (!CheckRcvStats(handler.recv.stats, handler.recv.size, handler.mpi_tag)) {
812 amrex::Abort("NonLocalPC::ParallelCopy_finish failed with wrong message size");
813 }
814#endif
815 UnpackRecvBuffers(data_packing, dest, handler.recv);
816 }
817
818 // Wait for all sends to be done
819 if (cmd.m_SndTags && !(cmd.m_SndTags->empty())) {
821 }
822}
823#else
824ParallelCopy_finish (FabArray<FAB>&, CommHandler, const FabArrayBase::CommMetaData&, const DataPacking&) {}
825#endif
826
846template <typename FAB, typename DataPacking>
847std::enable_if_t<IsBaseFab<FAB>() && IsDataPacking<DataPacking, FAB>()>
849 const FabArrayBase::CommMetaData& cmd, const DataPacking& data_packing) {
850 // Eagerly do the local work and hope for some overlap with communication
851 if (cmd.m_LocTags && !cmd.m_LocTags->empty()) {
852 LocalCopy(data_packing, dest, src, *cmd.m_LocTags);
853 }
854 ParallelCopy_finish(dest, std::move(handler), cmd, data_packing); // NOLINT
855}
856
881template <typename FAB, typename DTOS = Identity, typename Proj = Identity>
882std::enable_if_t<IsBaseFab<FAB>() && IsCallableR<Dim3, DTOS, Dim3>() && IsFabProjection<Proj, FAB>()>
884 SrcComp srccomp, DestComp destcomp, NumComps numcomp, DTOS const& dtos = DTOS{}, Proj const& proj = Proj{}) {
885 PackComponents components{};
886 components.dest_component = destcomp.i;
887 components.src_component = srccomp.i;
888 components.n_components = numcomp.n;
889#if defined(__GNUC__) && !defined(__clang__)
890#pragma GCC diagnostic push
891#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
892#endif
893 ApplyDtosAndProjectionOnReciever<DTOS, Proj> packing{components, dtos, proj};
894 CommHandler handler = ParallelCopy_nowait(dest, src, cmd, packing);
895 ParallelCopy_finish(dest, std::move(handler), cmd, packing); // NOLINT
896#if defined(__GNUC__) && !defined(__clang__)
897#pragma GCC diagnostic pop
898#endif
899}
900
925template <typename FAB, typename DTOS = Identity, typename Proj = Identity>
926std::enable_if_t<IsBaseFab<FAB>() && IsCallableR<Dim3, DTOS, Dim3>() && IsFabProjection<Proj, FAB>()>
928 int srccomp, int destcomp, int numcomp, DTOS const& dtos = DTOS{}, Proj const& proj = Proj{}) {
929 ParallelCopy(dest, src, cmd, SrcComp(srccomp), DestComp(destcomp), NumComps(numcomp), dtos, proj);
930}
931
961template <typename FAB, typename DTOS = Identity, typename Proj = Identity>
962std::enable_if_t<IsBaseFab<FAB>() && IsIndexMapping<DTOS>() && IsFabProjection<Proj, FAB>(),
963MultiBlockCommMetaData>
964ParallelCopy (FabArray<FAB>& dest, const Box& destbox, const FabArray<FAB>& src, SrcComp srccomp,
965 DestComp destcomp, NumComps numcomp, const IntVect& ngrow, DTOS const& dtos = DTOS{}, Proj const& proj = Proj{}) {
966 MultiBlockCommMetaData cmd(dest, destbox, src, ngrow, dtos);
967 ParallelCopy(dest, src, cmd, srccomp, destcomp, numcomp, dtos, proj);
968 return cmd;
969}
970
1000template <typename FAB, typename DTOS = Identity, typename Proj = Identity>
1001std::enable_if_t<IsBaseFab<FAB>() && IsIndexMapping<DTOS>() && IsFabProjection<Proj, FAB>(),
1002MultiBlockCommMetaData>
1003ParallelCopy (FabArray<FAB>& dest, const Box& destbox, const FabArray<FAB>& src, int srccomp,
1004 int destcomp, int numcomp, const IntVect& ngrow, DTOS const& dtos = DTOS{}, Proj const& proj = Proj{}) {
1005 return ParallelCopy(dest, destbox, src, SrcComp(srccomp), DestComp(destcomp), NumComps(numcomp), ngrow, dtos, proj);
1006}
1007
1008// Rotate90 fills the lo-x and lo-y boundary regions by rotating the data
1009// around (x=0,y=0) by 90 degrees in either direction. It also fills the
1010// corner of lo-x and lo-y boundary region by rotating the data by 180
1011// degrees.
1012
1013template <class FAB>
1014std::enable_if_t<IsBaseFab<FAB>::value>
1015Rotate90 (FabArray<FAB>& mf, int scomp, int ncomp, IntVect const& nghost, Box const& domain);
1016
1017template <class FAB>
1018std::enable_if_t<IsBaseFab<FAB>::value>
1019Rotate90 (FabArray<FAB>& mf, Box const& domain);
1020
1021// Rotate180 fills the lo-x boundary by rotating the data around
1022// (x=0,y=L_y/2) by 180 degrees.
1023
1024template <class FAB>
1025std::enable_if_t<IsBaseFab<FAB>::value>
1026Rotate180 (FabArray<FAB>& mf, int scomp, int ncomp, IntVect const& nghost, Box const& domain);
1027
1028template <class FAB>
1029std::enable_if_t<IsBaseFab<FAB>::value>
1030Rotate180 (FabArray<FAB>& mf, Box const& domain);
1031
1032// Fill the polar boundaries of the spherical coordinates (theta, phi, r).
1033// The lo-x boundary is filled with f(-x,y) = f(x,mod(y+pi,2*pi)), and
1034// the hi-x boundary is filled with f(pi+x,y) = f(pi-x,mod(y+pi,2*pi)).
1035
1036template <class FAB>
1037std::enable_if_t<IsBaseFab<FAB>::value>
1038FillPolar (FabArray<FAB>& mf, int scomp, int ncomp, IntVect const& nghost, Box const& domain);
1039
1040template <class FAB>
1041std::enable_if_t<IsBaseFab<FAB>::value>
1042FillPolar (FabArray<FAB>& mf, Box const& domain);
1043
1080template <typename FAB, typename DTOS, typename Proj = Identity>
1081[[nodiscard]]
1082std::enable_if_t<IsBaseFab<FAB>() &&
1087 int scomp, int ncomp, DTOS const& dtos,
1088 Proj const& proj = Proj{});
1089
1125template <typename FAB, typename DTOS, typename Proj = Identity>
1126std::enable_if_t<IsBaseFab<FAB>() &&
1128 IsFabProjection<Proj,FAB>()>
1131 int scomp, int ncomp, DTOS const& dtos,
1132 Proj const& proj = Proj{});
1133
1165template <typename FAB, typename DTOS, typename Proj = Identity>
1166std::enable_if_t<IsBaseFab<FAB>() &&
1168 IsFabProjection<Proj,FAB>()>
1170 int scomp, int ncomp, DTOS const& dtos, Proj const& proj = Proj{})
1171{
1172 BL_PROFILE("FillBoundary(cmd)");
1173 auto handler = FillBoundary_nowait(mf, cmd, scomp, ncomp, dtos, proj);
1174 FillBoundary_finish(std::move(handler), mf, cmd, scomp, ncomp, dtos, proj);
1175}
1176
1191template <typename FAB, typename DTOS>
1192[[nodiscard]]
1193std::enable_if_t<IsBaseFab<FAB>() && IsCallableR<Dim3,DTOS,Dim3>(),
1194 FabArrayBase::CommMetaData>
1196 Geometry const& geom, DTOS const& dtos);
1197
1198}
1199
1200#include <AMReX_NonLocalBCImpl.H>
1201
1202namespace amrex {
1207 using NonLocalBC::SphThetaPhiRIndexMapping;
1208 using NonLocalBC::SphThetaPhiRComponentMapping;
1215}
1216
1217#endif
#define BL_PROFILE(a)
Definition AMReX_BLProfiler.H:551
#define AMREX_ASSERT(EX)
Definition AMReX_BLassert.H:38
#define AMREX_NODISCARD
Definition AMReX_Extension.H:251
std::enable_if_t< IsFabArray< MF >::value > FillBoundary(Vector< MF * > const &mf, Vector< int > const &scomp, Vector< int > const &ncomp, Vector< IntVect > const &nghost, Vector< Periodicity > const &period, Vector< int > const &cross={})
Definition AMReX_FabArrayCommI.H:932
#define AMREX_GPU_HOST_DEVICE
Definition AMReX_GpuQualifiers.H:20
A collection of Boxes stored in an Array.
Definition AMReX_BoxArray.H:550
AMREX_GPU_HOST_DEVICE BoxND & setType(const IndexTypeND< dim > &t) noexcept
Set indexing type.
Definition AMReX_Box.H:492
AMREX_GPU_HOST_DEVICE IndexTypeND< dim > ixType() const noexcept
Returns the indexing type.
Definition AMReX_Box.H:127
AMREX_GPU_HOST_DEVICE const IntVectND< dim > & smallEnd() const &noexcept
Get the smallend of the BoxND.
Definition AMReX_Box.H:105
AMREX_GPU_HOST_DEVICE const IntVectND< dim > & bigEnd() const &noexcept
Get the bigend.
Definition AMReX_Box.H:116
Calculates the distribution of FABs to MPI processes.
Definition AMReX_DistributionMapping.H:41
A Fortran Array of REALs.
Definition AMReX_FArrayBox.H:229
Base class for FabArray.
Definition AMReX_FabArrayBase.H:41
CopyComTag::CopyComTagsContainer CopyComTagsContainer
Definition AMReX_FabArrayBase.H:219
CopyComTag::MapOfCopyComTagContainers MapOfCopyComTagContainers
Definition AMReX_FabArrayBase.H:220
bool empty() const noexcept
Definition AMReX_FabArrayBase.H:88
An Array of FortranArrayBox(FAB)-like Objects.
Definition AMReX_FabArray.H:344
static void pack_send_buffer_gpu(FabArray< FAB > const &src, int scomp, int ncomp, Vector< char * > const &send_data, Vector< std::size_t > const &send_size, Vector< const CopyComTagsContainer * > const &send_cctc)
static void pack_send_buffer_cpu(FabArray< FAB > const &src, int scomp, int ncomp, Vector< char * > const &send_data, Vector< std::size_t > const &send_size, Vector< const CopyComTagsContainer * > const &send_cctc)
Rectangular problem domain geometry.
Definition AMReX_Geometry.H:73
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Dim3 dim3() const noexcept
Definition AMReX_IntVect.H:163
This class is a thin wrapper around std::vector. Unlike vector, Vector::operator[] provides bound che...
Definition AMReX_Vector.H:27
@ FAB
Definition AMReX_AmrvisConstants.H:86
bool inLaunchRegion() noexcept
Definition AMReX_GpuControl.H:86
Definition AMReX_NonLocalBC.cpp:3
decltype(UnpackRecvBuffers(std::declval< Args >()...)) UnpackRecvBuffers_t
Definition AMReX_NonLocalBC.H:473
std::enable_if_t< IsCallableR< Dim3, DTOS, Dim3 >::value, IntVect > Apply(DTOS const &dtos, const IntVect &iv)
Applies the Dim3 to Dim3 mapping onto IntVects.
Definition AMReX_NonLocalBC.H:102
std::enable_if_t< IsBaseFab< FAB >() &&IsCallableR< Dim3, DTOS, Dim3 >() &&IsFabProjection< Proj, FAB >()> unpack_recv_buffer_cpu(FabArray< FAB > &mf, int dcomp, int ncomp, Vector< char * > const &recv_data, Vector< std::size_t > const &recv_size, Vector< FabArrayBase::CopyComTagsContainer const * > const &recv_cctc, DTOS const &dtos=DTOS{}, Proj const &proj=Proj{}) noexcept
decltype(std::declval< T >().Inverse(std::declval< Args >()...)) Inverse_t
Return type of an InverseImage class member function.
Definition AMReX_NonLocalBC.H:16
std::enable_if_t< IsBaseFab< FAB >::value > Rotate90(FabArray< FAB > &mf, int scomp, int ncomp, IntVect const &nghost, Box const &domain)
std::enable_if_t< IsBaseFab< FAB >() &&IsCallableR< Dim3, DTOS, Dim3 >() &&IsFabProjection< Proj, FAB >()> FillBoundary(FabArray< FAB > &mf, const FabArrayBase::CommMetaData &cmd, int scomp, int ncomp, DTOS const &dtos, Proj const &proj=Proj{})
Fill ghost cells for FabArray/MultiFab.
Definition AMReX_NonLocalBC.H:1169
decltype(PackSendBuffers(std::declval< Args >()...)) PackSendBuffers_t
Definition AMReX_NonLocalBC.H:470
void PrepareCommBuffers(CommData &comm, const FabArrayBase::MapOfCopyComTagContainers &cctc, int n_components, std::size_t object_size, std::size_t align)
Fill all class member variables of comm but the request and the stats vector.
Definition AMReX_NonLocalBC.cpp:41
std::enable_if_t< IsBaseFab< FAB >::value > Rotate180(FabArray< FAB > &mf, int scomp, int ncomp, IntVect const &nghost, Box const &domain)
std::enable_if_t< IsCallableR< Dim3, DTOS, Dim3 >::value &&!IsCallableR< IndexType, DTOS, IndexType >::value, Box > Image(DTOS const &dtos, const Box &box)
Applies the Dim3 to Dim3 mapping onto Boxes but does not change the index type.
Definition AMReX_NonLocalBC.H:118
std::enable_if_t< IsBaseFab< FAB >::value > LocalCopy(const PackComponents &components, FabArray< FAB > &dest, const FabArray< FAB > &src, const FabArrayBase::CopyComTagsContainer &local_tags)
Dispatch local copies to the default behaviour that knows no DTOS nor projection.
Definition AMReX_NonLocalBC.H:541
decltype(LocalCopy(std::declval< Args >()...)) LocalCopy_t
Definition AMReX_NonLocalBC.H:476
std::enable_if_t< HasInverseMemFn< DTOS >::value, IntVect > ApplyInverse(DTOS const &dtos, const IntVect &iv)
Applies the Dim3 to Dim3 invserse mapping onto IntVects.
Definition AMReX_NonLocalBC.H:163
void PostSends(CommData &send, int mpi_tag)
Initiate all sends with MPI_Isend calls associated with tag mpi_tag.
Definition AMReX_NonLocalBC.cpp:121
static constexpr SwapComponents< I, J > swap_indices
Definition AMReX_NonLocalBC.H:388
void PostRecvs(CommData &recv, int mpi_tag)
Initiate all recvieves with MPI_Irecv calls associated with tag mpi_tag.
Definition AMReX_NonLocalBC.cpp:105
std::enable_if_t< IsBaseFab< FAB >() &&IsCallableR< Dim3, DTOS, Dim3 >(), FabArrayBase::CommMetaData > makeFillBoundaryMetaData(FabArray< FAB > &mf, IntVect const &nghost, Geometry const &geom, DTOS const &dtos)
Make metadata for FillBoundary.
AMREX_NODISCARD CommHandler ParallelCopy_nowait(NoLocalCopy, FabArray< FAB > &dest, const FabArray< FAB > &src, const FabArrayBase::CommMetaData &cmd, const DataPacking &data_packing)
Definition AMReX_NonLocalBC.H:705
std::enable_if_t< IsBaseFab< FAB >() &&IsCallableR< Dim3, DTOS, Dim3 >() &&IsFabProjection< Proj, FAB >()> local_copy_gpu(FabArray< FAB > &dest, const FabArray< FAB > &src, int dcomp, int scomp, int ncomp, FabArrayBase::CopyComTagsContainer const &local_tags, DTOS const &dtos=DTOS{}, Proj const &proj=Proj{}) noexcept
std::enable_if_t< IsBaseFab< FAB >() &&IsCallableR< Dim3, DTOS, Dim3 >() &&IsFabProjection< Proj, FAB >()> FillBoundary_finish(CommHandler handler, FabArray< FAB > &mf, const FabArrayBase::CommMetaData &cmd, int scomp, int ncomp, DTOS const &dtos, Proj const &proj=Proj{})
Finish communication started by FillBoundary_nowait.
std::enable_if_t< IsBaseFab< FAB >::value > FillPolar(FabArray< FAB > &mf, int scomp, int ncomp, IntVect const &nghost, Box const &domain)
static constexpr struct amrex::NonLocalBC::DoLocalCopy do_local_copy
decltype(PrepareSendBuffers(std::declval< Args >()...)) PrepareSendBuffers_t
Definition AMReX_NonLocalBC.H:464
std::enable_if_t< HasInverseMemFn< DTOS >::value &&!IsCallableR< IndexType, DTOS, IndexType >::value, Box > InverseImage(DTOS const &dtos, const Box &box)
Applies the inverse Dim3 to Dim3 mapping onto Boxes without changing the index type.
Definition AMReX_NonLocalBC.H:178
template MultiBlockCommMetaData ParallelCopy(FabArray< FArrayBox > &dest, const Box &destbox, const FabArray< FArrayBox > &src, int destcomp, int srccomp, int numcomp, const IntVect &ngrow, MultiBlockIndexMapping const &, Identity const &)
std::enable_if_t< IsBaseFab< FAB >() &&IsCallableR< Dim3, DTOS, Dim3 >() &&IsFabProjection< Proj, FAB >()> local_copy_cpu(FabArray< FAB > &dest, const FabArray< FAB > &src, int dcomp, int scomp, int ncomp, FabArrayBase::CopyComTagsContainer const &local_tags, DTOS const &dtos=DTOS{}, Proj const &proj=Proj{}) noexcept
std::enable_if_t< IsBaseFab< FAB >::value > PrepareRecvBuffers(const PackComponents &components, FabArray< FAB > &dest, const FabArray< FAB > &src, CommData &comm, const FabArrayBase::MapOfCopyComTagContainers &cctc)
Calls PrepareComBuffers.
Definition AMReX_NonLocalBC.H:569
static constexpr Identity identity
Definition AMReX_NonLocalBC.H:296
decltype(PrepareRecvBuffers(std::declval< Args >()...)) PrepareRecvBuffers_t
Definition AMReX_NonLocalBC.H:467
std::enable_if_t< IsBaseFab< FAB >() &&IsCallableR< Dim3, DTOS, Dim3 >() &&IsFabProjection< Proj, FAB >(), CommHandler > FillBoundary_nowait(FabArray< FAB > &mf, const FabArrayBase::CommMetaData &cmd, int scomp, int ncomp, DTOS const &dtos, Proj const &proj=Proj{})
Start communication to fill boundary.
std::enable_if_t< IsBaseFab< FAB >::value > UnpackRecvBuffers(const PackComponents &components, FabArray< FAB > &dest, const CommData &recv)
De-serializes FAB data without any knowledge of a DTOS nor a projection.
Definition AMReX_NonLocalBC.H:595
std::enable_if_t< IsBaseFab< FAB >::value > PrepareSendBuffers(const PackComponents &components, FabArray< FAB > &dest, const FabArray< FAB > &src, CommData &comm, const FabArrayBase::MapOfCopyComTagContainers &cctc)
Calls PrepareComBuffers.
Definition AMReX_NonLocalBC.H:559
std::enable_if_t< IsBaseFab< FAB >() &&IsCallableR< Dim3, DTOS, Dim3 >() &&IsFabProjection< Proj, FAB >()> unpack_recv_buffer_gpu(FabArray< FAB > &mf, int scomp, int ncomp, Vector< char * > const &recv_data, Vector< std::size_t > const &recv_size, Vector< FabArrayBase::CopyComTagsContainer const * > const &recv_cctc, DTOS const &dtos=DTOS{}, Proj const &proj=Proj{})
static constexpr struct amrex::NonLocalBC::NoLocalCopy no_local_copy
SwapComponents<-1, -1 > DynamicSwapComponents
Definition AMReX_NonLocalBC.H:386
std::enable_if_t< IsBaseFab< FAB >::value > PackSendBuffers(const PackComponents &components, const FabArray< FAB > &src, CommData &send)
Serializes FAB data without any knowledge of a DTOS nor a projection.
Definition AMReX_NonLocalBC.H:579
std::enable_if_t< IsBaseFab< FAB >() &&IsDataPacking< DataPacking, FAB >()> ParallelCopy_finish(FabArray< FAB > &dest, CommHandler handler, const FabArrayBase::CommMetaData &cmd, const DataPacking &data_packing)
Definition AMReX_NonLocalBC.H:797
int NProcsSub() noexcept
number of ranks in current frame
Definition AMReX_ParallelContext.H:74
void Waitall(Vector< MPI_Request > &, Vector< MPI_Status > &)
Definition AMReX_ParallelDescriptor.cpp:1298
int SeqNum() noexcept
Returns sequential message sequence numbers, usually used as tags for send/recv.
Definition AMReX_ParallelDescriptor.H:613
Definition AMReX_Amr.cpp:49
std::unique_ptr< char, TheFaArenaDeleter > TheFaArenaPointer
Definition AMReX_FabArray.H:104
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void ignore_unused(const Ts &...)
This shuts up the compiler about unused variables.
Definition AMReX.H:127
void Abort(const std::string &msg)
Print out message to cerr and exit via abort().
Definition AMReX.cpp:230
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:1900
std::is_same< Expected, Detected_t< Op, Args... > > IsDetectedExact
Definition AMReX_TypeTraits.H:181
Definition AMReX_Array4.H:61
Logical traits let us combine multiple type requirements in one enable_if_t clause.
Definition AMReX_TypeTraits.H:225
Definition AMReX_BaseFab.H:72
int i
Definition AMReX_BaseFab.H:75
Definition AMReX_Dim3.H:12
int x
Definition AMReX_Dim3.H:12
int z
Definition AMReX_Dim3.H:12
int y
Definition AMReX_Dim3.H:12
Definition AMReX_FabArrayBase.H:471
std::unique_ptr< MapOfCopyComTagContainers > m_RcvTags
Definition AMReX_FabArrayBase.H:477
std::unique_ptr< MapOfCopyComTagContainers > m_SndTags
Definition AMReX_FabArrayBase.H:476
std::unique_ptr< CopyComTagsContainer > m_LocTags
Definition AMReX_FabArrayBase.H:475
Test if a given type T is callable with arguments of type Args...
Definition AMReX_TypeTraits.H:207
Test if a given type T is callable with arguments of type Args...
Definition AMReX_TypeTraits.H:201
This class specializes behaviour on local copies and unpacking receive buffers.
Definition AMReX_NonLocalBC.H:619
constexpr ApplyDtosAndProjectionOnReciever(const PackComponents &components, DTOS dtos_=DTOS{}, FabProj proj_=FabProj{})
Definition AMReX_NonLocalBC.H:621
FabProj proj
Definition AMReX_NonLocalBC.H:625
DTOS dtos
Definition AMReX_NonLocalBC.H:624
This class holds data buffers for either immediate MPI send or recv calls.
Definition AMReX_NonLocalBC.H:415
Vector< std::size_t > size
The size in bytes for each data transaction.
Definition AMReX_NonLocalBC.H:426
Vector< char * > data
Pointers to the_data that can be used for each single data transaction.
Definition AMReX_NonLocalBC.H:422
Vector< const FabArrayBase::CopyComTagsContainer * > cctc
For each request the copy comm tags for the corresponding data FABs.
Definition AMReX_NonLocalBC.H:432
Vector< MPI_Status > stats
For each request the corresponding MPI_status, used for debugging.
Definition AMReX_NonLocalBC.H:430
Vector< MPI_Request > request
The associated MPI_Request for each data transaction.
Definition AMReX_NonLocalBC.H:428
TheFaArenaPointer the_data
Holds 'em all in one data pointer.
Definition AMReX_NonLocalBC.H:418
Vector< int > rank
Stores MPI ranks. For recvs it is the 'from' rank and for sends it is the 'to' rank.
Definition AMReX_NonLocalBC.H:420
Vector< std::size_t > offset
All offsets of data in the_data.
Definition AMReX_NonLocalBC.H:424
This class stores both recv and send buffers with an associated MPI tag.
Definition AMReX_NonLocalBC.H:452
CommData send
Definition AMReX_NonLocalBC.H:456
int mpi_tag
Definition AMReX_NonLocalBC.H:454
CommData recv
Definition AMReX_NonLocalBC.H:455
Definition AMReX_NonLocalBC.H:677
Type trait that tests if T has an InverseImage class member function.
Definition AMReX_NonLocalBC.H:20
This class acts as a default no-op operator.
Definition AMReX_NonLocalBC.H:280
constexpr Dim3 operator()(Dim3 i) const noexcept
The identity function for Dim3.
Definition AMReX_NonLocalBC.H:282
constexpr T operator()(Array4< const T > array, Dim3 i, int comp=0) const noexcept(noexcept(array(i.x, i.y, i.z, comp)))
Definition AMReX_NonLocalBC.H:288
constexpr int operator()(int i) const noexcept
The identity for int.
Definition AMReX_NonLocalBC.H:294
static constexpr Dim3 Inverse(Dim3 i) noexcept
The identity function for Dim3.
Definition AMReX_NonLocalBC.H:284
This type trait tests if a given type DP satisfies the DataPacking concept for type FAB.
Definition AMReX_NonLocalBC.H:492
This type trait tests if a type P is a projection for FAB.
Definition AMReX_NonLocalBC.H:271
Tests if a given type IndexMap is usable as an index mapping between two index based coordinate syste...
Definition AMReX_NonLocalBC.H:27
This class takes a projection and a component map and combines them to form a new projection.
Definition AMReX_NonLocalBC.H:314
Base base
Definition AMReX_NonLocalBC.H:321
Map map
Definition AMReX_NonLocalBC.H:322
This is the index mapping based on the DTOS MultiBlockDestToSrc.
Definition AMReX_NonLocalBC.H:210
MultiBlockCommMetaData(const FabArrayBase &dst, const Box &dstbox, const FabArrayBase &src, const IntVect &ngrow, DTOS const &dtos)
Build global meta data by calling the define() member function.
std::enable_if_t< IsIndexMapping< DTOS >::value > define(const BoxArray &dstba, const DistributionMapping &dstdm, const Box &dstbox, const BoxArray &srcba, const DistributionMapping &srcdm, const IntVect &ngrow, DTOS const &dtos)
Build global meta data that is being used to identify send and recv dependencies in communication rou...
MultiBlockCommMetaData(const BoxArray &dstba, const DistributionMapping &dstdm, const Box &dstbox, const BoxArray &srcba, const DistributionMapping &srcdm, const IntVect &ngrow, DTOS const &dtos)
Build global meta data by calling the define() member function.
This struct describes an affine index transformation for two coordinate systems.
Definition AMReX_NonLocalBC.H:37
IndexType operator()(IndexType it) const noexcept
Definition AMReX_NonLocalBC.H:76
IntVect sign
A vector of 1 and -1 describing the orientation in each component.
Definition AMReX_NonLocalBC.H:43
IntVect offset
The offset in the source index space.
Definition AMReX_NonLocalBC.H:41
AMREX_GPU_HOST_DEVICE Dim3 operator()(Dim3 i) const noexcept
Applies this mapping on the index from destination space and returns an index in the source space.
Definition AMReX_NonLocalBC.H:51
IntVect permutation
This vector needs to be a valid permutation.
Definition AMReX_NonLocalBC.H:39
IndexType Inverse(IndexType it) const noexcept
Definition AMReX_NonLocalBC.H:80
AMREX_GPU_HOST_DEVICE Dim3 Inverse(Dim3 i) const noexcept
The inverse function is given by rearringing all above terms.
Definition AMReX_NonLocalBC.H:66
Definition AMReX_NonLocalBC.H:676
Contains information about which components take part of the data transaction.
Definition AMReX_NonLocalBC.H:532
int dest_component
Definition AMReX_NonLocalBC.H:533
int src_component
Definition AMReX_NonLocalBC.H:534
int n_components
Definition AMReX_NonLocalBC.H:535
Definition AMReX_NonLocalBC.H:377
int J
Definition AMReX_NonLocalBC.H:379
int I
Definition AMReX_NonLocalBC.H:378
constexpr int operator()(int i) const noexcept
Definition AMReX_NonLocalBC.H:380
constexpr int operator()(int i) const noexcept
Definition AMReX_NonLocalBC.H:371
int I
Definition AMReX_NonLocalBC.H:370
int J
Definition AMReX_NonLocalBC.H:360
constexpr int operator()(int i) const noexcept
Definition AMReX_NonLocalBC.H:361
This is a permutation where only two components are swapped.
Definition AMReX_NonLocalBC.H:345
constexpr int operator()(int i) const noexcept
Swaps indices I and J.
Definition AMReX_NonLocalBC.H:351
Definition AMReX_BaseFab.H:78
int n
Definition AMReX_BaseFab.H:81
Definition AMReX_BaseFab.H:66
int i
Definition AMReX_BaseFab.H:69