interac_list.hpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /**
  2. * \file interac_list.hpp
  3. * \author Dhairya Malhotra, dhairya.malhotra@gmail.com
  4. * \date 6-11-2012
  5. * \brief This file contains the definition of the InteracList class.
  6. * Handles the logic for different interaction lists, and determines the
  7. * symmetry class for each interaction.
  8. */
  9. #ifndef _PVFMM_INTERAC_LIST_HPP_
  10. #define _PVFMM_INTERAC_LIST_HPP_
  11. #include <pvfmm_common.hpp>
  12. #include <tree_node.hpp>
  13. #include <precomp_mat.hpp>
  14. namespace pvfmm{
  15. template <class Node_t>
  16. class InteracList{
  17. typedef typename Node_t::Real_t Real_t;
  18. public:
  19. /**
  20. * \brief Constructor.
  21. */
  22. InteracList(){}
  23. /**
  24. * \brief Constructor.
  25. */
  26. InteracList(unsigned int dim_){
  27. Initialize(dim_);
  28. }
  29. /**
  30. * \brief Initialize.
  31. */
  32. void Initialize(unsigned int dim_, PrecompMat<Real_t>* mat_=NULL);
  33. /**
  34. * \brief Number of possible interactions in each list.
  35. */
  36. size_t ListCount(Mat_Type t);
  37. /**
  38. * \brief Returns the relative octant coordinates for an interaction i of
  39. * type t.
  40. */
  41. int* RelativeCoord(Mat_Type t, size_t i);
  42. /**
  43. * \brief Build interaction list for this node.
  44. */
  45. std::vector<Node_t*> BuildList(Node_t* n, Mat_Type t);
  46. /**
  47. * \brief For an interaction of type t and index i, returns the symmetry
  48. * class for the same.
  49. */
  50. size_t InteracClass(Mat_Type t, size_t i);
  51. Matrix<Real_t>& ClassMat(int l, Mat_Type type, size_t indx);
  52. Permutation<Real_t>& Perm_R(int l, Mat_Type type, size_t indx);
  53. Permutation<Real_t>& Perm_C(int l, Mat_Type type, size_t indx);
  54. private:
  55. /**
  56. * \brief Returns the list of permutations to be applied to the matrix to
  57. * convert it to its interac_class.
  58. */
  59. std::vector<Perm_Type>& PermutList(Mat_Type t, size_t i);
  60. /**
  61. * \brief Set relative coordinates of the interacting node in
  62. * rel_coord[Type][idx][1:3].
  63. */
  64. void InitList(int max_r, int min_r, int step, Mat_Type t);
  65. /**
  66. * \brief A hash function defined on the relative coordinates of octants.
  67. */
  68. static int coord_hash(int* c);
  69. static int class_hash(int* c);
  70. unsigned int dim; //Spatial dimension.
  71. std::vector<Matrix<int> > rel_coord; //Relative coordinates of interacting octant.
  72. std::vector<std::vector<int> > hash_lut; //Lookup table for hash code of relative coordinates.
  73. std::vector<std::vector<size_t> > interac_class; //The symmetry class corresponding to each interaction.
  74. std::vector<std::vector<std::vector<Perm_Type> > > perm_list; //Permutation to convert it to it's interac_class.
  75. std::vector<size_t> class_count; //Number of symmetry classes in each interaction list.
  76. PrecompMat<Real_t>* mat; //Handles storage of matrices.
  77. };
  78. }//end namespace
  79. #include <interac_list.txx>
  80. #endif //_PVFMM_INTERAC_LIST_HPP_