Commit 26d8dfe6 authored by incardon's avatar incardon

Fixing bugs

parent 261069df
......@@ -820,7 +820,7 @@ public:
* \return a sub-grid iterator
*
*/
inline grid_key_dx_iterator_sub<dim> getSubIterator(grid_key_dx<dim> & start, grid_key_dx<dim> & stop) const
inline grid_key_dx_iterator_sub<dim> getSubIterator(const grid_key_dx<dim> & start, const grid_key_dx<dim> & stop) const
{
#ifdef SE_CLASS2
check_valid(this,8);
......
......@@ -676,7 +676,7 @@ public:
* \param stop stop point
*
*/
inline grid_key_dx_iterator_sub<N> getSubIterator(grid_key_dx<N> & start, grid_key_dx<N> & stop) const
inline grid_key_dx_iterator_sub<N> getSubIterator(const grid_key_dx<N> & start, const grid_key_dx<N> & stop) const
{
return grid_key_dx_iterator_sub<N>(*this,start,stop);
}
......
......@@ -181,6 +181,8 @@ void test_stencil_sub_iterator(grid_sm<3,void> & g_sm)
while (gsi.isNext() == true)
{
auto key = gsi.get();
size_t lin1 = gsi.getStencil<0>();
size_t lin2 = gsi.getStencil<1>();
size_t lin3 = gsi.getStencil<2>();
......@@ -200,6 +202,8 @@ void test_stencil_sub_iterator(grid_sm<3,void> & g_sm)
ret &= (sum == 0);
ret &= g_sm.LinId(key) == (long int)lin1;
++gsi;
}
......
......@@ -36,10 +36,6 @@ class grid_key_dx_iterator
//! information of the grid where this iterator iterate
grid_sm<dim,void> grid_base;
//! Additional operation and information in case we do stencil
//! operations
stencil stl_code;
/*! \brief return the index i of the gk key
*
* \param i index to get
......@@ -58,6 +54,10 @@ protected:
//! Actual key
grid_key_dx<dim> gk;
//! Additional operation and information in case we do stencil
//! operations
stencil stl_code;
public:
/*! \brief Default constructor
......
......@@ -401,6 +401,8 @@ public:
size_t id = this->gk.get(0);
this->gk.set_d(0,id+1);
this->stl_code.increment();
//! check the overflow of all the index with exception of the last dimensionality
long int i = 0;
......@@ -412,9 +414,12 @@ public:
{
// ! overflow, increment the next index
size_t idr = this->gk.get(i) - gk_start.get(i);
this->gk.set_d(i,gk_start.get(i));
id = this->gk.get(i+1);
this->gk.set_d(i+1,id+1);
this->stl_code.adjust_offset(i,idr,grid_base);
}
else
{
......
......@@ -1488,44 +1488,75 @@ Box "b" <-----------------+ | | | | | | Grid (7, 6)
return g_box;
}
inline Box<dim,long int> convertDomainSpaceIntoCellUnitsNear(const Box<dim,T> & b_d) const
{
Box<dim,long int> g_box;
Box<dim,T> b = b_d;
b -= getOrig();
// Convert b into grid units
b /= getCellBox().getP2();
/*! \brief Convert a Box from grid units into domain space (Negative contour included, positive contour excluded)
*
* Given the following
*
* \verbatim
// Considering that we are interested in a box decomposition of the space
// where each box does not intersect any other boxes in the decomposition we include the negative
// countour and exclude the positive one. So ceilP1 do the job for P1 while ceilP2 - 1
// do the job for P2
+-----+-----+-----+-----+-----+-----+ (1.0. 1.0) Domain box
| | | | | | |
| | | | | | |
| | | | | | |
+-----+-----+-----+-----+----{2}----+
| | | | | | |
| | | | | | | |
| | | | | | |
+-----+-----+-----+-----+-----+-----+
| | | | | | |
| | | | | | |
| | | | | |
+-----+----{1}----+-----+-----+-----+
| | | | | | |
| | | | | | |
+-----+-----+-----+-----+-----+-----+
| | | | | | |
| | | | | | |
| | | | | | |
+-----+-----+-----+-----+-----+-----+
(0.0, 0.0)
for (size_t i = 0 ; i < dim ; i++)
{
b.setLow(i,b.getLow(i) + 0.125);
b.setHigh(i,b.getHigh(i) + 0.125);
}
b.floorP1();
b.floorP2();
+ = grid points
g_box = b;
\verbatim
// Translate the box by the offset
Giving a box P1 = (2,2), P2 = (5,4)
it return a box (0.333333,0.33333333) (0.8333333,0.8)
*
* \param b Box in grid units
*
* \return the box in domain space
*
*/
inline Box<dim,T> convertCellUnitsIntoDomainSpace(const Box<dim,long int> & b_d) const
{
Box<dim,T> be;
for (size_t i = 0 ; i < dim ; i++)
{
g_box.setLow(i,g_box.getLow(i) + off[i]);
g_box.setHigh(i,g_box.getHigh(i) + off[i]);
}
if ((long int)gr_cell.size(i) - (long int)off[i] == b_d.getLow(i))
be.setLow(i,box.getHigh(i));
else if ((long int)off[i] == b_d.getLow(i))
be.setLow(i,box.getLow(i));
else
be.setLow(i,(b_d.getLow(i) - off[i]) * box_unit.getP2()[i] + box.getLow(i));
if ((long int)gr_cell.size(i) - (long int)off[i] == b_d.getHigh(i))
be.setHigh(i,box.getHigh(i));
else if ((long int)off[i] == b_d.getHigh(i))
be.setHigh(i,box.getLow(i));
else
be.setHigh(i,(b_d.getHigh(i) - off[i]) * box_unit.getP2()[i] + box.getLow(i));
}
return g_box;
return be;
}
/*! \brief Convert a Box in grid units into the domain space (Negative contour included, positive contour excluded)
/*! \brief Convert a Box from grid units into domain space (Negative contour included, positive contour excluded)
*
* Given the following
*
......@@ -1533,18 +1564,19 @@ Box "b" <-----------------+ | | | | | | Grid (7, 6)
+-----+-----+-----+-----+-----+-----+ (1.0. 1.0) Domain box
| | | | | | |
| | | | | | |
| +-----------------+ | | |
+-----+-----+-----+-----+-----+-----+
| | | | | | | | |
Box "b" <-----------------+ | | | | | | Grid (7, 6)
(0.1 , 0.42) | | | | | | | | |
(0.64, 0.85) +-----+-----+-----+-----+-----+-----+
| | | | | | | | |
| | | | | | | | |
| +-----------------+ | | |
+-----+-----+-----+-----+-----+-----+
| | | | | | |
| | *-----------------------* |
| | | | | | | | |
+-----+--|--+-----+-----+----{2}-|--+
| | | | | | | | |
| | | | | | | | |
| | | | | | | | |
+-----+--|--+-----+-----+-----+--|--+
| | | | | | | | |
| | | | | | | | |
| | | | | | | | |
+-----+--|-{1}----+-----+-----+--|--+
| | | | | | | | |
| | *-----------------------* |
| | | | | | |
+-----+-----+-----+-----+-----+-----+
| | | | | | |
......@@ -1558,33 +1590,37 @@ Box "b" <-----------------+ | | | | | | Grid (7, 6)
\verbatim
It return a Box with P1 = (1,3), P2 = (3,4)
Giving a box P1 = (2,2), P2 = (5,4)
it return a box (0.25,0.25) (0.916666,0.9)
*
* \param b Box in grid units
*
* \return Box in domain space, if P2 < P1 the method return an invalid box
* The box is never allowed to be bigger than the domain and is always cropped
* by the domain size
*
* \return the box in domain space
*
*/
inline Box<dim,T> convertCellUnitsIntoDomainSpace(const Box<dim,long int> & b_d) const
inline Box<dim,T> convertCellUnitsIntoDomainSpaceMiddle(const Box<dim,long int> & b_d) const
{
Box<dim,T> be;
for (size_t i = 0 ; i < dim ; i++)
{
if ((long int)gr_cell.size(i) - (long int)off[i] == b_d.getLow(i))
be.setLow(i,box.getHigh(i));
{be.setLow(i,box.getHigh(i));}
else if ((long int)off[i] == b_d.getLow(i))
be.setLow(i,box.getLow(i));
{be.setLow(i,box.getLow(i));}
else
be.setLow(i,(b_d.getLow(i) - off[i]) * box_unit.getP2()[i] + box.getLow(i));
{be.setLow(i,(b_d.getLow(i) - off[i]) * box_unit.getP2()[i] + box.getLow(i) - box_unit.getP2()[i] / 2.0);}
if ((long int)gr_cell.size(i) - (long int)off[i] == b_d.getHigh(i))
be.setHigh(i,box.getHigh(i));
{be.setHigh(i,box.getHigh(i));}
else if ((long int)off[i] == b_d.getHigh(i))
be.setHigh(i,box.getLow(i));
{be.setHigh(i,box.getLow(i));}
else
be.setHigh(i,(b_d.getHigh(i) - off[i]) * box_unit.getP2()[i] + box.getLow(i));
{be.setHigh(i,(b_d.getHigh(i) - off[i]) * box_unit.getP2()[i] + box.getLow(i) + box_unit.getP2()[i] / 2.0);}
}
return be;
......
......@@ -120,7 +120,7 @@ public:
*/
template<typename Mem> bool Intersect(const encapc<1,Box<dim,T>,Mem> & e_b, Box<dim,T> & b_out) const
{
return Intersect(e_b,b_out);
return Intersect(Box<dim,T>(e_b),b_out);
}
/*!
......
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