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
| 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(1,2) | = | reshape([1, 2], [1, 2]) | |
| integer, | public, | parameter | :: | mg_child_dix(1,2) | = | reshape([0, 1], [1, 2]) | |
| logical, | public, | parameter | :: | mg_child_low(1,2) | = | reshape([.true., .false.], [1, 2]) | |
| integer, | public, | parameter | :: | mg_child_rev(2,1) | = | reshape([2, 1], [2, 1]) | |
| 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_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 | = | 1 |
Problem dimension |
| integer, | public, | parameter | :: | mg_neighb_dim(2) | = | [1, 1] | |
| integer, | public, | parameter | :: | mg_neighb_dix(1,2) | = | reshape([-1, 1], [1, 2]) | |
| integer, | public, | parameter | :: | mg_neighb_high_pm(2) | = | [-1, 1] | |
| integer, | public, | parameter | :: | mg_neighb_highx | = | 2 | |
| logical, | public, | parameter | :: | mg_neighb_low(2) | = | [.true., .false.] | |
| integer, | public, | parameter | :: | mg_neighb_lowx | = | 1 | |
| integer, | public, | parameter | :: | mg_neighb_rev(2) | = | [2, 1] | |
| integer, | public, | parameter | :: | mg_no_box | = | 0 |
Special value that indicates there is no box |
| integer, | public, | parameter | :: | mg_num_children | = | 2 | |
| integer, | public, | parameter | :: | mg_num_neighbors | = | 2 | |
| 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 |
Subroutine that performs Gauss-Seidel relaxation
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg | |||
| integer, | intent(in) | :: | id | |||
| integer, | intent(in) | :: | nc | |||
| integer, | intent(in) | :: | redblack_cntr |
Subroutine that performs A * cc(..., i_in) = cc(..., i_out)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg | |||
| integer, | intent(in) | :: | id | |||
| integer, | intent(in) | :: | nc | |||
| integer, | intent(in) | :: | i_out |
Subroutine that performs prolongation to a single child
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg | |||
| integer, | intent(in) | :: | p_id |
Id of parent |
||
| integer, | intent(in) | :: | dix(1) |
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) |
Prolonged values |
To fill ghost cells near physical boundaries
| Type | Intent | Optional | 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(1) |
Boundary values |
To fill ghost cells near refinement boundaries
| Type | Intent | Optional | 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(1) |
Coarse data |
| 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 |
Box data structure
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| real(kind=dp), | public, | allocatable | :: | cc(:,:) |
Cell-centered data |
||
| integer, | public | :: | children(2**1) |
Ids of children |
|||
| real(kind=dp), | public | :: | dr(1) |
Grid spacing |
|||
| integer, | public | :: | id |
Box id (index in boxes(:) array) |
|||
| integer, | public | :: | ix(1) |
Spatial index |
|||
| integer, | public | :: | lvl |
Refinement level |
|||
| integer, | public | :: | neighbors(2*1) |
Ids of neighbors |
|||
| integer, | public | :: | parent |
Id of parent |
|||
| real(kind=dp), | public | :: | r_min(1) |
Minimum coordinate |
|||
| integer, | public | :: | rank |
Which process owns this box |
Buffer type (one is used for each pair of communicating processes)
| 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 | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | public, | allocatable | :: | n_recv(:,:) | |||
| integer, | public, | allocatable | :: | n_send(:,:) |
Lists of blocks per refinement level
| 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 | 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(1) | = | 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(1,mg_lvl_lo:mg_lvl_hi) |
Size of domain per level (if uniformly refined) |
|||
| real(kind=dp), | public | :: | dr(1,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(1) | = | .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(1) |
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 | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| character(len=20), | public | :: | name | ||||
| real(kind=dp), | public | :: | t | = | 0.0_dp | ||
| real(kind=dp), | public | :: | t0 |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg | |||
| character(len=*), | intent(in) | :: | name |
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
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(in) | :: | mg | |||
| integer, | intent(in) | :: | id |
Return .true. if a box has children
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_box_t), | intent(in) | :: | box |
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.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | ix(1) |
Spatial index of the box |
Determine total number of unknowns (on leaves)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(in) | :: | mg |
Get the id of neighbor nb of boxes(id), through its parent
| Type | Intent | Optional | 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 |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(in) | :: | mg | |||
| integer, | intent(in) | :: | iv |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg | |||
| integer, | intent(in) | :: | lvl |
Determine most popular rank in the list. In case of ties, assign the rank with the least work.
| Type | Intent | Optional | 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 |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=dp), | intent(in) | :: | lambda |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg |
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.
| Type | Intent | Optional | 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 |
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.
| Type | Intent | Optional | 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 |
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.
| Type | Intent | Optional | 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 |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=dp), | intent(in) | :: | lambda |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg | |||
| integer, | intent(in) | :: | id |
Id of box that gets children |
Allocate communication buffers and local boxes for a tree that has already been created
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg | |||
| integer, | intent(in) | :: | domain_size(1) | |||
| integer, | intent(in) | :: | box_size | |||
| real(kind=dp), | intent(in) | :: | dx(1) | |||
| real(kind=dp), | intent(in) | :: | r_min(1) | |||
| logical, | intent(in) | :: | periodic(1) | |||
| integer, | intent(in) | :: | n_finer |
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
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg | |||
| integer, | intent(in), | optional | :: | comm |
MPI communicator (default: MPI_COMM_WORLD) |
Deallocate all allocatable arrays
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg |
Perform FAS-FMG cycle (full approximation scheme, full multigrid).
| Type | Intent | Optional | 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)) |
Perform FAS V-cycle (full approximation scheme).
| Type | Intent | Optional | 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) |
Fill ghost cells at all grid levels
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t) | :: | mg | ||||
| integer, | intent(in) | :: | iv |
Index of variable |
Fill ghost cells at a grid level
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t) | :: | mg | ||||
| integer, | intent(in) | :: | lvl | |||
| integer, | intent(in) | :: | iv |
Index of variable |
Get coordinates at the face of a box
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_box_t), | intent(in) | :: | box | |||
| integer, | intent(in) | :: | nb | |||
| integer, | intent(in) | :: | nc | |||
| real(kind=dp), | intent(out) | :: | x(1) |
Specify minimum buffer size (per process) for communication
| Type | Intent | Optional | 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 |
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
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg |
Load balance the parents (non-leafs). Assign them to the rank that has most children.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | 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.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg |
Store boundary conditions for the solution variable, this can speed up calculations if the same boundary conditions are re-used.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg |
Prolong variable iv from lvl to variable iv_to at lvl+1
| Type | Intent | Optional | 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 |
Specify minimum buffer size (per process) for communication
| Type | Intent | Optional | 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 |
Prolong from a parent to a child with index offset dix
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg | |||
| integer, | intent(in) | :: | p_id |
Id of parent |
||
| integer, | intent(in) | :: | dix(1) |
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) |
Prolonged values |
Restrict all levels
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg | |||
| integer, | intent(in) | :: | iv |
Specify minimum buffer size (per process) for communication
| Type | Intent | Optional | 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 |
Restrict from lvl to lvl-1
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg | |||
| integer, | intent(in) | :: | iv | |||
| integer, | intent(in) | :: | lvl |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg | |||
| integer, | intent(in) | :: | lvl |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg | |||
| integer, | intent(in) | :: | lvl |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_timer_t), | intent(inout) | :: | timer |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_timer_t), | intent(inout) | :: | timer |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(in) | :: | mg |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg | |||
| integer, | intent(in) | :: | dsize |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=dp), | intent(in) | :: | lambda |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in), | Dimension (:) | :: | XDONT | ||
| integer, | intent(out), | Dimension (:) | :: | IRNGT |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg | |||
| integer, | intent(in) | :: | id |
Id of box that gets children |
||
| integer, | intent(in) | :: | n_boxes_lvl |
| Type | Intent | Optional | 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. |
Perform Helmholtz operator on a box
| Type | Intent | Optional | 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 |
Get ghost cells for a fine neighbor
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_box_t), | intent(in) | :: | box | |||
| integer, | intent(in) | :: | nb |
Direction of fine neighbor |
||
| integer, | intent(in) | :: | di(1) |
Index offset of fine neighbor |
||
| integer, | intent(in) | :: | nc | |||
| integer, | intent(in) | :: | iv | |||
| real(kind=dp), | intent(out) | :: | gc(1) |
| Type | Intent | Optional | 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(1) |
| Type | Intent | Optional | 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(1) |
Perform Gauss-Seidel relaxation on box for a Helmholtz operator
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg | |||
| integer, | intent(in) | :: | id | |||
| integer, | intent(in) | :: | nc | |||
| integer, | intent(in) | :: | redblack_cntr |
Iteration counter |
Perform Gauss-Seidel relaxation on box for a Helmholtz operator
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg | |||
| integer, | intent(in) | :: | id | |||
| integer, | intent(in) | :: | nc | |||
| integer, | intent(in) | :: | redblack_cntr |
Iteration counter |
Perform Gauss-Seidel relaxation on box for a Laplacian operator
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg | |||
| integer, | intent(in) | :: | id | |||
| integer, | intent(in) | :: | nc | |||
| integer, | intent(in) | :: | redblack_cntr |
Iteration counter |
Perform Gauss-Seidel relaxation on box for a Helmholtz operator
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg | |||
| integer, | intent(in) | :: | id | |||
| integer, | intent(in) | :: | nc | |||
| integer, | intent(in) | :: | redblack_cntr |
Iteration counter |
Perform Gauss-Seidel relaxation on box for a Laplacian operator
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg | |||
| integer, | intent(in) | :: | id | |||
| integer, | intent(in) | :: | nc | |||
| integer, | intent(in) | :: | redblack_cntr |
Iteration counter |
Perform Helmholtz operator on a box
| Type | Intent | Optional | 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 |
Perform Laplacian operator on a box
| Type | Intent | Optional | 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 |
| Type | Intent | Optional | 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(1) |
Perform Helmholtz operator on a box
| Type | Intent | Optional | 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 |
Perform Laplacian operator on a box
| Type | Intent | Optional | 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 |
| Type | Intent | Optional | 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 |
| Type | Intent | Optional | 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 |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg | |||
| integer, | intent(in) | :: | lvl |
| Type | Intent | Optional | 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 |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg | |||
| integer, | intent(in) | :: | lvl | |||
| integer, | intent(in) | :: | nc |
Prolong onto a child box
| Type | Intent | Optional | 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 |
In case the fine grid is on a different CPU, perform the prolongation and store the fine-grid values in the send buffer.
| Type | Intent | Optional | 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 |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg | |||
| integer, | intent(in) | :: | id | |||
| integer, | intent(in) | :: | nc |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg | |||
| integer, | intent(in) | :: | id | |||
| integer, | intent(in) | :: | nc | |||
| integer, | intent(in) | :: | iv |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg | |||
| integer, | intent(in) | :: | id | |||
| integer, | intent(in) | :: | iv |
The routine that actually fills the ghost cells
| Type | Intent | Optional | 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 |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_box_t), | intent(inout) | :: | boxes(:) | |||
| integer, | intent(in) | :: | id |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg | |||
| real(kind=dp), | intent(in) | :: | f1 | |||
| real(kind=dp), | intent(in) | :: | f2 |
Fill ghost cells near refinement boundaries which preserves diffusive fluxes.
| Type | Intent | Optional | 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(1) |
Interpolated coarse grid ghost cell data (but not yet in the nb direction) |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg | |||
| integer, | intent(in) | :: | lvl | |||
| integer, | intent(in) | :: | n_cycle |
Number of cycles to perform |
Sort send buffers according to the idbuf array
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_buf_t), | intent(inout) | :: | gc | |||
| integer, | intent(in) | :: | dsize |
Size of send buffer elements |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg | |||
| integer, | intent(in) | :: | iv | |||
| logical, | intent(in) | :: | include_ghostcells |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mg_t), | intent(inout) | :: | mg |
Tree containing full grid |
||
| integer, | intent(in) | :: | lvl |
Update coarse values at lvl-1 |