Commit a66e35a2 authored by incardon's avatar incardon

Fixing sparse grid

parent 75474224
openfpm_data @ c08415a1
Subproject commit 3e0315170808242eb5ea6a9b86fea3e3763344f0
Subproject commit c08415a142c1b7fe865af3cc068f1a1ff0cc8a9e
......@@ -194,7 +194,7 @@ public:
{g_sz_lvl[i] = g_sz[i];}
// Add the coarse level
gd_array.add(grid_dist_id<dim,St,T,Decomposition,Memory,device_grid>(dec,g_sz,g_int,bc));
gd_array.add(grid_dist_id<dim,St,T,Decomposition,Memory,device_grid>(dec,g_sz,g_int));
initialize_other(n_lvl,g_sz_lvl);
}
......@@ -709,13 +709,13 @@ public:
* \param output filename output
*
*/
bool write(std::string output)
bool write(std::string output, size_t opt = VTK_WRITER | FORMAT_ASCII )
{
bool ret = true;
for (size_t i = 0 ; i < gd_array.size() ; i++)
{
ret &= gd_array.get(i).write(output + "_" + std::to_string(i));
ret &= gd_array.get(i).write(output + "_" + std::to_string(i),opt);
}
return ret;
......
......@@ -964,6 +964,42 @@ BOOST_AUTO_TEST_CASE( grid_dist_amr_get_domain_ghost_check )
Test3D_ghost_put(sg_dist,k);
}
BOOST_AUTO_TEST_CASE( grid_dist_amr_ghost_put_create )
{
// Test grid periodic
Box<3,float> domain({0.0,0.0,0.0},{1.0,1.0,1.0});
Vcluster & v_cl = create_vcluster();
if ( v_cl.getProcessingUnits() > 32 )
{return;}
long int k = 13;
BOOST_TEST_CHECKPOINT( "Testing grid periodic k<=" << k );
// grid size
size_t sz[3];
sz[0] = k;
sz[1] = k;
sz[2] = k;
// Ghost
Ghost<3,long int> g(1);
// periodicity
periodicity<3> pr = {{PERIODIC,PERIODIC,PERIODIC}};
// Distributed grid with id decomposition
grid_dist_amr<3, float, aggregate<long int>> g_dist(domain,g,pr);
Test3D_ghost_put(g_dist,k);
// Distributed grid with id decomposition
sgrid_dist_amr<3, float, aggregate<long int>> sg_dist(domain,g,pr);
Test3D_ghost_put(sg_dist,k);
}
BOOST_AUTO_TEST_SUITE_END()
......@@ -294,7 +294,7 @@ class grid_dist_iterator<dim,device_grid,device_sub_it,FIXED,stencil>
do
{
// When the grid has size 0 potentially all the other informations are garbage
while (g_c < gList.size() && (gList.get(g_c).size() == 0 || gdb_ext.get(g_c).Dbox.isValid() == false) ) g_c++;
while (g_c < gList.size() && (gList.get(g_c).size() == 0 || gdb_ext.get(g_c).GDbox.isValid() == false) ) g_c++;
// get the next grid iterator
if (g_c < gList.size())
......
......@@ -2142,7 +2142,7 @@ public:
* \return true if the write operation succeed
*
*/
bool write(std::string output, size_t opt = VTK_WRITER | FORMAT_ASCII)
bool write(std::string output, size_t opt = VTK_WRITER | FORMAT_ASCII )
{
#ifdef SE_CLASS2
check_valid(this,8);
......@@ -2158,7 +2158,11 @@ public:
for (size_t i = 0 ; i < loc_grid.size() ; i++)
{
Point<dim,St> offset = getOffset(i);
vtk_g.add(loc_grid.get(i),offset,cd_sm.getCellBox().getP2(),gdb_ext.get(i).Dbox);
if (opt & PRINT_GHOST)
{vtk_g.add(loc_grid.get(i),offset,cd_sm.getCellBox().getP2(),gdb_ext.get(i).GDbox);}
else
{vtk_g.add(loc_grid.get(i),offset,cd_sm.getCellBox().getP2(),gdb_ext.get(i).Dbox);}
}
vtk_g.write(output + "_" + std::to_string(v_cl.getProcessUnitID()) + ".vtk", prp_names, "grids", ft);
......@@ -2246,6 +2250,8 @@ public:
*/
void debugPrint()
{
size_t tot_volume = 0;
std::cout << "-------- External Ghost boxes ---------- " << std::endl;
for (size_t i = 0 ; i < eg_box.size() ; i++)
......@@ -2255,11 +2261,15 @@ public:
for (size_t j = 0; j < eg_box.get(i).bid.size() ; j++)
{
std::cout << " Box: " << eg_box.get(i).bid.get(j).g_e_box.toString() << " Id: " << eg_box.get(i).bid.get(j).g_id << std::endl;
tot_volume += eg_box.get(i).bid.get(j).g_e_box.getVolumeKey();
}
}
std::cout << "TOT volume external ghost " << tot_volume << std::endl;
std::cout << "-------- Internal Ghost boxes ---------- " << std::endl;
tot_volume = 0;
for (size_t i = 0 ; i < ig_box.size() ; i++)
{
std::cout << "Processor: " << ig_box.get(i).prc << " Boxes:" << std::endl;
......@@ -2267,8 +2277,11 @@ public:
for (size_t j = 0 ; j < ig_box.get(i).bid.size() ; j++)
{
std::cout << " Box: " << ig_box.get(i).bid.get(j).box.toString() << " Id: " << ig_box.get(i).bid.get(j).g_id << std::endl;
tot_volume += ig_box.get(i).bid.get(j).box.getVolumeKey();
}
}
std::cout << "TOT volume internal ghost " << tot_volume << std::endl;
}
/*! \brief Set the properties names
......
......@@ -11,7 +11,6 @@
#include "Vector/vector_dist_ofb.hpp"
#include "data_type/scalar.hpp"
/*! \brief Unpack selector
*
*
......@@ -233,6 +232,7 @@ class grid_dist_id_comm
#endif
auto & gd = loc_grid.get(sub_id_dst_gdb_ext);
gd.remove(bx_dst);
gd.copy_to(loc_grid.get(sub_id_src_gdb_ext),bx_src,bx_dst);
}
......@@ -488,6 +488,7 @@ class grid_dist_id_comm
Box<dim,size_t> box = eg_box.get(ei).bid.get(nle_id).l_e_box;
Box<dim,size_t> rbox = eg_box.get(ei).bid.get(nle_id).lr_e_box;
loc_grid.get(n_sub_id).remove(box);
loc_grid.get(n_sub_id).copy_to(loc_grid.get(sub_id),rbox,box);
}
}
......@@ -602,7 +603,6 @@ class grid_dist_id_comm
// sub-grid where to unpack
auto sub2 = loc_grid.get(sub_id).getIterator(box.getKP1(),box.getKP2());
grid_unpack_with_prp<op,prp_object,device_grid,Memory>::template unpacking<decltype(sub2),prp...>(prRecv_prp,sub2,loc_grid.get(sub_id),ps);
}
}
......@@ -654,7 +654,6 @@ class grid_dist_id_comm
// sub-grid where to unpack
auto sub2 = loc_grid.get(sub_id).getIterator(box.getKP1(),box.getKP2());
grid_unpack_with_prp<op,prp_object,device_grid,BHeapMemory>::template unpacking<decltype(sub2),prp...>(mem,sub2,loc_grid.get(sub_id),ps);
}
}
......@@ -718,21 +717,6 @@ public:
}
loc_grid.get(j).copy_to(g,box_src,box_dst);
/* auto it = loc_grid.get(j).getIterator(start,stop);
// Copy selected elements into a local grid
while (it.isNext())
{
auto key = it.get();
std::string str = key.to_string();
grid_key_dx<dim> key2 = key - start;
//std::cout << "Key: " << str << std::endl;
loc_grid.get(j).get_o(key) = g.get_o(key2);
++it;
}*/
}
}
}
......@@ -840,18 +824,6 @@ public:
gr_send.copy_to(gr,box_src,box_dst);
// Copy selected elements into a new sub-grid
/* while (it.isNext())
{
auto key = it.get();
grid_key_dx<dim> key2 = key - start;
std::string str = key.to_string();
gr_send.get_o(key2) = gr.get_o(key);
++it;
}*/
aggregate<device_grid,SpaceBox<dim,long int>> aggr;
aggr.template get<0>() = gr_send;
......
......@@ -1925,5 +1925,209 @@ BOOST_AUTO_TEST_CASE( grid_dist_domain_ghost_put_check )
}
template<typename grid_amr>
void TestXD_ghost_put_create(grid_amr & g_dist_amr, long int k)
{
// check the consistency of the decomposition
bool val = g_dist_amr.getDecomposition().check_consistency();
BOOST_REQUIRE_EQUAL(val,true);
size_t count = 0;
auto dom = g_dist_amr.getGridIterator();
while (dom.isNext())
{
auto key = dom.get_dist();
g_dist_amr.template insert<1>(key) = 1;
// Count the points
count++;
++dom;
}
// Fill the ghost
g_dist_amr.template ghost_get<1>();
// Now we count the ghost point
size_t g_point = 0;
auto itg = g_dist_amr.getDomainGhostIterator();
while (itg.isNext())
{
g_point++;
++itg;
}
{
auto it = g_dist_amr.getDomainIterator();
while (it.isNext())
{
auto p = it.get();
g_dist_amr.remove(p);
g_point--;
++it;
}
}
// A domain iterator should not produce points
{
auto it = g_dist_amr.getDomainIterator();
size_t cnt = 0;
while (it.isNext())
{
cnt++;
++it;
}
BOOST_REQUIRE_EQUAL(cnt,0);
}
g_dist_amr.template ghost_put<add_,1>();
{
auto it = g_dist_amr.getDomainIterator();
bool check = true;
size_t cnt = 0;
while (it.isNext())
{
auto p = it.get();
cnt += g_dist_amr.template get<1>(p);
check &= (g_dist_amr.template get<1>(p) >= 1);
++it;
}
// Sum all the points
auto & v_cl = create_vcluster();
v_cl.sum(g_point);
v_cl.sum(cnt);
v_cl.execute();
BOOST_REQUIRE_EQUAL(g_point,cnt);
BOOST_REQUIRE_EQUAL(check,true);
}
}
BOOST_AUTO_TEST_CASE( grid_dist_domain_ghost_2D_put_create_check )
{
// Test grid periodic
Box<2,float> domain({0.0,0.0},{1.0,1.0});
Vcluster & v_cl = create_vcluster();
if ( v_cl.getProcessingUnits() > 32 )
{return;}
long int k = 13;
BOOST_TEST_CHECKPOINT( "Testing grid periodic k<=" << k );
// grid size
size_t sz[2];
sz[0] = k;
sz[1] = k;
// Ghost
Ghost<2,long int> g(1);
// periodicity
periodicity<2> pr = {{PERIODIC,PERIODIC}};
// Distributed grid with id decomposition
sgrid_dist_id<2, float, aggregate<long int, int>> sg_dist(sz,domain,g,pr);
TestXD_ghost_put_create(sg_dist,k);
k = 7;
sz[0] = k;
sz[1] = k;
// Distributed grid with id decomposition
sgrid_dist_id<2, float, aggregate<long int, int>> sg_dist2(sz,domain,g,pr);
TestXD_ghost_put_create(sg_dist2,k);
k = 23;
sz[0] = k;
sz[1] = k;
// Distributed grid with id decomposition
sgrid_dist_id<2, float, aggregate<long int, int>> sg_dist3(sz,domain,g,pr);
TestXD_ghost_put_create(sg_dist3,k);
}
BOOST_AUTO_TEST_CASE( grid_dist_domain_ghost_3D_put_create_check )
{
// Test grid periodic
Box<3,float> domain({0.0,0.0,0.0},{1.0,1.0,1.0});
Vcluster & v_cl = create_vcluster();
if ( v_cl.getProcessingUnits() > 32 )
{return;}
long int k = 13;
BOOST_TEST_CHECKPOINT( "Testing grid periodic k<=" << k );
// grid size
size_t sz[3];
sz[0] = k;
sz[1] = k;
sz[2] = k;
// Ghost
Ghost<3,long int> g(1);
// periodicity
periodicity<3> pr = {{PERIODIC,PERIODIC,PERIODIC}};
// Distributed grid with id decomposition
sgrid_dist_id<3, float, aggregate<long int, int>> sg_dist(sz,domain,g,pr);
TestXD_ghost_put_create(sg_dist,k);
k = 7;
sz[0] = k;
sz[1] = k;
sz[2] = k;
// Distributed grid with id decomposition
sgrid_dist_id<3, float, aggregate<long int, int>> sg_dist2(sz,domain,g,pr);
TestXD_ghost_put_create(sg_dist2,k);
k = 23;
sz[0] = k;
sz[1] = k;
sz[2] = k;
// Distributed grid with id decomposition
sgrid_dist_id<3, float, aggregate<long int, int>> sg_dist3(sz,domain,g,pr);
TestXD_ghost_put_create(sg_dist3,k);
}
BOOST_AUTO_TEST_SUITE_END()
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