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 | a2_init (tree, n_cell, n_var_cell, n_var_face, dr, r_min, lvl_limit, n_boxes, coarsen_to, coord, cc_names, fc_names, mem_limit_gb) |
Initialize a 2d tree type. More... | |
subroutine, public | a2_set_cc_methods (tree, iv, bc, rb, prolong, restrict) |
Set the methods for a cell-centered variable. More... | |
subroutine, public | a2_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, public | a2_set_base (tree, n_boxes, ix_list, nb_list) |
Create the base level of the tree, ix_list(:, id) stores the spatial index of box(id), nb_list(:, id) stores the neighbors of box(id). The connection between neighbors is handled automatically, so only boundary conditions have to be specified. Periodic boundaries only have to be specified from one side. A default value of af_no_box in the nb_list is converted to a physical boundary with index of -1. More... | |
subroutine, public | a2_tidy_up (tree, max_hole_frac, n_clean_min) |
Reorder and resize the list of boxes. More... | |
subroutine | set_leaves_parents (boxes, level) |
Create a list of leaves and a list of parents for a level. More... | |
subroutine, public | a2_init_box (box, n_cell, n_cc, n_fc) |
Mark box as active and allocate data storage for a box, for its cell- and face-centered data. More... | |
subroutine, public | a2_resize_box_storage (tree, new_size) |
Resize box storage to new_size. More... | |
subroutine, public | a2_adjust_refinement (tree, ref_subr, ref_info, ref_buffer, keep_buffer) |
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 | set_ref_info (tree, ref_flags, ref_info) |
Set information about the refinement for all "normal" levels (>= 1) More... | |
subroutine | cell_to_ref_flags (cell_flags, nc, ref_flags, tree, id, ref_buffer, keep_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 (boxes, id) |
Remove the children of box id. More... | |
subroutine, public | a2_consistent_fluxes (tree, f_ixs) |
Restrict fluxes from children to parents on refinement boundaries. More... | |
This module contains the core routines of Afivo, namely those that deal with initializing and changing the quadtree/octree mesh.
subroutine, public m_a2_core::a2_init | ( | type(a2_t), intent(inout) | tree, |
integer, intent(in) | n_cell, | ||
integer, intent(in) | n_var_cell, | ||
integer, intent(in) | n_var_face, | ||
real(dp), intent(in) | dr, | ||
real(dp), dimension(2), intent(in), optional | r_min, | ||
integer, intent(in), optional | lvl_limit, | ||
integer, intent(in), optional | n_boxes, | ||
integer, intent(in), optional | coarsen_to, | ||
integer, intent(in), optional | coord, | ||
character(len=*), dimension(:), intent(in), optional | cc_names, | ||
character(len=*), dimension(:), intent(in), optional | fc_names, | ||
real(dp), intent(in), optional | mem_limit_gb | ||
) |
Initialize a 2d tree type.
[in,out] | tree | The tree to initialize |
[in] | n_cell | Boxes have n_cell^dim cells |
[in] | n_var_cell | Number of cell-centered variables |
[in] | n_var_face | Number of face-centered variables |
[in] | dr | spacing of a cell at lvl 1 |
[in] | r_min | Lowest coordinate of box at 1,1. Default is (0, 0) |
[in] | coarsen_to | Create additional coarse grids down to this size. Default is -1 (which means don't do this) |
[in] | lvl_limit | Maximum number of levels. Default is 30 |
[in] | n_boxes | Allocate initial storage for n_boxes. Default is 1000 |
[in] | coord | Select coordinate type |
[in] | mem_limit_gb | Memory limit in GByte |
[in] | cc_names | Names of cell-centered variables |
[in] | fc_names | Names of face-centered variables |
Definition at line 25 of file m_a2_core.f90.
subroutine, public m_a2_core::a2_set_cc_methods | ( | type(a2_t), intent(inout) | tree, |
integer, intent(in) | iv, | ||
procedure(a2_subr_bc) | bc, | ||
procedure(a2_subr_rb), optional | rb, | ||
procedure(a2_subr_prolong), optional | prolong, | ||
procedure(a2_subr_restrict), optional | restrict | ||
) |
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 |
Definition at line 137 of file m_a2_core.f90.
subroutine, public m_a2_core::a2_destroy | ( | type(a2_t), intent(inout) | 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 175 of file m_a2_core.f90.
subroutine, public m_a2_core::a2_set_base | ( | type(a2_t), intent(inout) | tree, |
integer, intent(in) | n_boxes, | ||
integer, dimension(2, n_boxes), intent(in) | ix_list, | ||
integer, dimension(a2_num_neighbors, n_boxes), intent(inout), optional | nb_list | ||
) |
Create the base level of the tree, ix_list(:, id) stores the spatial index of box(id), nb_list(:, id) stores the neighbors of box(id). The connection between neighbors is handled automatically, so only boundary conditions have to be specified. Periodic boundaries only have to be specified from one side. A default value of af_no_box in the nb_list is converted to a physical boundary with index of -1.
[in,out] | tree | Tree for which we set the base |
[in] | n_boxes | Number of boxes on coarse grid |
[in] | ix_list | List of spatial indices for the initial boxes |
[in,out] | nb_list | Neighbors for the initial boxes |
Definition at line 197 of file m_a2_core.f90.
subroutine, public m_a2_core::a2_tidy_up | ( | type(a2_t), intent(inout) | tree, |
real(dp), intent(in) | max_hole_frac, | ||
integer, intent(in) | n_clean_min | ||
) |
Reorder and resize the list of boxes.
[in,out] | tree | The tree to tidy up |
[in] | max_hole_frac | Maximum fraction of holes in boxes array |
[in] | n_clean_min | Reorganize memory if at least this many boxes can be cleaned up |
Definition at line 429 of file m_a2_core.f90.
subroutine m_a2_core::set_leaves_parents | ( | type(box2_t), dimension(:), intent(in) | boxes, |
type(lvl_t), intent(inout) | level | ||
) |
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 515 of file m_a2_core.f90.
subroutine, public m_a2_core::a2_init_box | ( | type(box2_t), intent(inout) | box, |
integer, intent(in) | n_cell, | ||
integer, intent(in) | n_cc, | ||
integer, intent(in) | n_fc | ||
) |
Mark box as active and allocate data storage for a box, for its cell- and face-centered data.
[in,out] | box | Box for which we allocate memory |
[in] | n_cell | Number of cells per dimension in the box |
[in] | n_cc | Number of cell-centered variables |
[in] | n_fc | Number of face-centered variables |
Definition at line 550 of file m_a2_core.f90.
subroutine, public m_a2_core::a2_resize_box_storage | ( | type(a2_t), intent(inout) | tree, |
integer, intent(in) | new_size | ||
) |
Resize box storage to new_size.
[in,out] | tree | Tree to resize |
[in] | new_size | New size for the array boxes(:) |
Definition at line 633 of file m_a2_core.f90.
subroutine, public m_a2_core::a2_adjust_refinement | ( | type(a2_t), intent(inout) | tree, |
procedure(a2_subr_ref) | ref_subr, | ||
type(ref_info_t), intent(inout) | ref_info, | ||
integer, intent(in), optional | ref_buffer, | ||
logical, intent(in), optional | keep_buffer | ||
) |
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] | keep_buffer | Use buffer for 'keep refinement' flags |
Definition at line 659 of file m_a2_core.f90.
subroutine m_a2_core::set_ref_info | ( | type(a2_t), intent(in) | tree, |
integer, dimension(:), intent(in) | ref_flags, | ||
type(ref_info_t), intent(inout) | ref_info | ||
) |
Set information about the refinement for all "normal" levels (>= 1)
Definition at line 826 of file m_a2_core.f90.
subroutine m_a2_core::cell_to_ref_flags | ( | integer, dimension(nc, nc), intent(in) | cell_flags, |
integer, intent(in) | nc, | ||
integer, dimension(:), intent(inout) | ref_flags, | ||
type(a2_t), intent(in) | tree, | ||
integer, intent(in) | id, | ||
integer, intent(in) | ref_buffer, | ||
logical, intent(in) | keep_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).
[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 |
[in] | keep_buffer | Buffer around 'keep refinement' flags |
Definition at line 1044 of file m_a2_core.f90.
subroutine m_a2_core::remove_children | ( | type(box2_t), dimension(:), intent(inout) | boxes, |
integer, intent(in) | id | ||
) |
Remove the children of box id.
[in,out] | boxes | List of all boxes |
[in] | id | Id of box whose children will be removed |
Definition at line 1103 of file m_a2_core.f90.
subroutine, public m_a2_core::a2_consistent_fluxes | ( | type(a2_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 1199 of file m_a2_core.f90.