interac_list.hpp 2.8 KB

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