Afivo  0.3
Functions/Subroutines
m_a2_core Module Reference

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...
 

Detailed Description

This module contains the core routines of Afivo, namely those that deal with initializing and changing the quadtree/octree mesh.

Function/Subroutine Documentation

§ a2_init()

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.

Parameters
[in,out]treeThe tree to initialize
[in]n_cellBoxes have n_cell^dim cells
[in]n_var_cellNumber of cell-centered variables
[in]n_var_faceNumber of face-centered variables
[in]drspacing of a cell at lvl 1
[in]r_minLowest coordinate of box at 1,1. Default is (0, 0)
[in]coarsen_toCreate additional coarse grids down to this size. Default is -1 (which means don't do this)
[in]lvl_limitMaximum number of levels. Default is 30
[in]n_boxesAllocate initial storage for n_boxes. Default is 1000
[in]coordSelect coordinate type
[in]mem_limit_gbMemory limit in GByte
[in]cc_namesNames of cell-centered variables
[in]fc_namesNames of face-centered variables
Todo:
remove subtree in future

Definition at line 25 of file m_a2_core.f90.

§ a2_set_cc_methods()

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.

Parameters
[in,out]treeTree to operate on
[in]ivIndex of variable
bcBoundary condition method
rbRefinement boundary method
prolongProlongation method
restrictRestriction method

Definition at line 137 of file m_a2_core.f90.

§ a2_destroy()

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.

§ a2_set_base()

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.

Parameters
[in,out]treeTree for which we set the base
[in]n_boxesNumber of boxes on coarse grid
[in]ix_listList of spatial indices for the initial boxes
[in,out]nb_listNeighbors for the initial boxes

Definition at line 197 of file m_a2_core.f90.

§ a2_tidy_up()

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.

Parameters
[in,out]treeThe tree to tidy up
[in]max_hole_fracMaximum fraction of holes in boxes array
[in]n_clean_minReorganize memory if at least this many boxes can be cleaned up

Definition at line 429 of file m_a2_core.f90.

§ set_leaves_parents()

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.

Parameters
[in]boxesList of boxes
[in,out]levelLevel type which contains the indices of boxes

Definition at line 515 of file m_a2_core.f90.

§ a2_init_box()

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.

Parameters
[in,out]boxBox for which we allocate memory
[in]n_cellNumber of cells per dimension in the box
[in]n_ccNumber of cell-centered variables
[in]n_fcNumber of face-centered variables

Definition at line 550 of file m_a2_core.f90.

§ a2_resize_box_storage()

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.

Parameters
[in,out]treeTree to resize
[in]new_sizeNew size for the array boxes(:)

Definition at line 633 of file m_a2_core.f90.

§ a2_adjust_refinement()

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).

Parameters
[in,out]treeThe tree to adjust
ref_subrRefinement function
[in,out]ref_infoInformation about refinement
[in]ref_bufferBuffer width (in cells)
[in]keep_bufferUse buffer for 'keep refinement' flags

Definition at line 659 of file m_a2_core.f90.

§ set_ref_info()

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.

§ cell_to_ref_flags()

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).

Parameters
[in]ncn_cell for the box
[in]cell_flagsCell refinement flags
[in,out]ref_flagsBox refinement flags for this thread
[in]treeFull tree
[in]idWhich box is considered
[in]ref_bufferBuffer cells around refinement
[in]keep_bufferBuffer around 'keep refinement' flags

Definition at line 1044 of file m_a2_core.f90.

§ remove_children()

subroutine m_a2_core::remove_children ( type(box2_t), dimension(:), intent(inout)  boxes,
integer, intent(in)  id 
)

Remove the children of box id.

Parameters
[in,out]boxesList of all boxes
[in]idId of box whose children will be removed

Definition at line 1103 of file m_a2_core.f90.

§ a2_consistent_fluxes()

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.

Parameters
[in,out]treeTree to operate on
[in]f_ixsIndices of the fluxes

Definition at line 1199 of file m_a2_core.f90.