leapHypre Module

Module giving access to the HYPRE solvers for sparse linear systems.

Note 1. Solver naming convention: X_Y_Z, where X: HYPRE interface (S: Struct, SS: SStruct, IJ: IJ), Y: Solver (e.g. PCG), Z: Preconditioner (e.g. DS). Available solvers: S_SMG_NONE, S_PFMG_NONE, S_PCG_NONE, IJ_AMG_NONE, IJ_PCG_DS, IJ_PCG_AMG

Note 2. GPU support is enabled with IJ_AMG_NONE. To be able to use GPU acceleration, LEAP must be compiled against GPU-enabled HYPRE.



Uses

  • module~~leaphypre~~UsesGraph module~leaphypre leapHypre iso_c_binding iso_c_binding module~leaphypre->iso_c_binding module~leapblock leapBlock module~leaphypre->module~leapblock module~leapeulerian leapEulerian module~leaphypre->module~leapeulerian module~leapkinds leapKinds module~leaphypre->module~leapkinds module~leapparallel leapParallel module~leaphypre->module~leapparallel mpi_f08 mpi_f08 module~leaphypre->mpi_f08 module~leapblock->module~leapkinds module~leapblock->module~leapparallel module~leapblock->mpi_f08 module~leapeulerian->module~leapblock module~leapeulerian->module~leapkinds module~leapeulerian->module~leapparallel module~leapeulerian->mpi_f08 module~leapio leapIO module~leapeulerian->module~leapio module~leapio_mpi leapIO_mpi module~leapeulerian->module~leapio_mpi module~leapparser leapParser module~leapeulerian->module~leapparser module~leaputils leapUtils module~leapeulerian->module~leaputils iso_fortran_env iso_fortran_env module~leapkinds->iso_fortran_env module~leapparallel->module~leapkinds module~leapparallel->mpi_f08 module~leapparallel->module~leapparser module~leapio->module~leapio_mpi module~leapio_h5hut leapIO_h5hut module~leapio->module~leapio_h5hut module~leapio_hdf5 leapIO_hdf5 module~leapio->module~leapio_hdf5 module~leapio_silo leapIO_silo module~leapio->module~leapio_silo module~leapio_mpi->module~leapblock module~leapio_mpi->module~leapkinds module~leapio_mpi->module~leapparallel module~leapio_mpi->mpi_f08 module~leapparser->module~leapkinds module~leapcli leapCli module~leapparser->module~leapcli module~leaputils->module~leapkinds module~leaputils->mpi_f08 module~leapcli->module~leapkinds module~leapio_h5hut->module~leapkinds module~leapio_h5hut->module~leapparallel h5hut h5hut module~leapio_h5hut->h5hut module~leapio_hdf5->module~leapkinds module~leapio_hdf5->module~leapparallel module~leapio_hdf5->module~leaputils hdf5 hdf5 module~leapio_hdf5->hdf5 module~leapio_silo->module~leapblock module~leapio_silo->module~leapkinds module~leapio_silo->module~leapparallel module~leapio_silo->mpi_f08 module~leapio_silo->module~leaputils

Used by

  • module~~leaphypre~~UsedByGraph module~leaphypre leapHypre module~cdifs cdifs module~cdifs->module~leaphypre module~immersed_boundaries immersed_boundaries module~cdifs->module~immersed_boundaries module~particles_resolved particles_resolved module~cdifs->module~particles_resolved module~grans grans module~grans->module~leaphypre module~grans->module~immersed_boundaries module~grans_cases grans_cases module~grans->module~grans_cases module~grans->module~particles_resolved module~immersed_boundaries_markers immersed_boundaries_markers module~immersed_boundaries_markers->module~leaphypre module~cdifs_advancesolution_smod cdifs_AdvanceSolution_smod module~cdifs_advancesolution_smod->module~cdifs module~cdifs_monitor_smod cdifs_Monitor_smod module~cdifs_monitor_smod->module~cdifs module~cdifs_preparesolver_smod cdifs_PrepareSolver_smod module~cdifs_preparesolver_smod->module~cdifs module~cdifs_writeoutputdata_smod cdifs_WriteOutputData_smod module~cdifs_writeoutputdata_smod->module~cdifs module~cdifs_writerestartdata_smod cdifs_WriteRestartData_smod module~cdifs_writerestartdata_smod->module~cdifs module~grans_advancesolution_smod grans_AdvanceSolution_smod module~grans_advancesolution_smod->module~grans module~grans_module_smod grans_module_smod module~grans_module_smod->module~grans module~grans_preparesolver_smod grans_PrepareSolver_smod module~grans_preparesolver_smod->module~grans module~grans_writeoutputdata_smod grans_WriteOutputData_smod module~grans_writeoutputdata_smod->module~grans module~grans_writerestartdata_smod grans_WriteRestartData_smod module~grans_writerestartdata_smod->module~grans module~immersed_boundaries->module~immersed_boundaries_markers module~immersed_boundaries_solids immersed_boundaries_solids module~immersed_boundaries->module~immersed_boundaries_solids module~immersed_boundaries_solids->module~immersed_boundaries_markers program~main main program~main->module~cdifs program~main->module~grans module~grans_cases->module~immersed_boundaries module~grans_cases->module~particles_resolved module~particles_resolved->module~immersed_boundaries proc~add_markers add_markers proc~add_markers->module~immersed_boundaries proc~add_markers->module~particles_resolved proc~add_markers~2 add_markers proc~add_markers~2->module~immersed_boundaries proc~add_markers~2->module~particles_resolved proc~cdifs_cylinder_ib cdifs_cylinder_IB proc~cdifs_cylinder_ib->module~immersed_boundaries proc~cdifs_rebound_ib cdifs_rebound_IB proc~cdifs_rebound_ib->module~immersed_boundaries proc~cdifs_settling_sphere_ib cdifs_settling_sphere_IB proc~cdifs_settling_sphere_ib->module~immersed_boundaries module~headon_collision_smod headon_collision_smod module~headon_collision_smod->module~grans_cases module~homogeneous_cooling_smod homogeneous_cooling_smod module~homogeneous_cooling_smod->module~grans_cases module~rotating_drum_smod rotating_drum_smod module~rotating_drum_smod->module~grans_cases proc~cdifs_rebound_respart cdifs_rebound_ResPart proc~cdifs_rebound_respart->module~particles_resolved proc~cdifs_settling_sphere_respart cdifs_settling_sphere_ResPart proc~cdifs_settling_sphere_respart->module~particles_resolved

Variables

Type Visibility Attributes Name Initial
integer, private, parameter :: HYPRE_INT_IJ = 1
integer, private, parameter :: HYPRE_INT_SStruct = 3
integer, private, parameter :: HYPRE_INT_Struct = 2
character(len=*), private, parameter :: HYPRE_SOL_IJ_AMG_NONE = 'IJ-AMG-NONE'
character(len=*), private, parameter :: HYPRE_SOL_IJ_PCG_AMG = 'IJ-PCG-AMG'
character(len=*), private, parameter :: HYPRE_SOL_IJ_PCG_DS = 'IJ-PCG-DS'
character(len=*), private, parameter :: HYPRE_SOL_S_PCG_NONE = 'PCG'

HYPRE DOC: Preconditioned Conjugate Gradient, belongs to family of Krylov Solvers

character(len=*), private, parameter :: HYPRE_SOL_S_PFMG_NONE = 'PFMG'

HYPRE DOC: PFMG is a parallel semicoarsening multigrid solver that uses pointwise relaxation. For periodic problems, users should try to set the grid size in periodic dimensions to be as close to a power-of-two as possible. That is, if the grid size in a periodic dimension is given by N=2^m * M where M is not a power-of-two, then M should be as small as possible. Large values of will generally result in slower convergence rates. Note: PFMG is not as robust as SMG, but is much more efficient per V-cycle.

character(len=*), private, parameter :: HYPRE_SOL_S_SMG_NONE = 'SMG'

HYPRE DOC: SMG is a parallel semicoarsening multigrid solver for solving \nabla \cdot \left( D\nabla u\right) + \sigma u = f on logically rectangular grids. The code solves both 2D and 3D problems with discretization stencils of up to 9-points in 2D and up to 27-points in 3D. Note: SMG is a particularly robust method. The algorithm semicoarsens in the z-direction and uses plane smoothing. The xy plane-solves are effected by one V-cycle of the 2D SMG algorithm, which semicoarsens in the y-direction and uses line smoothing.


Derived Types

type, public ::  hypre_obj

A utility to call/use HYPRE scallable solvers

Components

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

Type-Bound Procedures

procedure, public :: Finalize => hypre_obj_Final
procedure, public :: Initialize => hypre_obj_Init
procedure, public :: SelectSolver => hypre_obj_SelectSolver
procedure, public :: SetRHS => hypre_obj_SetRHS
procedure, public :: Setup => hypre_obj_Setup
procedure, public :: Solve => hypre_obj_Solve
procedure, public :: hypre_obj_BuildMatrixIJ
procedure, public :: hypre_obj_BuildMatrixS
procedure, public :: hypre_obj_PrintMatrixS
procedure, public :: hypre_obj_SetRHSIJ
procedure, public :: hypre_obj_SetRHSS
procedure, public :: hypre_obj_SetupGridS
procedure, public :: hypre_obj_SetupMatrixIJ
procedure, public :: hypre_obj_SetupMatrixS
procedure, public :: hypre_obj_SetupPointersIJ
procedure, public :: hypre_obj_SetupRHSIJ
procedure, public :: hypre_obj_SetupRHSS
procedure, public :: hypre_obj_SetupRowsIJ
procedure, public :: hypre_obj_SetupSolIJ
procedure, public :: hypre_obj_SetupSolIJver
procedure, public :: hypre_obj_SetupSolS
procedure, public :: hypre_obj_SetupSolverS
procedure, public :: hypre_obj_SetupStencilS
procedure, public :: hypre_obj_SolveIJ
procedure, public :: hypre_obj_SolveS

Subroutines

private subroutine hypre_obj_BuildMatrixIJ(this)

Set the coefficients of the matrix

Arguments

Type IntentOptional Attributes Name
class(hypre_obj), intent(inout) :: this

Hypre machinery

private subroutine hypre_obj_BuildMatrixS(this)

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

Arguments

Type IntentOptional Attributes Name
class(hypre_obj), intent(inout) :: this

Hypre machinery

private subroutine hypre_obj_Final(this)

Destroy objects/pointers and clear data

Arguments

Type IntentOptional Attributes Name
class(hypre_obj), intent(inout) :: this

Hypre machinery

private subroutine hypre_obj_Init(this, block, parallel)

Initialize the hypre object

Arguments

Type IntentOptional 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 from main program

private subroutine hypre_obj_PrintMatrixS(this)

Setup the hypre grid

Arguments

Type IntentOptional Attributes Name
class(hypre_obj), intent(inout) :: this

Hypre machinery

private subroutine hypre_obj_SelectSolver(this, name, MaxTol, MaxIt, RelaxType)

Select one of the preconfigured solvers and get solver-specific parameters

Arguments

Type IntentOptional 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

private subroutine hypre_obj_SetRHS(this, rhs)

Set the entries of the rhs vector, one element at a time

Arguments

Type IntentOptional Attributes Name
class(hypre_obj), intent(inout) :: this

Hypre machinery

type(eulerian_obj_r), intent(in) :: rhs

Right hand side

private subroutine hypre_obj_SetRHSIJ(this, rhs)

Set the entries of the rhs vector, one element at a time

Arguments

Type IntentOptional Attributes Name
class(hypre_obj), intent(inout) :: this

Hypre machinery

type(eulerian_obj_r), intent(in) :: rhs

Right hand side

private subroutine hypre_obj_SetRHSS(this, rhs)

Set the entries of the rhs vector, one element at a time

Arguments

Type IntentOptional Attributes Name
class(hypre_obj), intent(inout) :: this

Hypre machinery

type(eulerian_obj_r), intent(in) :: rhs

Right hand side

private subroutine hypre_obj_Setup(this)

Setup 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.

Arguments

Type IntentOptional Attributes Name
class(hypre_obj), intent(inout) :: this

Hypre machinery

private subroutine hypre_obj_SetupGridS(this)

Setup the hypre grid

Arguments

Type IntentOptional Attributes Name
class(hypre_obj), intent(inout) :: this

Hypre machinery

private subroutine hypre_obj_SetupMatrixIJ(this)

Setup matrix with IJ interface

Arguments

Type IntentOptional Attributes Name
class(hypre_obj), intent(inout) :: this

Hypre machinery

private subroutine hypre_obj_SetupMatrixS(this)

Setup and build the matrix

Read more…

Arguments

Type IntentOptional Attributes Name
class(hypre_obj), intent(inout) :: this

Hypre machinery

private subroutine hypre_obj_SetupPointersIJ(this)

Arguments

Type IntentOptional Attributes Name
class(hypre_obj), intent(inout) :: this

Hypre machinery

private subroutine hypre_obj_SetupRHSIJ(this)

Setup the rhs vector

Arguments

Type IntentOptional Attributes Name
class(hypre_obj), intent(inout) :: this

Hypre machinery

private subroutine hypre_obj_SetupRHSS(this)

Setup the rhs vector

Arguments

Type IntentOptional Attributes Name
class(hypre_obj), intent(inout) :: this

Hypre machinery

private subroutine hypre_obj_SetupRowsIJ(this)

Setup row indexing used with IJ interface

Arguments

Type IntentOptional Attributes Name
class(hypre_obj), intent(inout) :: this

Hypre machinery

private subroutine hypre_obj_SetupSolIJ(this)

Setup the solution vector, and initialize it to zero

Arguments

Type IntentOptional Attributes Name
class(hypre_obj), intent(inout) :: this

Hypre machinery

private subroutine hypre_obj_SetupSolIJver(this)

Setup solver with IJ interface

Arguments

Type IntentOptional Attributes Name
class(hypre_obj), intent(inout) :: this

Hypre machinery

private subroutine hypre_obj_SetupSolS(this)

Setup the solution vector, and initialize it to zero

Arguments

Type IntentOptional Attributes Name
class(hypre_obj), intent(inout) :: this

Hypre machinery

private subroutine hypre_obj_SetupSolverS(this)

Setup the hypre solver

Arguments

Type IntentOptional Attributes Name
class(hypre_obj), intent(inout) :: this

Hypre machinery

private subroutine hypre_obj_SetupStencilS(this)

Setup 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} }

Arguments

Type IntentOptional Attributes Name
class(hypre_obj), intent(inout) :: this

Hypre machinery

private subroutine hypre_obj_Solve(this, sol)

Solve the system Ax=b and return the solution

Arguments

Type IntentOptional Attributes Name
class(hypre_obj), intent(inout) :: this

Hypre machinery

type(eulerian_obj_r), intent(inout) :: sol

Solution vector

private subroutine hypre_obj_SolveIJ(this, sol)

Solve the system Ax=b and return the solution, IJ interface

Arguments

Type IntentOptional Attributes Name
class(hypre_obj), intent(inout) :: this

Hypre machinery

type(eulerian_obj_r), intent(inout) :: sol

Solution vector

private subroutine hypre_obj_SolveS(this, sol)

Solve the system Ax=b and return the solution, Struct interface

Arguments

Type IntentOptional Attributes Name
class(hypre_obj), intent(inout) :: this

Hypre machinery

type(eulerian_obj_r), intent(inout) :: sol

Solution vector