OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
DcpseRhs_unit_tests.cpp
1//
2// Created by tommaso on 28/03/19.
3//
4
5#define BOOST_TEST_DYN_LINK
6
7#include <boost/test/unit_test.hpp>
8#include <DCPSE/DcpseRhs.hpp>
9#include "../../openfpm_numerics/src/DMatrix/EMatrix.hpp"
10
11BOOST_AUTO_TEST_SUITE(DcpseRhs_tests)
12
13// If EIGEN is not present, EMatrix is not available and we don't need to build this test
14#ifdef HAVE_EIGEN
15
16 BOOST_AUTO_TEST_CASE(DcpseRhs_dx_test)
17 {
18 unsigned int r = 2;
20 MonomialBasis<2> mb(m.asArray(), r);
21 //std::cout << mb << std::endl;
22 EMatrix<double, Eigen::Dynamic, 1> b(mb.size());
23
24 DcpseRhs<2> rhs(mb, m);
25 rhs.getVector<double>(b);
26// for (unsigned int i = 0; i < mb.size(); ++i)
27// {
28// //std::cout << b(i) << std::endl;
29// }
30
31 // Validation
32 const MonomialBasis<2> &Dmb = mb.getDerivative(m);
33 //std::cout << Dmb << std::endl;
34 auto p0 = Point<2, double>({0,0});
35 BOOST_REQUIRE_CLOSE(b(0), -Dmb.getElement(0).evaluate(p0), 1e-16);
36 BOOST_REQUIRE_CLOSE(b(1), -Dmb.getElement(1).evaluate(p0), 1e-16);
37 BOOST_REQUIRE_CLOSE(b(2), -Dmb.getElement(2).evaluate(p0), 1e-16);
38 BOOST_REQUIRE_CLOSE(b(3), -Dmb.getElement(3).evaluate(p0), 1e-16);
39 BOOST_REQUIRE_CLOSE(b(4), -Dmb.getElement(4).evaluate(p0), 1e-16);
40 BOOST_REQUIRE_CLOSE(b(5), -Dmb.getElement(5).evaluate(p0), 1e-16);
41 }
42
43 BOOST_AUTO_TEST_CASE(DcpseRhs_dxdy_test)
44 {
45 unsigned int r = 2;
47 MonomialBasis<2> mb(m.asArray(), r);
49 EMatrix<double, Eigen::Dynamic, Eigen::Dynamic> b(mb.size(), 1);
50
51 DcpseRhs<2> rhs(mb, m);
52 rhs.getVector<double>(b);
53// for (unsigned int i = 0; i < mb.size(); ++i)
54// {
55// //std::cout << b(i) << std::endl;
56// }
57
58 // Validation
59 const MonomialBasis<2> &Dmb = mb.getDerivative(m);
61 auto p0 = Point<2, double>({0,0});
62 BOOST_REQUIRE_CLOSE(b(0), Dmb.getElement(0).evaluate(p0), 1e-16);
63 BOOST_REQUIRE_CLOSE(b(1), Dmb.getElement(1).evaluate(p0), 1e-16);
64 BOOST_REQUIRE_CLOSE(b(2), Dmb.getElement(2).evaluate(p0), 1e-16);
65 BOOST_REQUIRE_CLOSE(b(3), Dmb.getElement(3).evaluate(p0), 1e-16);
66 BOOST_REQUIRE_CLOSE(b(4), Dmb.getElement(4).evaluate(p0), 1e-16);
67 BOOST_REQUIRE_CLOSE(b(5), Dmb.getElement(5).evaluate(p0), 1e-16);
68 BOOST_REQUIRE_CLOSE(b(6), Dmb.getElement(6).evaluate(p0), 1e-16);
69 BOOST_REQUIRE_CLOSE(b(7), Dmb.getElement(7).evaluate(p0), 1e-16);
70 BOOST_REQUIRE_CLOSE(b(8), Dmb.getElement(8).evaluate(p0), 1e-16);
71 //BOOST_REQUIRE_CLOSE(b(9), Dmb.getElement(9).evaluate(p0), 1e-16);
72 }
73
74 BOOST_AUTO_TEST_CASE(DcpseRhs_laplacian_test)
75 {
76 unsigned int r = 2;
78 MonomialBasis<2> mb(m.asArray(), r);
80 EMatrix<double, Eigen::Dynamic, Eigen::Dynamic> b(mb.size(), 1);
81
82 DcpseRhs<2> rhs(mb, m);
83 rhs.getVector<double>(b);
84
85 // Validation
86 const MonomialBasis<2> &Dmb = mb.getDerivative(m);
88 auto p0 = Point<2, double>({0,0});
89 BOOST_REQUIRE_CLOSE(b(0), Dmb.getElement(0).evaluate(p0), 1e-16);
90 BOOST_REQUIRE_CLOSE(b(1), Dmb.getElement(1).evaluate(p0), 1e-16);
91 BOOST_REQUIRE_CLOSE(b(2), Dmb.getElement(2).evaluate(p0), 1e-16);
92 BOOST_REQUIRE_CLOSE(b(3), Dmb.getElement(3).evaluate(p0), 1e-16);
93 BOOST_REQUIRE_CLOSE(b(4), Dmb.getElement(4).evaluate(p0), 1e-16);
94 BOOST_REQUIRE_CLOSE(b(5), Dmb.getElement(5).evaluate(p0), 1e-16);
95 BOOST_REQUIRE_CLOSE(b(6), Dmb.getElement(6).evaluate(p0), 1e-16);
96 BOOST_REQUIRE_CLOSE(b(7), Dmb.getElement(7).evaluate(p0), 1e-16);
97 BOOST_REQUIRE_CLOSE(b(8), Dmb.getElement(8).evaluate(p0), 1e-16);
98 BOOST_REQUIRE_CLOSE(b(9), Dmb.getElement(9).evaluate(p0), 1e-16);
99 BOOST_REQUIRE_CLOSE(b(10), Dmb.getElement(10).evaluate(p0), 1e-16);
100 BOOST_REQUIRE_CLOSE(b(11), Dmb.getElement(11).evaluate(p0), 1e-16);
101 BOOST_REQUIRE_CLOSE(b(12), Dmb.getElement(12).evaluate(p0), 1e-16);
102 BOOST_REQUIRE_CLOSE(b(13), Dmb.getElement(13).evaluate(p0), 1e-16);
103 BOOST_REQUIRE_CLOSE(b(14), Dmb.getElement(14).evaluate(p0), 1e-16);
104 BOOST_REQUIRE_CLOSE(b(15), Dmb.getElement(15).evaluate(p0), 1e-16);
105 BOOST_REQUIRE_CLOSE(b(16), Dmb.getElement(16).evaluate(p0), 1e-16);
106 BOOST_REQUIRE_CLOSE(b(17), Dmb.getElement(17).evaluate(p0), 1e-16);
107 BOOST_REQUIRE_CLOSE(b(18), Dmb.getElement(18).evaluate(p0), 1e-16);
108 BOOST_REQUIRE_CLOSE(b(19), Dmb.getElement(19).evaluate(p0), 1e-16);
109 }
110
111#endif // HAVE_EIGEN
112
113BOOST_AUTO_TEST_SUITE_END()
This class implement the point shape in an N-dimensional space.
Definition Point.hpp:28