Module: struct_mv
Data Structure/Function: hypre_BoxExpand(ghostbox, numghost)
Changes: New function that takes in a box and a num_ghost and expands the
box with the box layer. The result is a bigger box (or smaller).
Reason: to make the code shorter.
Files = struct_grid.c
Module: struct_mv
Data Structure/Function: hypre_StructGridSetNumGhost( hypre_StructGrid *grid, int *num_ghost)
Changes: New function to set the ghosts in the struct_grid.
Reason: To have the ability to set ghost in the data structure struct_grid
Files: struct_grid.c
Module: struct_mv
Data Structure/Function: HYPRE_StructGridCreate
Changes: setting up the defaults for num_ghost=(1,1,1,1,1,1) and for ghlocal_size=0
Reason: To have a starting point.
Files: HYPRE_struct_grid.c
Module: struct_mv
Data Structure/Function: hypre_StructGridAssemble
Changes: The calculation of the ghlocalsize during the assemble phase. The calculation mimics
the calculation of the localsize of the grid. Here is where the boxexpand is used.
Reason: Needed for calculating correctly the offsets and start rank in the sstruct interface
Files: struct_grid.c
Module: struct_mv
Data Structure/Function :HYPRE_StructGridSetNumGhost( HYPRE_StructGrid grid, int *num_ghost )
Changes: A wrapper to the hypre_StructGridSetNumGhost function
Reason: To separate the user interface from the core code
Files: HYPRE_struct_grid.c
This commit is contained in:
parent
774ebf26b4
commit
1f553ac997
@ -95,3 +95,15 @@ HYPRE_StructGridAssemble( HYPRE_StructGrid grid )
|
||||
{
|
||||
return ( hypre_StructGridAssemble(grid) );
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* GEC0902
|
||||
* HYPRE_StructGridSetNumGhost
|
||||
* to set the numghost array inside the struct_grid_struct using an internal
|
||||
* function. This is just a wrapper.
|
||||
*--------------------------------------------------------------------------*/
|
||||
int
|
||||
HYPRE_StructGridSetNumGhost( HYPRE_StructGrid grid, int *num_ghost )
|
||||
{
|
||||
return ( hypre_StructGridSetNumGhost(grid, num_ghost) );
|
||||
}
|
||||
|
||||
@ -363,4 +363,35 @@ hypre_BoxGetStrideSize( hypre_Box *box,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
* GEC0209 function to expand a box given a ghostvector numexp
|
||||
* the idea is to dilatate the box using two vectors.
|
||||
*
|
||||
* even components of numexp shift negatively the imin of the box
|
||||
* odd components of numexp shift positively the imax of the box
|
||||
*
|
||||
*
|
||||
*--------------------------------------------------------------------------*/
|
||||
|
||||
int
|
||||
hypre_BoxExpand( hypre_Box *box,
|
||||
int *numexp)
|
||||
{
|
||||
int ierr = 0;
|
||||
int *imin = hypre_BoxIMin(box);
|
||||
int *imax = hypre_BoxIMax(box);
|
||||
int d;
|
||||
|
||||
for (d = 0; d < 3; d++)
|
||||
{
|
||||
imin[d] -= numexp[2*d];
|
||||
imax[d] += numexp[2*d+1];
|
||||
}
|
||||
|
||||
return ierr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -24,6 +24,7 @@ hypre_StructGridCreate( MPI_Comm comm,
|
||||
hypre_StructGrid **grid_ptr)
|
||||
{
|
||||
hypre_StructGrid *grid;
|
||||
int i;
|
||||
|
||||
grid = hypre_TAlloc(hypre_StructGrid, 1);
|
||||
|
||||
@ -39,6 +40,15 @@ hypre_StructGridCreate( MPI_Comm comm,
|
||||
hypre_SetIndex(hypre_StructGridPeriodic(grid), 0, 0, 0);
|
||||
hypre_StructGridRefCount(grid) = 1;
|
||||
|
||||
/* additional defaults for the grid ghosts GEC0902 */
|
||||
|
||||
hypre_StructGridGhlocalSize(grid) = 0;
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
{
|
||||
hypre_StructGridNumGhost(grid)[i] = 1;
|
||||
}
|
||||
|
||||
*grid_ptr = grid;
|
||||
|
||||
return 0;
|
||||
@ -234,6 +244,10 @@ hypre_StructGridAssemble( hypre_StructGrid *grid )
|
||||
int size;
|
||||
int prune;
|
||||
int i, d, idmin, idmax;
|
||||
/* GEC new declarations for the ghost size local */
|
||||
int *numghost;
|
||||
int ghostsize;
|
||||
hypre_Box *ghostbox;
|
||||
|
||||
prune = 1;
|
||||
|
||||
@ -318,14 +332,45 @@ hypre_StructGridAssemble( hypre_StructGrid *grid )
|
||||
hypre_BoxNeighborsAssemble(neighbors, max_distance, prune);
|
||||
|
||||
/* compute local size */
|
||||
|
||||
size = 0;
|
||||
ghostsize = 0;
|
||||
hypre_ForBoxI(i, boxes)
|
||||
{
|
||||
box = hypre_BoxArrayBox(boxes, i);
|
||||
size += hypre_BoxVolume(box);
|
||||
size += hypre_BoxVolume(box);
|
||||
}
|
||||
|
||||
hypre_StructGridLocalSize(grid) = size;
|
||||
|
||||
/* GEC0902 expand the box to include the ghosts. Create, copy and expand
|
||||
* the ghostbox and finally inserting into the ghlocalsize. As a reminder
|
||||
* the boxes variable is the localboxes of the grid (owned by the processor)
|
||||
*/
|
||||
|
||||
numghost = hypre_StructGridNumGhost(grid) ;
|
||||
ghostsize = 0;
|
||||
ghostbox = hypre_BoxCreate();
|
||||
hypre_ForBoxI(i, boxes)
|
||||
{
|
||||
box = hypre_BoxArrayBox(boxes, i);
|
||||
|
||||
hypre_CopyBox(box, ghostbox);
|
||||
hypre_BoxExpand(ghostbox, numghost);
|
||||
|
||||
/* for (d = 0; d < 3; d++)
|
||||
* {
|
||||
* hypre_BoxIminD(ghostbox, d) -= numghost[2*d];
|
||||
* hypre_BoxImaxD(ghostbox, d) += numghost[2*d + 1];
|
||||
* } */
|
||||
|
||||
ghostsize += hypre_BoxVolume(ghostbox);
|
||||
|
||||
}
|
||||
|
||||
hypre_StructGridGhlocalSize(grid) = ghostsize;
|
||||
hypre_BoxDestroy(ghostbox);
|
||||
|
||||
return ierr;
|
||||
}
|
||||
|
||||
@ -674,3 +719,23 @@ hypre_StructGridPeriodicAllBoxes( hypre_StructGrid *grid,
|
||||
|
||||
return ierr;
|
||||
}
|
||||
/*------------------------------------------------------------------------------
|
||||
* GEC0902 hypre_StructGridSetNumGhost
|
||||
*
|
||||
* the purpose is to set num ghost in the structure grid. It is identical
|
||||
* to the function that is used in the structure vector entity.
|
||||
*-----------------------------------------------------------------------------*/
|
||||
|
||||
int
|
||||
hypre_StructGridSetNumGhost( hypre_StructGrid *grid, int *num_ghost )
|
||||
{
|
||||
int ierr = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
{
|
||||
hypre_StructGridNumGhost(grid)[i] = num_ghost[i];
|
||||
}
|
||||
|
||||
return ierr;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user