OpenFPM_io  0.2.0
Project that contain the implementation and interfaces for basic structure like vectors, grids, graph ... .
 All Data Structures Functions Variables Typedefs
HDF5_XdmfWriter_unit_tests.hpp
1 /*
2  * H5PartWriter_unit_tests.hpp
3  *
4  * Created on: Feb 22, 2016
5  * Author: i-bird
6  */
7 
8 #ifndef OPENFPM_IO_SRC_HDF5_XDMFWRITER_HDF5_XDMFWRITER_UNIT_TESTS_HPP_
9 #define OPENFPM_IO_SRC_HDF5_XDMFWRITER_HDF5_XDMFWRITER_UNIT_TESTS_HPP_
10 
11 #include "VCluster.hpp"
12 #include "util/SimpleRNG.hpp"
13 #include "HDF5_XdmfWriter.hpp"
14 
15 BOOST_AUTO_TEST_SUITE( HDF5_writer_test )
16 
17 
18 BOOST_AUTO_TEST_CASE( HDF5_writer_use)
19 {
20  openfpm::vector<Point<3,double>> pv;
21  openfpm::vector<Point_test<double>> pvp;
22 
23  SimpleRNG rng;
24 
25  Vcluster & v_cl = *global_v_cluster;
26 
27  if (v_cl.getProcessingUnits() != 3)
28  return;
29 
30  double z_base = v_cl.getProcessUnitID();
31 
32  // fill 1000 particles for each processors
33 
34  for (size_t i = 0 ; i < 1000 ; i++)
35  {
36  Point<3,double> p;
37  p[0] = rng.GetUniform();
38  p[1] = rng.GetUniform();
39  p[2] = z_base+rng.GetUniform();
40 
41  pv.add(p);
42 
43  p[0] += 2.0;
44 
45  Point_test<double> pt;
46  pt.fill();
47 
48  pvp.add(pt);
49  }
50 
52  h5p.template write<Point<3,double>,Point_test<double>,0,1,4,5>("h5part.h5",pv,pvp,1000);
53 
54  // check that match
55 
56  bool test = compare("test_h5part.h5part","test_h5part_test.h5part");
57  BOOST_REQUIRE_EQUAL(true,test);
58 }
59 
60 BOOST_AUTO_TEST_SUITE_END()
61 
62 
63 
64 #endif /* OPENFPM_IO_SRC_HDF5_XDMFWRITER_HDF5_XDMFWRITER_UNIT_TESTS_HPP_ */