Commit 0c66b3b5 authored by incardon's avatar incardon

Several fixes for DLB

parent fd9a74fd
This diff is collapsed.
...@@ -351,11 +351,13 @@ public: ...@@ -351,11 +351,13 @@ public:
for (size_t i = 0; i < dist.getNSubSubDomains(); i++) for (size_t i = 0; i < dist.getNSubSubDomains(); i++)
{ {
dist.setMigrationCost(i, norm * migration * dist.getSubSubDomainComputationCost(i) ); dist.setMigrationCost(i, norm * migration /* * dist.getSubSubDomainComputationCost(i)*/ );
for (size_t s = 0; s < dist.getNSubSubDomainNeighbors(i); s++) for (size_t s = 0; s < dist.getNSubSubDomainNeighbors(i); s++)
{ {
dist.setCommunicationCost(i, s, 1 * dist.getSubSubDomainComputationCost(i) * ts); // We have to remove dist.getSubSubDomainComputationCost(i) otherwise the graph is
// not directed
dist.setCommunicationCost(i, s, 1 /** dist.getSubSubDomainComputationCost(i)*/ * ts);
} }
prev += dist.getNSubSubDomainNeighbors(i); prev += dist.getNSubSubDomainNeighbors(i);
} }
...@@ -1017,6 +1019,8 @@ public: ...@@ -1017,6 +1019,8 @@ public:
createSubdomains(v_cl,bc); createSubdomains(v_cl,bc);
calculateGhostBoxes(); calculateGhostBoxes();
domain_nn_calculator_cart<dim>::reset();
} }
/*! \brief Refine the decomposition, available only for ParMetis distribution, for Metis it is a null call /*! \brief Refine the decomposition, available only for ParMetis distribution, for Metis it is a null call
...@@ -1036,6 +1040,8 @@ public: ...@@ -1036,6 +1040,8 @@ public:
createSubdomains(v_cl,bc); createSubdomains(v_cl,bc);
calculateGhostBoxes(); calculateGhostBoxes();
domain_nn_calculator_cart<dim>::reset();
} }
/*! \brief Refine the decomposition, available only for ParMetis distribution, for Metis it is a null call /*! \brief Refine the decomposition, available only for ParMetis distribution, for Metis it is a null call
......
...@@ -20,6 +20,12 @@ class domain_nn_calculator_cart ...@@ -20,6 +20,12 @@ class domain_nn_calculator_cart
//! True if domain and anomalous domain cells are computed //! True if domain and anomalous domain cells are computed
bool are_domain_anom_computed; bool are_domain_anom_computed;
//! Are linearized the domain cell
bool are_dom_lin;
//! are linearized the anomalous cells
bool are_anom_lin;
//! anomalous cell neighborhood //! anomalous cell neighborhood
openfpm::vector<subsub<dim>> anom; openfpm::vector<subsub<dim>> anom;
...@@ -95,8 +101,16 @@ class domain_nn_calculator_cart ...@@ -95,8 +101,16 @@ class domain_nn_calculator_cart
* *
* *
*/ */
void CalculateDomAndAnomCells(openfpm::vector<subsub<dim>> & sub_keys, openfpm::vector<grid_key_dx<dim>> & dom_subsub, const ::Box<dim,long int> & proc_box, grid_key_dx<dim> & shift, const openfpm::vector<::Box<dim, size_t>> & loc_box) void CalculateDomAndAnomCells(openfpm::vector<subsub<dim>> & sub_keys,
openfpm::vector<grid_key_dx<dim>> & dom_subsub,
const ::Box<dim,long int> & proc_box,
grid_key_dx<dim> & shift,
const openfpm::vector<::Box<dim, size_t>> & loc_box)
{ {
// Reset dom and dom_subsub
sub_keys.clear();
dom_subsub.clear();
size_t sz[dim]; size_t sz[dim];
for (size_t j = 0 ; j < dim ; j++) for (size_t j = 0 ; j < dim ; j++)
...@@ -169,7 +183,7 @@ class domain_nn_calculator_cart ...@@ -169,7 +183,7 @@ class domain_nn_calculator_cart
public: public:
domain_nn_calculator_cart() domain_nn_calculator_cart()
:are_domain_anom_computed(false) :are_domain_anom_computed(false),are_dom_lin(false),are_anom_lin(false)
{} {}
/*! \brief Get the domain Cells /*! \brief Get the domain Cells
...@@ -190,13 +204,15 @@ public: ...@@ -190,13 +204,15 @@ public:
are_domain_anom_computed = true; are_domain_anom_computed = true;
} }
if (shift != shift_calc_dom || gs != gs_calc_dom || dom_lin.size() == 0) if (are_dom_lin == false)
{ {
dom_lin.clear(); dom_lin.clear();
shift_calc_dom = shift; shift_calc_dom = shift;
gs_calc_dom = gs; gs_calc_dom = gs;
for (size_t i = 0 ; i < dom.size() ; i++) for (size_t i = 0 ; i < dom.size() ; i++)
dom_lin.add(gs.LinId(dom.get(i) - cell_shift)); dom_lin.add(gs.LinId(dom.get(i) - cell_shift));
are_dom_lin = true;
} }
return dom_lin; return dom_lin;
...@@ -221,10 +237,7 @@ public: ...@@ -221,10 +237,7 @@ public:
are_domain_anom_computed = true; are_domain_anom_computed = true;
} }
// Convert the list of the neighborhood sub-sub-domains for each sub-sub-domains if (are_anom_lin == false)
// into a linearized sub-sub-domain index. Again we check that this operation has not
// been already executed
if (shift != shift_calc_anom || gs != gs_calc_anom || anom_lin.size() == 0)
{ {
anom_lin.clear(); anom_lin.clear();
shift_calc_anom = shift; shift_calc_anom = shift;
...@@ -257,10 +270,19 @@ public: ...@@ -257,10 +270,19 @@ public:
anom_lin.get(i).NN_subsub.get(self_cell) = tmp; anom_lin.get(i).NN_subsub.get(self_cell) = tmp;
} }
} }
are_anom_lin = true;
} }
return anom_lin; return anom_lin;
} }
void reset()
{
are_domain_anom_computed = false;
are_dom_lin = false;
are_anom_lin = false;
}
}; };
#endif /* SRC_DECOMPOSITION_DOMAIN_NN_CALCULATOR_CART_HPP_ */ #endif /* SRC_DECOMPOSITION_DOMAIN_NN_CALCULATOR_CART_HPP_ */
...@@ -193,6 +193,39 @@ private: ...@@ -193,6 +193,39 @@ private:
return !bx.isContained(pbox); return !bx.isContained(pbox);
} }
template<typename CellList> bool check_cl_reconstruct_sym(const CellList & NN, St r_cut)
{
Box<dim,long int> pbox_prev;
for (size_t i = 0 ; i < dim ; i++)
{
pbox_prev.setLow(i,NN.getStartDomainCell().get(i));
pbox_prev.setHigh(i,NN.getStopDomainCell().get(i));
}
// get the processor bounding box
Box<dim, St> pbox = getDecomposition().getProcessorBounds();
CellDecomposer_sm<dim,St,shift<dim,St>> cd2;
size_t pad = 0;
cl_param_calculateSym(NN.getDomain(),cd2,getDecomposition().getGhost(),r_cut,pad);
CellDecomposer_sm<dim,St,shift<dim,St>> cd3;
NN.setCellDecomposer(cd3,cd2,pbox,pad);
Box<dim,long int> pbox_disc;
for (size_t i = 0 ; i < dim ; i++)
{
pbox_disc.setLow(i,cd3.getStartDomainCell().get(i));
pbox_disc.setHigh(i,cd3.getStopDomainCell().get(i));
}
return !pbox_prev.isContained(pbox_disc);
}
public: public:
//! space type //! space type
...@@ -708,32 +741,121 @@ public: ...@@ -708,32 +741,121 @@ public:
* \param r_cut cut-off radius * \param r_cut cut-off radius
* \param ver Verlet to update * \param ver Verlet to update
* \param r_cut cutoff radius * \param r_cut cutoff radius
* \param opt option like VL_SYMMETRIC and VL_NON_SYMMETRIC * \param opt option like VL_SYMMETRIC and VL_NON_SYMMETRIC or VL_CRS_SYMMETRIC
* *
*/ */
void updateVerlet(VerletList<dim,St,FAST,shift<dim,St> > & ver, St r_cut, size_t opt = VL_NON_SYMMETRIC) void updateVerlet(VerletList<dim,St,FAST,shift<dim,St> > & ver, St r_cut, size_t opt = VL_NON_SYMMETRIC)
{ {
if (opt == VL_CRS_SYMMETRIC) if (opt == VL_SYMMETRIC)
{
auto & NN = ver.getInternalCellList();
// Here we have to check that the Box defined by the Cell-list is the same as the domain box of this
// processor. if it is not like that we have to completely reconstruct from stratch
bool to_reconstruct = check_cl_reconstruct_sym(NN,r_cut);
if (to_reconstruct == false)
ver.update(getDecomposition().getDomain(),r_cut,v_pos,g_m, opt);
else
{
VerletList<dim,St,FAST,shift<dim,St> > ver_tmp;
ver_tmp = getVerlet(r_cut);
ver.swap(ver);
}
}
else if (opt == VL_CRS_SYMMETRIC)
{
auto & NN = ver.getInternalCellList();
// Here we have to check that the Box defined by the Cell-list is the same as the domain box of this
// processor. if it is not like that we have to completely reconstruct from stratch
bool to_reconstruct = check_cl_reconstruct_sym(NN,r_cut);
if (to_reconstruct == false)
{
// Shift
grid_key_dx<dim> cell_shift = NN.getShift();
// Shift
grid_key_dx<dim> shift = NN.getShift();
// Add padding
for (size_t i = 0 ; i < dim ; i++)
shift.set_d(i,shift.get(i) + NN.getPadding(i));
grid_sm<dim,void> gs = NN.getInternalGrid();
ver.updateCrs(getDecomposition().getDomain(),r_cut,v_pos,g_m,getDecomposition().getDomainCells(shift,cell_shift,gs),getDecomposition().getAnomDomainCells(shift,cell_shift,gs));
}
else
{
VerletList<dim,St,FAST,shift<dim,St> > ver_tmp;
ver_tmp = getVerletCrs(r_cut);
ver.swap(ver_tmp);
}
}
else
{ {
// Get the internal cell list
auto & NN = ver.getInternalCellList(); auto & NN = ver.getInternalCellList();
// Shift // Here we have to check that the Box defined by the Cell-list is the same as the domain box of this
grid_key_dx<dim> cell_shift = NN.getShift(); // processor. if it is not like that we have to completely reconstruct from stratch
bool to_reconstruct = check_cl_reconstruct(NN.getDomain(),r_cut);
// Shift if (to_reconstruct == false)
grid_key_dx<dim> shift = NN.getShift(); ver.update(getDecomposition().getDomain(),r_cut,v_pos,g_m, opt);
else
{
VerletList<dim,St,FAST,shift<dim,St> > ver_tmp;
// Add padding ver_tmp = getVerlet(r_cut);
for (size_t i = 0 ; i < dim ; i++) ver.swap(ver_tmp);
shift.set_d(i,shift.get(i) + NN.getPadding(i)); }
}
grid_sm<dim,void> gs = NN.getInternalGrid(); /* // Get the internal cell list
auto & NN = ver.getInternalCellList();
// Here we have to check that the Box defined by the Cell-list is the same as the domain box of this
// processor. if it is not like that we have to completely reconstruct from stratch
bool to_reconstruct = check_cl_reconstruct(NN.getDomain(),r_cut);
if (to_reconstruct == false)
{
if (opt == VL_CRS_SYMMETRIC)
{
// Shift
grid_key_dx<dim> cell_shift = NN.getShift();
ver.updateCrs(getDecomposition().getDomain(),r_cut,v_pos,g_m,getDecomposition().getDomainCells(shift,cell_shift,gs),getDecomposition().getAnomDomainCells(shift,cell_shift,gs)); // Shift
grid_key_dx<dim> shift = NN.getShift();
// Add padding
for (size_t i = 0 ; i < dim ; i++)
shift.set_d(i,shift.get(i) + NN.getPadding(i));
grid_sm<dim,void> gs = NN.getInternalGrid();
ver.updateCrs(getDecomposition().getDomain(),r_cut,v_pos,g_m,getDecomposition().getDomainCells(shift,cell_shift,gs),getDecomposition().getAnomDomainCells(shift,cell_shift,gs));
}
else
ver.update(getDecomposition().getDomain(),r_cut,v_pos,g_m, opt);
} }
else else
ver.update(getDecomposition().getDomain(),r_cut,v_pos,g_m, opt); {
VerletList<dim,St,FAST,shift<dim,St> > ver_tmp;
if (opt == VL_SYMMETRIC)
ver_tmp = getVerletSym(r_cut);
else if (opt == VL_CRS_SYMMETRIC)
ver_tmp = getVerletCrs(r_cut);
else
ver_tmp = getVerlet(r_cut);
ver.swap(ver_tmp);
}*/
} }
/*! \brief for each particle get the verlet list /*! \brief for each particle get the verlet list
......
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