OpenFPM_pdata  1.1.0
Project that contain the implementation of distributed structures
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Friends Pages
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 
15 BOOST_AUTO_TEST_SUITE( vd_hdf5_chckpnt_rstrt_test )
16 
17 // Dimensionality
18 const size_t dim = 3;
19 
20 BOOST_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 
75 BOOST_AUTO_TEST_CASE( vector_dist_hdf5_load_test )
76 {
77  Vcluster & v_cl = create_vcluster();
78 
81 
83 
84  size_t g_m = 0;
85 
86  // Load the vector
87  h5.load("test_data/vector_dist_24.h5",vpos,vprp,g_m);
88 
90 
91  // Check total number of particles
92  size_t n_part = vpos.size();
93  v_cl.sum(n_part);
94  v_cl.execute();
95 
96  BOOST_REQUIRE_EQUAL(n_part,1024ul*24ul);
97 
98  BOOST_REQUIRE_EQUAL(vpos.size(),vprp.size());
99 
100  bool check = true;
101 
102  for (size_t i = 0 ; i < vpos.size() ; i++)
103  {
104  check &= (vprp.template get<0>(i)[0] == vpos.template get<0>(i)[0] + 100.0);
105  check &= (vprp.template get<0>(i)[1] == vpos.template get<0>(i)[1] + 200.0);
106  check &= (vprp.template get<0>(i)[2] == vpos.template get<0>(i)[2] + 300.0);
107  }
108 
109 
110 }
111 
112 BOOST_AUTO_TEST_SUITE_END()
113 
114 
115 #endif /* OPENFPM_IO_SRC_HDF5_WR_HDF5_WRITER_UNIT_TESTS_HPP_ */
void sum(T &num)
Sum the numbers across all processors and get the result.
void execute()
Execute all the requests.
size_t size()
Stub size.
Definition: map_vector.hpp:70
This class implement the point shape in an N-dimensional space.
Definition: Point.hpp:22
Implementation of VCluster class.
Definition: VCluster.hpp:36
const T & get(size_t i) const
Get coordinate.
Definition: Point.hpp:142
Implementation of 1-D std::vector like structure.
Definition: map_vector.hpp:61