Commit 0b85159a authored by incardon's avatar incardon
Browse files

Fixing data

parent 285463e5
......@@ -357,6 +357,7 @@ class CellDecomposer_sm
return id;
}
/*! \brief Convert the coordinates into id
*
* \param x point
......@@ -416,49 +417,31 @@ class CellDecomposer_sm
return cell_id;
}
template<typename Ele> inline size_t getCellPad_impl(const Ele & pos) const
{
check_and_print_error(pos,0);
size_t cell_id = ConvertToID(pos,0);
cell_id = (cell_id == off[0])?off[0]-1:cell_id;
cell_id = (cell_id == gr_cell2.size(0) - off[0] - 1)?gr_cell2.size(0) - off[0]:cell_id;
for (size_t s = 1 ; s < dim ; s++)
{
check_and_print_error(pos,s);
size_t cell_idt = ConvertToID(pos,s);
cell_idt = (cell_idt == off[s])?off[s]-1:cell_idt;
cell_idt = (cell_idt == gr_cell2.size(s) - off[s] - 1)?gr_cell2.size(s) - off[s]:cell_idt;
cell_id += gr_cell2.size_s(s-1) * cell_idt;
}
return cell_id;
}
protected:
// Total number of cell
//! Total number of cell
size_t tot_n_cell;
// Domain of the cell list
//! Domain of the cell list
SpaceBox<dim,T> box;
// Unit box of the Cell list
//! Unit box of the Cell list
SpaceBox<dim,T> box_unit;
// Grid structure of the Cell list
//! Grid structure of the Cell list
grid_sm<dim,void> gr_cell;
// Grid structure of the internal Cell list
//! Grid structure of the internal Cell list
grid_sm<dim,void> gr_cell2;
// cell padding on each dimension
//! Box in continuum for the gr_cell2
Box<dim,T> box_gr_cell2;
//! cell padding on each dimension
size_t off[dim];
// cell_shift
//! cell_shift
Point<dim,long int> cell_shift;
......@@ -717,38 +700,6 @@ public:
return getCellDom_impl<T[dim]>(pos);
}
/*! \brief Get the cell-id enforcing that is from a padding cell
*
* Convert the point coordinates into the cell id
*
* \note this function is in general used to bypass round-off error
*
* \param pos Point position
*
* \return the cell-id
*
*/
inline size_t getCellPad(const Point<dim,T> & pos) const
{
return getCellPad_impl<Point<dim,T>>(pos);
}
/*! \brief Get the cell-id enforcing that is from a padding cell
*
* Convert the point coordinates into the cell id
*
* \note this function is in general used to bypass round-off error
*
* \param pos Point position
*
* \return the cell-id
*
*/
inline size_t getCellPad(const T (& pos)[dim]) const
{
return getCellPad_impl<T[dim]>(pos);
}
/*! \brief Get the cell-id
*
* Convert the point coordinates into the cell id
......@@ -943,6 +894,15 @@ public:
Initialize(pad,div);
// calculate the box for gr_cell2
Box<dim,T> box_gr_cell2;
for (size_t i = 0 ; i < dim ; i++)
{
box_gr_cell2.setLow(i,cell_shift.get(i) * box_unit.getHigh(i));
box_gr_cell2.setHigh(i,(cell_shift.get(i) + div2[i]) * box_unit.getHigh(i));
}
size_t cells[dim];
for (size_t i = 0 ; i < dim ; i++)
......
......@@ -172,10 +172,8 @@ BOOST_AUTO_TEST_CASE( CellDecomposer_use )
{
CellDecomposer_sm<3,double> cd(box,div,1);
size_t cell_cor_dom = cd.getCellDom(Point<3,double>({-0.000001,-0.000001,-0.000001}));
size_t cell_cor_pad = cd.getCellPad(Point<3,double>({0.000001,0.000001,0.000001}));
size_t cell_not_cor_pad1 = cd.getCell(Point<3,double>({-0.000001,-0.000001,-0.000001}));
size_t cell_not_cor_pad2 = cd.getCell(Point<3,double>({0.000001,0.000001,0.000001}));
BOOST_REQUIRE_EQUAL(cell_cor_pad,0ul);
BOOST_REQUIRE_EQUAL(cell_cor_dom,(size_t)(1*18*18 + 1*18 + 1));
BOOST_REQUIRE_EQUAL(cell_not_cor_pad1,0ul);
BOOST_REQUIRE_EQUAL(cell_not_cor_pad2,(size_t)(1*18*18 + 1*18 + 1));
......
......@@ -805,44 +805,6 @@ public:
addCell(cell_id,ele);
}
/*! \brief Add an element in the cell list forcing to be in the padding cells
*
* \warning careful is intended to be used ONLY to avoid round-off problems
*
* \param pos array that contain the coordinate
* \param ele element to store
*
*/
inline void addPad(const T (& pos)[dim], typename base::value_type ele)
{
// calculate the Cell id
size_t cell_id = this->getCellPad(pos);
// add the element to the cell
addCell(cell_id,ele);
}
/*! \brief Add an element in the cell list forcing to be in the padding cells
*
* \warning careful is intended to be used ONLY to avoid round-off problems
*
* \param pos array that contain the coordinate
* \param ele element to store
*
*/
inline void addPad(const Point<dim,T> & pos, typename base::value_type ele)
{
// calculate the Cell id
size_t cell_id = this->getCellPad(pos);
// add the element to the cell
addCell(cell_id,ele);
}
/*! \brief remove an element from the cell
*
* \param cell cell id
......
......@@ -54,7 +54,7 @@ template<unsigned int dim, typename T, typename CellList> void populate_cell_lis
for (size_t i = g_m; i < pos.size() ; i++)
{
cli.addPad(pos.get(i), i);
cli.add(pos.get(i), i);
}
}
......
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