OpenFPM  5.2.0
Project that contain the implementation of distributed structures
DcpseDiagonalScalingMatrix.hpp
1 //
2 // Created by tommaso on 29/03/19.
3 // Modified by Serhii
4 //
5 
6 #ifndef OPENFPM_PDATA_DCPSEDIAGONALSCALINGMATRIX_HPP
7 #define OPENFPM_PDATA_DCPSEDIAGONALSCALINGMATRIX_HPP
8 
9 #include "MonomialBasis.hpp"
10 
11 
12 template <unsigned int dim, typename monomialBasis_type = MonomialBasis<dim>>
14 {
15 private:
16  const monomialBasis_type& monomialBasis;
17 
18 public:
19  DcpseDiagonalScalingMatrix(const monomialBasis_type &monomialBasis) : monomialBasis(monomialBasis) {}
20 
21  template <typename T, typename MatrixType, typename verletIterator_type, typename vector_type, typename vector_type2>
22  void buildMatrix(MatrixType &M, size_t p, verletIterator_type &it, T eps, vector_type & particlesSupport , vector_type2 & particlesDomain)
23  {
24  // Fill the diagonal matrix
25  M.setZero(); // Make sure the rest of the matrix is zero!
26 
27  Point<dim,typename vector_type::stype> xp = particlesDomain.getPos(p);
28 
29  int i = 0;
30  while (it.isNext())
31  {
33 
34  size_t q = it.get();
35  _xp -= particlesSupport.getPos(q);
36 
37  M(i,i) = exp(- norm2(_xp) / (2.0 * eps * eps));
38 
39  ++it; ++i;
40  }
41  }
42 
43  template <typename T, typename vector_type, typename vector_type2>
44  __host__ __device__ void buildMatrix(T* M, size_t p, size_t supportKeysSize, const size_t* supportKeys, T eps, vector_type & particlesSupport, vector_type2 & particlesDomain)
45  {
46  // Check that all the dimension constraints are met
47  assert(supportKeysSize >= monomialBasis.size());
48 
49  Point<dim,typename vector_type::stype> xp = particlesDomain.getPos(p);
50 
51  for (size_t i = 0; i < supportKeysSize; ++i)
52  {
53  size_t q = supportKeys[i];
55  _xp -= particlesSupport.getPos(q);
56 
57  M[i] = exp(- norm2(_xp) / (2.0 * eps * eps));
58  }
59  }
60 };
61 
62 #endif //OPENFPM_PDATA_DCPSEDIAGONALSCALINGMATRIX_HPP
This class implement the point shape in an N-dimensional space.
Definition: Point.hpp:28
__device__ __host__ const T & get(unsigned int i) const
Get coordinate.
Definition: Point.hpp:172
auto getPos(size_t vec_key) -> decltype(vd.getPos(vec_key))
Get the position of an element.
Distributed vector.
auto getPos(vect_dist_key_dx vec_key) -> decltype(vPos.template get< 0 >(vec_key.getKey()))
Get the position of an element.