# Multigrid solvers

The following inputs can be set directly in the AMReX solver classes but we set them via the MFIX-Exa routines because we may want different inputs for the different solvers called by MFIX-Exa.

## Nodal projection

NOTE: the nodal solver settings are read in directly by AMReX, the MAC and diffusion settings by MFIX-Exa.

These control the nodal projection and must be preceded by “nodal_proj.”:

| Description | Type | Default
verbose | Verbosity of multigrid solver in nodal projection | Int | 0
bottom_verbose | Verbosity of BiCGStab solver in nodal projection | Int | 0
mg_rtol | Relative tolerance in nodal projection | Real | 1.e-11
mg_atol | Absolute tolerance in nodal projection | Real | 1.e-14
maxiter | Maximum number of iterations in the nodal projection | Int | 100
bottom_maxiter | Maximum number of iterations in the nodal projection bottom solver if using bicg, cg, bicgcg or cgbicg | Int | 100
mg_max_coarsening_level | Maximum number of coarser levels to allowin the nodal projection If set to 0, the bottom solver will be called at the current level | Int | 100
bottom_solver | Which bottom solver to use in the nodal projection Options are bicgcg, bicgstab, cg, cgbicg, smoother or hypre | String | bicgcg
hypre_namespace | Namespace to use in the nodal projection when using hypre to control hypre specific settings. It can be any string. | String | hypre
hypre_interface | Which interface to use in the nodal projection when using hypre Options are ij, semi_structured or structured | String | ij

## MAC projection

These control the MAC projection and must be preceded by “mac_proj.”:

| Description | Type | Default
--- | --- | --- | ---
verbose | Verbosity of multigrid solver in MAC projection | Int | 0
bottom_verbose | Verbosity of BiCGStab solver in MAC projection | Int | 0
mg_rtol | Relative tolerance in MAC projection | Real | 1.e-11
mg_atol | Absolute tolerance in MAC projection | Real | 1.e-14
maxiter | Maximum number of iterations in the MAC projection | Int | 200
bottom_maxiter | Maximum number of iterations in the MAC projection bottom solver if using bicg, cg, bicgcg or cgbicg | Int | 200
mg_max_coarsening_level | Maximum number of coarser levels to allow in the MAC projection If set to 0, the bottom solver will be called at the current level | Int | 100
bottom_solver | Which bottom solver to use in the MAC projection Options are bicgcg, bicgstab, cg, cgbicg, smoother or hypre | String | bicgcg
hypre_namespace | Namespace to use in the MAC projection when using hypre to control hypre specific settings. It can be any string. | String | hypre
hypre_interface | Which interface to use in the MAC projection when using hypre Options are ij, semi_structured or structured | String | ij

NOTE: If the `nodal_proj` and `mac_proj` `hypre_namespace`’s are set, they must be distinct unless set to `hypre`, in which case the default behavior is recovered in which case hypre settings apply to all solvers.

## Diffusion

These control the diffusion solver and must be preceded by “diffusion.”:

| Description | Type | Default
--- | --- | --- | ---
verbose | Verbosity of linear solver for diffusion solve | Int | 0
bottom_verbose | Verbosity of BiCGStab solver in diffusion solve | Int | 0
mg_rtol | Relative tolerance in diffusion solve | Real | 1.e-11
mg_atol | Absolute tolerance in diffusion solve | Real | 1.e-14
maxiter | Maximum number of iterations in diffusion solve | Int | 100
bottom_maxiter | Maximum number of iterations in diffusion solve bottom solver if using bicg, cg, bicgcg or cgbicg | Int | 100
mg_max_coarsening_level | Maximum number of coarser levels to allow in diffusion solve If set to 0, the bottom solver will be called at the current level | Int | 100
bottom_solver | Which bottom solver to use in the diffusion solve Options are bicgcg, bicgstab, cg, cgbicg, or smoother | String | bicgcg

## Hypre Settings

The following inputs control the hypre settings and are read directly by AMReX when we use hypre as the bottom solver, i.e., when `nodal_proj.bottom_solver = hypre` and/or when `mac_proj.bottom_solver = hypre` (see Multigrid solvers) These settings must be preceded by the hypre_namespace setting corresponding to the solver (see Multigrid solvers).

NOTE: By default, the MAC and nodal projections use the same settings specified with the namespace `hypre`, however the solvers can be configured separately by specifying `mac_proj.hypre_namespace` and `nodal_proj.hypre_namespace`.

When not using the default namespace `hypre`, additional restrictions apply:

1. Both `mac_proj.hypre_namespace` and `nodal_proj.hypre_namespace` must be set.

2. `mac_proj.hypre_namespace` and `nodal_proj.hypre_namespace` must be unique.

| Description | Type | Default
verbose | Verbosity of hypre | Int | 0
adjust_singular_matrix | Should be true if the problem to be solved has singular matrix | Bool | false
hypre_solver | Type of hypre solver Options are BoomerAMG, GMRES, COGMRES, LGMRES, FlexGMRES, BiCGSTAB, PCG or Hybrid | String | BoomerAMG
hypre_preconditioner | Type of preconditioner Options are BoomerAMG or euclid | String | none
recompute_preconditioner | Recompute preconditioner during runs | Bool | true
write_matrix_files | Write out matrix into text files | Bool | false
overwrite_existing_matrix_files | Over-write existing matrix files | Bool | false
bamg_verbose | Verbosity of BoomerAMG preconditioner | Int | 0
bamg_logging | When using BoomerAMG preconditioner See HYPRE_BoomerAMGSetLogging | Int | 0
bamg_coarsen_type | When using BoomerAMG preconditioner See HYPRE_BoomerAMGSetCoarsenType | Int | 6
bamg_cycle_type | When using BoomerAMG preconditioner See HYPRE_BoomerAMGSetCycleType | Int | 1
bamg_relax_type | When using BoomerAMG preconditioner See HYPRE_BoomerAMGSetRelaxType | Int | 6
bamg_relax_order | When using BoomerAMG preconditioner See HYPRE_BoomerAMGSetRelaxOrder | Int | 1
bamg_num_sweeps | When using BoomerAMG preconditioner See HYPRE_BoomerAMGSetNumSweeps | Int | 2
bamg_max_levels | When using BoomerAMG preconditioner See HYPRE_BoomerAMGSetMaxLevels | Int | 20
bamg_strong_threshold | When using BoomerAMG preconditioner See HYPRE_BoomerAMGSetStrongThreshold | Real | 0.57
bamg_interp_type | When using BoomerAMG preconditioner HYPRE_BoomerAMGSetInterpType | Int | 0