m_octree_mg_2d Module

Module for implicitly solving diffusion equations Module which contains multigrid procedures for a Laplacian operator

Module for load balancing a tree (that already has been constructed). The load balancing determines which ranks (MPI processes) allocated physical storage for boxes. The tree structure itself is present on all processes. Module which contains multigrid procedures for a variable-coefficient Laplacian operator, assuming the variation is smooth


Uses

  • module~~m_octree_mg_2d~~UsesGraph module~m_octree_mg_2d m_octree_mg_2d module~mod_mpi_wrapper mod_mpi_wrapper module~m_octree_mg_2d->module~mod_mpi_wrapper mpi mpi module~m_octree_mg_2d->mpi module~mod_mpi_wrapper->mpi

Variables

Type Visibility Attributes Name Initial
integer, public, parameter :: dp = kind(0.0d0)

Type of reals

integer, public, parameter :: i8 = selected_int_kind(18)

Type for 64-bit integers

integer, public, parameter :: mg_ahelmholtz = 5

Indicates a anisotropic-coefficient Helmholtz equation

integer, public, parameter :: mg_bc_continuous = -12

Value to indicate a continuous boundary condition

integer, public, parameter :: mg_bc_dirichlet = -10

Value to indicate a Dirichlet boundary condition

integer, public, parameter :: mg_bc_neumann = -11

Value to indicate a Neumann boundary condition

integer, public, parameter :: mg_cartesian = 1

Cartesian coordinate system

integer, public, parameter :: mg_child_adj_nb(2,4) = reshape([1, 3, 2, 4, 1, 2, 3, 4], [2, 4])
integer, public, parameter :: mg_child_dix(2,4) = reshape([0, 0, 1, 0, 0, 1, 1, 1], [2, 4])
logical, public, parameter :: mg_child_low(2,4) = reshape([.true., .true., .false., .true., .true., .false., .false., .false.], [2, 4])
integer, public, parameter :: mg_child_rev(4,2) = reshape([2, 1, 4, 3, 3, 4, 1, 2], [4, 2])
integer, public, parameter :: mg_cylindrical = 2

Cylindrical coordinate system

integer, public, parameter :: mg_helmholtz = 3

Indicates a constant-coefficient Helmholtz equation

integer, public, parameter :: mg_iold = 3

Index of previous solution (used for correction)

integer, public, parameter :: mg_iphi = 1

Index of solution

integer, public, parameter :: mg_ires = 4

Index of residual

integer, public, parameter :: mg_irhs = 2

Index of right-hand side

integer, public, parameter :: mg_iveps = 5

Index of the variable coefficient (at cell centers)

integer, public, parameter :: mg_iveps1 = 5

Indexes of anisotropic variable coefficients

integer, public, parameter :: mg_iveps2 = 6
integer, public, parameter :: mg_laplacian = 1

Indicates a standard Laplacian

integer, public, parameter :: mg_lvl_hi = 20

Maximum allowed grid level

integer, public, parameter :: mg_lvl_lo = -20

Minimum allowed grid level

integer, public, parameter :: mg_max_num_vars = 10

Maximum number of variables

integer, public, parameter :: mg_max_timers = 20

Maximum number of timers to use

integer, public, parameter :: mg_ndim = 2

Problem dimension

integer, public, parameter :: mg_neighb_dim(4) = [1, 1, 2, 2]
integer, public, parameter :: mg_neighb_dix(2,4) = reshape([-1, 0, 1, 0, 0, -1, 0, 1], [2, 4])
integer, public, parameter :: mg_neighb_high_pm(4) = [-1, 1, -1, 1]
integer, public, parameter :: mg_neighb_highx = 2
integer, public, parameter :: mg_neighb_highy = 4
logical, public, parameter :: mg_neighb_low(4) = [.true., .false., .true., .false.]
integer, public, parameter :: mg_neighb_lowx = 1
integer, public, parameter :: mg_neighb_lowy = 3
integer, public, parameter :: mg_neighb_rev(4) = [2, 1, 4, 3]
integer, public, parameter :: mg_no_box = 0

Special value that indicates there is no box

integer, public, parameter :: mg_num_children = 4
integer, public, parameter :: mg_num_neighbors = 4
integer, public, parameter :: mg_num_vars = 4

Number of predefined multigrid variables

integer, public, parameter :: mg_physical_boundary = -1

Special value that indicates there is a physical boundary

integer, public, parameter :: mg_smoother_gs = 1
integer, public, parameter :: mg_smoother_gsrb = 2
integer, public, parameter :: mg_smoother_jacobi = 3
integer, public, parameter :: mg_spherical = 3

Spherical coordinate system

integer, public, parameter :: mg_vhelmholtz = 4

Indicates a variable-coefficient Helmholtz equation

integer, public, parameter :: mg_vlaplacian = 2

Indicates a variable-coefficient Laplacian

real(kind=dp), protected :: ahelmholtz_lambda = 0.0_dp

Module which contains multigrid procedures for a Helmholtz operator of the form: div(D grad(phi)) - lambda*phi = f, where D has a smooth spatial variation and a component in each spatial direction The lambda used for the Helmholtz equation (should be >= 0)

real(kind=dp), protected :: helmholtz_lambda = 0.0_dp

Module which contains multigrid procedures for a Helmholtz operator of the form: laplacian(phi) - lambda*phi = f The lambda used for the Helmholtz equation (should be >= 0)

real(kind=dp), protected :: vhelmholtz_lambda = 0.0_dp

Module which contains multigrid procedures for a Helmholtz operator of the form: div(D grad(phi)) - lambda*phi = f, where D has a smooth spatial variation The lambda used for the Helmholtz equation (should be >= 0)

integer, private, parameter :: kdp = selected_real_kind(15)
integer, private :: timer_coarse = -1
integer, private :: timer_correct = -1
integer, private :: timer_smoother = -1
integer, private :: timer_smoother_gc = -1
integer, private :: timer_total_fmg = -1
integer, private :: timer_total_vcycle = -1
integer, private :: timer_update_coarse = -1

Interfaces

interface

  • public subroutine mg_box_gsrb(mg, id, nc, redblack_cntr)

    Subroutine that performs Gauss-Seidel relaxation

    Arguments

    Type IntentOptional Attributes Name
    type(mg_t), intent(inout) :: mg
    integer, intent(in) :: id
    integer, intent(in) :: nc
    integer, intent(in) :: redblack_cntr

interface

  • public subroutine mg_box_op(mg, id, nc, i_out)

    Subroutine that performs A * cc(..., i_in) = cc(..., i_out)

    Arguments

    Type IntentOptional Attributes Name
    type(mg_t), intent(inout) :: mg
    integer, intent(in) :: id
    integer, intent(in) :: nc
    integer, intent(in) :: i_out

interface

  • public subroutine mg_box_prolong(mg, p_id, dix, nc, iv, fine)

    Subroutine that performs prolongation to a single child

    Arguments

    Type IntentOptional Attributes Name
    type(mg_t), intent(inout) :: mg
    integer, intent(in) :: p_id

    Id of parent

    integer, intent(in) :: dix(2)

    Offset of child in parent grid

    integer, intent(in) :: nc

    Child grid size

    integer, intent(in) :: iv

    Prolong from this variable

    real(kind=dp), intent(out) :: fine(nc,nc)

    Prolonged values

interface

  • public subroutine mg_subr_bc(box, nc, iv, nb, bc_type, bc)

    To fill ghost cells near physical boundaries

    Arguments

    Type IntentOptional Attributes Name
    type(mg_box_t), intent(in) :: box
    integer, intent(in) :: nc
    integer, intent(in) :: iv

    Index of variable

    integer, intent(in) :: nb

    Direction

    integer, intent(out) :: bc_type

    Type of b.c.

    real(kind=dp), intent(out) :: bc(nc)

    Boundary values

interface

  • public subroutine mg_subr_rb(box, nc, iv, nb, cgc)

    To fill ghost cells near refinement boundaries

    Arguments

    Type IntentOptional Attributes Name
    type(mg_box_t), intent(inout) :: box
    integer, intent(in) :: nc
    integer, intent(in) :: iv

    Index of variable

    integer, intent(in) :: nb

    Direction

    real(kind=dp), intent(in) :: cgc(nc)

    Coarse data

public interface mrgrnk

  • private subroutine I_mrgrnk(XDONT, IRNGT)

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(in), Dimension (:) :: XDONT
    integer, intent(out), Dimension (:) :: IRNGT

Derived Types

type, public ::  mg_bc_t

Components

Type Visibility Attributes Name Initial
integer, public :: bc_type = mg_bc_dirichlet

Type of boundary condition

real(kind=dp), public :: bc_value = 0.0_dp

Value (for e.g. Dirichlet or Neumann)

procedure(mg_subr_bc), public, pointer, nopass :: boundary_cond => null()

To set user-defined boundary conditions (overrides bc(:))

procedure(mg_subr_rb), public, pointer, nopass :: refinement_bnd => null()

To set a user-defined refinement boundary method

type, public ::  mg_box_t

Box data structure

Components

Type Visibility Attributes Name Initial
real(kind=dp), public, allocatable :: cc(:,:,:)

Cell-centered data

integer, public :: children(2**2)

Ids of children

real(kind=dp), public :: dr(2)

Grid spacing

integer, public :: id

Box id (index in boxes(:) array)

integer, public :: ix(2)

Spatial index

integer, public :: lvl

Refinement level

integer, public :: neighbors(2*2)

Ids of neighbors

integer, public :: parent

Id of parent

real(kind=dp), public :: r_min(2)

Minimum coordinate

integer, public :: rank

Which process owns this box

type, public ::  mg_buf_t

Buffer type (one is used for each pair of communicating processes)

Components

Type Visibility Attributes Name Initial
integer, public :: i_ix
integer, public :: i_recv
integer, public :: i_send

Index in send array

integer, public, allocatable :: ix(:)

Will be used to sort the data

real(kind=dp), public, allocatable :: recv(:)
real(kind=dp), public, allocatable :: send(:)

type, public ::  mg_comm_t

Components

Type Visibility Attributes Name Initial
integer, public, allocatable :: n_recv(:,:)
integer, public, allocatable :: n_send(:,:)

type, public ::  mg_lvl_t

Lists of blocks per refinement level

Components

Type Visibility Attributes Name Initial
integer, public, allocatable :: ids(:)
integer, public, allocatable :: leaves(:)
integer, public, allocatable :: my_ids(:)
integer, public, allocatable :: my_leaves(:)
integer, public, allocatable :: my_parents(:)
integer, public, allocatable :: my_ref_bnds(:)
integer, public, allocatable :: parents(:)
integer, public, allocatable :: ref_bnds(:)

type, public ::  mg_t

Components

Type Visibility Attributes Name Initial
type(mg_bc_t), public :: bc(mg_num_neighbors,mg_max_num_vars)

To store pre-defined boundary conditions per direction per variable

procedure(mg_box_op), public, pointer, nopass :: box_op => null()

Multigrid operator (e.g., Laplacian)

procedure(mg_box_prolong), public, pointer, nopass :: box_prolong => null()

Multigrid prolongation method

integer, public :: box_size = -1

Size of boxes in cells, be equal for all dimensions

integer, public :: box_size_lvl(mg_lvl_lo:mg_lvl_hi)

Size of boxes per level (differs for coarsest levels)

procedure(mg_box_gsrb), public, pointer, nopass :: box_smoother => null()

Multigrid smoother

type(mg_box_t), public, allocatable :: boxes(:)

Array with all boxes in the tree. Only boxes owned by this task are actually allocated

type(mg_buf_t), public, allocatable :: buf(:)

Buffer for communication with each other task

integer, public :: coarsest_grid(2) = 2
integer, public :: comm = -1

MPI communicator

type(mg_comm_t), public :: comm_ghostcell

Communication info for ghost cell filling

type(mg_comm_t), public :: comm_prolong

Communication info for prolongation

type(mg_comm_t), public :: comm_restrict

Communication info for restriction

integer, public :: domain_size_lvl(2,mg_lvl_lo:mg_lvl_hi)

Size of domain per level (if uniformly refined)

real(kind=dp), public :: dr(2,mg_lvl_lo:mg_lvl_hi)

Grid spacing per level

integer, public :: first_normal_lvl = -1

First normal level of the quadtree/octree, at coarser levels parents have only one child

integer, public :: geometry_type = mg_cartesian

Type of grid geometry

integer, public :: highest_lvl = -1

Highest grid level in the tree

logical, public :: is_allocated = .false.

Whether storage has been allocated for boxes

integer, public :: lowest_lvl = -1

Lowest grid level in the tree

type(mg_lvl_t), public :: lvls(mg_lvl_lo:mg_lvl_hi)

List of all levels

integer, public :: max_coarse_cycles = 1000

Maximum number of cycles on the coarse grid

integer, public :: my_rank = -1

MPI rank of this task

integer, public :: n_boxes = 0

Total number of boxes in the tree (among all processes)

integer, public :: n_cpu = -1

Number of MPI tasks

integer, public :: n_cycle_down = 2

Number of cycles when doing downwards relaxation

integer, public :: n_cycle_up = 2

Number of cycles when doing upwards relaxation

integer, public :: n_extra_vars = 0

Number of extra cell-centered variable (e.g., for coefficients)

integer, public :: n_smoother_substeps = 1

Number of substeps for the smoother (for GSRB this is 2)

integer, public :: n_timers = 0

Number of timers

integer, public :: operator_type = mg_laplacian

Type of operator

logical, public :: periodic(2) = .false.

Whether a dimension is periodic

logical, public :: phi_bc_data_stored = .false.

Whether boundary condition data has been stored for mg solution

real(kind=dp), public :: r_min(2)

Minimum coordinates

real(kind=dp), public :: residual_coarse_abs = 1e-8_dp

Stop coarse grid when max. residual is smaller than this

real(kind=dp), public :: residual_coarse_rel = 1e-8_dp

Stop coarse grid when residual has been reduced by this factor

integer, public :: smoother_type = mg_smoother_gs

Type of multigrid smoother

logical, public :: subtract_mean = .false.

Whether the mean has to be subtracted from the multigrid solution

type(mg_timer_t), public :: timers(mg_max_timers)

Values for the timers

logical, public :: tree_created = .false.

Whether the multigrid tree structure has been created

type, public ::  mg_timer_t

Components

Type Visibility Attributes Name Initial
character(len=20), public :: name
real(kind=dp), public :: t = 0.0_dp
real(kind=dp), public :: t0

Functions

public function mg_add_timer(mg, name)

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
character(len=*), intent(in) :: name

Return Value integer

public pure function mg_get_child_offset(mg, id) result(ix_offset)

Get the offset of a box with respect to its parent (e.g. in 2d, there can be a child at offset 0,0, one at n_cell/2,0, one at 0,n_cell/2 and one at n_cell/2, n_cell/2) n_cell / 2

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(in) :: mg
integer, intent(in) :: id

Return Value integer, (2)

public elemental function mg_has_children(box)

Return .true. if a box has children

Arguments

Type IntentOptional Attributes Name
type(mg_box_t), intent(in) :: box

Return Value logical

public pure function mg_highest_uniform_lvl(mg) result(lvl)

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(in) :: mg

Return Value integer

public function mg_ix_to_ichild(ix)

Compute the child index for a box with spatial index ix. With child index we mean the index in the children(:) array of its parent.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ix(2)

Spatial index of the box

Return Value integer

public function mg_number_of_unknowns(mg) result(n_unknowns)

Determine total number of unknowns (on leaves)

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(in) :: mg

Return Value integer(kind=i8)

private function find_neighb(boxes, id, nb) result(nb_id)

Get the id of neighbor nb of boxes(id), through its parent

Arguments

Type IntentOptional Attributes Name
type(mg_box_t), intent(in) :: boxes(:)

List with all the boxes

integer, intent(in) :: id

Box whose neighbor we are looking for

integer, intent(in) :: nb

Neighbor index

Return Value integer

private function get_sum(mg, iv)

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(in) :: mg
integer, intent(in) :: iv

Return Value real(kind=dp)

private function max_residual_lvl(mg, lvl)

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(in) :: lvl

Return Value real(kind=dp)

private pure function most_popular(list, work, n_cpu)

Determine most popular rank in the list. In case of ties, assign the rank with the least work.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: list(:)

List of MPI ranks

integer, intent(in) :: work(0:n_cpu-1)

Existing work per rank

integer, intent(in) :: n_cpu

Return Value integer


Subroutines

public subroutine ahelmholtz_set_lambda(lambda)

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(in) :: lambda

public subroutine ahelmholtz_set_methods(mg)

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg

public subroutine diffusion_solve(mg, dt, diffusion_coeff, order, max_res)

Solve a diffusion equation implicitly, assuming a constant diffusion coefficient. The solution at time t should be stored in mg_iphi, which is on output replaced by the solution at time t+dt.

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
real(kind=dp), intent(in) :: dt
real(kind=dp), intent(in) :: diffusion_coeff
integer, intent(in) :: order
real(kind=dp), intent(in) :: max_res

public subroutine diffusion_solve_acoeff(mg, dt, order, max_res)

Solve a diffusion equation implicitly, assuming anisotropic diffusion coefficient which has been stored in mg_iveps1, mg_iveps2, mg_iveps3 (also on coarse grids). The solution at time t should be stored in mg_iphi, which is on output replaced by the solution at time t+dt.

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
real(kind=dp), intent(in) :: dt
integer, intent(in) :: order
real(kind=dp), intent(in) :: max_res

public subroutine diffusion_solve_vcoeff(mg, dt, order, max_res)

Solve a diffusion equation implicitly, assuming a variable diffusion coefficient which has been stored in mg_iveps (also on coarse grids). The solution at time t should be stored in mg_iphi, which is on output replaced by the solution at time t+dt.

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
real(kind=dp), intent(in) :: dt
integer, intent(in) :: order
real(kind=dp), intent(in) :: max_res

public subroutine helmholtz_set_lambda(lambda)

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(in) :: lambda

public subroutine helmholtz_set_methods(mg)

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg

public subroutine laplacian_set_methods(mg)

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg

public subroutine mg_add_children(mg, id)

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(in) :: id

Id of box that gets children

public subroutine mg_allocate_storage(mg)

Allocate communication buffers and local boxes for a tree that has already been created

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg

public subroutine mg_apply_op(mg, i_out, op)

Apply operator to the tree and store in variable i_out

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(in) :: i_out
procedure(mg_box_op), optional :: op

public subroutine mg_build_rectangle(mg, domain_size, box_size, dx, r_min, periodic, n_finer)

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(in) :: domain_size(2)
integer, intent(in) :: box_size
real(kind=dp), intent(in) :: dx(2)
real(kind=dp), intent(in) :: r_min(2)
logical, intent(in) :: periodic(2)
integer, intent(in) :: n_finer

public subroutine mg_comm_init(mg, comm)

Prolong from a parent to a child with index offset dix. This method could sometimes work better than the default prolongation, which does not take the variation in epsilon into account Initialize MPI if needed, and store MPI information

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(in), optional :: comm

MPI communicator (default: MPI_COMM_WORLD)

public subroutine mg_deallocate_storage(mg)

Deallocate all allocatable arrays

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg

public subroutine mg_fas_fmg(mg, have_guess, max_res)

Perform FAS-FMG cycle (full approximation scheme, full multigrid).

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
logical, intent(in) :: have_guess

If false, start from phi = 0

real(kind=dp), intent(out), optional :: max_res

Store max(abs(residual))

public subroutine mg_fas_vcycle(mg, highest_lvl, max_res, standalone)

Perform FAS V-cycle (full approximation scheme).

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(in), optional :: highest_lvl

Maximum level for V-cycle

real(kind=dp), intent(out), optional :: max_res

Store max(abs(residual))

logical, intent(in), optional :: standalone

Whether the V-cycle is called by itself (default: true)

public subroutine mg_fill_ghost_cells(mg, iv)

Fill ghost cells at all grid levels

Arguments

Type IntentOptional Attributes Name
type(mg_t) :: mg
integer, intent(in) :: iv

Index of variable

public subroutine mg_fill_ghost_cells_lvl(mg, lvl, iv)

Fill ghost cells at a grid level

Arguments

Type IntentOptional Attributes Name
type(mg_t) :: mg
integer, intent(in) :: lvl
integer, intent(in) :: iv

Index of variable

public subroutine mg_get_face_coords(box, nb, nc, x)

Get coordinates at the face of a box

Arguments

Type IntentOptional Attributes Name
type(mg_box_t), intent(in) :: box
integer, intent(in) :: nb
integer, intent(in) :: nc
real(kind=dp), intent(out) :: x(nc,2)

public subroutine mg_ghost_cell_buffer_size(mg, n_send, n_recv, dsize)

Specify minimum buffer size (per process) for communication

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(out) :: n_send(0:mg%n_cpu-1)
integer, intent(out) :: n_recv(0:mg%n_cpu-1)
integer, intent(out) :: dsize

public subroutine mg_load_balance(mg)

Load balance all boxes in the multigrid tree. Compared to mg_load_balance_simple, this method does a better job of setting the ranks of parent boxes

Read more…

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg

public subroutine mg_load_balance_parents(mg)

Load balance the parents (non-leafs). Assign them to the rank that has most children.

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg

public subroutine mg_load_balance_simple(mg)

Load balance all boxes in the multigrid tree, by simply distributing the load per grid level. This method will only work well for uniform grids.

Read more…

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg

public subroutine mg_phi_bc_store(mg)

Store boundary conditions for the solution variable, this can speed up calculations if the same boundary conditions are re-used.

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg

public subroutine mg_prolong(mg, lvl, iv, iv_to, method, add)

Prolong variable iv from lvl to variable iv_to at lvl+1

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(in) :: lvl

Level to prolong from

integer, intent(in) :: iv

Source variable

integer, intent(in) :: iv_to

Target variable

procedure(mg_box_prolong) :: method

Prolongation method

logical, intent(in) :: add

If true, add to current values

public subroutine mg_prolong_buffer_size(mg, n_send, n_recv, dsize)

Specify minimum buffer size (per process) for communication

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(out) :: n_send(0:mg%n_cpu-1)
integer, intent(out) :: n_recv(0:mg%n_cpu-1)
integer, intent(out) :: dsize

public subroutine mg_prolong_sparse(mg, p_id, dix, nc, iv, fine)

Prolong from a parent to a child with index offset dix

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(in) :: p_id

Id of parent

integer, intent(in) :: dix(2)

Offset of child in parent grid

integer, intent(in) :: nc

Child grid size

integer, intent(in) :: iv

Prolong from this variable

real(kind=dp), intent(out) :: fine(nc,nc)

Prolonged values

public subroutine mg_restrict(mg, iv)

Restrict all levels

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(in) :: iv

public subroutine mg_restrict_buffer_size(mg, n_send, n_recv, dsize)

Specify minimum buffer size (per process) for communication

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(out) :: n_send(0:mg%n_cpu-1)
integer, intent(out) :: n_recv(0:mg%n_cpu-1)
integer, intent(out) :: dsize

public subroutine mg_restrict_lvl(mg, iv, lvl)

Restrict from lvl to lvl-1

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(in) :: iv
integer, intent(in) :: lvl

public subroutine mg_set_leaves_parents(boxes, level)

Create a list of leaves and a list of parents for a level

Arguments

Type IntentOptional Attributes Name
type(mg_box_t), intent(in) :: boxes(:)

List of boxes

type(mg_lvl_t), intent(inout) :: level

Level type which contains the indices of boxes

public subroutine mg_set_methods(mg)

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg

public subroutine mg_set_neighbors_lvl(mg, lvl)

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(in) :: lvl

public subroutine mg_set_next_level_ids(mg, lvl)

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(in) :: lvl

public subroutine mg_set_refinement_boundaries(boxes, level)

Create a list of refinement boundaries (from the coarse side)

Arguments

Type IntentOptional Attributes Name
type(mg_box_t), intent(in) :: boxes(:)
type(mg_lvl_t), intent(inout) :: level

public subroutine mg_timer_end(timer)

Arguments

Type IntentOptional Attributes Name
type(mg_timer_t), intent(inout) :: timer

public subroutine mg_timer_start(timer)

Arguments

Type IntentOptional Attributes Name
type(mg_timer_t), intent(inout) :: timer

public subroutine mg_timers_show(mg)

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(in) :: mg

public subroutine sort_and_transfer_buffers(mg, dsize)

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(in) :: dsize

public subroutine vhelmholtz_set_lambda(lambda)

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(in) :: lambda

public subroutine vhelmholtz_set_methods(mg)

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg

public subroutine vlaplacian_set_methods(mg)

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg

private subroutine I_mrgrnk(XDONT, IRNGT)

Arguments

Type IntentOptional Attributes Name
integer, intent(in), Dimension (:) :: XDONT
integer, intent(out), Dimension (:) :: IRNGT

private subroutine add_single_child(mg, id, n_boxes_lvl)

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(in) :: id

Id of box that gets children

integer, intent(in) :: n_boxes_lvl

private subroutine bc_to_gc(mg, id, nc, iv, nb, bc_type)

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(in) :: id
integer, intent(in) :: nc
integer, intent(in) :: iv
integer, intent(in) :: nb

Neighbor direction

integer, intent(in) :: bc_type

Type of b.c.

private subroutine box_ahelmh(mg, id, nc, i_out)

Perform Helmholtz operator on a box

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(in) :: id
integer, intent(in) :: nc
integer, intent(in) :: i_out

Index of variable to store Helmholtz in

private subroutine box_clpl(mg, id, nc, i_out)

Perform Laplacian operator on a box in cylindrical geometry, using (r,z) and (r,phi,z) coordinates in 2D/3D.

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(in) :: id
integer, intent(in) :: nc
integer, intent(in) :: i_out

Index of variable to store Laplacian in

private subroutine box_gc_for_fine_neighbor(box, nb, di, nc, iv, gc)

Get ghost cells for a fine neighbor

Arguments

Type IntentOptional Attributes Name
type(mg_box_t), intent(in) :: box
integer, intent(in) :: nb

Direction of fine neighbor

integer, intent(in) :: di(2)

Index offset of fine neighbor

integer, intent(in) :: nc
integer, intent(in) :: iv
real(kind=dp), intent(out) :: gc(nc)

private subroutine box_gc_for_neighbor(box, nb, nc, iv, gc)

Arguments

Type IntentOptional Attributes Name
type(mg_box_t), intent(in) :: box
integer, intent(in) :: nb
integer, intent(in) :: nc
integer, intent(in) :: iv
real(kind=dp), intent(out) :: gc(nc)

private subroutine box_get_gc(box, nb, nc, iv, gc)

Arguments

Type IntentOptional Attributes Name
type(mg_box_t), intent(in) :: box
integer, intent(in) :: nb
integer, intent(in) :: nc
integer, intent(in) :: iv
real(kind=dp), intent(out) :: gc(nc)

private subroutine box_gs_ahelmh(mg, id, nc, redblack_cntr)

Perform Gauss-Seidel relaxation on box for a Helmholtz operator

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(in) :: id
integer, intent(in) :: nc
integer, intent(in) :: redblack_cntr

Iteration counter

private subroutine box_gs_clpl(mg, id, nc, redblack_cntr)

Perform Gauss-Seidel relaxation on box for a Laplacian operator in cylindrical geometry. TODO: in 3D this does not converge well, maybe it will for a stretched grid.

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(in) :: id
integer, intent(in) :: nc
integer, intent(in) :: redblack_cntr

Iteration counter

private subroutine box_gs_helmh(mg, id, nc, redblack_cntr)

Perform Gauss-Seidel relaxation on box for a Helmholtz operator

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(in) :: id
integer, intent(in) :: nc
integer, intent(in) :: redblack_cntr

Iteration counter

private subroutine box_gs_lpl(mg, id, nc, redblack_cntr)

Perform Gauss-Seidel relaxation on box for a Laplacian operator

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(in) :: id
integer, intent(in) :: nc
integer, intent(in) :: redblack_cntr

Iteration counter

private subroutine box_gs_vhelmh(mg, id, nc, redblack_cntr)

Perform Gauss-Seidel relaxation on box for a Helmholtz operator

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(in) :: id
integer, intent(in) :: nc
integer, intent(in) :: redblack_cntr

Iteration counter

private subroutine box_gs_vlpl(mg, id, nc, redblack_cntr)

Perform Gauss-Seidel relaxation on box for a Laplacian operator

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(in) :: id
integer, intent(in) :: nc
integer, intent(in) :: redblack_cntr

Iteration counter

private subroutine box_helmh(mg, id, nc, i_out)

Perform Helmholtz operator on a box

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(in) :: id
integer, intent(in) :: nc
integer, intent(in) :: i_out

Index of variable to store Helmholtz in

private subroutine box_lpl(mg, id, nc, i_out)

Perform Laplacian operator on a box

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(in) :: id
integer, intent(in) :: nc
integer, intent(in) :: i_out

Index of variable to store Laplacian in

private subroutine box_set_gc(box, nb, nc, iv, gc)

Arguments

Type IntentOptional Attributes Name
type(mg_box_t), intent(inout) :: box
integer, intent(in) :: nb
integer, intent(in) :: nc
integer, intent(in) :: iv
real(kind=dp), intent(in) :: gc(nc)

private subroutine box_vhelmh(mg, id, nc, i_out)

Perform Helmholtz operator on a box

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(in) :: id
integer, intent(in) :: nc
integer, intent(in) :: i_out

Index of variable to store Helmholtz in

private subroutine box_vlpl(mg, id, nc, i_out)

Perform Laplacian operator on a box

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(in) :: id
integer, intent(in) :: nc
integer, intent(in) :: i_out

Index of variable to store Laplacian in

private subroutine buffer_for_fine_nb(mg, box, nc, iv, fine_id, fine_rank, nb, dry_run)

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
type(mg_box_t), intent(inout) :: box
integer, intent(in) :: nc
integer, intent(in) :: iv
integer, intent(in) :: fine_id
integer, intent(in) :: fine_rank
integer, intent(in) :: nb
logical, intent(in) :: dry_run

private subroutine buffer_for_nb(mg, box, nc, iv, nb_id, nb_rank, nb, dry_run)

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
type(mg_box_t), intent(inout) :: box
integer, intent(in) :: nc
integer, intent(in) :: iv
integer, intent(in) :: nb_id
integer, intent(in) :: nb_rank
integer, intent(in) :: nb
logical, intent(in) :: dry_run

private subroutine buffer_ghost_cells(mg, id, nc, iv, dry_run)

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(in) :: id
integer, intent(in) :: nc
integer, intent(in) :: iv
logical, intent(in) :: dry_run

private subroutine buffer_refinement_boundaries(mg, id, nc, iv, dry_run)

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(in) :: id
integer, intent(in) :: nc
integer, intent(in) :: iv
logical, intent(in) :: dry_run

private subroutine check_methods(mg)

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg

private subroutine copy_from_nb(box, box_nb, nb, nc, iv)

Arguments

Type IntentOptional Attributes Name
type(mg_box_t), intent(inout) :: box
type(mg_box_t), intent(in) :: box_nb
integer, intent(in) :: nb
integer, intent(in) :: nc
integer, intent(in) :: iv

private subroutine correct_children(mg, lvl)

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(in) :: lvl

private subroutine fill_buffered_nb(mg, box, nb_rank, nb, nc, iv, dry_run)

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
type(mg_box_t), intent(inout) :: box
integer, intent(in) :: nb_rank
integer, intent(in) :: nb
integer, intent(in) :: nc
integer, intent(in) :: iv
logical, intent(in) :: dry_run

private subroutine fill_refinement_bnd(mg, id, nb, nc, iv, dry_run)

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(in) :: id
integer, intent(in) :: nb
integer, intent(in) :: nc
integer, intent(in) :: iv
logical, intent(in) :: dry_run

private subroutine mg_add_timers(mg)

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg

private subroutine mg_phi_bc_store_lvl(mg, lvl, nc)

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(in) :: lvl
integer, intent(in) :: nc

private subroutine prolong_onto(mg, id, nc, iv, iv_to, add, method)

Prolong onto a child box

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(in) :: id
integer, intent(in) :: nc
integer, intent(in) :: iv

Prolong from this variable

integer, intent(in) :: iv_to

Prolong to this variable

logical, intent(in) :: add

If true, add to current values

procedure(mg_box_prolong) :: method

private subroutine prolong_set_buffer(mg, id, nc, iv, method)

In case the fine grid is on a different CPU, perform the prolongation and store the fine-grid values in the send buffer.

Read more…

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(in) :: id
integer, intent(in) :: nc
integer, intent(in) :: iv
procedure(mg_box_prolong) :: method

private subroutine residual_box(mg, id, nc)

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(in) :: id
integer, intent(in) :: nc

private subroutine restrict_onto(mg, id, nc, iv)

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(in) :: id
integer, intent(in) :: nc
integer, intent(in) :: iv

private subroutine restrict_set_buffer(mg, id, iv)

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(in) :: id
integer, intent(in) :: iv

private subroutine set_ghost_cells(mg, id, nc, iv, dry_run)

The routine that actually fills the ghost cells

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(in) :: id
integer, intent(in) :: nc
integer, intent(in) :: iv
logical, intent(in) :: dry_run

private subroutine set_neighbs(boxes, id)

Arguments

Type IntentOptional Attributes Name
type(mg_box_t), intent(inout) :: boxes(:)
integer, intent(in) :: id

private subroutine set_rhs(mg, f1, f2)

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
real(kind=dp), intent(in) :: f1
real(kind=dp), intent(in) :: f2

private subroutine sides_rb(box, nc, iv, nb, gc)

Fill ghost cells near refinement boundaries which preserves diffusive fluxes.

Arguments

Type IntentOptional Attributes Name
type(mg_box_t), intent(inout) :: box
integer, intent(in) :: nc
integer, intent(in) :: iv
integer, intent(in) :: nb

Ghost cell direction

real(kind=dp), intent(in) :: gc(nc)

Interpolated coarse grid ghost cell data (but not yet in the nb direction)

private subroutine smooth_boxes(mg, lvl, n_cycle)

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(in) :: lvl
integer, intent(in) :: n_cycle

Number of cycles to perform

private subroutine sort_sendbuf(gc, dsize)

Sort send buffers according to the idbuf array

Arguments

Type IntentOptional Attributes Name
type(mg_buf_t), intent(inout) :: gc
integer, intent(in) :: dsize

Size of send buffer elements

private subroutine subtract_mean(mg, iv, include_ghostcells)

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
integer, intent(in) :: iv
logical, intent(in) :: include_ghostcells

private subroutine update_coarse(mg, lvl)

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg

Tree containing full grid

integer, intent(in) :: lvl

Update coarse values at lvl-1

private subroutine update_lvl_info(mg, lvl)

Arguments

Type IntentOptional Attributes Name
type(mg_t), intent(inout) :: mg
type(mg_lvl_t), intent(inout) :: lvl