interac_list.hpp 2.8 KB

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