MCPcopy Create free account
hub / github.com/AMReX-Codes/amrex / ParallelCopyFaceToFace

Function ParallelCopyFaceToFace

Tests/MultiBlock/IndexType/main.cpp:89–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87}
88
89bool ParallelCopyFaceToFace(amrex::iMultiFab& dest, const amrex::Box& domain_dest, amrex::Orientation::Side dest_side,
90 const amrex::iMultiFab& src, const amrex::Box& domain_src, amrex::Orientation::Side src_side)
91{
92 int sdir = GetFaceDir(domain_src.ixType());
93 int ddir = GetFaceDir(domain_dest.ixType());
94 const amrex::Box src_box = GetFaceBoundary(domain_src, src_side);
95 const amrex::Box dest_box = GetFaceBoundary(domain_dest, dest_side);
96
97 // Default construction is identity
98 amrex::NonLocalBC::MultiBlockIndexMapping dtos{};
99 // Change permutation to get a correct mapping between index types
100 std::swap(dtos.permutation[sdir], dtos.permutation[ddir]);
101 // Map smallest destination box index as an index in the source space
102 const amrex::IntVect dest_smallEnd_in_src = amrex::NonLocalBC::Apply(dtos, dest_box.smallEnd());
103 // Compute the offset to get the proper shift in the source space
104 dtos.offset = dest_smallEnd_in_src - src_box.smallEnd();
105 // Sanity-Check that the correct box is being mapped
106 // Note, this checks index types, too!
107 AMREX_ASSERT(amrex::NonLocalBC::Image(dtos, dest_box) == src_box);
108
109 amrex::NonLocalBC::ParallelCopy(dest, dest_box, src, 0, 0, 1, amrex::IntVect{0}, dtos);
110 int fails = 0;
111 const int nx = domain_src.length(0);
112 const int ny = domain_src.length(1);
113 amrex::ReduceOps<amrex::ReduceOpSum> reduce_op;
114 amrex::ReduceData<int> reduce_data(reduce_op);
115 using ReduceTuple = amrex::GpuTuple<int>;
116 for (amrex::MFIter mfi(dest); mfi.isValid(); ++mfi) {
117 const amrex::Box section = dest_box & mfi.tilebox();
118 if (section.isEmpty()) { continue; }
119 auto darray = dest.const_array(mfi);
120 reduce_op.eval(section, reduce_data,
121 [=] AMREX_GPU_DEVICE (int i, int j, int k) -> ReduceTuple
122 {
123 amrex::Dim3 si = dtos(amrex::Dim3{.x = i, .y = j, .z = k});
124 int value = si.x + si.y*nx + si.z*nx*ny;
125 auto r = int(darray(i,j,k) != value);
126 return { r };
127 });
128 }
129 fails += amrex::get<0>(reduce_data.value());
130 return fails == 0;
131}
132
133int MyMain()
134{

Callers 1

MyMainFunction · 0.85

Calls 13

GetFaceDirFunction · 0.85
GetFaceBoundaryFunction · 0.85
ImageFunction · 0.85
tileboxMethod · 0.80
ApplyFunction · 0.50
ParallelCopyFunction · 0.50
ixTypeMethod · 0.45
lengthMethod · 0.45
isValidMethod · 0.45
isEmptyMethod · 0.45
const_arrayMethod · 0.45
evalMethod · 0.45

Tested by

no test coverage detected