Afivo  0.3
Functions/Subroutines
m_a2_utils Module Reference

This module contains all kinds of different 'helper' routines for Afivo. If the number of routines for a particular topic becomes large, they should probably be put in a separate module. More...

Functions/Subroutines

subroutine, public a2_loop_box (tree, my_procedure, leaves_only)
 Call procedure for each box in tree. More...
 
subroutine, public a2_loop_box_arg (tree, my_procedure, rarg, leaves_only)
 Call procedure for each box in tree, with argument rarg. More...
 
subroutine, public a2_loop_boxes (tree, my_procedure, leaves_only)
 Call procedure for each id in tree, giving the list of boxes. More...
 
subroutine, public a2_loop_boxes_arg (tree, my_procedure, rarg, leaves_only)
 Call procedure for each id in tree, giving the list of boxes. More...
 
pure logical function, public a2_r_inside (box, r, d)
 Returns whether r is inside or within a distance d from box. More...
 
pure integer function, public a2_get_id_at (tree, rr, highest_lvl, guess)
 Get the id of the finest box containing rr. If highest_lvl is present, do not go to a finer level than highest_lvl. If there is no box containing rr, return a location of -1. More...
 
pure type(a2_loc_t) function, public a2_get_loc (tree, rr, highest_lvl, guess)
 Get the location of the finest cell containing rr. If highest_lvl is present, do not go to a finer level than highest_lvl. If there is no box containing rr, return a location of -1. More...
 
pure real(dp) function, dimension(2), public a2_r_loc (tree, loc)
 Get the coordinate of the cell-center at loc. More...
 
subroutine, public a2_tree_clear_cc (tree, iv)
 
subroutine, public a2_box_clear_cc (box, iv)
 Set cc(..., iv) = 0. More...
 
subroutine, public a2_tree_clear_ghostcells (tree, iv)
 
subroutine, public a2_box_clear_ghostcells (box, iv)
 Set cc(..., iv) = 0. More...
 
subroutine, public a2_box_add_cc (box, iv_from, iv_to)
 Add cc(..., iv_from) to boxcc(..., iv_to) More...
 
subroutine, public a2_box_sub_cc (box, iv_from, iv_to)
 Subtract cc(..., iv_from) from boxcc(..., iv_to) More...
 
subroutine, public a2_tree_apply (tree, iv_a, iv_b, op, eps)
 Perform cc(..., iv_a) = cc(..., iv_a) 'op' cc(..., iv_b), where 'op' can be '+', '*' or '/'. More...
 
subroutine, public a2_tree_times_cc (tree, ivs, facs)
 
subroutine, public a2_box_times_cc (box, a, iv)
 Multipy cc(..., iv) with a. More...
 
subroutine, public a2_box_lincomb_cc (box, a, iv_a, b, iv_b)
 Set cc(..., iv_b) = a * cc(..., iv_a) + b * cc(..., iv_b) More...
 
subroutine, public a2_box_copy_cc_to (box_from, iv_from, box_to, iv_to)
 Copy cc(..., iv_from) from box_in to cc(..., iv_to) on box_out. More...
 
subroutine, public a2_box_copy_cc (box, iv_from, iv_to)
 Copy cc(..., iv_from) to boxcc(..., iv_to) More...
 
subroutine, public a2_boxes_copy_cc (boxes, ids, iv_from, iv_to)
 Copy cc(..., iv_from) to boxcc(..., iv_to) for all ids. More...
 
subroutine, public a2_tree_copy_cc (tree, iv_from, iv_to)
 Copy cc(..., iv_from) to boxcc(..., iv_to) for full tree. More...
 
subroutine, public a2_reduction (tree, box_func, reduction, init_val, out_val)
 A general scalar reduction method. More...
 
subroutine, public a2_reduction_vec (tree, box_func, reduction, init_val, out_val, n_vals)
 A general vector reduction method. More...
 
subroutine, public a2_reduction_loc (tree, iv, box_subr, reduction, init_val, out_val, out_loc)
 A general scalar reduction method, that returns the location of the minimum/maximum value found. More...
 
subroutine, public a2_tree_max_cc (tree, iv, cc_max, loc)
 Find maximum value of cc(..., iv). By default, only loop over leaves, and ghost cells are not used. More...
 
subroutine, public a2_tree_min_cc (tree, iv, cc_min, loc)
 Find minimum value of cc(..., iv). By default, only loop over leaves, and ghost cells are not used. More...
 
subroutine, public a2_tree_max_fc (tree, dim, iv, fc_max, loc)
 Find maximum value of fc(..., dim, iv). By default, only loop over leaves. More...
 
subroutine, public a2_tree_sum_cc (tree, iv, cc_sum)
 Find weighted sum of cc(..., iv). Only loop over leaves, and ghost cells are not used. More...
 
subroutine, public a2_box_copy_fc (box, iv_from, iv_to)
 Copy fx/fy/fz(..., iv_from) to fx/fy/fz(..., iv_to) More...
 
subroutine, public a2_boxes_copy_fc (boxes, ids, iv_from, iv_to)
 Copy fx/fy/fz(..., iv_from) to fx/fy/fz(..., iv_to) for all ids. More...
 
subroutine, public a2_tree_copy_fc (tree, iv_from, iv_to)
 Copy fx/fy/fz(..., iv_from) to fx/fy/fz(..., iv_to) for full tree. More...
 
pure integer function, public a2_n_cell (tree, lvl)
 Return n_cell at lvl. For all lvls >= 1, n_cell has the same value, but for lvls <= 0, n_cell changes. More...
 

Detailed Description

This module contains all kinds of different 'helper' routines for Afivo. If the number of routines for a particular topic becomes large, they should probably be put in a separate module.

Function/Subroutine Documentation

§ a2_loop_box()

subroutine, public m_a2_utils::a2_loop_box ( type(a2_t), intent(inout)  tree,
procedure(a2_subr my_procedure,
logical, intent(in), optional  leaves_only 
)

Call procedure for each box in tree.

Definition at line 52 of file m_a2_utils.f90.

§ a2_loop_box_arg()

subroutine, public m_a2_utils::a2_loop_box_arg ( type(a2_t), intent(inout)  tree,
procedure(a2_subr_arg my_procedure,
real(dp), dimension(:), intent(in)  rarg,
logical, intent(in), optional  leaves_only 
)

Call procedure for each box in tree, with argument rarg.

Definition at line 84 of file m_a2_utils.f90.

§ a2_loop_boxes()

subroutine, public m_a2_utils::a2_loop_boxes ( type(a2_t), intent(inout)  tree,
procedure(a2_subr_boxes my_procedure,
logical, intent(in), optional  leaves_only 
)

Call procedure for each id in tree, giving the list of boxes.

Definition at line 117 of file m_a2_utils.f90.

§ a2_loop_boxes_arg()

subroutine, public m_a2_utils::a2_loop_boxes_arg ( type(a2_t), intent(inout)  tree,
procedure(a2_subr_boxes_arg my_procedure,
real(dp), dimension(:), intent(in)  rarg,
logical, intent(in), optional  leaves_only 
)

Call procedure for each id in tree, giving the list of boxes.

Definition at line 149 of file m_a2_utils.f90.

§ a2_r_inside()

pure logical function, public m_a2_utils::a2_r_inside ( type(box2_t), intent(in)  box,
real(dp), dimension(2), intent(in)  r,
real(dp), intent(in), optional  d 
)

Returns whether r is inside or within a distance d from box.

Definition at line 182 of file m_a2_utils.f90.

§ a2_get_id_at()

pure integer function, public m_a2_utils::a2_get_id_at ( type(a2_t), intent(in)  tree,
real(dp), dimension(2), intent(in)  rr,
integer, intent(in), optional  highest_lvl,
integer, intent(in), optional  guess 
)

Get the id of the finest box containing rr. If highest_lvl is present, do not go to a finer level than highest_lvl. If there is no box containing rr, return a location of -1.

Parameters
[in]treeFull grid
[in]rrCoordinate
[in]highest_lvlMaximum level of box
[in]guessGuess of box id, cannot be used with highest_lvl
Returns
Id of finest box containing rr

Definition at line 200 of file m_a2_utils.f90.

§ a2_get_loc()

pure type(a2_loc_t) function, public m_a2_utils::a2_get_loc ( type(a2_t), intent(in)  tree,
real(dp), dimension(2), intent(in)  rr,
integer, intent(in), optional  highest_lvl,
integer, intent(in), optional  guess 
)

Get the location of the finest cell containing rr. If highest_lvl is present, do not go to a finer level than highest_lvl. If there is no box containing rr, return a location of -1.

Parameters
[in]treeFull grid
[in]rrCoordinate
[in]highest_lvlMaximum level of box
[in]guessGuess of box id, cannot be used with highest_lvl
Returns
Location of cell

Definition at line 253 of file m_a2_utils.f90.

§ a2_r_loc()

pure real(dp) function, dimension(2), public m_a2_utils::a2_r_loc ( type(a2_t), intent(in)  tree,
type(a2_loc_t), intent(in)  loc 
)

Get the coordinate of the cell-center at loc.

Parameters
[in]treeFull grid
[in]locLocation object
Returns
Coordinate at cell center

Definition at line 290 of file m_a2_utils.f90.

§ a2_tree_clear_cc()

subroutine, public m_a2_utils::a2_tree_clear_cc ( type(a2_t), intent(inout)  tree,
integer, intent(in)  iv 
)
Parameters
[in]ivVariable to clear

Definition at line 298 of file m_a2_utils.f90.

§ a2_box_clear_cc()

subroutine, public m_a2_utils::a2_box_clear_cc ( type(box2_t), intent(inout)  box,
integer, intent(in)  iv 
)

Set cc(..., iv) = 0.

Parameters
[in]ivVariable to clear

Definition at line 316 of file m_a2_utils.f90.

§ a2_tree_clear_ghostcells()

subroutine, public m_a2_utils::a2_tree_clear_ghostcells ( type(a2_t), intent(inout)  tree,
integer, intent(in)  iv 
)
Parameters
[in]ivVariable to clear

Definition at line 322 of file m_a2_utils.f90.

§ a2_box_clear_ghostcells()

subroutine, public m_a2_utils::a2_box_clear_ghostcells ( type(box2_t), intent(inout)  box,
integer, intent(in)  iv 
)

Set cc(..., iv) = 0.

Parameters
[in]ivVariable to clear

Definition at line 340 of file m_a2_utils.f90.

§ a2_box_add_cc()

subroutine, public m_a2_utils::a2_box_add_cc ( type(box2_t), intent(inout)  box,
integer, intent(in)  iv_from,
integer, intent(in)  iv_to 
)

Add cc(..., iv_from) to boxcc(..., iv_to)

Definition at line 354 of file m_a2_utils.f90.

§ a2_box_sub_cc()

subroutine, public m_a2_utils::a2_box_sub_cc ( type(box2_t), intent(inout)  box,
integer, intent(in)  iv_from,
integer, intent(in)  iv_to 
)

Subtract cc(..., iv_from) from boxcc(..., iv_to)

Definition at line 361 of file m_a2_utils.f90.

§ a2_tree_apply()

subroutine, public m_a2_utils::a2_tree_apply ( type(a2_t), intent(inout)  tree,
integer, intent(in)  iv_a,
integer, intent(in)  iv_b,
character(len=*), intent(in)  op,
real(dp), intent(in), optional  eps 
)

Perform cc(..., iv_a) = cc(..., iv_a) 'op' cc(..., iv_b), where 'op' can be '+', '*' or '/'.

Parameters
[in]epsMin value for division

Definition at line 369 of file m_a2_utils.f90.

§ a2_tree_times_cc()

subroutine, public m_a2_utils::a2_tree_times_cc ( type(a2_t), intent(inout)  tree,
integer, dimension(:), intent(in)  ivs,
real(dp), dimension(:), intent(in)  facs 
)

Definition at line 407 of file m_a2_utils.f90.

§ a2_box_times_cc()

subroutine, public m_a2_utils::a2_box_times_cc ( type(box2_t), intent(inout)  box,
real(dp), intent(in)  a,
integer, intent(in)  iv 
)

Multipy cc(..., iv) with a.

Definition at line 431 of file m_a2_utils.f90.

§ a2_box_lincomb_cc()

subroutine, public m_a2_utils::a2_box_lincomb_cc ( type(box2_t), intent(inout)  box,
real(dp), intent(in)  a,
integer, intent(in)  iv_a,
real(dp), intent(in)  b,
integer, intent(in)  iv_b 
)

Set cc(..., iv_b) = a * cc(..., iv_a) + b * cc(..., iv_b)

Definition at line 439 of file m_a2_utils.f90.

§ a2_box_copy_cc_to()

subroutine, public m_a2_utils::a2_box_copy_cc_to ( type(box2_t), intent(in)  box_from,
integer, intent(in)  iv_from,
type(box2_t), intent(inout)  box_to,
integer, intent(in)  iv_to 
)

Copy cc(..., iv_from) from box_in to cc(..., iv_to) on box_out.

Definition at line 447 of file m_a2_utils.f90.

§ a2_box_copy_cc()

subroutine, public m_a2_utils::a2_box_copy_cc ( type(box2_t), intent(inout)  box,
integer, intent(in)  iv_from,
integer, intent(in)  iv_to 
)

Copy cc(..., iv_from) to boxcc(..., iv_to)

Definition at line 455 of file m_a2_utils.f90.

§ a2_boxes_copy_cc()

subroutine, public m_a2_utils::a2_boxes_copy_cc ( type(box2_t), dimension(:), intent(inout)  boxes,
integer, dimension(:), intent(in)  ids,
integer, intent(in)  iv_from,
integer, intent(in)  iv_to 
)

Copy cc(..., iv_from) to boxcc(..., iv_to) for all ids.

Definition at line 462 of file m_a2_utils.f90.

§ a2_tree_copy_cc()

subroutine, public m_a2_utils::a2_tree_copy_cc ( type(a2_t), intent(inout)  tree,
integer, intent(in)  iv_from,
integer, intent(in)  iv_to 
)

Copy cc(..., iv_from) to boxcc(..., iv_to) for full tree.

Definition at line 475 of file m_a2_utils.f90.

§ a2_reduction()

subroutine, public m_a2_utils::a2_reduction ( type(a2_t), intent(in)  tree,
  box_func,
  reduction,
real(dp), intent(in)  init_val,
real(dp), intent(out)  out_val 
)

A general scalar reduction method.

Parameters
[in]treeTree to do the reduction on
[in]init_valInitial value for the reduction
[out]out_valResult of the reduction

Definition at line 486 of file m_a2_utils.f90.

§ a2_reduction_vec()

subroutine, public m_a2_utils::a2_reduction_vec ( type(a2_t), intent(in)  tree,
  box_func,
  reduction,
real(dp), dimension(n_vals), intent(in)  init_val,
real(dp), dimension(n_vals), intent(out)  out_val,
integer, intent(in)  n_vals 
)

A general vector reduction method.

Parameters
[in]treeTree to do the reduction on
[in]n_valsSize of vector
[in]init_valInitial value for the reduction
[out]out_valResult of the reduction

Definition at line 530 of file m_a2_utils.f90.

§ a2_reduction_loc()

subroutine, public m_a2_utils::a2_reduction_loc ( type(a2_t), intent(in)  tree,
integer, intent(in)  iv,
  box_subr,
  reduction,
real(dp), intent(in)  init_val,
real(dp), intent(out)  out_val,
type(a2_loc_t), intent(out)  out_loc 
)

A general scalar reduction method, that returns the location of the minimum/maximum value found.

Parameters
[in]treeTree to do the reduction on
[in]ivVariable to operate on (can be ignored)
[in]init_valInitial value for the reduction
[out]out_valResult of the reduction
[out]out_locLocation

Definition at line 580 of file m_a2_utils.f90.

§ a2_tree_max_cc()

subroutine, public m_a2_utils::a2_tree_max_cc ( type(a2_t), intent(in)  tree,
integer, intent(in)  iv,
real(dp), intent(out)  cc_max,
type(a2_loc_t), intent(out), optional  loc 
)

Find maximum value of cc(..., iv). By default, only loop over leaves, and ghost cells are not used.

Parameters
[in]treeFull grid
[in]ivIndex of variable
[out]cc_maxMaximum value
[out]locLocation of maximum

Definition at line 643 of file m_a2_utils.f90.

§ a2_tree_min_cc()

subroutine, public m_a2_utils::a2_tree_min_cc ( type(a2_t), intent(in)  tree,
integer, intent(in)  iv,
real(dp), intent(out)  cc_min,
type(a2_loc_t), intent(out), optional  loc 
)

Find minimum value of cc(..., iv). By default, only loop over leaves, and ghost cells are not used.

Parameters
[in]treeFull grid
[in]ivIndex of variable
[out]cc_minMinimum value
[out]locLocation of minimum

Definition at line 658 of file m_a2_utils.f90.

§ a2_tree_max_fc()

subroutine, public m_a2_utils::a2_tree_max_fc ( type(a2_t), intent(in)  tree,
integer, intent(in)  dim,
integer, intent(in)  iv,
real(dp), intent(out)  fc_max,
type(a2_loc_t), intent(out), optional  loc 
)

Find maximum value of fc(..., dim, iv). By default, only loop over leaves.

Parameters
[in]treeFull grid
[in]dimFlux dimension
[in]ivIndex of face variable
[out]fc_maxMaximum value
[out]locLocation of maximum

Definition at line 673 of file m_a2_utils.f90.

§ a2_tree_sum_cc()

subroutine, public m_a2_utils::a2_tree_sum_cc ( type(a2_t), intent(in)  tree,
integer, intent(in)  iv,
real(dp), intent(out)  cc_sum 
)

Find weighted sum of cc(..., iv). Only loop over leaves, and ghost cells are not used.

Parameters
[in]treeFull grid
[in]ivIndex of variable
[out]cc_sumVolume-integrated sum of variable

Definition at line 748 of file m_a2_utils.f90.

§ a2_box_copy_fc()

subroutine, public m_a2_utils::a2_box_copy_fc ( type(box2_t), intent(inout)  box,
integer, intent(in)  iv_from,
integer, intent(in)  iv_to 
)

Copy fx/fy/fz(..., iv_from) to fx/fy/fz(..., iv_to)

Parameters
[in,out]boxOperate on this box
[in]iv_fromFrom this variable
[in]iv_toTo this variable

Definition at line 802 of file m_a2_utils.f90.

§ a2_boxes_copy_fc()

subroutine, public m_a2_utils::a2_boxes_copy_fc ( type(box2_t), dimension(:), intent(inout)  boxes,
integer, dimension(:), intent(in)  ids,
integer, intent(in)  iv_from,
integer, intent(in)  iv_to 
)

Copy fx/fy/fz(..., iv_from) to fx/fy/fz(..., iv_to) for all ids.

Parameters
[in,out]boxesList of all boxes
[in]idsOperate on these boxes
[in]iv_fromFrom this variable
[in]iv_toTo this variable

Definition at line 810 of file m_a2_utils.f90.

§ a2_tree_copy_fc()

subroutine, public m_a2_utils::a2_tree_copy_fc ( type(a2_t), intent(inout)  tree,
integer, intent(in)  iv_from,
integer, intent(in)  iv_to 
)

Copy fx/fy/fz(..., iv_from) to fx/fy/fz(..., iv_to) for full tree.

Parameters
[in,out]treeFull grid
[in]iv_fromFrom this variable
[in]iv_toTo this variable

Definition at line 825 of file m_a2_utils.f90.

§ a2_n_cell()

pure integer function, public m_a2_utils::a2_n_cell ( type(a2_t), intent(in)  tree,
integer, intent(in)  lvl 
)

Return n_cell at lvl. For all lvls >= 1, n_cell has the same value, but for lvls <= 0, n_cell changes.

Todo:
remove this in future
Parameters
[in]treeFull grid
[in]lvlRefinement level
Returns
Output: n_cell at lvl

Definition at line 840 of file m_a2_utils.f90.