Commit baf78730 authored by Pietro Incardona's avatar Pietro Incardona

Add pdata

parent 812b8f0b
......@@ -593,7 +593,7 @@ p1[0]<-----+ +----> p2[0]
* \return a duplicated decomposition with different ghost boxes
*
*/
CartDecomposition<dim,T,Memory,Domain> duplicate(Ghost<dim,T> & g)
CartDecomposition<dim,T,Memory,Domain> duplicate(const Ghost<dim,T> & g)
{
CartDecomposition<dim,T,Memory,Domain> cart(v_cl);
......@@ -613,10 +613,10 @@ p1[0]<-----+ +----> p2[0]
cart.ss_box = ss_box;
cart.ghost = g;
nn_prcs<dim,T>::create(box_nn_processor, sub_domains);
cart.create(box_nn_processor, sub_domains);
calculateGhostBoxes();
Initialize_geo_cell_lists();
cart.Initialize_geo_cell_lists();
cart.calculateGhostBoxes();
return cart;
}
......@@ -955,9 +955,14 @@ p1[0]<-----+ +----> p2[0]
*/
bool is_equal(CartDecomposition<dim,T,Memory,Domain> & cart)
{
static_cast<ie_loc_ghost<dim,T>*>(this)->is_equal(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 (static_cast<ie_loc_ghost<dim,T>*>(this)->is_equal(static_cast<ie_loc_ghost<dim,T>&>(cart)) == false)
return false;
if (static_cast<nn_prcs<dim,T>*>(this)->is_equal(static_cast<nn_prcs<dim,T>&>(cart)) == false)
return false;
if (static_cast<ie_ghost<dim,T>*>(this)->is_equal(static_cast<ie_ghost<dim,T>&>(cart)) == false)
return false;
if (sub_domains != cart.sub_domains)
return false;
......@@ -994,9 +999,14 @@ p1[0]<-----+ +----> p2[0]
*/
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 (static_cast<ie_loc_ghost<dim,T>*>(this)->is_equal_ng(static_cast<ie_loc_ghost<dim,T>&>(cart)) == false)
return false;
if (static_cast<nn_prcs<dim,T>*>(this)->is_equal(static_cast<nn_prcs<dim,T>&>(cart)) == false)
return false;
if (static_cast<ie_ghost<dim,T>*>(this)->is_equal_ng(static_cast<ie_ghost<dim,T>&>(cart)) == false)
return false;
if (sub_domains != cart.sub_domains)
return false;
......
......@@ -80,13 +80,12 @@ BOOST_AUTO_TEST_CASE( CartDecomposition_test_use)
CartDecomposition<3,float> dec2 = dec.duplicate();
dec2.check_consistency();
// check that dec and dec2 contain the same information
bool ret = dec.is_equal(dec2);
// We check if the two decomposition are equal
BOOST_REQUIRE_EQUAL(ret,true);
// check that dec and dec2 contain the same information
// We duplicate the decomposition redefining the ghost
// Define ghost
......@@ -98,10 +97,11 @@ BOOST_AUTO_TEST_CASE( CartDecomposition_test_use)
ret = dec3.check_consistency();
BOOST_REQUIRE_EQUAL(ret,true);
// Check that g3 is equal to dec2 with the exception of the ghost part
dec3.write("output_dec3_1.vtk");
// Check that dec3 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()
......
......@@ -626,6 +626,8 @@ public:
return false;
}
}
return true;
}
/*! \brief Check if the ie_loc_ghosts contain the same information with the exception of the ghost part
......@@ -650,14 +652,14 @@ public:
return false;
for (size_t j = 0 ; j < getProcessorNIGhost(i) ; j++)
{
if (getProcessorIGhostBox(i,j).intersect(ig.getProcessorIGhostBox(i,j),bt) == false)
if (getProcessorIGhostBox(i,j).Intersect(ig.getProcessorIGhostBox(i,j),bt) == false)
return false;
if (getProcessorIGhostId(i,j).intersect(ig.getProcessorIGhostId(i,j),bt) == false)
if (getProcessorIGhostId(i,j) != ig.getProcessorIGhostId(i,j))
return false;
if (getProcessorIGhostSub(i,j) != ig.getProcessorIGhostSub(i,j))
return false;
}
if (getIGhostBox(i) != ig.getIGhostBox(i))
if (getIGhostBox(i).Intersect(ig.getIGhostBox(i),bt) == false)
return false;
if (getIGhostBoxProcessor(i) != ig.getIGhostBoxProcessor(i))
return false;
......@@ -669,18 +671,20 @@ public:
return false;
for (size_t j = 0 ; j < getProcessorNEGhost(i) ; j++)
{
if (getProcessorEGhostBox(i,j).intersect(ig.getProcessorEGhostBox(i,j),bt) == false)
if (getProcessorEGhostBox(i,j).Intersect(ig.getProcessorEGhostBox(i,j),bt) == false)
return false;
if (getProcessorEGhostId(i,j),intersect(ig.getProcessorEGhostId(i,j),bt) == false)
if (getProcessorEGhostId(i,j) != ig.getProcessorEGhostId(i,j))
return false;
if (getProcessorEGhostSub(i,j) != ig.getProcessorEGhostSub(i,j))
return false;
}
if (getEGhostBox(i) != ig.getEGhostBox(i))
if (getEGhostBox(i).Intersect(ig.getEGhostBox(i),bt) == false)
return false;
if (getEGhostBoxProcessor(i).intersect(ig.getEGhostBoxProcessor(i),bt) == false)
if (getEGhostBoxProcessor(i) != ig.getEGhostBoxProcessor(i))
return false;
}
return true;
}
};
......
......@@ -487,9 +487,37 @@ public:
// Decomposition used
typedef Decomposition decomposition;
static inline Ghost<dim,float> convert_ghost(const Ghost<dim,long int> & gd,const CellDecomposer_sm<dim,St> & cd_sm)
{
Ghost<dim,float> gc;
// get the grid spacing
Box<dim,St> sp = cd_sm.getCellBox();
// enlarge 0.001 of the spacing
sp.magnify_fix_P1(1.1);
// set the ghost
for (size_t i = 0 ; i < dim ; i++)
{
gc.setLow(i,-sp.getHigh(i));
gc.setHigh(i,sp.getHigh(i));
}
return gc;
}
//! constructor
grid_dist_id(Decomposition & dec, const size_t (& g_sz)[dim], const Box<dim,St> & domain, const Ghost<dim,St> & ghost)
:domain(domain),ghost(ghost),dec(dec),v_cl(*global_v_cluster)
{
InitializeCellDecomposer(g_sz);
InitializeStructures(g_sz);
}
//! constructor
grid_dist_id(Decomposition && dec, const size_t (& g_sz)[dim], const Box<dim,St> & domain, const Ghost<dim,St> & ghost)
:domain(domain),ghost(ghost),dec(dec),v_cl(*global_v_cluster)
{
InitializeCellDecomposer(g_sz);
......@@ -523,18 +551,7 @@ public:
{
InitializeCellDecomposer(g_sz);
// get the grid spacing
Box<dim,St> sp = cd_sm.getCellBox();
// enlarge 0.001 of the spacing
sp.magnify_fix_P1(1.1);
// set the ghost
for (size_t i = 0 ; i < dim ; i++)
{
ghost.setLow(i,-sp.getHigh(i));
ghost.setHigh(i,sp.getHigh(i));
}
ghost = convert_ghost(g,cd_sm);
InitializeDecomposition(g_sz);
// Initialize structures
......@@ -553,18 +570,26 @@ public:
{
InitializeCellDecomposer(g_sz);
// get the grid spacing
Box<dim,St> sp = cd_sm.getCellBox();
ghost = convert_ghost(g,cd_sm);
// enlarge 0.001 of the spacing
sp.magnify_fix_P1(1.1);
InitializeDecomposition(g_sz);
// Initialize structures
InitializeStructures(g_sz);
}
// set the ghost
for (size_t i = 0 ; i < dim ; i++)
{
ghost.setLow(i,-sp.getHigh(i));
ghost.setHigh(i,sp.getHigh(i));
}
/*! \brief Constrcuctor
*
* \param g_sz array with the grid size on each dimension
* \param domain domain where this grid live
* \param g Ghost given in grid units
*
*/
grid_dist_id(Decomposition && dec, const size_t (& g_sz)[dim],const Box<dim,St> & domain, const Ghost<dim,long int> & g)
:domain(domain),dec(dec),v_cl(*global_v_cluster),ginfo(g_sz),ginfo_v(g_sz)
{
InitializeCellDecomposer(g_sz);
ghost = convert_ghost(g,cd_sm);
InitializeDecomposition(g_sz);
// Initialize structures
......
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