7def get_face_merge_implementation(patch_overlap):
10 Generic exchange of block-structured halo layers
12 This routine realises a halo exchange via plain copies. It assumes that the
13 overhead itself is modelled as a patch, where the first dimension of the
14 patch_overlap is actually the "short" dimension, i.e. the direction which
15 indeed overlaps with the two adjacent patches. It has to be a multiple of 2.
16 The other remaining dimensions are plain Cartesian overlaps and match the
17 size of the adjacent blocks.
21 "OVERLAP": int(patch_overlap.dim[0]/2),
22 "DOFS_PER_AXIS": int(patch_overlap.dim[1]),
23 "UNKNOWNS": int(patch_overlap.no_of_unknowns)
28 auto serialisePatchIndex = [](tarch::la::Vector<Dimensions,int> overlapCell, int normal) {{
31 for (int d=0; d<Dimensions; d++) {{
32 result += overlapCell(d) * base;
37 base *= {DOFS_PER_AXIS};
45 case ::peano4::grid::TraversalObserver::SendReceiveContext::PeriodicBoundaryDataSwap:
46 case ::peano4::grid::TraversalObserver::SendReceiveContext::BoundaryExchange:
48 const int faceNormal = marker.getSelectedFaceNumber() % Dimensions;
49 dfore(i,{DOFS_PER_AXIS},faceNormal,0) {{
50 for (int j=0; j<{OVERLAP}; j++) {{
51 tarch::la::Vector<Dimensions,int> volume = i;
52 volume(faceNormal) += marker.outerNormal()(faceNormal)>0 ? j + {OVERLAP} : j;
54 int volumeSerialised = serialisePatchIndex(volume, faceNormal);
55 for (int k=0; k<{UNKNOWNS}; k++) {{
57 neighbour.value[volumeSerialised*{UNKNOWNS}+k]==neighbour.value[volumeSerialised*{UNKNOWNS}+k],
58 value[volumeSerialised*{UNKNOWNS}+k],
64 value[volumeSerialised*{UNKNOWNS}+k] = neighbour.value[volumeSerialised*{UNKNOWNS}+k];
68 // This should be non-critical assertion, but this assertion is only
69 // generically available in ExaHyPE 2, so I comment the assertion out
71 // assertion(value[volumeSerialised]==value[volumeSerialised]);
77 case ::peano4::grid::TraversalObserver::SendReceiveContext::MultiscaleExchange:
78 assertionMsg( false, "not implemented yet" );
82 assertionMsg( false, "not implemented yet" );
87 return template.format(**d)