| 1 | /* |
| 2 | * Kernels_unit_tests.hpp |
| 3 | * |
| 4 | * Created on: Feb 17, 2016 |
| 5 | * Author: i-bird |
| 6 | */ |
| 7 | |
| 8 | #ifndef OPENFPM_NUMERICS_SRC_PSE_KERNELS_UNIT_TESTS_HPP_ |
| 9 | #define OPENFPM_NUMERICS_SRC_PSE_KERNELS_UNIT_TESTS_HPP_ |
| 10 | |
| 11 | #include "PSE/Kernels_test_util.hpp" |
| 12 | #ifdef HAVE_LIBQUADMATH |
| 13 | #include <boost/multiprecision/float128.hpp> |
| 14 | #endif |
| 15 | |
| 16 | BOOST_AUTO_TEST_SUITE( pse_kernels_unit_tests ) |
| 17 | |
| 18 | BOOST_AUTO_TEST_CASE( pse_ker ) |
| 19 | { |
| 20 | Vcluster<> & v_cl = create_vcluster(); |
| 21 | |
| 22 | // This test is not made to run in parallel |
| 23 | if (v_cl.getProcessingUnits() > 1) |
| 24 | return; |
| 25 | |
| 26 | openfpm::vector<openfpm::vector<double>> y; |
| 27 | openfpm::vector<openfpm::vector<double>> y_res; |
| 28 | |
| 29 | // Load the result of the test |
| 30 | |
| 31 | #ifdef HAVE_LIBQUADMATH |
| 32 | y_res.load("test/PSE_convergence" ); |
| 33 | #else |
| 34 | y_res.load("test/PSE_convergence_osx" ); |
| 35 | #endif |
| 36 | |
| 37 | // Every time increase the number of particles by 2 |
| 38 | for (size_t i = 250 ; i <= 2097152000 ; i*=2) |
| 39 | { |
| 40 | y.add(); |
| 41 | |
| 42 | PSEError err; |
| 43 | |
| 44 | /////// Order 2 ////////////// |
| 45 | |
| 46 | #ifdef HAVE_LIBQUADMATH |
| 47 | |
| 48 | PSE_test<boost::multiprecision::float128,Lap_PSE<1,boost::multiprecision::float128,2>>(i,2,err); |
| 49 | y.last().add(err.linf_error); |
| 50 | |
| 51 | PSE_test<boost::multiprecision::float128,Lap_PSE<1,boost::multiprecision::float128,2>>(i,4,err); |
| 52 | y.last().add(err.linf_error); |
| 53 | #endif |
| 54 | |
| 55 | PSE_test<double,Lap_PSE<1,double,2>>(i,2,err); |
| 56 | y.last().add(err.linf_error); |
| 57 | |
| 58 | PSE_test<double,Lap_PSE<1,double,2>>(i,4,err); |
| 59 | y.last().add(err.linf_error); |
| 60 | |
| 61 | PSE_test<float,Lap_PSE<1,float,2>>(i,2,err); |
| 62 | y.last().add(err.linf_error); |
| 63 | |
| 64 | PSE_test<float,Lap_PSE<1,float,2>>(i,4,err); |
| 65 | y.last().add(err.linf_error); |
| 66 | |
| 67 | //////// Order 4 ///////////// |
| 68 | |
| 69 | #ifdef HAVE_LIBQUADMATH |
| 70 | |
| 71 | PSE_test<boost::multiprecision::float128,Lap_PSE<1,boost::multiprecision::float128,4>>(i,2,err); |
| 72 | y.last().add(err.linf_error); |
| 73 | |
| 74 | PSE_test<boost::multiprecision::float128,Lap_PSE<1,boost::multiprecision::float128,4>>(i,4,err); |
| 75 | y.last().add(err.linf_error); |
| 76 | |
| 77 | //////// Order 6 ///////////// |
| 78 | |
| 79 | |
| 80 | PSE_test<boost::multiprecision::float128,Lap_PSE<1,boost::multiprecision::float128,6>>(i,2,err); |
| 81 | y.last().add(err.linf_error); |
| 82 | |
| 83 | PSE_test<boost::multiprecision::float128,Lap_PSE<1,boost::multiprecision::float128,6>>(i,4,err); |
| 84 | y.last().add(err.linf_error); |
| 85 | |
| 86 | |
| 87 | //////// Order 8 ///////////// |
| 88 | |
| 89 | |
| 90 | PSE_test<boost::multiprecision::float128,Lap_PSE<1,boost::multiprecision::float128,8>>(i,8,err); |
| 91 | y.last().add(err.linf_error); |
| 92 | |
| 93 | PSE_test<boost::multiprecision::float128,Lap_PSE<1,boost::multiprecision::float128,8>>(i,16,err); |
| 94 | y.last().add(err.linf_error); |
| 95 | |
| 96 | #endif |
| 97 | } |
| 98 | |
| 99 | // Check the result |
| 100 | for (size_t i = 0 ; i < y.size(); i++) |
| 101 | { |
| 102 | for (size_t j = 0 ; j < y.get(i).size(); j++) |
| 103 | { |
| 104 | double c1 = y.get(i).get(j); |
| 105 | double c2 = y_res.get(i).get(j); |
| 106 | |
| 107 | #ifdef HAVE_LIBQUADMATH |
| 108 | |
| 109 | // In divergent mode the system is too sensitive |
| 110 | // to compiler/hardware differences disable them |
| 111 | if (j != 4 && j != 5) |
| 112 | {BOOST_REQUIRE_CLOSE(c1,c2,3.0);} |
| 113 | |
| 114 | #else |
| 115 | |
| 116 | // In divergent mode the system is too sensitive |
| 117 | // to compiler/hardware differences disable them |
| 118 | if (j != 2 && j != 3) |
| 119 | {BOOST_REQUIRE_CLOSE(c1,c2,3.0);} |
| 120 | |
| 121 | #endif |
| 122 | } |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | BOOST_AUTO_TEST_SUITE_END() |
| 127 | |
| 128 | #endif /* OPENFPM_NUMERICS_SRC_PSE_KERNELS_UNIT_TESTS_HPP_ */ |
| 129 | |