Commit e7888de5 authored by incardon's avatar incardon

Fixing CartDecomposition operator==

parent a5160634
......@@ -116,8 +116,10 @@ private:
//! Runtime virtual cluster machine
Vcluster & v_cl;
//! Cell-list that store the geometrical information of the local internal ghost boxes
CellList<dim,T,FAST> lgeo_cell;
// Smallest subdivision on each direction
::Box<dim,T> ss_box;
::Box<dim,T> bbox;
// Heap memory receiver
HeapMemory hp_recv;
......@@ -254,6 +256,7 @@ private:
}
nn_prcs<dim,T>::create(box_nn_processor, sub_domains);
nn_prcs<dim,T>::refine_ss_box(ss_box);
// fill fine_s structure
// fine_s structure contain the processor id for each sub-sub-domain
......@@ -271,6 +274,16 @@ private:
++it;
}
Initialize_geo_cell_lists();
}
/*! \brief Initialize geo_cell lists
*
*
*
*/
void Initialize_geo_cell_lists()
{
// Get the smallest sub-division on each direction
::Box<dim,T> unit = getSmallestSubdivision();
// Get the processor bounding Box
......@@ -290,7 +303,6 @@ private:
// Initialize the geo_cell structure
ie_ghost<dim,T>::Initialize_geo_cell(domain,div,orig);
lgeo_cell.Initialize(domain,div,orig);
}
/*! \brief Create the subspaces that decompose your domain
......@@ -567,14 +579,49 @@ p1[0]<-----+ +----> p2[0]
// get the smallest sub-domain dimension on each direction
for (size_t i = 0 ; i < dim ; i++)
{
if (ghost.template getLow(i) >= ss_box.getHigh(i) || ghost.template getHigh(i) >= domain.template getHigh(i) / gr.size(i))
if (fabs(ghost.template getLow(i)) >= ss_box.getHigh(i) || ghost.template getHigh(i) >= ss_box.getHigh(i))
{
std::cerr << "Error " << __FILE__ << ":" << __LINE__ << " : Ghost are bigger than one sub-domain" << "\n";
}
}
}
/*! \brief It create anothe object that contain the same information and act in the same way
/*! \brief It create another object that contain the same decomposition information but with different ghost boxes
*
* \param g ghost
*
* \return a duplicated decomposition with different ghost boxes
*
*/
CartDecomposition<dim,T,Memory,Domain> duplicate(Ghost<dim,T> & g)
{
CartDecomposition<dim,T,Memory,Domain> cart(v_cl);
cart.box_nn_processor = box_nn_processor;
cart.sub_domains = sub_domains;
cart.fine_s = fine_s;
cart.gr = gr;
cart.cd = cd;
cart.domain = domain;
std::copy(spacing,spacing+3,cart.spacing);
//! Runtime virtual cluster
cart.v_cl = v_cl;
cart.bbox = bbox;
cart.ss_box = ss_box;
cart.ghost = g;
nn_prcs<dim,T>::create(box_nn_processor, sub_domains);
calculateGhostBoxes();
Initialize_geo_cell_lists();
return cart;
}
/*! \brief It create another object that contain the same information and act in the same way
*
* \return a duplicated decomposition
*
......@@ -598,10 +645,11 @@ p1[0]<-----+ +----> p2[0]
//! Runtime virtual cluster
cart.v_cl = v_cl;
//! Cell-list that store the geometrical information of the local internal ghost boxes
cart.lgeo_cell = lgeo_cell;
cart.ghost = ghost;
cart.bbox = bbox;
cart.ss_box = ss_box;
return cart;
}
......@@ -627,10 +675,11 @@ p1[0]<-----+ +----> p2[0]
//! Runtime virtual cluster
v_cl = cart.v_cl;
//! Cell-list that store the geometrical information of the local internal ghost boxes
lgeo_cell = cart.lgeo_cell;
ghost = cart.ghost;
bbox = cart.bbox;
ss_box = cart.ss_box;
return *this;
}
......@@ -656,10 +705,11 @@ p1[0]<-----+ +----> p2[0]
//! Runtime virtual cluster
v_cl = cart.v_cl;
//! Cell-list that store the geometrical information of the local internal ghost boxes
lgeo_cell.swap(cart.lgeo_cell);
ghost = cart.ghost;
cart.bbox = bbox;
cart.ss_box = ss_box;
return *this;
}
......@@ -687,9 +737,6 @@ p1[0]<-----+ +----> p2[0]
return fine_s.get(cd.getCell(p));
}
// Smallest subdivision on each direction
::Box<dim,T> ss_box;
/*! \brief Get the smallest subdivision of the domain on each direction
*
* \return a box p1 is set to zero
......@@ -816,8 +863,6 @@ p1[0]<-----+ +----> p2[0]
return processorID(pos) == v_cl.getProcessUnitID();
}
::Box<dim,T> bbox;
/*! \brief Return the bounding box containing union of all the sub-domains for the local processor
*
* \return The bounding box
......@@ -926,16 +971,13 @@ p1[0]<-----+ +----> p2[0]
if (gr != cart.gr)
return false;
if (cd != cart.cd)
return false;
if (domain != cart.domain)
return false;
std::copy(cart.spacing,cart.spacing+3,spacing);
if (lgeo_cell != cart.lgeo_cell)
if (meta_compare<T[dim]>::meta_compare_f(cart.spacing,spacing) == false)
return false;
if (ghost != cart.ghost)
......@@ -943,6 +985,42 @@ p1[0]<-----+ +----> p2[0]
return true;
}
/*! \brief Check if the CartDecomposition contain the same information with the exception of the ghost part
* It is anyway required that the ghost come from the same sub-domains decomposition
*
* \param ele Element to check
*
*/
bool is_equal_ng(CartDecomposition<dim,T,Memory,Domain> & cart)
{
static_cast<ie_loc_ghost<dim,T>*>(this)->is_equal_ng(static_cast<ie_loc_ghost<dim,T>&>(cart));
static_cast<nn_prcs<dim,T>*>(this)->is_equal(static_cast<nn_prcs<dim,T>&>(cart));
static_cast<ie_ghost<dim,T>*>(this)->is_equal(static_cast<ie_ghost<dim,T>&>(cart));
if (sub_domains != cart.sub_domains)
return false;
if (box_nn_processor != cart.box_nn_processor)
return false;
if (fine_s != cart.fine_s)
return false;
if (gr != cart.gr)
return false;
if (cd != cart.cd)
return false;
if (domain != cart.domain)
return false;
if (meta_compare<T[dim]>::meta_compare_f(cart.spacing,spacing) == false)
return false;
return true;
}
};
......
......@@ -80,18 +80,28 @@ BOOST_AUTO_TEST_CASE( CartDecomposition_test_use)
CartDecomposition<3,float> dec2 = dec.duplicate();
dec2.check_consistency();
bool ret = dec.is_equal(dec2);
// We check if the two decomposition are equal
BOOST_REQUIRE_EQUAL(dec.is_equal(dec2),true);
BOOST_REQUIRE_EQUAL(ret,true);
// check that dec and dec2 contain the same information
// We duplicate the decomposition redefining the ghost
// Define ghost
Ghost<3,float> g3(0.02);
Ghost<3,float> g3(0.005);
// We duplicate the decomposition refefining the ghost
// CartDecomposition<3,float> dec3 = dec.duplicate(g3);
CartDecomposition<3,float> dec3 = dec.duplicate(g3);
ret = dec3.check_consistency();
BOOST_REQUIRE_EQUAL(ret,true);
// Check that g3 is equal to dec2 with the exception of the ghost part
ret = dec3.is_equal_ng(dec2);
BOOST_REQUIRE_EQUAL(ret,true);
}
BOOST_AUTO_TEST_SUITE_END()
......
......@@ -174,6 +174,29 @@ struct N_box
return * this;
}
/*! \brief Compare two N_box object
*
* \return true if they match
*
*/
bool operator==(const N_box<dim,T> & ele) const
{
if (id != ele.id)
return false;
return bx == ele.bx;
}
/*! \brief Compare two N_box object
*
* \return true if they match
*
*/
bool operator!=(const N_box<dim,T> & ele) const
{
return ! this->operator==(ele);
}
};
// It store all the boxes of the near processors in a linear array
......
......@@ -619,6 +619,61 @@ public:
return false;
}
}
/*! \brief Check if the ie_loc_ghosts contain the same information with the exception of the ghost part
* It is anyway required that the ghost come from the same sub-domains decomposition
*
* \param ele Element to check
*
*/
bool is_equal_ng(ie_ghost<dim,T> & ig)
{
Box<dim,T> & bt;
if (getNEGhostBox() != ig.getNEGhostBox())
return false;
if (getNIGhostBox() != ig.getNIGhostBox())
return false;
for (size_t i = 0 ; i < getNIGhostBox() ; i++)
{
if (getProcessorNIGhost(i) != ig.getProcessorNIGhost(i))
return false;
for (size_t j = 0 ; j < getProcessorNIGhost(i) ; j++)
{
if (getProcessorIGhostBox(i,j).intersect(ig.getProcessorIGhostBox(i,j),bt) == false)
return false;
if (getProcessorIGhostId(i,j).intersect(ig.getProcessorIGhostId(i,j),bt) == false)
return false;
if (getProcessorIGhostSub(i,j) != ig.getProcessorIGhostSub(i,j))
return false;
}
if (getIGhostBox(i) != ig.getIGhostBox(i))
return false;
if (getIGhostBoxProcessor(i) != ig.getIGhostBoxProcessor(i))
return false;
}
for (size_t i = 0 ; i < getNEGhostBox() ; i++)
{
if (getProcessorNEGhost(i) != ig.getProcessorNEGhost(i))
return false;
for (size_t j = 0 ; j < getProcessorNEGhost(i) ; j++)
{
if (getProcessorEGhostBox(i,j).intersect(ig.getProcessorEGhostBox(i,j),bt) == false)
return false;
if (getProcessorEGhostId(i,j),intersect(ig.getProcessorEGhostId(i,j),bt) == false)
return false;
if (getProcessorEGhostSub(i,j) != ig.getProcessorEGhostSub(i,j))
return false;
}
if (getEGhostBox(i) != ig.getEGhostBox(i))
return false;
if (getEGhostBoxProcessor(i).intersect(ig.getEGhostBoxProcessor(i),bt) == false)
return false;
}
}
};
......
......@@ -368,6 +368,52 @@ public:
return true;
}
/*! \brief Check if the ie_loc_ghosts contain the same information
* with the exception of the ghost part
*
* \param ele Element to check
*
*/
bool is_equal_ng(ie_loc_ghost<dim,T> & ilg)
{
Box<dim,T> bt;
if (ilg.loc_ghost_box.size() != loc_ghost_box.size())
return false;
// Explore all the subdomains
for (size_t i = 0 ; i < loc_ghost_box.size() ; i++)
{
if (getLocalNIGhost(i) != ilg.getLocalNIGhost(i))
return false;
if (getLocalNEGhost(i) != ilg.getLocalNEGhost(i))
return false;
for (size_t j = 0 ; j < getLocalNIGhost(i) ; j++)
{
if (getLocalIGhostE(i,j) != ilg.getLocalIGhostE(i,j))
return false;
if (getLocalIGhostBox(i,j).Intersect(ilg.getLocalIGhostBox(i,j),bt) == false)
return false;
if (getLocalIGhostSub(i,j) != ilg.getLocalIGhostSub(i,j))
return false;
}
for (size_t j = 0 ; j < getLocalNEGhost(i) ; j++)
{
if (getLocalEGhostBox(i,j).Intersect(ilg.getLocalEGhostBox(i,j),bt) == false)
return false;
if (getLocalEGhostSub(i,j) != ilg.getLocalEGhostSub(i,j))
return false;
}
}
return true;
}
};
......
......@@ -115,6 +115,23 @@ public:
return *this;
}
/*! \brief Refine the ss_box to have the smallest size on each direction of the local subdomain and adjacent (from other processor) one
*
* \param ss_box box that store the smallest size of the sub-domain
*
*/
void refine_ss_box(Box<dim,T> & ss_box)
{
for (size_t p = 0 ; p < getNNProcessors() ; p++)
{
auto list_p_box = getExternalAdjSubdomain(IDtoProc(p));
// Create the smallest box contained in all sub-domain
for (size_t b = 0 ; b < list_p_box.bx.size() ; b++)
ss_box.contained(list_p_box.bx.get(b));
}
}
/*! \brief Create the list of adjacent processors and the list of adjacent sub-domains
*
* \param box_nn_processors
......@@ -337,19 +354,18 @@ public:
for (size_t p = 0 ; p < getNNProcessors() ; p++)
{
if (getAdjacentSubdomain(p) != np.getAdjacentSubdomain(p))
if (getAdjacentSubdomain(IDtoProc(p)) != np.getAdjacentSubdomain(IDtoProc(p)))
return false;
if (getAdjacentProcessor(p) != np.getAdjacentProcessor(p))
if (getAdjacentProcessor(IDtoProc(p)) != np.getAdjacentProcessor(IDtoProc(p)))
return false;
if (getInternalAdjSubdomain(p) != np.getInternalAdjSubdomain(p))
if (getInternalAdjSubdomain(IDtoProc(p)) != np.getInternalAdjSubdomain(IDtoProc(p)))
return false;
if (getExternalAdjSubdomain(p) != np.getExternalAdjSubdomain(p))
if (getExternalAdjSubdomain(IDtoProc(p)) != np.getExternalAdjSubdomain(IDtoProc(p)))
return false;
}
return true;
}
};
......
......@@ -999,7 +999,7 @@ void Test3D_dup(const Box<3,float> & domain, long int k)
BOOST_REQUIRE_EQUAL(g_dist2->getDecomposition().ref(),1);
BOOST_REQUIRE_EQUAL(g_dist2->getDecomposition().getLocalNEGhost(0) != 0, true);
BOOST_REQUIRE_EQUAL(g_dist2->getDecomposition().check_consistency(),false);
BOOST_REQUIRE_EQUAL(g_dist2->getDecomposition().check_consistency(),true);
}
}
......
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