Commit 55e4c00a authored by incardon's avatar incardon

Fixing distributed grid

parent bcacb98e
......@@ -374,6 +374,19 @@ class grid_dist_id
}
}
/*! \brief Check the the grid has valid size
*
* Distributed grids with size < 2 on each dimension are not supported
*
*/
inline void check_size(const size_t (& g_sz)[dim])
{
for (size_t i = 0 ; i < dim ; i++)
{
if (g_sz[i] < 2)
std::cerr << "Error: " << __FILE__ << ":" << __LINE__ << " distrobuted grids with size smaller than 2 are not supported\n";
}
}
public:
......@@ -381,6 +394,8 @@ public:
grid_dist_id(Vcluster v_cl, Decomposition & dec, const size_t (& g_sz)[dim], const Box<dim,St> & domain, const Ghost<dim,T> & ghost)
:domain(domain),ghost(ghost),loc_grid(NULL),v_cl(v_cl),dec(dec)
{
check_size(g_sz);
// For a 5x5 grid you have 4x4 Cell
size_t c_g[dim];
for (size_t i = 0 ; i < dim ; i++) {c_g[i] = g_sz[i]-1;}
......@@ -421,9 +436,12 @@ public:
grid_dist_id(const size_t (& g_sz)[dim],const Box<dim,St> & domain, const Ghost<dim,St> & g)
:domain(domain),ghost(g),dec(Decomposition(*global_v_cluster)),v_cl(*global_v_cluster)
{
// check that the grid has valid size
check_size(g_sz);
// For a 5x5 grid you have 4x4 Cell
size_t c_g[dim];
for (size_t i = 0 ; i < dim ; i++) {c_g[i] = g_sz[i]-1;}
for (size_t i = 0 ; i < dim ; i++) {c_g[i] = (g_sz[i]-1 > 0)?(g_sz[i]-1):1;}
// Initialize the cell decomposer
cd_sm.setDimensions(domain,c_g,0);
......
......@@ -96,6 +96,21 @@ class grid_dist_iterator<dim,device_grid,FREE>
//! margin of the grid iterator
size_t m;
/*! \brief from g_c increment g_c until you find a valid grid
*
*/
void selectValidGrid()
{
// When the grid has size 0 potentially all the other informations are garbage
while (g_c < gList.size() && (gList[g_c].size() == 0 || gdb_ext.get(g_c).Dbox.isValid() == false ) ) g_c++;
// get the next grid iterator
if (g_c < gList.size())
{
a_it.reinitialize(gList[g_c].getIterator(gdb_ext.get(g_c).Dbox.getKP1(),gdb_ext.get(g_c).Dbox.getKP2()));
}
}
public:
/*! \brief Constructor of the distributed grid
......@@ -108,7 +123,7 @@ class grid_dist_iterator<dim,device_grid,FREE>
{
// Initialize the current iterator
// with the first grid
a_it.reinitialize(gList[0].getIterator(gdb_ext.get(0).Dbox.getKP1(),gdb_ext.get(0).Dbox.getKP2()));
selectValidGrid();
}
// Destructor
......@@ -135,14 +150,7 @@ class grid_dist_iterator<dim,device_grid,FREE>
// switch to the new grid
g_c++;
// When the grid has size 0 potentially all the other informations are garbage
while (g_c < gList.size() && (gList[g_c].size() == 0 || gdb_ext.get(g_c).Dbox.isValid() == false ) ) g_c++;
// get the next grid iterator
if (g_c < gList.size())
{
a_it.reinitialize(gList[g_c].getIterator(gdb_ext.get(g_c).Dbox.getKP1(),gdb_ext.get(g_c).Dbox.getKP2()));
}
selectValidGrid();
}
return *this;
......@@ -239,7 +247,7 @@ class grid_dist_iterator<dim,device_grid,FIXED>
g_c++;
// When the grid has size 0 potentially all the other informations are garbage
while (g_c < gList.size() && gList[g_c].size() == 0 ) g_c++;
while (g_c < gList.size() && gdb_ext.get(g_c).Dbox.getVolumeKey() == 0 ) g_c++;
// get the next grid iterator
if (g_c < gList.size())
......
......@@ -40,7 +40,7 @@ BOOST_AUTO_TEST_CASE( grid_dist_id_domain_grid_unit_converter_test)
// Test several grid dimensions
for (size_t k = 1024 ; k >= 1 ; k--)
for (size_t k = 1024 ; k >= 2 ; k--)
{
std::cout << "Testing: " << k << "\n";
......@@ -94,7 +94,7 @@ BOOST_AUTO_TEST_CASE( grid_dist_id_iterator_test_use)
// Initialize the global VCluster
init_global_v_cluster(&boost::unit_test::framework::master_test_suite().argc,&boost::unit_test::framework::master_test_suite().argv);
for (long int k = 1024 ; k >= 1 ; k-= (k >= 66)?33:1 )
for (long int k = 8 ; k >= 2 ; k-= (k >= 66)?33:1 )
{
std::cout << "Testing: " << k << "\n";
......
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