fmm_tree.hpp 2.1 KB

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