HYPRE_Int hypre_BoxBoundaryIntersect( hypre_Box *box, hypre_StructGrid *grid, HYPRE_Int d, HYPRE_Int dir, hypre_BoxArray *boundary ) { HYPRE_Int ndim = hypre_BoxNDim(box); hypre_BoxManager *boxman; hypre_BoxManEntry **entries; hypre_BoxArray *int_boxes, *tmp_boxes; hypre_Box *bbox, *ibox; HYPRE_Int nentries, i; /* set bbox to the box surface of interest */ hypre_BoxArraySetSize(boundary, 1); bbox = hypre_BoxArrayBox(boundary, 0); hypre_CopyBox(box, bbox); if (dir > 0) { hypre_BoxIMinD(bbox, d) = hypre_BoxIMaxD(bbox, d); } else if (dir < 0) { hypre_BoxIMaxD(bbox, d) = hypre_BoxIMinD(bbox, d); } /* temporarily shift bbox in direction dir and intersect with the grid */ hypre_BoxIMinD(bbox, d) += dir; hypre_BoxIMaxD(bbox, d) += dir; boxman = hypre_StructGridBoxMan(grid); hypre_BoxManIntersect(boxman, hypre_BoxIMin(bbox), hypre_BoxIMax(bbox), &entries, &nentries); hypre_BoxIMinD(bbox, d) -= dir; hypre_BoxIMaxD(bbox, d) -= dir; /* shift intersected boxes in direction -dir and subtract from bbox */ int_boxes = hypre_BoxArrayCreate(nentries, ndim); tmp_boxes = hypre_BoxArrayCreate(0, ndim); for (i = 0; i < nentries; i++) { ibox = hypre_BoxArrayBox(int_boxes, i); hypre_BoxManEntryGetExtents( entries[i], hypre_BoxIMin(ibox), hypre_BoxIMax(ibox)); hypre_BoxIMinD(ibox, d) -= dir; hypre_BoxIMaxD(ibox, d) -= dir; } hypre_SubtractBoxArrays(boundary, int_boxes, tmp_boxes); hypre_BoxArrayDestroy(int_boxes); hypre_BoxArrayDestroy(tmp_boxes); hypre_TFree(entries); return hypre_error_flag; }
int hypre_StructMatrixDestroy( hypre_StructMatrix *matrix ) { int i; int ierr = 0; if (matrix) { hypre_StructMatrixRefCount(matrix) --; if (hypre_StructMatrixRefCount(matrix) == 0) { if (hypre_StructMatrixDataAlloced(matrix)) { hypre_SharedTFree(hypre_StructMatrixData(matrix)); } hypre_CommPkgDestroy(hypre_StructMatrixCommPkg(matrix)); hypre_ForBoxI(i, hypre_StructMatrixDataSpace(matrix)) hypre_TFree(hypre_StructMatrixDataIndices(matrix)[i]); hypre_TFree(hypre_StructMatrixDataIndices(matrix)); hypre_BoxArrayDestroy(hypre_StructMatrixDataSpace(matrix)); hypre_TFree(hypre_StructMatrixSymmElements(matrix)); hypre_StructStencilDestroy(hypre_StructMatrixUserStencil(matrix)); hypre_StructStencilDestroy(hypre_StructMatrixStencil(matrix)); hypre_StructGridDestroy(hypre_StructMatrixGrid(matrix)); hypre_TFree(matrix); } } return ierr; }
int hypre_SMGRelaxSetBase( void *relax_vdata, hypre_Index base_index, hypre_Index base_stride ) { hypre_SMGRelaxData *relax_data = relax_vdata; int d; int ierr = 0; for (d = 0; d < 3; d++) { hypre_IndexD((relax_data -> base_index), d) = hypre_IndexD(base_index, d); hypre_IndexD((relax_data -> base_stride), d) = hypre_IndexD(base_stride, d); } if ((relax_data -> base_box_array) != NULL) { hypre_BoxArrayDestroy((relax_data -> base_box_array)); (relax_data -> base_box_array) = NULL; } (relax_data -> setup_temp_vec) = 1; (relax_data -> setup_a_rem) = 1; (relax_data -> setup_a_sol) = 1; return ierr; }
int hypre_SMGRelaxDestroy( void *relax_vdata ) { hypre_SMGRelaxData *relax_data = relax_vdata; int ierr = 0; if (relax_data) { hypre_TFree(relax_data -> space_indices); hypre_TFree(relax_data -> space_strides); hypre_TFree(relax_data -> pre_space_ranks); hypre_TFree(relax_data -> reg_space_ranks); hypre_BoxArrayDestroy(relax_data -> base_box_array); hypre_StructMatrixDestroy(relax_data -> A); hypre_StructVectorDestroy(relax_data -> b); hypre_StructVectorDestroy(relax_data -> x); hypre_SMGRelaxDestroyTempVec(relax_vdata); hypre_SMGRelaxDestroyARem(relax_vdata); hypre_SMGRelaxDestroyASol(relax_vdata); hypre_FinalizeTiming(relax_data -> time_index); hypre_TFree(relax_data); } return ierr; }
int hypre_SMGResidualDestroy(void *residual_vdata) { int ierr = 0; hypre_SMGResidualData *residual_data = residual_vdata; if (residual_data != (0)) { hypre_StructMatrixDestroy((residual_data -> A)); hypre_StructVectorDestroy((residual_data -> x)); hypre_StructVectorDestroy((residual_data -> b)); hypre_StructVectorDestroy((residual_data -> r)); hypre_BoxArrayDestroy((residual_data -> base_points)); hypre_ComputePkgDestroy((residual_data -> compute_pkg)); hypre_FinalizeTiming((residual_data -> time_index)); (hypre_Free(((char *)residual_data)) , (residual_data = ((0)))); } return ierr; }
int hypre_BoxArrayArrayDestroy( hypre_BoxArrayArray *box_array_array ) { int ierr = 0; int i; if (box_array_array) { hypre_ForBoxArrayI(i, box_array_array) hypre_BoxArrayDestroy( hypre_BoxArrayArrayBoxArray(box_array_array, i)); hypre_TFree(hypre_BoxArrayArrayBoxArrays(box_array_array)); hypre_TFree(box_array_array); } return ierr; }
hypre_BoxArrayArray * hypre_GrowBoxArrayByStencil( hypre_BoxArray *box_array, hypre_StructStencil *stencil, int transpose ) { hypre_BoxArrayArray *grow_box_array_array; int i; grow_box_array_array = hypre_BoxArrayArrayCreate(hypre_BoxArraySize(box_array)); hypre_ForBoxI(i, box_array) { hypre_BoxArrayDestroy( hypre_BoxArrayArrayBoxArray(grow_box_array_array, i)); hypre_BoxArrayArrayBoxArray(grow_box_array_array, i) = hypre_GrowBoxByStencil(hypre_BoxArrayBox(box_array, i), stencil, transpose); }
HYPRE_Int hypre_StructVectorDestroy( hypre_StructVector *vector ) { if (vector) { hypre_StructVectorRefCount(vector) --; if (hypre_StructVectorRefCount(vector) == 0) { if (hypre_StructVectorDataAlloced(vector)) { hypre_SharedTFree(hypre_StructVectorData(vector)); } hypre_TFree(hypre_StructVectorDataIndices(vector)); hypre_BoxArrayDestroy(hypre_StructVectorDataSpace(vector)); hypre_StructGridDestroy(hypre_StructVectorGrid(vector)); hypre_TFree(vector); } } return hypre_error_flag; }
HYPRE_Int hypre_BoxBoundaryG( hypre_Box *box, hypre_StructGrid *g, hypre_BoxArray *boundary ) { HYPRE_Int ndim = hypre_BoxNDim(box); hypre_BoxArray *boundary_d; HYPRE_Int d; boundary_d = hypre_BoxArrayCreate(0, ndim); for (d = 0; d < ndim; d++) { hypre_BoxBoundaryIntersect(box, g, d, -1, boundary_d); hypre_AppendBoxArray(boundary_d, boundary); hypre_BoxBoundaryIntersect(box, g, d, 1, boundary_d); hypre_AppendBoxArray(boundary_d, boundary); } hypre_BoxArrayDestroy(boundary_d); return hypre_error_flag; }
HYPRE_Int hypre_GeneralBoxBoundaryIntersect( hypre_Box *box, hypre_StructGrid *grid, hypre_Index stencil_element, hypre_BoxArray *boundary ) { hypre_BoxManager *boxman; hypre_BoxManEntry **entries; hypre_BoxArray *int_boxes, *tmp_boxes; hypre_Box *bbox, *ibox; HYPRE_Int nentries, i, j; HYPRE_Int *dd; HYPRE_Int ndim; ndim = hypre_StructGridNDim(grid); dd = hypre_CTAlloc(HYPRE_Int, ndim); for (i=0; i < ndim; i++) dd[i] = hypre_IndexD(stencil_element, i); /* set bbox to the box surface of interest */ hypre_BoxArraySetSize(boundary, 1); bbox = hypre_BoxArrayBox(boundary, 0); hypre_CopyBox(box, bbox); /* temporarily shift bbox in direction dir and intersect with the grid */ for (i=0; i < ndim; i++) { hypre_BoxIMinD(bbox, i) += dd[i]; hypre_BoxIMaxD(bbox, i) += dd[i]; } boxman = hypre_StructGridBoxMan(grid); hypre_BoxManIntersect(boxman, hypre_BoxIMin(bbox), hypre_BoxIMax(bbox), &entries, &nentries); for (i=0; i < ndim; i++) { hypre_BoxIMinD(bbox, i) -= dd[i]; hypre_BoxIMaxD(bbox, i) -= dd[i]; } /* shift intersected boxes in direction -dir and subtract from bbox */ int_boxes = hypre_BoxArrayCreate(nentries, ndim); tmp_boxes = hypre_BoxArrayCreate(0, ndim); for (i = 0; i < nentries; i++) { ibox = hypre_BoxArrayBox(int_boxes, i); hypre_BoxManEntryGetExtents( entries[i], hypre_BoxIMin(ibox), hypre_BoxIMax(ibox)); for (j=0; j < ndim; j++) { hypre_BoxIMinD(ibox, j) -= dd[j]; hypre_BoxIMaxD(ibox, j) -= dd[j]; } } hypre_SubtractBoxArrays(boundary, int_boxes, tmp_boxes); hypre_BoxArrayDestroy(int_boxes); hypre_BoxArrayDestroy(tmp_boxes); hypre_TFree(entries); hypre_TFree(dd); return hypre_error_flag; }