Commit a7ff67d7 authored by Yaroslav's avatar Yaroslav

FUCK YEAH!

parent 14ba2dc5
This diff is collapsed.
......@@ -18,7 +18,7 @@ BOOST_AUTO_TEST_CASE( grid_dist_id_hdf5_save_test )
// Input data
size_t k = 10;
size_t ghost_part = 0.2;
float ghost_part = 0.0;
// Domain
Box<2,float> domain({0.0,0.0},{1.0,1.0});
......@@ -50,6 +50,36 @@ BOOST_AUTO_TEST_CASE( grid_dist_id_hdf5_save_test )
bool val = dec.check_consistency();
BOOST_REQUIRE_EQUAL(val,true);
size_t count = 0;
auto it = g_dist.getDomainIterator();
while (it.isNext())
{
//key
auto key = it.get();
auto keyg = g_dist.getGKey(key);
g_dist.template get<0>(key) = keyg.get(0);
++it;
count++;
}
std::cout << "Count: " << count << std::endl;
openfpm::vector<size_t> count_total;
v_cl.allGather(count,count_total);
v_cl.execute();
size_t sum = 0;
for (size_t i = 0; i < count_total.size(); i++)
sum += count_total.get(i);
std::cout << "Sum: " << sum << std::endl;
timer t;
t.start();
// Save the grid
......@@ -65,7 +95,7 @@ BOOST_AUTO_TEST_CASE( grid_dist_id_hdf5_load_test )
// Input data
size_t k = 10;
size_t ghost_part = 0.2;
float ghost_part = 0.0;
// Domain
Box<2,float> domain({0.0,0.0},{1.0,1.0});
......@@ -77,7 +107,7 @@ BOOST_AUTO_TEST_CASE( grid_dist_id_hdf5_load_test )
return;
if (v_cl.getProcessUnitID() == 0)
std::cout << "Loading Distributed 2D Grid..." << std::endl;
std::cout << "Loading Distributed 2D Grid..." << std::endl;
// grid size
size_t sz[2];
......@@ -90,29 +120,42 @@ BOOST_AUTO_TEST_CASE( grid_dist_id_hdf5_load_test )
// Distributed grid with id decomposition
grid_dist_id<2, float, scalar<float>, CartDecomposition<2,float>> g_dist(sz,domain,g);
g_dist.getDecomposition().write("Before_load_grid_decomposition");
g_dist.write("Before_Loaded_grid");
timer t;
t.start();
// Save the grid
g_dist.load("grid_dist_id.h5");
t.stop();
g_dist.write("Loaded_grid");
g_dist.getDecomposition().write("Loaded_grid_decomposition");
std::cout << "Loading time: " << t.getwct() << std::endl;
auto it = g_dist.getOldDomainIterator();
auto it = g_dist.getDomainIterator();
size_t count = 0;
while (it.isNext())
{
//key
grid_dist_key_dx<2> key = it.get();
auto key = it.get();
//g_dist.get(key);
//BOOST_CHECK_CLOSE(g_dist.template get<0>(key),1,0.0001);
//std::cout << "Element: " << g_dist.template get<0>(key) << std::endl;
auto keyg = g_dist.getGKey(key);
BOOST_REQUIRE_EQUAL(g_dist.template get<0>(key), keyg.get(0));
++it;
count++;
}
std::cout << "COOOOOOUNT: " << count << std::endl;
openfpm::vector<size_t> count_total;
v_cl.allGather(count,count_total);
v_cl.execute();
......@@ -130,7 +173,7 @@ BOOST_AUTO_TEST_CASE( grid_gdb_test )
// Input data
size_t k = 10;
size_t ghost_part = 0.2;
float ghost_part = 0.2;
// Domain
Box<2,float> domain({0.0,0.0},{1.0,1.0});
......
This diff is collapsed.
This diff is collapsed.
......@@ -48,7 +48,7 @@ BOOST_AUTO_TEST_CASE( vector_dist_hdf5_save_test )
const size_t Ng = cbrt(k);
// we create a Grid iterator
size_t sz[3] = {Ng,Ng,Ng};
size_t sz[dim] = {Ng,Ng,Ng};
for (size_t i = 0; i < dim; i++)
bc[i] = NON_PERIODIC;
......@@ -75,16 +75,12 @@ BOOST_AUTO_TEST_CASE( vector_dist_hdf5_save_test )
++it;
}
BOOST_REQUIRE_EQUAL(it.getSpacing(0),1.0f/(Ng-1));
BOOST_REQUIRE_EQUAL(it.getSpacing(1),1.0f/(Ng-1));
BOOST_REQUIRE_EQUAL(it.getSpacing(2),1.0f/(Ng-1));
//std::cout << "Size_local: " << vd.size_local_with_ghost() << std::endl;
//BOOST_REQUIRE_EQUAL(it.getSpacing(0),1.0f/(Ng-1));
//BOOST_REQUIRE_EQUAL(it.getSpacing(1),1.0f/(Ng-1));
//BOOST_REQUIRE_EQUAL(it.getSpacing(2),1.0f/(Ng-1));
vd.map();
//std::cout << "Size_local after map: " << vd.size_local_with_ghost() << std::endl;
// Put forces
auto it2 = vd.getDomainIterator();
......@@ -95,7 +91,7 @@ BOOST_AUTO_TEST_CASE( vector_dist_hdf5_save_test )
//Put the forces
for (size_t i = 0; i < dim; i++)
vd.template getProp<0>(key)[i] = 0.51234;
vd.template getProp<0>(key)[i] = 0.51234 + vd.getPos(key)[0] + vd.getPos(key)[1]+ vd.getPos(key)[2];
++it2;
}
......@@ -109,6 +105,8 @@ BOOST_AUTO_TEST_CASE( vector_dist_hdf5_save_test )
std::cout << "Saving time: " << t.getwct() << std::endl;
}
BOOST_AUTO_TEST_CASE( vector_dist_hdf5_load_test )
{
Vcluster & v_cl = create_vcluster();
......@@ -141,6 +139,8 @@ BOOST_AUTO_TEST_CASE( vector_dist_hdf5_load_test )
vector_dist<dim,float, aggregate<float[dim]>, CartDecomposition<dim,float> > vd(0,box,bc,ghost);
vd.load("vector_dist.h5");
timer t;
t.start();
// Save the vector
......@@ -164,13 +164,15 @@ BOOST_AUTO_TEST_CASE( vector_dist_hdf5_load_test )
BOOST_REQUIRE_EQUAL(sum,k);
//std::cout << "Sum: " << sum << std::endl;
// Check spacing (positions)
auto it = vd.getGridIterator(sz);
while (it.isNext())
{
auto key = it.get();
//auto key = it.get();
++it;
}
......@@ -179,7 +181,7 @@ BOOST_AUTO_TEST_CASE( vector_dist_hdf5_load_test )
BOOST_REQUIRE_EQUAL(it.getSpacing(1),1.0f/(Ng-1));
BOOST_REQUIRE_EQUAL(it.getSpacing(2),1.0f/(Ng-1));
/*
// Check properties
auto it2 = vd.getDomainIterator();
......@@ -190,11 +192,10 @@ BOOST_AUTO_TEST_CASE( vector_dist_hdf5_load_test )
//Put the forces
for (size_t i = 0; i < dim; i++)
BOOST_CHECK_CLOSE(vd.template getProp<0>(key)[i],0.51234,0.0001);
BOOST_CHECK_CLOSE(vd.template getProp<0>(key)[i],0.51234 + vd.getPos(key)[0] + vd.getPos(key)[1]+ vd.getPos(key)[2],0.0001);
++it2;
}
*/
}
BOOST_AUTO_TEST_SUITE_END()
......
......@@ -217,5 +217,4 @@ BOOST_AUTO_TEST_CASE( vector_dist_full_NN )
}
}
#endif /* SRC_VECTOR_VECTOR_DIST_NN_TESTS_HPP_ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment