Afivo
0.3
|
This module contains the core routines of Afivo, namely those that deal with initializing and changing the quadtree/octree mesh. More...
Functions/Subroutines | |
subroutine, public | af_add_cc_variable (tree, name, write_out, n_copies, ix, write_binary) |
Add cell-centered variable. More... | |
subroutine, public | af_add_fc_variable (tree, name, ix, write_binary) |
Add face-centered variable. More... | |
integer function, public | af_find_cc_variable (tree, name) |
Find index of cell-centered variable. More... | |
integer function, public | af_find_fc_variable (tree, name) |
Find index of face-centered variable. More... | |
subroutine, public | af_init (tree, n_cell, r_max, grid_size, periodic, r_min, coord, mem_limit_gb, box_limit) |
Initialize a NDIM-d octree/quadtree grid. More... | |
subroutine | af_set_coarse_grid (tree, coarse_grid_size, periodic_dims) |
Create the coarse grid. More... | |
subroutine, public | af_set_cc_methods (tree, iv, bc, rb, prolong, restrict, bc_custom, funcval, prolong_limiter) |
Set the methods for a cell-centered variable. More... | |
subroutine, public | af_destroy (tree) |
"Destroy" the data in a tree. Since we don't use pointers, you can also just let a tree get out of scope More... | |
subroutine | create_index_array (nx, periodic, id_array) |
Create an array for easy lookup of indices. More... | |
subroutine | set_leaves_parents (boxes, level) |
Create a list of leaves and a list of parents for a level. More... | |
subroutine, public | af_init_box (tree, id) |
Mark box as active and allocate data storage for a box, for its cell- and face-centered data. More... | |
subroutine | af_deactivate_box (box) |
Mark box as inactive, but keep storage for cell- and face-centered data to avoid reallocating this. More... | |
subroutine | set_neighbs (boxes, id) |
integer function | find_neighb (boxes, id, dix) |
Get the id of all neighbors of boxes(id), through its parent. More... | |
subroutine, public | af_refine_up_to_lvl (tree, lvl) |
Refine a tree up to a given refinement lvl. More... | |
subroutine, public | af_adjust_refinement (tree, ref_subr, ref_info, ref_buffer, ref_links) |
Adjust the refinement of a tree using the user-supplied ref_subr. The optional argument ref_buffer controls over how many cells neighbors are affected by refinement flags. More... | |
subroutine | auto_restrict (tree, id) |
Try to automatically restrict to box with index id. More... | |
subroutine | auto_prolong (tree, ref_info) |
Try to automatically prolong to all new boxes. More... | |
subroutine | get_free_ids (tree, ids) |
Get free ids from the boxes(:) array to store new boxes in. These ids are always consecutive. More... | |
subroutine | consistent_ref_flags (tree, ref_flags, ref_subr, ref_buffer, ref_links) |
Given the refinement function, return consistent refinement flags, that ensure that the tree is still balanced. Furthermore, it cannot derefine the base level, and it cannot refine above af_max_lvl. The argument ref_flags is changed: for boxes that will be refined it holds af_refine, for boxes that will be derefined it holds af_derefine. More... | |
subroutine | ensure_two_one_balance (tree, ref_flags) |
Adjust refinement flags to ensure 2-1 balance is maintained. More... | |
subroutine | handle_derefinement_flags (tree, ref_flags) |
subroutine | cell_to_ref_flags (cell_flags, nc, ref_flags, tree, id, ref_buffer) |
Given the cell refinement flags of a box, set the refinement flag for that box and potentially also its neighbors (in case of refinement near a boundary). More... | |
subroutine | remove_children (tree, id) |
Remove the children of box id. More... | |
subroutine | add_children (tree, id, c_ids) |
Add children to box id, using the indices in c_ids. More... | |
subroutine | set_child_ids (p_ids, c_ids, boxes) |
Create a list c_ids(:) of all the children of p_ids(:). This is used after a level has been refined. More... | |
subroutine, public | af_consistent_fluxes (tree, f_ixs) |
Restrict fluxes from children to parents on refinement boundaries. More... | |
subroutine | flux_from_children (boxes, id, nb, f_ixs) |
The neighbor nb has no children and id does, so set flux on the neighbor from our children. This ensures flux consistency at refinement boundary. More... | |
This module contains the core routines of Afivo, namely those that deal with initializing and changing the quadtree/octree mesh.
subroutine, public m_af_core::af_add_cc_variable | ( | type(af_t), intent(inout) | tree, |
character(len=*), intent(in) | name, | ||
logical, intent(in), optional | write_out, | ||
integer, intent(in), optional | n_copies, | ||
integer, intent(out), optional | ix, | ||
logical, intent(in), optional | write_binary | ||
) |
Add cell-centered variable.
[in,out] | tree | Tree to add variable to |
[in] | name | Name of the variable |
[in] | write_out | Include variable in output |
[in] | write_binary | Include variable in binary output (for restarting) |
[in] | n_copies | How many copies of variable to store (default: 1) |
[out] | ix | On output: index of variable |
Definition at line 26 of file m_af_core.f90.
subroutine, public m_af_core::af_add_fc_variable | ( | type(af_t), intent(inout) | tree, |
character(len=*), intent(in) | name, | ||
integer, intent(out), optional | ix, | ||
logical, intent(in), optional | write_binary | ||
) |
Add face-centered variable.
[in,out] | tree | Tree to add variable to |
[in] | name | Name of the variable |
[out] | ix | On output: index of variable |
[in] | write_binary | Include variable in binary output |
Definition at line 76 of file m_af_core.f90.
integer function, public m_af_core::af_find_cc_variable | ( | type(af_t), intent(in) | tree, |
character(len=*), intent(in) | name | ||
) |
Find index of cell-centered variable.
Definition at line 102 of file m_af_core.f90.
integer function, public m_af_core::af_find_fc_variable | ( | type(af_t), intent(in) | tree, |
character(len=*), intent(in) | name | ||
) |
Find index of face-centered variable.
Definition at line 120 of file m_af_core.f90.
subroutine, public m_af_core::af_init | ( | type(af_t), intent(inout) | tree, |
integer, intent(in) | n_cell, | ||
real(dp), dimension(ndim), intent(in) | r_max, | ||
integer, dimension(ndim), intent(in) | grid_size, | ||
logical, dimension(ndim), intent(in), optional | periodic, | ||
real(dp), dimension(ndim), intent(in), optional | r_min, | ||
integer, intent(in), optional | coord, | ||
real(dp), intent(in), optional | mem_limit_gb, | ||
integer, intent(in), optional | box_limit | ||
) |
Initialize a NDIM-d octree/quadtree grid.
[in,out] | tree | The tree to initialize |
[in] | n_cell | Boxes have n_cell^dim cells |
[in] | r_max | Maximal coordinates of the domain |
[in] | grid_size | Size of the coarse grid |
[in] | periodic | True for periodic dimensions |
[in] | r_min | Lowest coordinate, default is (0., 0., 0.) |
[in] | coord | Select coordinate type |
[in] | mem_limit_gb | Memory limit in GByte |
[in] | box_limit | Maximum number of boxes (overrides mem_limit_gb) |
Definition at line 138 of file m_af_core.f90.
|
private |
Create the coarse grid.
[in,out] | tree | Tree for which we set the base |
[in] | coarse_grid_size | Size of coarse grid (in cells) |
[in] | periodic_dims | Whether dimensions are periodic (default: false) |
Definition at line 206 of file m_af_core.f90.
subroutine, public m_af_core::af_set_cc_methods | ( | type(af_t), intent(inout) | tree, |
integer, intent(in) | iv, | ||
procedure(af_subr_bc), optional | bc, | ||
procedure(af_subr_rb), optional | rb, | ||
procedure(af_subr_prolong), optional | prolong, | ||
procedure(af_subr_restrict), optional | restrict, | ||
procedure(af_subr_bc_custom), optional | bc_custom, | ||
procedure(af_subr_funcval), optional | funcval, | ||
integer, intent(in), optional | prolong_limiter | ||
) |
Set the methods for a cell-centered variable.
[in,out] | tree | Tree to operate on |
[in] | iv | Index of variable |
bc | Boundary condition method | |
rb | Refinement boundary method | |
prolong | Prolongation method | |
restrict | Restriction method | |
bc_custom | Custom b.c. method | |
funcval | Variable defined by function Type of limiter to use for prolongation (of values or ghost cells) |
Definition at line 343 of file m_af_core.f90.
subroutine, public m_af_core::af_destroy | ( | type(af_t), intent(out) | tree | ) |
"Destroy" the data in a tree. Since we don't use pointers, you can also just let a tree get out of scope
Definition at line 431 of file m_af_core.f90.
|
private |
Create an array for easy lookup of indices.
Definition at line 436 of file m_af_core.f90.
|
private |
Create a list of leaves and a list of parents for a level.
[in] | boxes | List of boxes |
[in,out] | level | Level type which contains the indices of boxes |
Definition at line 504 of file m_af_core.f90.
subroutine, public m_af_core::af_init_box | ( | type(af_t), intent(inout) | tree, |
integer, intent(in) | id | ||
) |
Mark box as active and allocate data storage for a box, for its cell- and face-centered data.
[in] | id | Box id |
Definition at line 539 of file m_af_core.f90.
|
private |
Mark box as inactive, but keep storage for cell- and face-centered data to avoid reallocating this.
Definition at line 583 of file m_af_core.f90.
|
private |
Definition at line 595 of file m_af_core.f90.
|
private |
Get the id of all neighbors of boxes(id), through its parent.
[in] | boxes | List with all the boxes |
[in] | id | Box whose neighbor we are looking for |
Definition at line 636 of file m_af_core.f90.
subroutine, public m_af_core::af_refine_up_to_lvl | ( | type(af_t), intent(inout) | tree, |
integer, intent(in) | lvl | ||
) |
Refine a tree up to a given refinement lvl.
[in,out] | tree | The tree to adjust |
[in] | lvl | Refine up to this lvl |
Definition at line 664 of file m_af_core.f90.
subroutine, public m_af_core::af_adjust_refinement | ( | type(af_t), intent(inout) | tree, |
procedure(af_subr_ref) | ref_subr, | ||
type(ref_info_t), intent(inout) | ref_info, | ||
integer, intent(in), optional | ref_buffer, | ||
integer, dimension(:, :), intent(in), optional | ref_links | ||
) |
Adjust the refinement of a tree using the user-supplied ref_subr. The optional argument ref_buffer controls over how many cells neighbors are affected by refinement flags.
On input, the tree should be balanced. On output, the tree is still balanced, and its refinement is updated (with at most one level per call).
[in,out] | tree | The tree to adjust |
ref_subr | Refinement function | |
[in,out] | ref_info | Information about refinement |
[in] | ref_buffer | Buffer width (in cells) |
[in] | ref_links | Lists of linked boxes which should have the same refinement |
Definition at line 697 of file m_af_core.f90.
|
private |
Try to automatically restrict to box with index id.
Definition at line 825 of file m_af_core.f90.
|
private |
Try to automatically prolong to all new boxes.
Definition at line 843 of file m_af_core.f90.
subroutine m_af_core::get_free_ids | ( | type(af_t), intent(inout) | tree, |
integer, dimension(:), intent(out) | ids | ||
) |
Get free ids from the boxes(:) array to store new boxes in. These ids are always consecutive.
[out] | ids | Array which will be filled with free box ids |
Definition at line 885 of file m_af_core.f90.
|
private |
Given the refinement function, return consistent refinement flags, that ensure that the tree is still balanced. Furthermore, it cannot derefine the base level, and it cannot refine above af_max_lvl. The argument ref_flags is changed: for boxes that will be refined it holds af_refine, for boxes that will be derefined it holds af_derefine.
[in,out] | tree | Tree for which we set refinement flags |
[in,out] | ref_flags | List of refinement flags for all boxes(:) |
ref_subr | User-supplied refinement function. | |
[in] | ref_buffer | Buffer width (in cells) |
[in] | ref_links | Lists of linked boxes which should have the same refinement |
Definition at line 929 of file m_af_core.f90.
subroutine m_af_core::ensure_two_one_balance | ( | type(af_t), intent(inout) | tree, |
integer, dimension(:), intent(inout) | ref_flags | ||
) |
Adjust refinement flags to ensure 2-1 balance is maintained.
Definition at line 1016 of file m_af_core.f90.
|
private |
Definition at line 1059 of file m_af_core.f90.
|
private |
Given the cell refinement flags of a box, set the refinement flag for that box and potentially also its neighbors (in case of refinement near a boundary).
[in] | nc | n_cell for the box |
[in] | cell_flags | Cell refinement flags |
[in,out] | ref_flags | Box refinement flags for this thread |
[in] | tree | Full tree |
[in] | id | Which box is considered |
[in] | ref_buffer | Buffer cells around refinement |
Definition at line 1095 of file m_af_core.f90.
subroutine m_af_core::remove_children | ( | type(af_t), intent(inout) | tree, |
integer, intent(in) | id | ||
) |
Remove the children of box id.
[in] | id | Id of box whose children will be removed |
Definition at line 1151 of file m_af_core.f90.
|
private |
Add children to box id, using the indices in c_ids.
[in] | id | Id of box that gets children |
[in] | c_ids | Free ids for the children |
Definition at line 1188 of file m_af_core.f90.
|
private |
Create a list c_ids(:) of all the children of p_ids(:). This is used after a level has been refined.
[in] | p_ids | All the parents ids |
[in,out] | c_ids | Output: all the children's ids |
[in] | boxes | List of all the boxes |
Definition at line 1237 of file m_af_core.f90.
subroutine, public m_af_core::af_consistent_fluxes | ( | type(af_t), intent(inout) | tree, |
integer, dimension(:), intent(in) | f_ixs | ||
) |
Restrict fluxes from children to parents on refinement boundaries.
[in,out] | tree | Tree to operate on |
[in] | f_ixs | Indices of the fluxes |
Definition at line 1257 of file m_af_core.f90.
|
private |
The neighbor nb has no children and id does, so set flux on the neighbor from our children. This ensures flux consistency at refinement boundary.
[in,out] | boxes | List of all the boxes |
[in] | id | Id of box for which we set fluxes |
[in] | nb | Direction in which fluxes are set |
[in] | f_ixs | Indices of the fluxes |
Definition at line 1286 of file m_af_core.f90.