OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
HDF5_writer_unit_tests.hpp
1/*
2 * HDF5_writer_unit_test.hpp
3 *
4 * Created on: May 1, 2017
5 * Author: i-bird
6 */
7
8#ifndef OPENFPM_IO_SRC_HDF5_WR_HDF5_WRITER_UNIT_TESTS_HPP_
9#define OPENFPM_IO_SRC_HDF5_WR_HDF5_WRITER_UNIT_TESTS_HPP_
10
11#include "HDF5_wr.hpp"
12
13#include "hdf5.h"
14
15BOOST_AUTO_TEST_SUITE( vd_hdf5_chckpnt_rstrt_test_io )
16
17// Dimensionality
18const size_t dim = 3;
19
20BOOST_AUTO_TEST_CASE( vector_dist_hdf5_save_test )
21{
24
25 // Put forces
26
27 for (size_t i = 0 ; i < 1024 ; i++)
28 {
30
31 p.get(0) = i;
32 p.get(1) = i+13;
33 p.get(2) = i+17;
34
35 vpos.add(p);
36
37 vprp.add();
38 vprp.template get<0>(vprp.size()-1)[0] = p.get(0) + 100.0;
39 vprp.template get<0>(vprp.size()-1)[1] = p.get(1) + 200.0;
40 vprp.template get<0>(vprp.size()-1)[2] = p.get(2) + 300.0;
41 }
42
44
45 // Save the vector
46 h5.save("vector_dist.h5",vpos,vprp);
47
49
52
53 size_t g_m = 0;
54 h5r.load("vector_dist.h5",vpos2,vprp2,g_m);
55
56 BOOST_REQUIRE_EQUAL(1024ul,vpos2.size());
57 BOOST_REQUIRE_EQUAL(1024ul,vprp2.size());
58
59 BOOST_REQUIRE_EQUAL(1024ul,g_m);
60
61 // Check that vpos == vpos2 and vprp2 == vprp2
62
63 bool check = true;
64 for (size_t i = 0 ; i < vpos.size() ; i++)
65 {
66 check &= (vpos.get(i) == vpos2.get(i));
67 check &= (vprp.get_o(i) == vprp2.get_o(i));
68 }
69
70 BOOST_REQUIRE_EQUAL(check,true);
71}
72
73
74
75BOOST_AUTO_TEST_CASE( vector_dist_hdf5_load_test )
76{
77 Vcluster<> & v_cl = create_vcluster();
78
79#ifdef OPENFPM_PDATA
80
81 std::string c2 = std::string("openfpm_io/test_data/vector_dist_24.h5");
82
83#else
84
85 std::string c2 = std::string("test_data/vector_dist_24.h5");
86
87#endif
88
91
93
94 size_t g_m = 0;
95
96 // Load the vector
97 h5.load(c2,vpos,vprp,g_m);
98
100
101 // Check total number of particles
102 size_t n_part = vpos.size();
103 v_cl.sum(n_part);
104 v_cl.execute();
105
106 BOOST_REQUIRE_EQUAL(n_part,1024ul*24ul);
107
108 BOOST_REQUIRE_EQUAL(vpos.size(),vprp.size());
109
110 bool check = true;
111
112 for (size_t i = 0 ; i < vpos.size() ; i++)
113 {
114 check &= (vprp.template get<0>(i)[0] == vpos.template get<0>(i)[0] + 100.0);
115 check &= (vprp.template get<0>(i)[1] == vpos.template get<0>(i)[1] + 200.0);
116 check &= (vprp.template get<0>(i)[2] == vpos.template get<0>(i)[2] + 300.0);
117 }
118
119
120}
121
122BOOST_AUTO_TEST_SUITE_END()
123
124
125#endif /* OPENFPM_IO_SRC_HDF5_WR_HDF5_WRITER_UNIT_TESTS_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
void execute()
Execute all the requests.
void sum(T &num)
Sum the numbers across all processors and get the result.
Implementation of VCluster class.
Definition VCluster.hpp:59
Implementation of 1-D std::vector like structure.
size_t size()
Stub size.