tree.f90 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. interface
  2. !> Create a tree and return its pointer
  3. !! @param tree_ctx pointer to the tree
  4. subroutine Createtree_(tree_ctx)
  5. use, intrinsic :: ISO_C_BINDING
  6. type(c_ptr), intent(out) :: tree_ctx
  7. end subroutine
  8. !> Delete the tree and free memeory
  9. !! @param tree_ctx pointer to the tree
  10. subroutine DeleteTree(tree_ctx)
  11. use, intrinsic :: ISO_C_BINDING
  12. type(c_ptr), intent(in) :: tree_ctx
  13. end subroutine
  14. !> Get the node list for the tree
  15. !! @param node_coord coordinates of each tree node {x1,y1,z1,x2,y2,z2,...}
  16. !! @param parent_lst index of the parent node if it exists; -1 otherwise
  17. !! @param child_lst index of 8 child nodes if it has children; -1 otherwise
  18. !! @param node_depth depth of the tree node
  19. !! @param node_ghost 1 if the node is a ghost node; 0 otherwise
  20. !! @param node_leaf 1 if the node is a leaf node; 0 otherwise
  21. !! @param Nnodes number of tree nodes
  22. !! @param tree_ctx pointer to the tree
  23. subroutine GetTree(node_coord, parent_lst, child_lst, node_depth, node_ghost, node_leaf, Nnodes, tree_ctx)
  24. use, intrinsic :: ISO_C_BINDING
  25. type(c_ptr), intent(out) :: node_coord ! real*8, dimension(Nnode*3)
  26. type(c_ptr), intent(out) :: parent_lst ! integer*4, dimension(Nnode)
  27. type(c_ptr), intent(out) :: child_lst ! integer*4, dimension(Nnode*8)
  28. type(c_ptr), intent(out) :: node_depth ! integer*1, dimension(Nnode)
  29. type(c_ptr), intent(out) :: node_ghost ! integer*1, dimension(Nnode)
  30. type(c_ptr), intent(out) :: node_leaf ! integer*1, dimension(Nnode)
  31. integer*4 , intent(out) :: Nnodes
  32. type(c_ptr), intent(in) :: tree_ctx
  33. end subroutine
  34. !> Change refinement of the tree
  35. !! @param pt_coord coordinates of the points
  36. !! @param Npt number of points
  37. !! @param max_pts maximum number of points per tree node
  38. !! @param level_restrict .true. to enable level restriction
  39. !! @param periodic .true. for periodic level restriction
  40. !! @param tree_ctx pointer to the tree
  41. subroutine UpdateRefinement(pt_coord, Npt, max_pts, level_restrict, periodic, tree_ctx)
  42. use, intrinsic :: ISO_C_BINDING
  43. real*8 , intent(in) :: pt_coord(*)
  44. integer*4 , intent(in) :: Npt
  45. integer*4 , intent(in) :: max_pts
  46. logical , intent(in) :: level_restrict
  47. logical , intent(in) :: periodic
  48. type(c_ptr), intent(in) :: tree_ctx
  49. end subroutine
  50. !> Add some data to the tree nodes (for example multipole expansions)
  51. !! @param data_name name for the data
  52. !! @param node_data data array
  53. !! @param Ndata length of the data array
  54. !! @param cnt array of data-length for each node
  55. !! @param Ncnt length of cnt array (must be equal to #-of-nodes)
  56. !! @param tree_ctx pointer to the tree
  57. subroutine AddData(data_name, node_data, Ndata, cnt, Ncnt, tree_ctx)
  58. use, intrinsic :: ISO_C_BINDING
  59. character , intent(in) :: data_name(*)
  60. real*8 , intent(in) :: node_data(*)
  61. integer*4 , intent(in) :: Ndata
  62. integer*4 , intent(in) :: cnt(*)
  63. integer*4 , intent(in) :: Ncnt
  64. type(c_ptr), intent(in) :: tree_ctx
  65. end subroutine
  66. !> Get node data from the tree
  67. !! @param node_data data array
  68. !! @param Ndata length of the data array
  69. !! @param cnt array of data-length for each node
  70. !! @param Ncnt length of cnt array (equal to #-of-nodes)
  71. !! @param data_name name for the data
  72. !! @param tree_ctx pointer to the tree
  73. subroutine GetData(node_data, Ndata, cnt, Ncnt, data_name, tree_ctx)
  74. use, intrinsic :: ISO_C_BINDING
  75. type(c_ptr), intent(out) :: node_data ! real*8 , dimension(Ndata)
  76. integer*4 , intent(out) :: Ndata
  77. type(c_ptr), intent(out) :: cnt ! integer*4, dimension(Ncnt)
  78. integer*4 , intent(out) :: Ncnt
  79. character , intent(in) :: data_name(*)
  80. type(c_ptr), intent(in) :: tree_ctx
  81. end subroutine
  82. !> Delete node data from the tree
  83. !! @param data_name name for the data
  84. !! @param tree_ctx pointer to the tree
  85. subroutine DeleteData(data_name, tree_ctx)
  86. use, intrinsic :: ISO_C_BINDING
  87. character , intent(in) :: data_name(*)
  88. type(c_ptr), intent(in) :: tree_ctx
  89. end subroutine
  90. !> Write VTK output
  91. !! @param fname name of output file
  92. !! @param show_ghost .true. to show ghost nodes
  93. !! @param tree_ctx pointer to the tree
  94. subroutine WriteTreeVTK(fname, show_ghost, tree_ctx)
  95. use, intrinsic :: ISO_C_BINDING
  96. character , intent(in) :: fname(*)
  97. logical , intent(in) :: show_ghost
  98. type(c_ptr), intent(in) :: tree_ctx
  99. end subroutine
  100. !> Add particles to the tree
  101. !! @param pt_name name of the particles
  102. !! @param coord coordinates of the particles {x1,y1,z1,x2,y2,...}
  103. !! @param Npt number of particles
  104. !! @param tree_ctx pointer to the tree
  105. subroutine AddParticles(pt_name, coord, Npt, tree_ctx)
  106. use, intrinsic :: ISO_C_BINDING
  107. character , intent(in) :: pt_name
  108. real*8 , intent(in) :: coord(*)
  109. integer*4 , intent(in) :: Npt
  110. type(c_ptr), intent(in) :: tree_ctx
  111. end subroutine
  112. !> Associate some data with the particles (for example charge density). The
  113. !! data must be in the original order of the points.
  114. !! @param pt_name name of the particles
  115. !! @param data_name name of the data
  116. !! @param pt_data data array
  117. !! @param Ndata size of the data array
  118. !! @param tree_ctx pointer to the tree
  119. subroutine AddParticleData(data_name, pt_name, pt_data, Ndata, tree_ctx)
  120. use, intrinsic :: ISO_C_BINDING
  121. character , intent(in) :: data_name(*)
  122. character , intent(in) :: pt_name(*)
  123. real*8 , intent(in) :: pt_data(*)
  124. integer*4 , intent(in) :: Ndata
  125. type(c_ptr), intent(in) :: tree_ctx
  126. end subroutine
  127. !> Get data associated with the particles. The output array will be ordered
  128. !! according to the original ordering of the points
  129. !! @param pt_data data array
  130. !! @param Ndata size of the data array
  131. !! @param data_name name of the data
  132. !! @param tree_ctx pointer to the tree
  133. subroutine GetParticleData(pt_data, Ndata, data_name, tree_ctx)
  134. use, intrinsic :: ISO_C_BINDING
  135. type(c_ptr), intent(out) :: pt_data ! real*8, dimension(N)
  136. integer*4 , intent(out) :: Ndata
  137. character , intent(in) :: data_name(*)
  138. type(c_ptr), intent(in) :: tree_ctx
  139. end subroutine
  140. !> Delete data associated with a particle (or a particle and all its data)
  141. !! @param data_name name of the data (or particle)
  142. !! @param tree_ctx pointer to the tree
  143. subroutine DeleteParticleData(data_name, tree_ctx)
  144. use, intrinsic :: ISO_C_BINDING
  145. character , intent(in) :: data_name
  146. type(c_ptr), intent(in) :: tree_ctx
  147. end subroutine
  148. !> Write VTK output
  149. !! @param fname name of output file
  150. !! @param data_name name of the data
  151. !! @param show_ghost .true. to show ghost nodes
  152. !! @param tree_ctx pointer to the tree
  153. subroutine WriteParticleVTK(fname, data_name, show_ghost, tree_ctx)
  154. use, intrinsic :: ISO_C_BINDING
  155. character , intent(in) :: fname(*)
  156. character , intent(in) :: data_name(*)
  157. logical , intent(in) :: show_ghost
  158. type(c_ptr), intent(in) :: tree_ctx
  159. end subroutine
  160. end interface