OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
DcpseRhs.hpp
1//
2// Created by tommaso on 28/03/19.
3//
4
5#ifndef OPENFPM_PDATA_DCPSERHS_HPP
6#define OPENFPM_PDATA_DCPSERHS_HPP
7
8#include "MonomialBasis.hpp"
9
10template<unsigned int dim>
12{
13private:
14 const Point<dim, unsigned int> differentialSignature;
15 const MonomialBasis<dim> derivatives;
16 int sign;
17public:
18 DcpseRhs(const MonomialBasis<dim> &monomialBasis, const Point<dim, unsigned int> &differentialSignature);
19
20 template<typename T, typename MatrixType>
21 MatrixType &getVector(MatrixType &b);
22};
23
24// Definitions below
25
26template<unsigned int dim>
28 const Point<dim, unsigned int> &differentialSignature)
29 : differentialSignature(differentialSignature), derivatives(monomialBasis.getDerivative(differentialSignature))
30{
31 unsigned int order = (Monomial<dim>(differentialSignature)).order();
32 if (order % 2 == 0)
33 {
34 sign = 1;
35 } else
36 {
37 sign = -1;
38 }
39}
40
41template<unsigned int dim>
42template<typename T, typename MatrixType>
43MatrixType &DcpseRhs<dim>::getVector(MatrixType &b)
44{
45 // The given vector V should have the right dimensions
46 assert(b.cols() == 1);
47 assert(b.rows() == derivatives.size());
48 for (unsigned int i = 0; i < derivatives.size(); ++i)
49 {
50 const Monomial<dim> dm = derivatives.getElement(i);
51 b(i, 0) = sign * dm.evaluate(Point<dim, T>(0));
52 }
53 //Choosing a(0,0) for even order as a free parameter can let us set b(0,0) for numerical robustness
54/* if (b(0,0) == 0.0 && sign == 1)
55 {
56 b(0,0) = 10.0;
57 }*/
58
59 return b;
60}
61
62#endif //OPENFPM_PDATA_DCPSERHS_HPP
This class implement the point shape in an N-dimensional space.
Definition Point.hpp:28