A utility to call/use HYPRE scallable solvers
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | public | :: | MaxIt | = | 20 |
Maximum number of subiterations |
|
| real(kind=wp), | public | :: | MaxTol | = | 1.0e-8_wp |
Maximum relative tolerance |
|
| integer, | public | :: | RelaxType | = | 1 |
Relaxation Type for multigrid solvers |
|
| type(block_obj), | public, | pointer | :: | block | => | null() |
Associated block structure |
| integer, | public, | pointer | :: | cols(:) |
Storage array, column indices |
||
| type(MPI_Comm), | public | :: | comm |
MPI communicator used by Hyper |
|||
| integer, | public | :: | dim | = | 3 |
Dimensionality of the problem |
|
| integer(kind=leapI8), | public | :: | grid |
Hypre grid pointer |
|||
| real(kind=wp), | public | :: | h2 |
Scaling factor |
|||
| integer, | public | :: | interface | = | -1 |
Hypre interface |
|
| type(eulerian_obj_i), | public | :: | irow |
Row index (one row = one grid point) |
|||
| integer, | public | :: | irow_hi |
low and high row indices |
|||
| integer, | public | :: | irow_lo |
low and high row indices |
|||
| integer, | public | :: | it | = | 0 |
Number of iteration at end of solve |
|
| real(kind=wp), | public, | allocatable | :: | mat(:,:,:,:,:) |
Matrix |
||
| integer(kind=leapI8), | public | :: | matrix |
Hypre matrix pointer |
|||
| type(c_ptr), | public | :: | p_cols | ||||
| type(c_ptr), | public | :: | p_rhs_values | ||||
| type(c_ptr), | public | :: | p_rows | ||||
| type(c_ptr), | public | :: | p_sol_values | ||||
| type(c_ptr), | public | :: | p_tmpi | ||||
| type(c_ptr), | public | :: | p_values | ||||
| integer(kind=leapI8), | public | :: | par_matrix |
Pointer to ParCSR storage |
|||
| integer(kind=leapI8), | public | :: | par_rhs |
Pointer to ParCSR storage |
|||
| integer(kind=leapI8), | public | :: | par_sol |
Pointer to ParCSR storage |
|||
| type(parallel_obj), | public, | pointer | :: | parallel | => | null() |
Associated parallel structure |
| integer(kind=leapI8), | public | :: | precond |
Hypre preconditioner pointer |
|||
| real(kind=wp), | public | :: | rel |
Relative error at end of solve |
|||
| integer(kind=leapI8), | public | :: | rhs |
Hypre vector pointer for right-hand side |
|||
| real(kind=wp), | public, | pointer | :: | rhs_values(:) |
Storage arrays, rhs |
||
| integer, | public, | pointer | :: | rows(:) |
Storage arrays, row indices |
||
| integer(kind=leapI8), | public | :: | sol |
Hypre vector pointer for solution |
|||
| real(kind=wp), | public, | pointer | :: | sol_values(:) |
Storage arrays, sol |
||
| integer(kind=leapI8), | public | :: | solver |
Hypre solver pointer |
|||
| character(len=:), | public, | allocatable | :: | solver_name |
Name of solver (see list below) |
||
| integer, | public | :: | st | = | 1 |
Stencil bounds (-st to +st); st=1 gives a 7-point stencil in 3D |
|
| integer, | public | :: | st_size |
Stencil size |
|||
| integer(kind=leapI8), | public | :: | stencil |
Hypre stencil pointer |
|||
| integer, | public | :: | stm | = | 1 |
Stencil extent for matrix |
|
| integer, | public, | pointer | :: | tmpi(:) |
Storage arrays, tmp integer values |
||
| real(kind=wp), | public, | pointer | :: | values(:) |
Storage arrays, matrix coefficients |
Destroys objects/pointers and clears data.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(hypre_obj), | intent(inout) | :: | this |
Hypre machinery |
Initializes the hypre object.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(hypre_obj), | intent(inout) | :: | this |
Hypre machinery |
||
| type(block_obj), | intent(in), | target | :: | block |
A block object |
|
| type(parallel_obj), | intent(in), | target | :: | parallel |
Parallel structure to link with |
Selects one of the preconfigured solvers and get solver-specific parameters.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(hypre_obj), | intent(inout) | :: | this |
Hypre machinery |
||
| character(len=*), | intent(in) | :: | name |
Name of solver to be used |
||
| real(kind=wp), | intent(in), | optional | :: | MaxTol |
Maximum relative tolerance |
|
| integer, | intent(in), | optional | :: | MaxIt |
Maximum number of subiterations |
|
| integer, | intent(in), | optional | :: | RelaxType |
Relaxation type |
Sets the entries of the rhs vector, one element at a time.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(hypre_obj), | intent(inout) | :: | this |
Hypre machinery |
||
| type(eulerian_obj_r), | intent(in) | :: | rhs |
Right hand side |
Sets up the hypre objects in preparation for solves. Note: Setting up HYPRE is an expensive operation so it's best to do this only once during a simulation as opposed to setting-up and destorying each time-step.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(hypre_obj), | intent(inout) | :: | this |
Hypre machinery |
Solves the system Ax=b and return the solution.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(hypre_obj), | intent(inout) | :: | this |
Hypre machinery |
||
| type(eulerian_obj_r), | intent(inout) | :: | sol |
Solution vector |
Sets the coefficients of the matrix.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(hypre_obj), | intent(inout) | :: | this |
Hypre machinery |
Define the entries of the matrix Ax=b one row at a time Finite difference/Finite volume 2nd order Laplacian: ddu/dxdx = -2 u(i,j,k)/dxdx + u(i-1,j,k)/dxdx + u(i+1,j,k)/dxdx ddu/dydy = -2 u(i,j,k)/dydy + u(i,j-1,k)/dydy + u(i,j+1,k)/dydy ddu/dzdz = -2 u(i,j,k)/dzdz + u(i,j,k-1)/dzdz + u(i,j,k+1)/dzdz
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(hypre_obj), | intent(inout) | :: | this |
Hypre machinery |
Prints the matrix coefficients for debugging.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(hypre_obj), | intent(inout) | :: | this |
Hypre machinery |
Sets the entries of the rhs vector, one element at a time.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(hypre_obj), | intent(inout) | :: | this |
Hypre machinery |
||
| type(eulerian_obj_r), | intent(in) | :: | rhs |
Right hand side |
Set the entries of the rhs vector for the Struct interface.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(hypre_obj), | intent(inout) | :: | this |
Hypre machinery |
||
| type(eulerian_obj_r), | intent(in) | :: | rhs |
Right hand side |
Sets up the hypre grid.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(hypre_obj), | intent(inout) | :: | this |
Hypre machinery |
Sets up matrix with IJ interface.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(hypre_obj), | intent(inout) | :: | this |
Hypre machinery |
Sets up and builds the matrix.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(hypre_obj), | intent(inout) | :: | this |
Hypre machinery |
Sets up pointers for IJ solver.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(hypre_obj), | intent(inout) | :: | this |
Hypre machinery |
Sets up the rhs vector.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(hypre_obj), | intent(inout) | :: | this |
Hypre machinery |
Sets up the rhs vector.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(hypre_obj), | intent(inout) | :: | this |
Hypre machinery |
Sets up row indexing used with IJ interface.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(hypre_obj), | intent(inout) | :: | this |
Hypre machinery |
Setup the solution vector, and initialize it to zero
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(hypre_obj), | intent(inout) | :: | this |
Hypre machinery |
Sets up solver with IJ interface.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(hypre_obj), | intent(inout) | :: | this |
Hypre machinery |
Setup the solution vector, and initialize it to zero
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(hypre_obj), | intent(inout) | :: | this |
Hypre machinery |
Sets up the hypre solver.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(hypre_obj), | intent(inout) | :: | this |
Hypre machinery |
Sets up the discretization stencil. Each entry represents the relative offset (in index space) E.g.: a 2D 5-pt stencil would have the following geometry -- Offset { {0,0}, {-1,0}, {1,0}, {0,-1}, {0,1} } E.g.: a 3D 7-pt stencil would have the following geometry -- Offset { {0,0,0}, {-1,0,0}, {1,0,0}, {0,-1,0}, {0,1,0}, {0,0,-1}, {0,0,1} }
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(hypre_obj), | intent(inout) | :: | this |
Hypre machinery |
Solves the system Ax=b and return the solution, IJ interface.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(hypre_obj), | intent(inout) | :: | this |
Hypre machinery |
||
| type(eulerian_obj_r), | intent(inout) | :: | sol |
Solution vector |
Solves the system Ax=b and return the solution, Struct interface.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(hypre_obj), | intent(inout) | :: | this |
Hypre machinery |
||
| type(eulerian_obj_r), | intent(inout) | :: | sol |
Solution vector |
type :: hypre_obj !> A utility to call/use HYPRE scallable solvers type(parallel_obj), pointer :: parallel=>null() !! Associated parallel structure type(block_obj), pointer :: block =>null() !! Associated block structure ! Parameters of linear system to solve (mat*sol=rhs) real(wp), allocatable :: mat(:,:,:,:,:) !! Matrix integer :: stm=1 !! Stencil extent for matrix real(wp) :: h2 !! Scaling factor ! Common variables to all HYPRE solvers character(len=:), & allocatable :: solver_name !! Name of solver (see list below) integer(kind=leapI8) :: solver !! Hypre solver pointer integer(kind=leapI8) :: precond !! Hypre preconditioner pointer integer(kind=leapI8) :: matrix !! Hypre matrix pointer integer(kind=leapI8) :: rhs !! Hypre vector pointer for right-hand side integer(kind=leapI8) :: sol !! Hypre vector pointer for solution integer :: interface=-1 !! Hypre interface type(MPI_Comm) :: comm !! MPI communicator used by Hyper ! Solver parameters real(wp) :: MaxTol = 1.0e-8_wp !! Maximum relative tolerance integer :: MaxIt = 20 !! Maximum number of subiterations integer :: RelaxType = 1 !! Relaxation Type for multigrid solvers integer :: it = 0 !! Number of iteration at end of solve real(wp) :: rel !! Relative error at end of solve ! Specific to Struct interface integer :: dim=3 !! Dimensionality of the problem integer :: st=1 !! Stencil bounds (-st to +st); st=1 gives a 7-point stencil in 3D integer :: st_size !! Stencil size integer(kind=leapI8) :: grid !! Hypre grid pointer integer(kind=leapI8) :: stencil !! Hypre stencil pointer ! Specific to IJ interface integer(kind=leapI8) :: par_matrix !! Pointer to ParCSR storage integer(kind=leapI8) :: par_rhs !! Pointer to ParCSR storage integer(kind=leapI8) :: par_sol !! Pointer to ParCSR storage type(eulerian_obj_i) :: irow !! Row index (one row = one grid point) integer :: irow_lo, irow_hi !! low and high row indices real(wp), pointer :: rhs_values(:) !! Storage arrays, rhs real(wp), pointer :: sol_values(:) !! Storage arrays, sol real(wp), pointer :: values(:) !! Storage arrays, matrix coefficients integer, pointer :: rows(:) !! Storage arrays, row indices integer, pointer :: cols(:) !! Storage array, column indices integer, pointer :: tmpi(:) !! Storage arrays, tmp integer values #ifdef USE_GPU type(c_ptr) :: p_rhs_values type(c_ptr) :: p_sol_values type(c_ptr) :: p_values type(c_ptr) :: p_rows type(c_ptr) :: p_cols type(c_ptr) :: p_tmpi #endif contains procedure :: Initialize => hypre_obj_Init procedure :: Finalize => hypre_obj_Final procedure :: SelectSolver => hypre_obj_SelectSolver procedure :: Setup => hypre_obj_Setup procedure :: SetRHS => hypre_obj_SetRHS procedure :: Solve => hypre_obj_Solve ! Internal/private procedures ! Subroutines for IJ interface procedure, private :: hypre_obj_SetupPointersIJ procedure, private :: hypre_obj_SetupRowsIJ procedure, private :: hypre_obj_SetupRHSIJ procedure, private :: hypre_obj_SetupSolIJ procedure, private :: hypre_obj_BuildMatrixIJ procedure, private :: hypre_obj_SetupMatrixIJ procedure, private :: hypre_obj_SetRHSIJ procedure, private :: hypre_obj_SetupSolIJver procedure, private :: hypre_obj_SolveIJ ! Subroutines for Struct interface procedure, private :: hypre_obj_SetupGridS procedure, private :: hypre_obj_SetupStencilS procedure, private :: hypre_obj_SetupSolverS procedure, private :: hypre_obj_SetupMatrixS procedure, private :: hypre_obj_SetupRHSS procedure, private :: hypre_obj_SetupSolS procedure, private :: hypre_obj_BuildMatrixS procedure, private :: hypre_obj_SetRHSS procedure, private :: hypre_obj_SolveS procedure, private :: hypre_obj_PrintMatrixS end type hypre_obj