hypre_BoxArray * hypre_GrowBoxByStencil( hypre_Box *box, hypre_StructStencil *stencil, int transpose ) { hypre_BoxArray *grow_box_array; hypre_BoxArray *shift_box_array; hypre_Box *shift_box; hypre_Index *stencil_shape; int s, d; stencil_shape = hypre_StructStencilShape(stencil); shift_box_array = hypre_BoxArrayCreate(hypre_StructStencilSize(stencil)); shift_box = hypre_BoxCreate(); for (s = 0; s < hypre_StructStencilSize(stencil); s++) { if (transpose) for (d = 0; d < 3; d++) { hypre_BoxIMinD(shift_box, d) = hypre_BoxIMinD(box, d) - hypre_IndexD(stencil_shape[s], d); hypre_BoxIMaxD(shift_box, d) = hypre_BoxIMaxD(box, d) - hypre_IndexD(stencil_shape[s], d); } else for (d = 0; d < 3; d++) { hypre_BoxIMinD(shift_box, d) = hypre_BoxIMinD(box, d) + hypre_IndexD(stencil_shape[s], d); hypre_BoxIMaxD(shift_box, d) = hypre_BoxIMaxD(box, d) + hypre_IndexD(stencil_shape[s], d); } hypre_CopyBox(shift_box, hypre_BoxArrayBox(shift_box_array, s)); } hypre_BoxDestroy(shift_box); hypre_UnionBoxes(shift_box_array); grow_box_array = shift_box_array; return grow_box_array; }
/*-------------------------------------------------------------------------- * hypre_CFInterfaceExtents: Given a cgrid_box, a fgrid_box, and stencils, * find the extents of the C/F interface (interface nodes in the C box). * Boxes corresponding to stencil shifts are stored in the first stencil_size * boxes, and the union of these are appended to the end of the returned * box_array. *--------------------------------------------------------------------------*/ hypre_BoxArray * hypre_CFInterfaceExtents( hypre_Box *fgrid_box, hypre_Box *cgrid_box, hypre_StructStencil *stencils, hypre_Index rfactors ) { hypre_BoxArray *stencil_box_extents; hypre_BoxArray *union_boxes; hypre_Box *cfine_box; hypre_Box *box; hypre_Index stencil_shape, cstart, zero_index, neg_index; HYPRE_Int stencil_size; HYPRE_Int abs_stencil; HYPRE_Int ndim= hypre_StructStencilDim(stencils); HYPRE_Int i, j; hypre_ClearIndex(zero_index); hypre_ClearIndex(neg_index); for (i= 0; i< ndim; i++) { neg_index[i]= -1; } hypre_CopyIndex(hypre_BoxIMin(cgrid_box), cstart); stencil_size = hypre_StructStencilSize(stencils); stencil_box_extents= hypre_BoxArrayCreate(stencil_size); union_boxes = hypre_BoxArrayCreate(0); for (i= 0; i< stencil_size; i++) { hypre_CopyIndex(hypre_StructStencilElement(stencils, i), stencil_shape); AbsStencilShape(stencil_shape, abs_stencil); if (abs_stencil) /* only do if not the centre stencil */ { cfine_box= hypre_CF_StenBox(fgrid_box, cgrid_box, stencil_shape, rfactors, ndim); if ( hypre_BoxVolume(cfine_box) ) { hypre_AppendBox(cfine_box, union_boxes); hypre_CopyBox(cfine_box, hypre_BoxArrayBox(stencil_box_extents, i)); for (j= 0; j< ndim; j++) { hypre_BoxIMin(cfine_box)[j]-= cstart[j]; hypre_BoxIMax(cfine_box)[j]-= cstart[j]; } hypre_CopyBox(cfine_box, hypre_BoxArrayBox(stencil_box_extents, i)); } else { hypre_BoxSetExtents(hypre_BoxArrayBox(stencil_box_extents, i), zero_index, neg_index); } hypre_BoxDestroy(cfine_box); } else /* centre */ { hypre_BoxSetExtents(hypre_BoxArrayBox(stencil_box_extents, i), zero_index, neg_index); } } /*-------------------------------------------------------------------------- * Union the stencil_box_extents to get the full CF extents and append to * the end of the stencil_box_extents BoxArray. Then shift the unioned boxes * by cstart. *--------------------------------------------------------------------------*/ if (hypre_BoxArraySize(union_boxes) > 1) { hypre_UnionBoxes(union_boxes); } hypre_ForBoxI(i, union_boxes) { hypre_AppendBox(hypre_BoxArrayBox(union_boxes, i), stencil_box_extents); }