Afivo  0.3
Functions/Subroutines
m_af_multigrid Module Reference

This module contains the geometric multigrid routines that come with Afivo. More...

Functions/Subroutines

subroutine, public mg_init (tree, mg)
 Check multigrid options or set them to default. More...
 
subroutine, public mg_destroy (mg)
 
subroutine use_mg (tree, mg)
 Make sure box tags and operators are set. More...
 
subroutine done_with_mg (tree)
 To be called at the end of a multigrid solve. More...
 
subroutine, public mg_fas_fmg (tree, mg, set_residual, have_guess)
 Perform FAS-FMG cycle (full approximation scheme, full multigrid). Note that this routine needs valid ghost cells (for i_phi) on input, and gives back valid ghost cells on output. More...
 
subroutine, public mg_fas_vcycle (tree, mg, set_residual, highest_lvl, standalone)
 Perform FAS V-cycle (full approximation scheme). Note that this routine needs valid ghost cells (for i_phi) on input, and gives back valid ghost cells on output. More...
 
subroutine solve_coarse_grid (tree, mg)
 
subroutine, public mg_sides_rb (boxes, id, nb, iv)
 Fill ghost cells near refinement boundaries which preserves diffusive fluxes. More...
 
subroutine mg_sides_rb_extrap (boxes, id, nb, iv)
 Fill ghost cells near refinement boundaries which preserves diffusive fluxes. This routine does not do interpolation of coarse grid values. Basically, we extrapolate from the fine cells to a corner point, and then take the average between this corner point and a coarse neighbor to fill ghost cells for the fine cells. More...
 
subroutine correct_children (boxes, ids, mg)
 
subroutine gsrb_boxes (tree, lvl, mg, type_cycle)
 
subroutine update_coarse (tree, lvl, mg)
 
subroutine set_coarse_phi_rhs (tree, lvl, mg)
 This routine performs the same as update_coarse, but it ignores the tmp variable. More...
 
subroutine init_phi_rhs (tree, mg)
 Set the initial guess for phi and restrict the rhs. More...
 
subroutine residual_box (box, mg)
 
subroutine mg_auto_gsrb (box, redblack_cntr, mg)
 Based on the box type, apply a Gauss-Seidel relaxation scheme. More...
 
subroutine mg_store_operator_stencil (box, mg, ix)
 Store operator stencil for a box. More...
 
subroutine mg_store_prolongation_stencil (tree, id, mg)
 Store prolongation stencil for a box. More...
 
subroutine mg_auto_op (box, i_out, mg)
 Based on the box type, apply the approriate operator. More...
 
subroutine mg_auto_rstr (box_c, box_p, iv, mg)
 Restriction operator. More...
 
subroutine mg_auto_rb (boxes, id, nb, iv, op_mask)
 Set ghost cells near refinement boundaries. More...
 
subroutine mg_auto_corr (box_p, box_c, mg)
 Based on the box type, correct the solution of the children. More...
 
subroutine get_possible_lsf_root_mask (box, nc, dmax, mg, root_mask)
 Check where the level-set function could have a root by computing the numerical gradient. More...
 
subroutine store_lsf_distance_matrix (box, nc, mg, boundary)
 Check if the level set function could have zeros, and store distances for the neighboring cells. More...
 
subroutine, public mg_set_box_tag (tree, id, mg)
 Set tag (box type) for a box in the tree. More...
 
subroutine, public mg_set_operators_lvl (tree, mg, lvl)
 
subroutine, public mg_update_operator_stencil (tree, mg)
 Update stencil for an operator, because (part of) the coefficients have changed. More...
 
subroutine, public mg_set_operators_tree (tree, mg)
 
subroutine mg_box_rstr_lpl (box_c, box_p, iv, mg)
 Restriction of child box (box_c) to its parent (box_p) More...
 
subroutine mg_box_lpl_stencil (box, mg, ix)
 Store the matrix stencil for each cell of the box. The order of the stencil is (i, j), (i-1, j), (i+1, j), (i, j-1), (i, j+1) (e.g., -4, 1, 1, 1, 1) More...
 
subroutine mg_box_prolong_linear_stencil (box, box_p, mg, ix)
 Store linear prolongation stencil for standard Laplacian. More...
 
subroutine mg_box_prolong_sparse_stencil (box, box_p, mg, ix)
 Store sparse linear prolongation stencil for standard Laplacian. More...
 
subroutine mg_box_prolong_eps_stencil (box, box_p, mg, ix)
 Store prolongation stencil for standard Laplacian with variable coefficient that can jump at cell faces. More...
 
subroutine mg_box_prolong_lsf_stencil (box, box_p, mg, ix)
 Store prolongation stencil for standard Laplacian with level set function for internal boundaries. More...
 
subroutine mg_box_lpld_stencil (box, mg, ix)
 Store the matrix stencil for each cell of the box. The order of the stencil is (i, j), (i-1, j), (i+1, j), (i, j-1), (i, j+1) (e.g., -4, 1, 1, 1, 1) More...
 
subroutine mg_box_lpld_lsf_stencil (box, mg, ix)
 Store stencil for a box with variable coefficient and level set function. More...
 
real(dp) function, public mg_lsf_dist_linear (a, b, mg)
 Compute distance to boundary starting at point a going to point b, in the range from [0, 1], with 1 meaning there is no boundary. More...
 
real(dp) function, public mg_lsf_dist_gss (a, b, mg)
 Find root of f in the interval [a, b]. If f(a) and f(b) have different signs, apply bisection directly. Else, first find the (assumed to be) unique local minimum/maximum to determine a bracket. Return relative location of root, or 1 if there is no root. More...
 
real(dp) function, dimension(ndim) bisection (f, in_a, in_b, tol, max_iter)
 Simple bisection. More...
 
real(dp) function, dimension(ndim, 2) gss (f, in_a, in_b, minimization, tol, find_bracket)
 Golden-section search on a line between a and b. Given a function f with a single local minimum/maximum in the interval [a,b], gss returns a subset interval [c,d] that contains the minimum/maximum with d-c <= tol. Adapted from https://en.wikipedia.org/wiki/Golden-section_search. More...
 
subroutine mg_box_lsf_stencil (box, mg, ix)
 Store the matrix stencil for each cell of the box. The order of the stencil is (i, j), (i-1, j), (i+1, j), (i, j-1), (i, j+1) (e.g., -4, 1, 1, 1, 1) More...
 
subroutine, public mg_compute_phi_gradient (tree, mg, i_fc, fac, i_norm)
 Compute the gradient of the potential and store in face-centered variables. More...
 
subroutine, public mg_box_lpl_gradient (tree, id, mg, i_fc, fac)
 Compute the gradient of the potential. More...
 
subroutine, public mg_compute_field_norm (tree, i_fc, i_norm)
 Compute norm of face-centered variable. More...
 
subroutine, public mg_box_field_norm (tree, id, i_fc, i_norm)
 
subroutine mg_box_lpllsf_gradient (tree, id, mg, i_fc, fac)
 Compute the gradient of the potential with a level set function and store in face-centered variables. The gradients are computed from the positive side of the level set function. More...
 
subroutine check_coarse_representation_lsf (tree, mg)
 This method checks whether the level set function is properly defined on the coarse grid. More...
 
real(dp) function, dimension(ndim) numerical_gradient (f, r)
 Get amplitude of numerical gradient of level set function. More...
 

Detailed Description

This module contains the geometric multigrid routines that come with Afivo.

Todo:
How to use box tag with different types of operators?

Function/Subroutine Documentation

◆ mg_init()

subroutine, public m_af_multigrid::mg_init ( type(af_t), intent(inout)  tree,
type(mg_t), intent(inout)  mg 
)

Check multigrid options or set them to default.

Parameters
[in,out]treeTree to do multigrid on
[in,out]mgMultigrid options

Definition at line 43 of file m_af_multigrid.f90.

◆ mg_destroy()

subroutine, public m_af_multigrid::mg_destroy ( type(mg_t), intent(inout)  mg)
Parameters
[in,out]mgMultigrid options

Definition at line 109 of file m_af_multigrid.f90.

◆ use_mg()

subroutine m_af_multigrid::use_mg ( type(af_t), intent(inout)  tree,
type(mg_t), intent(in), target  mg 
)
private

Make sure box tags and operators are set.

Parameters
[in]mgMultigrid options

Definition at line 116 of file m_af_multigrid.f90.

◆ done_with_mg()

subroutine m_af_multigrid::done_with_mg ( type(af_t), intent(inout)  tree)
private

To be called at the end of a multigrid solve.

Definition at line 127 of file m_af_multigrid.f90.

◆ mg_fas_fmg()

subroutine, public m_af_multigrid::mg_fas_fmg ( type(af_t), intent(inout)  tree,
type(mg_t), intent(inout)  mg,
logical, intent(in)  set_residual,
logical, intent(in)  have_guess 
)

Perform FAS-FMG cycle (full approximation scheme, full multigrid). Note that this routine needs valid ghost cells (for i_phi) on input, and gives back valid ghost cells on output.

Parameters
[in,out]treeTree to do multigrid on
[in,out]mgMultigrid options
[in]set_residualIf true, store residual in i_tmp
[in]have_guessIf false, start from phi = 0

Definition at line 135 of file m_af_multigrid.f90.

◆ mg_fas_vcycle()

subroutine, public m_af_multigrid::mg_fas_vcycle ( type(af_t), intent(inout)  tree,
type(mg_t), intent(in)  mg,
logical, intent(in)  set_residual,
integer, intent(in), optional  highest_lvl,
logical, intent(in), optional  standalone 
)

Perform FAS V-cycle (full approximation scheme). Note that this routine needs valid ghost cells (for i_phi) on input, and gives back valid ghost cells on output.

Parameters
[in,out]treeTree to do multigrid on
[in]mgMultigrid options
[in]set_residualIf true, store residual in i_tmp
[in]highest_lvlMaximum level for V-cycle
[in]standaloneFalse if called by other cycle

Definition at line 183 of file m_af_multigrid.f90.

◆ solve_coarse_grid()

subroutine m_af_multigrid::solve_coarse_grid ( type(af_t), intent(inout)  tree,
type(mg_t), intent(in)  mg 
)
Parameters
[in,out]treeTree to do multigrid on
[in]mgMultigrid options

Definition at line 264 of file m_af_multigrid.f90.

◆ mg_sides_rb()

subroutine, public m_af_multigrid::mg_sides_rb ( type(box_t), dimension(:), intent(inout)  boxes,
integer, intent(in)  id,
integer, intent(in)  nb,
integer, intent(in)  iv 
)

Fill ghost cells near refinement boundaries which preserves diffusive fluxes.

Parameters
[in,out]boxesList of all boxes
[in]idId of box
[in]nbGhost cell direction
[in]ivGhost cell variable

Definition at line 292 of file m_af_multigrid.f90.

◆ mg_sides_rb_extrap()

subroutine m_af_multigrid::mg_sides_rb_extrap ( type(box_t), dimension(:), intent(inout)  boxes,
integer, intent(in)  id,
integer, intent(in)  nb,
integer, intent(in)  iv 
)
private

Fill ghost cells near refinement boundaries which preserves diffusive fluxes. This routine does not do interpolation of coarse grid values. Basically, we extrapolate from the fine cells to a corner point, and then take the average between this corner point and a coarse neighbor to fill ghost cells for the fine cells.

Parameters
[in,out]boxesList of all boxes
[in]idId of box
[in]nbGhost cell direction
[in]ivGhost cell variable

Definition at line 466 of file m_af_multigrid.f90.

◆ correct_children()

subroutine m_af_multigrid::correct_children ( type(box_t), dimension(:), intent(inout)  boxes,
integer, dimension(:), intent(in)  ids,
type(mg_t), intent(in)  mg 
)
private
Parameters
[in,out]boxesList of all boxes
[in]idsOperate on these boxes
[in]mgMultigrid options

Definition at line 622 of file m_af_multigrid.f90.

◆ gsrb_boxes()

subroutine m_af_multigrid::gsrb_boxes ( type(af_t), intent(inout)  tree,
integer, intent(in)  lvl,
type(mg_t), intent(in)  mg,
integer, intent(in)  type_cycle 
)
private
Parameters
[in,out]treeTree containing full grid
[in]mgMultigrid options
[in]lvlOperate on this refinement level
[in]type_cycleType of cycle to perform

Definition at line 646 of file m_af_multigrid.f90.

◆ update_coarse()

subroutine m_af_multigrid::update_coarse ( type(af_t), intent(inout)  tree,
integer, intent(in)  lvl,
type(mg_t), intent(in)  mg 
)
private
Parameters
[in,out]treeTree containing full grid
[in]lvlUpdate coarse values at lvl-1
[in]mgMultigrid options

Definition at line 689 of file m_af_multigrid.f90.

◆ set_coarse_phi_rhs()

subroutine m_af_multigrid::set_coarse_phi_rhs ( type(af_t), intent(inout)  tree,
integer, intent(in)  lvl,
type(mg_t), intent(in)  mg 
)

This routine performs the same as update_coarse, but it ignores the tmp variable.

Parameters
[in,out]treeTree containing full grid
[in]lvlUpdate coarse values at lvl-1
[in]mgMultigrid options

Definition at line 740 of file m_af_multigrid.f90.

◆ init_phi_rhs()

subroutine m_af_multigrid::init_phi_rhs ( type(af_t), intent(inout)  tree,
type(mg_t), intent(in)  mg 
)

Set the initial guess for phi and restrict the rhs.

Parameters
[in,out]treeFull grid
[in]mgMultigrid options

Definition at line 777 of file m_af_multigrid.f90.

◆ residual_box()

subroutine m_af_multigrid::residual_box ( type(box_t), intent(inout)  box,
type(mg_t), intent(in)  mg 
)
Parameters
[in,out]boxOperate on this box
[in]mgMultigrid options

Definition at line 799 of file m_af_multigrid.f90.

◆ mg_auto_gsrb()

subroutine m_af_multigrid::mg_auto_gsrb ( type(box_t), intent(inout)  box,
integer, intent(in)  redblack_cntr,
type(mg_t), intent(in)  mg 
)
private

Based on the box type, apply a Gauss-Seidel relaxation scheme.

Parameters
[in,out]boxBox to operate on
[in]redblack_cntrIteration count
[in]mgMultigrid options

Definition at line 811 of file m_af_multigrid.f90.

◆ mg_store_operator_stencil()

subroutine m_af_multigrid::mg_store_operator_stencil ( type(box_t), intent(inout)  box,
type(mg_t), intent(in)  mg,
integer, intent(inout)  ix 
)
private

Store operator stencil for a box.

Parameters
[in,out]ixIndex of the stencil. If equal to af_stencil_none, store a new stencil

Definition at line 821 of file m_af_multigrid.f90.

◆ mg_store_prolongation_stencil()

subroutine m_af_multigrid::mg_store_prolongation_stencil ( type(af_t), intent(inout)  tree,
integer, intent(in)  id,
type(mg_t), intent(in)  mg 
)
private

Store prolongation stencil for a box.

Parameters
[in]idId of box

Definition at line 860 of file m_af_multigrid.f90.

◆ mg_auto_op()

subroutine m_af_multigrid::mg_auto_op ( type(box_t), intent(inout)  box,
integer, intent(in)  i_out,
type(mg_t), intent(in)  mg 
)
private

Based on the box type, apply the approriate operator.

Parameters
[in,out]boxOperate on this box
[in]i_outIndex of output variable
[in]mgMultigrid options

Definition at line 904 of file m_af_multigrid.f90.

◆ mg_auto_rstr()

subroutine m_af_multigrid::mg_auto_rstr ( type(box_t), intent(in)  box_c,
type(box_t), intent(inout)  box_p,
integer, intent(in)  iv,
type(mg_t), intent(in)  mg 
)
private

Restriction operator.

Parameters
[in]box_cChild box
[in,out]box_pParent box
[in]ivIndex of variable
[in]mgMultigrid options

Definition at line 913 of file m_af_multigrid.f90.

◆ mg_auto_rb()

subroutine m_af_multigrid::mg_auto_rb ( type(box_t), dimension(:), intent(inout)  boxes,
integer, intent(in)  id,
integer, intent(in)  nb,
integer, intent(in)  iv,
integer, intent(in)  op_mask 
)
private

Set ghost cells near refinement boundaries.

Parameters
[in,out]boxesList of all boxes
[in]idId of box
[in]nbGhost cell direction
[in]ivGhost cell variable
[in]op_maskOperator mask

Definition at line 924 of file m_af_multigrid.f90.

◆ mg_auto_corr()

subroutine m_af_multigrid::mg_auto_corr ( type(box_t), intent(in)  box_p,
type(box_t), intent(inout)  box_c,
type(mg_t), intent(in)  mg 
)
private

Based on the box type, correct the solution of the children.

Parameters
[in,out]box_cChild box
[in]box_pParent box
[in]mgMultigrid options

Definition at line 941 of file m_af_multigrid.f90.

◆ get_possible_lsf_root_mask()

subroutine m_af_multigrid::get_possible_lsf_root_mask ( type(box_t), intent(in)  box,
integer, intent(in)  nc,
real(dp), intent(in)  dmax,
type(mg_t), intent(in)  mg,
logical, dimension(dtimes(nc)), intent(out)  root_mask 
)
private

Check where the level-set function could have a root by computing the numerical gradient.

Parameters
[in]boxBox to operate on
[in]dmaxMaximal distance to consider
[in]ncBox size
[in]mgMultigrid options
[out]root_maskWhether there could be a root

Definition at line 952 of file m_af_multigrid.f90.

◆ store_lsf_distance_matrix()

subroutine m_af_multigrid::store_lsf_distance_matrix ( type(box_t), intent(inout)  box,
integer, intent(in)  nc,
type(mg_t), intent(in)  mg,
logical, intent(out)  boundary 
)
private

Check if the level set function could have zeros, and store distances for the neighboring cells.

Parameters
[in,out]boxBox to operate on
[in]ncBox size
[in]mgMultigrid options
[out]boundaryWhether a boundary is found

Definition at line 975 of file m_af_multigrid.f90.

◆ mg_set_box_tag()

subroutine, public m_af_multigrid::mg_set_box_tag ( type(af_t), intent(inout)  tree,
integer, intent(in)  id,
type(mg_t), intent(in)  mg 
)

Set tag (box type) for a box in the tree.

Definition at line 1098 of file m_af_multigrid.f90.

◆ mg_set_operators_lvl()

subroutine, public m_af_multigrid::mg_set_operators_lvl ( type(af_t), intent(inout)  tree,
type(mg_t), intent(in)  mg,
integer, intent(in)  lvl 
)

Definition at line 1131 of file m_af_multigrid.f90.

◆ mg_update_operator_stencil()

subroutine, public m_af_multigrid::mg_update_operator_stencil ( type(af_t), intent(inout)  tree,
type(mg_t), intent(inout)  mg 
)

Update stencil for an operator, because (part of) the coefficients have changed.

Definition at line 1172 of file m_af_multigrid.f90.

◆ mg_set_operators_tree()

subroutine, public m_af_multigrid::mg_set_operators_tree ( type(af_t), intent(inout)  tree,
type(mg_t), intent(in)  mg 
)

Definition at line 1195 of file m_af_multigrid.f90.

◆ mg_box_rstr_lpl()

subroutine m_af_multigrid::mg_box_rstr_lpl ( type(box_t), intent(in)  box_c,
type(box_t), intent(inout)  box_p,
integer, intent(in)  iv,
type(mg_t), intent(in)  mg 
)
private

Restriction of child box (box_c) to its parent (box_p)

Parameters
[in]box_cChild box to restrict
[in,out]box_pParent box to restrict to
[in]ivVariable to restrict
[in]mgMultigrid options

Definition at line 1206 of file m_af_multigrid.f90.

◆ mg_box_lpl_stencil()

subroutine m_af_multigrid::mg_box_lpl_stencil ( type(box_t), intent(inout)  box,
type(mg_t), intent(in)  mg,
integer, intent(in)  ix 
)

Store the matrix stencil for each cell of the box. The order of the stencil is (i, j), (i-1, j), (i+1, j), (i, j-1), (i, j+1) (e.g., -4, 1, 1, 1, 1)

Parameters
[in]ixStencil index

Definition at line 1225 of file m_af_multigrid.f90.

◆ mg_box_prolong_linear_stencil()

subroutine m_af_multigrid::mg_box_prolong_linear_stencil ( type(box_t), intent(inout)  box,
type(box_t), intent(in)  box_p,
type(mg_t), intent(in)  mg,
integer, intent(in)  ix 
)
private

Store linear prolongation stencil for standard Laplacian.

Parameters
[in,out]boxCurrent box
[in]box_pParent box
[in]ixStencil index

Definition at line 1246 of file m_af_multigrid.f90.

◆ mg_box_prolong_sparse_stencil()

subroutine m_af_multigrid::mg_box_prolong_sparse_stencil ( type(box_t), intent(inout)  box,
type(box_t), intent(in)  box_p,
type(mg_t), intent(in)  mg,
integer, intent(in)  ix 
)
private

Store sparse linear prolongation stencil for standard Laplacian.

Parameters
[in,out]boxCurrent box
[in]box_pParent box
[in]ixStencil index

Definition at line 1266 of file m_af_multigrid.f90.

◆ mg_box_prolong_eps_stencil()

subroutine m_af_multigrid::mg_box_prolong_eps_stencil ( type(box_t), intent(inout)  box,
type(box_t), intent(in)  box_p,
type(mg_t), intent(in)  mg,
integer, intent(in)  ix 
)
private

Store prolongation stencil for standard Laplacian with variable coefficient that can jump at cell faces.

Parameters
[in,out]boxCurrent box
[in]box_pParent box
[in]ixStencil index

Definition at line 1287 of file m_af_multigrid.f90.

◆ mg_box_prolong_lsf_stencil()

subroutine m_af_multigrid::mg_box_prolong_lsf_stencil ( type(box_t), intent(inout)  box,
type(box_t), intent(in)  box_p,
type(mg_t), intent(in)  mg,
integer, intent(in)  ix 
)
private

Store prolongation stencil for standard Laplacian with level set function for internal boundaries.

Parameters
[in,out]boxCurrent box
[in]box_pParent box
[in]ixStencil index

Definition at line 1371 of file m_af_multigrid.f90.

◆ mg_box_lpld_stencil()

subroutine m_af_multigrid::mg_box_lpld_stencil ( type(box_t), intent(inout)  box,
type(mg_t), intent(in)  mg,
integer, intent(in)  ix 
)
private

Store the matrix stencil for each cell of the box. The order of the stencil is (i, j), (i-1, j), (i+1, j), (i, j-1), (i, j+1) (e.g., -4, 1, 1, 1, 1)

Parameters
[in]ixIndex of the stencil

Definition at line 1472 of file m_af_multigrid.f90.

◆ mg_box_lpld_lsf_stencil()

subroutine m_af_multigrid::mg_box_lpld_lsf_stencil ( type(box_t), intent(inout)  box,
type(mg_t), intent(in)  mg,
integer, intent(in)  ix 
)
private

Store stencil for a box with variable coefficient and level set function.

Parameters
[in]ixIndex of the stencil
Todo:
This is not fully accurate when there is both a change in epsilon and a boundary for the same cell

Definition at line 1514 of file m_af_multigrid.f90.

◆ mg_lsf_dist_linear()

real(dp) function, public m_af_multigrid::mg_lsf_dist_linear ( real(dp), dimension(ndim), intent(in)  a,
real(dp), dimension(ndim), intent(in)  b,
type(mg_t), intent(in)  mg 
)

Compute distance to boundary starting at point a going to point b, in the range from [0, 1], with 1 meaning there is no boundary.

Parameters
[in]aStart point
[in]bEnd point

Definition at line 1605 of file m_af_multigrid.f90.

◆ mg_lsf_dist_gss()

real(dp) function, public m_af_multigrid::mg_lsf_dist_gss ( real(dp), dimension(ndim), intent(in)  a,
real(dp), dimension(ndim), intent(in)  b,
type(mg_t), intent(in)  mg 
)

Find root of f in the interval [a, b]. If f(a) and f(b) have different signs, apply bisection directly. Else, first find the (assumed to be) unique local minimum/maximum to determine a bracket. Return relative location of root, or 1 if there is no root.

Parameters
[in]aStart point
[in]bEnd point

Definition at line 1627 of file m_af_multigrid.f90.

◆ bisection()

real(dp) function, dimension(ndim) m_af_multigrid::bisection ( procedure(mg_func_lsf f,
real(dp), dimension(ndim), intent(in)  in_a,
real(dp), dimension(ndim), intent(in)  in_b,
real(dp), intent(in)  tol,
integer, intent(in)  max_iter 
)
private

Simple bisection.

Definition at line 1665 of file m_af_multigrid.f90.

◆ gss()

real(dp) function, dimension(ndim, 2) m_af_multigrid::gss ( procedure(mg_func_lsf f,
real(dp), dimension(ndim), intent(in)  in_a,
real(dp), dimension(ndim), intent(in)  in_b,
logical, intent(in)  minimization,
real(dp), intent(in)  tol,
logical, intent(in)  find_bracket 
)
private

Golden-section search on a line between a and b. Given a function f with a single local minimum/maximum in the interval [a,b], gss returns a subset interval [c,d] that contains the minimum/maximum with d-c <= tol. Adapted from https://en.wikipedia.org/wiki/Golden-section_search.

Parameters
fFunction to minimize/maximize
[in]in_aStart coordinate
[in]in_bEnd coordinate
[in]minimizationWhether to perform minimization or maximization
[in]tolAbsolute tolerance
[in]find_bracketWhether to search for a bracket

Definition at line 1692 of file m_af_multigrid.f90.

◆ mg_box_lsf_stencil()

subroutine m_af_multigrid::mg_box_lsf_stencil ( type(box_t), intent(inout)  box,
type(mg_t), intent(in)  mg,
integer, intent(in)  ix 
)
private

Store the matrix stencil for each cell of the box. The order of the stencil is (i, j), (i-1, j), (i+1, j), (i, j-1), (i, j+1) (e.g., -4, 1, 1, 1, 1)

Parameters
[in]ixIndex of stencil

Definition at line 1760 of file m_af_multigrid.f90.

◆ mg_compute_phi_gradient()

subroutine, public m_af_multigrid::mg_compute_phi_gradient ( type(af_t), intent(inout)  tree,
type(mg_t), intent(in)  mg,
integer, intent(in)  i_fc,
real(dp), intent(in)  fac,
integer, intent(in), optional  i_norm 
)

Compute the gradient of the potential and store in face-centered variables.

Parameters
[in]i_fcFace-centered indices
[in]facMultiply with this factor
[in]i_normIf present, store norm in this cell-centered variable
Todo:
Solution on coarse grid can lead to large gradient due to inconsistencies with level set function

Definition at line 1835 of file m_af_multigrid.f90.

◆ mg_box_lpl_gradient()

subroutine, public m_af_multigrid::mg_box_lpl_gradient ( type(af_t), intent(inout)  tree,
integer, intent(in)  id,
type(mg_t), intent(in)  mg,
integer, intent(in)  i_fc,
real(dp), intent(in)  fac 
)

Compute the gradient of the potential.

Parameters
[in]i_fcFace-centered indices
[in]facMultiply with this factor

Definition at line 1880 of file m_af_multigrid.f90.

◆ mg_compute_field_norm()

subroutine, public m_af_multigrid::mg_compute_field_norm ( type(af_t), intent(inout)  tree,
integer, intent(in)  i_fc,
integer, intent(in)  i_norm 
)

Compute norm of face-centered variable.

Parameters
[in]i_fcIndex of face-centered variable
[in]i_normIndex of cell-centered variable

Definition at line 1975 of file m_af_multigrid.f90.

◆ mg_box_field_norm()

subroutine, public m_af_multigrid::mg_box_field_norm ( type(af_t), intent(inout)  tree,
integer, intent(in)  id,
integer, intent(in)  i_fc,
integer, intent(in)  i_norm 
)
Parameters
[in]i_fcFace-centered indices
[in]i_normStore norm in this cell-centered variable

Definition at line 1993 of file m_af_multigrid.f90.

◆ mg_box_lpllsf_gradient()

subroutine m_af_multigrid::mg_box_lpllsf_gradient ( type(af_t), intent(inout)  tree,
integer, intent(in)  id,
type(mg_t), intent(in)  mg,
integer, intent(in)  i_fc,
real(dp), intent(in)  fac 
)
private

Compute the gradient of the potential with a level set function and store in face-centered variables. The gradients are computed from the positive side of the level set function.

Parameters
[in]i_fcFace-centered indices
[in]facMultiply with this factor

Definition at line 2028 of file m_af_multigrid.f90.

◆ check_coarse_representation_lsf()

subroutine m_af_multigrid::check_coarse_representation_lsf ( type(af_t), intent(in)  tree,
type(mg_t), intent(in)  mg 
)
private

This method checks whether the level set function is properly defined on the coarse grid.

Definition at line 2122 of file m_af_multigrid.f90.

◆ numerical_gradient()

real(dp) function, dimension(ndim) m_af_multigrid::numerical_gradient ( procedure(mg_func_lsf f,
real(dp), dimension(ndim), intent(in)  r 
)
private

Get amplitude of numerical gradient of level set function.

Definition at line 2142 of file m_af_multigrid.f90.