fmm_tree.hpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. public:
  23. typedef typename FMM_Mat_t::FMMNode_t Node_t;
  24. typedef typename FMM_Mat_t::Real_t Real_t;
  25. /**
  26. * \brief Constructor.
  27. */
  28. FMM_Tree(MPI_Comm c): MPI_Tree<Node_t>(c), fmm_mat(NULL), bndry(FreeSpace) { };
  29. /**
  30. * \brief Virtual destructor.
  31. */
  32. virtual ~FMM_Tree(){
  33. }
  34. /**
  35. * \brief Initialize the distributed MPI tree.
  36. */
  37. virtual void Initialize(typename Node_t::NodeData* data_) ;
  38. /**
  39. * \brief Initialize FMM_Tree.
  40. */
  41. void InitFMM_Tree(bool refine, BoundaryType bndry=FreeSpace);
  42. /**
  43. * \brief Run FMM
  44. */
  45. void SetupFMM(FMM_Mat_t* fmm_mat_);
  46. /**
  47. * \brief Run FMM
  48. */
  49. void RunFMM();
  50. /**
  51. * \brief Clear FMM data: multipole, local expansions and target potential.
  52. */
  53. void ClearFMMData();
  54. /**
  55. * \brief Build interaction lists for all nodes.
  56. */
  57. void BuildInteracLists();
  58. /**
  59. * \brief Upward FMM pass (Including MultipoleReduceBcast).
  60. */
  61. void UpwardPass();
  62. /**
  63. * \brief Reduction and broadcast of multipole expansions.
  64. */
  65. void MultipoleReduceBcast() ;
  66. /**
  67. * \brief Downward FMM pass.
  68. */
  69. void DownwardPass();
  70. /**
  71. * \brief Copy FMM output to the tree.
  72. */
  73. void Copy_FMMOutput();
  74. private:
  75. std::vector<Matrix<Real_t> > node_data_buff;
  76. InteracList<Node_t> interac_list;
  77. FMM_Mat_t* fmm_mat; //Computes all FMM translations.
  78. BoundaryType bndry;
  79. std::vector<Matrix<char> > precomp_lst; //Precomputed data for each interaction type.
  80. std::vector<SetupData<Real_t> > setup_data;
  81. };
  82. }//end namespace
  83. #include <fmm_tree.txx>
  84. #endif //_PVFMM_FMM_TREE_HPP_