fmm_tree.hpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /**
  2. * \file fmm_tree.hpp
  3. * \author Dhairya Malhotra, dhairya.malhotra@gmail.com
  4. * \date 12-11-2010
  5. * \brief This file contains the definition of the FMM_Tree class.
  6. */
  7. #include <mpi.h>
  8. #include <vector>
  9. #include <pvfmm_common.hpp>
  10. #include <interac_list.hpp>
  11. #include <fmm_node.hpp>
  12. #include <mpi_tree.hpp>
  13. #include <matrix.hpp>
  14. #ifndef _PVFMM_FMM_TREE_HPP_
  15. #define _PVFMM_FMM_TREE_HPP_
  16. namespace pvfmm{
  17. /**
  18. * \brief Base class for FMM tree.
  19. */
  20. template <class FMM_Mat_t>
  21. class FMM_Tree: public MPI_Tree<typename FMM_Mat_t::FMMNode_t>{
  22. friend FMM_Mat_t;
  23. public:
  24. typedef typename FMM_Mat_t::FMMNode_t Node_t;
  25. typedef typename FMM_Mat_t::Real_t Real_t;
  26. /**
  27. * \brief Constructor.
  28. */
  29. FMM_Tree(MPI_Comm c): MPI_Tree<Node_t>(c), fmm_mat(NULL), bndry(FreeSpace) { };
  30. /**
  31. * \brief Virtual destructor.
  32. */
  33. virtual ~FMM_Tree(){
  34. }
  35. /**
  36. * \brief Initialize the distributed MPI tree.
  37. */
  38. virtual void Initialize(typename Node_t::NodeData* data_) ;
  39. /**
  40. * \brief Initialize FMM_Tree.
  41. */
  42. void InitFMM_Tree(bool refine, BoundaryType bndry=FreeSpace);
  43. /**
  44. * \brief Run FMM
  45. */
  46. void SetupFMM(FMM_Mat_t* fmm_mat_);
  47. /**
  48. * \brief Run FMM
  49. */
  50. void RunFMM();
  51. /**
  52. * \brief Clear FMM data: multipole, local expansions and target potential.
  53. */
  54. void ClearFMMData();
  55. /**
  56. * \brief Build interaction lists for all nodes.
  57. */
  58. void BuildInteracLists();
  59. /**
  60. * \brief Upward FMM pass (Including MultipoleReduceBcast).
  61. */
  62. void UpwardPass();
  63. /**
  64. * \brief Reduction and broadcast of multipole expansions.
  65. */
  66. void MultipoleReduceBcast() ;
  67. /**
  68. * \brief Downward FMM pass.
  69. */
  70. void DownwardPass();
  71. /**
  72. * \brief Copy FMM output to the tree.
  73. */
  74. void Copy_FMMOutput();
  75. protected:
  76. std::vector<Matrix<Real_t> > node_data_buff;
  77. InteracList<Node_t> interac_list;
  78. FMM_Mat_t* fmm_mat; //Computes all FMM translations.
  79. BoundaryType bndry;
  80. std::vector<Matrix<char> > precomp_lst; //Precomputed data for each interaction type.
  81. std::vector<SetupData<Real_t> > setup_data;
  82. std::vector<Vector<Real_t> > upwd_check_surf;
  83. std::vector<Vector<Real_t> > upwd_equiv_surf;
  84. std::vector<Vector<Real_t> > dnwd_check_surf;
  85. std::vector<Vector<Real_t> > dnwd_equiv_surf;
  86. };
  87. }//end namespace
  88. #include <fmm_tree.txx>
  89. #endif //_PVFMM_FMM_TREE_HPP_