Commit d4dd1167 authored by incardon's avatar incardon
Browse files

Fixing check_bound function

parent bd0aaf51
......@@ -164,10 +164,17 @@ BOOST_AUTO_TEST_CASE( copy_grid_test_use)
Test_copy_grid(g3_src,g3_dst,bsrc_3,bdst_3);
#ifdef SE_CLASS1
Box<4,size_t> bsrc_4({4,7,1,3},{11,20,6,6});
Box<4,size_t> bdst_4({20,5,10,13},{27,18,15,16});
Test_copy_grid(g4_src,g4_dst,bsrc_4,bdst_4);
#else
Box<4,size_t> bsrc_4({4,7,1,3},{11,20,6,6});
Box<4,size_t> bdst_4({20,5,10,13},{27,18,15,16});
Test_copy_grid(g4_src,g4_dst,bsrc_4,bdst_4);
#endif
}
///////////
......@@ -206,15 +213,25 @@ BOOST_AUTO_TEST_CASE( copy_grid_test_use)
Test_copy_grid_cmp(g2_src,g2_dst,bsrc_2,bdst_2);
#ifndef SE_CLASS2
Box<3,size_t> bsrc_3({4,7,1},{11,20,6});
Box<3,size_t> bdst_3({20,5,10},{27,18,15});
Test_copy_grid_cmp(g3_src,g3_dst,bsrc_3,bdst_3);
#ifdef SE_CLASS1
Box<4,size_t> bsrc_4({4,7,1,3},{7,14,6,6});
Box<4,size_t> bdst_4({20,5,10,13},{23,12,15,16});
Test_copy_grid_cmp(g4_src,g4_dst,bsrc_4,bdst_4);
#else
Box<4,size_t> bsrc_4({4,7,1,3},{11,20,6,6});
Box<4,size_t> bdst_4({20,5,10,13},{27,18,15,16});
Test_copy_grid_cmp(g4_src,g4_dst,bsrc_4,bdst_4);
#endif
#endif
}
}
......
......@@ -134,6 +134,23 @@ private:
}
}
/*! \brief Check that the key is inside the grid
*
* check if key2 is inside the g grid boundary
*
* \param g grid
* \param key2
*
*/
template<typename Mem> inline void check_bound(const grid_base_impl<dim,T,Mem,layout,layout_base> & g,const size_t & key2) const
{
if (key2 >= g.getGrid().size())
{
std::cerr << "Error " __FILE__ << ":" << __LINE__ <<" grid overflow " << key2 << " >= " << getGrid().size() << "\n";
ACTION_ON_ERROR(GRID_ERROR_OBJECT);
}
}
#endif
public:
......
......@@ -102,9 +102,9 @@ public:
*/
template<typename ...T> inline grid_key_dx(const size_t v,const T...t)
{
#ifdef DEBUG
#ifdef SE_CLASS1
if (sizeof...(t) != dim -1)
std::cerr << "Error grid_key: " << __FILE__ << " " << __LINE__ << " creating a key of dimension " << dim << " require " << dim << " numbers " << sizeof...(t) + 1 << " provided" << "\n";
{std::cerr << "Error grid_key: " << __FILE__ << " " << __LINE__ << " creating a key of dimension " << dim << " require " << dim << " numbers " << sizeof...(t) + 1 << " provided" << "\n";}
#endif
k[dim-1] = v;
invert_assign(t...);
......@@ -395,7 +395,7 @@ public:
*/
void set_d(size_t i, mem_id id)
{
#ifdef DEBUG
#ifdef SE_CLASS1
if (i >= dim)
std::cerr << "grid_key_dx error: " << __FILE__ << " " << __LINE__ << " try to access dimension " << i << " on a grid_key_dx of size " << dim << "\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