OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
DcpseDiagonalScalingMatrix.hpp
1 //
2 // Created by tommaso on 29/03/19.
3 //
4 
5 #ifndef OPENFPM_PDATA_DCPSEDIAGONALSCALINGMATRIX_HPP
6 #define OPENFPM_PDATA_DCPSEDIAGONALSCALINGMATRIX_HPP
7 
8 #include "MonomialBasis.hpp"
9 #include "Support.hpp"
10 
11 template <unsigned int dim>
13 {
14 private:
15  const MonomialBasis<dim> monomialBasis;
16 
17 public:
18 
19  DcpseDiagonalScalingMatrix(const MonomialBasis<dim> &monomialBasis) : monomialBasis(monomialBasis) {}
20 
21  template <typename T, typename MatrixType, typename vector_type>
22  void buildMatrix(MatrixType &M, Support support, T eps, vector_type & particles)
23  {
24  // Check that all the dimension constraints are met
25  assert(support.size() >= monomialBasis.size());
26  assert(M.rows() == support.size());
27  assert(M.cols() == support.size());
28 
29  Point<dim,typename vector_type::stype> ref_p = particles.getPosOrig(support.getReferencePointKey());
30 
31  // Fill the diagonal matrix
32  M.setZero(); // Make sure the rest of the matrix is zero!
33  int i = 0;
34  for (const auto& pt : support.getKeys())
35  {
37  p -= particles.getPosOrig(pt);
38 
39  M(i,i) = exp(- norm2(p) / (2.0 * eps * eps));
40  ++i;
41  }
42  }
43 
44 };
45 
46 #endif //OPENFPM_PDATA_DCPSEDIAGONALSCALINGMATRIX_HPP
auto getPosOrig(vect_dist_key_dx vec_key) const -> decltype(v_pos.template get< 0 >(vec_key.getKey()))
Get the position of an element.
This class implement the point shape in an N-dimensional space.
Definition: Point.hpp:27
Distributed vector.