Commit 135d62cb authored by incardon's avatar incardon

Merge branch 'Release_0.9.0' into benchmark_paper

parents 8e034914 3eed4d7c
...@@ -1013,6 +1013,7 @@ public: ...@@ -1013,6 +1013,7 @@ public:
calculateGhostBoxes(); calculateGhostBoxes();
domain_nn_calculator_cart<dim>::reset(); domain_nn_calculator_cart<dim>::reset();
domain_nn_calculator_cart<dim>::setParameters(proc_box);
} }
/*! \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
...@@ -1034,6 +1035,7 @@ public: ...@@ -1034,6 +1035,7 @@ public:
calculateGhostBoxes(); calculateGhostBoxes();
domain_nn_calculator_cart<dim>::reset(); domain_nn_calculator_cart<dim>::reset();
domain_nn_calculator_cart<dim>::setParameters(proc_box);
} }
/*! \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
...@@ -1055,6 +1057,7 @@ public: ...@@ -1055,6 +1057,7 @@ public:
calculateGhostBoxes(); calculateGhostBoxes();
domain_nn_calculator_cart<dim>::reset(); domain_nn_calculator_cart<dim>::reset();
domain_nn_calculator_cart<dim>::setParameters(proc_box);
} }
/*! \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
...@@ -1283,9 +1286,9 @@ public: ...@@ -1283,9 +1286,9 @@ public:
* \param gs grid extension * \param gs grid extension
* *
*/ */
openfpm::vector<size_t> & getDomainCells(grid_key_dx<dim> & shift, grid_key_dx<dim> & cell_shift, grid_sm<dim,void> & gs) openfpm::vector<size_t> & getDomainCells()
{ {
return domain_nn_calculator_cart<dim>::getDomainCells(shift,cell_shift,gs,proc_box,loc_box); return domain_nn_calculator_cart<dim>::getDomainCells();
} }
/*! \brief Get the CRS domain Cells /*! \brief Get the CRS domain Cells
...@@ -1296,11 +1299,23 @@ public: ...@@ -1296,11 +1299,23 @@ public:
* \param shift Cell padding * \param shift Cell padding
* \param cell_shift where the domain cell start * \param cell_shift where the domain cell start
* \param gs grid extension * \param gs grid extension
* \param loc_box processor sub-domains
* *
*/ */
openfpm::vector<size_t> & getCRSDomainCells(grid_key_dx<dim> & shift, grid_key_dx<dim> & cell_shift, grid_sm<dim,void> & gs) openfpm::vector<size_t> & getCRSDomainCells()
{ {
return domain_nn_calculator_cart<dim>::getCRSDomainCells(shift,cell_shift,gs,proc_box,loc_box); return domain_nn_calculator_cart<dim>::getCRSDomainCells();
}
/*! \brief set NN parameters to calculate cell-list neighborhood
*
* \param shift to apply in cell linearization
* \param gs cell grid
*
*/
void setNNParameters(grid_key_dx<dim> & shift, grid_sm<dim,void> & gs)
{
domain_nn_calculator_cart<dim>::setNNParameters(loc_box, shift, gs);
} }
/*! \brief Get the CRS anomalous cells /*! \brief Get the CRS anomalous cells
...@@ -1316,9 +1331,9 @@ public: ...@@ -1316,9 +1331,9 @@ public:
* \return the anomalous cells with neighborhood * \return the anomalous cells with neighborhood
* *
*/ */
openfpm::vector<subsub_lin<dim>> & getCRSAnomDomainCells(grid_key_dx<dim> & shift, grid_key_dx<dim> & cell_shift, grid_sm<dim,void> & gs) openfpm::vector<subsub_lin<dim>> & getCRSAnomDomainCells()
{ {
return domain_nn_calculator_cart<dim>::getCRSAnomDomainCells(shift,cell_shift,gs,proc_box,loc_box); return domain_nn_calculator_cart<dim>::getCRSAnomDomainCells();
} }
/*! \brief Check if the particle is local considering boundary conditions /*! \brief Check if the particle is local considering boundary conditions
......
...@@ -8,6 +8,9 @@ ...@@ -8,6 +8,9 @@
#ifndef SRC_DECOMPOSITION_DOMAIN_NN_CALCULATOR_CART_HPP_ #ifndef SRC_DECOMPOSITION_DOMAIN_NN_CALCULATOR_CART_HPP_
#define SRC_DECOMPOSITION_DOMAIN_NN_CALCULATOR_CART_HPP_ #define SRC_DECOMPOSITION_DOMAIN_NN_CALCULATOR_CART_HPP_
#include <Vector/map_vector.hpp>
#include "NN/CellList/ParticleItCRS_Cells.hpp"
/*! \brief This class calculate processor domains and neighborhood /*! \brief This class calculate processor domains and neighborhood
* of each processor domain * of each processor domain
* *
...@@ -20,49 +23,39 @@ class domain_nn_calculator_cart ...@@ -20,49 +23,39 @@ 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 cells /////////////////////////////// CRS //////////////////////
bool are_dom_cells_lin;
//! Are linearized the CRS domain cell
bool are_dom_lin;
//! are linearized the CRS anomalous cells
bool are_anom_lin;
//! anomalous cell neighborhood for CRS //! anomalous cell neighborhood for CRS
openfpm::vector<subsub<dim>> anom; openfpm::vector<subsub<dim>> anom;
//! Set of anomalous CRS domain cells linearized
openfpm::vector<subsub_lin<dim>> anom_lin;
//! Set of normal domain cells for CRS //! Set of normal domain cells for CRS
openfpm::vector<grid_key_dx<dim>> dom; openfpm::vector<grid_key_dx<dim>> dom;
//! Set of domain cells
openfpm::vector<grid_key_dx<dim>> dom_cells;
//! Linearization is calculated out of a shift and grid dimension this is the shift
grid_key_dx<dim> shift_calc_dom;
//! Linearization is calculated out of a grid dimensions this is the grid dimension
grid_sm<dim,void> gs_calc_dom;
//! Linearization is calculated out of a shift and grid dimension this is the shift
grid_key_dx<dim> shift_calc_anom;
//! Linearization is calculated out of a grid dimensions this is the grid dimension
grid_sm<dim,void> gs_calc_anom;
//! Set of normal CRS domain cells linearized //! Set of normal CRS domain cells linearized
openfpm::vector<size_t> dom_lin; openfpm::vector<size_t> dom_lin;
//! Set of anomalous CRS domain cells linearized ////////////////////////////////// DOMAIN CELLS ///////////////////////
openfpm::vector<subsub_lin<dim>> anom_lin;
//! Set of domain cells
openfpm::vector<grid_key_dx<dim>> dom_cells;
//! Set of linearized domain cells //! Set of linearized domain cells
openfpm::vector<size_t> dom_cells_lin; openfpm::vector<size_t> dom_cells_lin;
//////////////////////////////////////////////////////////////
//! Processor box //! Processor box
Box<dim,long int> proc_box; Box<dim,long int> proc_box;
//! Processor cells-grid
grid_sm<dim,void> gs;
//! key with all coordinates set to one
grid_key_dx<dim> one;
/*! \brief Calculate the subdomain that are in the skin part of the domain /*! \brief Calculate the subdomain that are in the skin part of the domain
* *
\verbatim \verbatim
...@@ -114,7 +107,6 @@ class domain_nn_calculator_cart ...@@ -114,7 +107,6 @@ class domain_nn_calculator_cart
openfpm::vector<grid_key_dx<dim>> & dom_subsub, openfpm::vector<grid_key_dx<dim>> & dom_subsub,
openfpm::vector<grid_key_dx<dim>> & dom_cells, openfpm::vector<grid_key_dx<dim>> & dom_cells,
const ::Box<dim,long int> & proc_box, const ::Box<dim,long int> & proc_box,
grid_key_dx<dim> & shift,
const openfpm::vector<::Box<dim, size_t>> & loc_box) const openfpm::vector<::Box<dim, size_t>> & loc_box)
{ {
// Reset dom and dom_subsub // Reset dom and dom_subsub
...@@ -123,13 +115,21 @@ class domain_nn_calculator_cart ...@@ -123,13 +115,21 @@ class domain_nn_calculator_cart
size_t sz[dim]; size_t sz[dim];
// ----Grid size = proc_box.getHigh(j) - proc_box.getLow(j)
// +2 is padding
for (size_t j = 0 ; j < dim ; j++) for (size_t j = 0 ; j < dim ; j++)
sz[j] = proc_box.getHigh(j) - proc_box.getLow(j) + 2; sz[j] = proc_box.getHigh(j) - proc_box.getLow(j) + 2 + 1;
gs.setDimensions(sz);
// Set the grid // Set the grid
grid_cpu<dim, aggregate<openfpm::vector<grid_key_dx<dim>>> > g(sz); grid_cpu<dim, aggregate<openfpm::vector<grid_key_dx<dim>> >> g(sz);
g.setMemory(); g.setMemory();
for (size_t i = 0 ; i < dim ; i++)
one.set_d(i,1);
// Calculate the csr neighborhood // Calculate the csr neighborhood
openfpm::vector<std::pair<grid_key_dx<dim>,grid_key_dx<dim>>> csr; openfpm::vector<std::pair<grid_key_dx<dim>,grid_key_dx<dim>>> csr;
NNcalc_csr(csr); NNcalc_csr(csr);
...@@ -142,8 +142,8 @@ class domain_nn_calculator_cart ...@@ -142,8 +142,8 @@ class domain_nn_calculator_cart
for (size_t j = 0 ; j < dim ; j++) for (size_t j = 0 ; j < dim ; j++)
{ {
start.set_d(j,loc_box.template get<0>(i)[j] - proc_box.getLow(j)); start.set_d(j,loc_box.template get<0>(i)[j] - proc_box.getLow(j) + 1);
stop.set_d(j,loc_box.template get<1>(i)[j] - proc_box.getLow(j)); stop.set_d(j,loc_box.template get<1>(i)[j] - proc_box.getLow(j) + 1);
} }
grid_key_dx_iterator_sub<dim> sub(g.getGrid(),start,stop); grid_key_dx_iterator_sub<dim> sub(g.getGrid(),start,stop);
...@@ -156,10 +156,10 @@ class domain_nn_calculator_cart ...@@ -156,10 +156,10 @@ class domain_nn_calculator_cart
{ {
grid_key_dx<dim> src = key + csr.get(j).first; grid_key_dx<dim> src = key + csr.get(j).first;
grid_key_dx<dim> dst = key + csr.get(j).second; grid_key_dx<dim> dst = key + csr.get(j).second;
g.template get<0>(src).add(dst + shift); g.template get<0>(src).add(dst);
} }
dom_cells.add(key + shift); dom_cells.add(key - one);
++sub; ++sub;
} }
...@@ -178,152 +178,154 @@ class domain_nn_calculator_cart ...@@ -178,152 +178,154 @@ class domain_nn_calculator_cart
if (g.template get<0>(key).size() == openfpm::math::pow(3,dim)/2+1) if (g.template get<0>(key).size() == openfpm::math::pow(3,dim)/2+1)
{ {
// Add in the list of the normal neighborhood list // Add in the list of the normal neighborhood list
dom_subsub.add(key + shift); dom_subsub.add(key - one);
} }
else if (g.template get<0>(key).size() != 0) else if (g.template get<0>(key).size() != 0)
{ {
sub_keys.add(); sub_keys.add();
sub_keys.last().subsub = key + shift; sub_keys.last().subsub = key - one;
// Adding the neighborhood of the cell // Adding the neighborhood of the cell
sub_keys.last().NN_subsub = g.template get<0>(key);
sub_keys.last().NN_subsub.resize(g.template get<0>(key).size());
for (size_t i = 0 ; i < g.template get<0>(key).size() ; i++)
sub_keys.last().NN_subsub.get(i) = g.template get<0>(key).get(i) - one;
} }
++it; ++it;
} }
} }
/*! \brief Linearize the sub-sub-domains
*
* \param anon set of grid keys to linearize
* \param anom_lin linearized output
* \param shift shifting
*
*/
void linearize_subsub(const openfpm::vector<subsub<dim>> & anom,
openfpm::vector<subsub_lin<dim>> & anom_lin,
const grid_key_dx<dim> & shift,
const grid_sm<dim,void> & gs)
{
anom_lin.clear();
for (size_t i = 0 ; i < anom.size() ; i++)
{
anom_lin.add();
anom_lin.last().subsub = gs.LinId(anom.get(i).subsub + shift);
long int self_cell = -1;
for (size_t j = 0 ; j < anom.get(i).NN_subsub.size() ; j++)
{
anom_lin.get(i).NN_subsub.add((long int)gs.LinId(anom.get(i).NN_subsub.get(j) + shift) - anom_lin.get(i).subsub);
// This indicate that for example in the neighborhood of one cell it-self is included in the list
// For example the cell 100 is in the neighborhood of the cell 100
if (anom_lin.get(i).NN_subsub.last() == 0)
self_cell = anom_lin.get(i).NN_subsub.size() - 1;
}
// if exist the self interacting cell (Example cell 100 neighborhood of cell 100), this cell MUST BE ALWAYS at the beginning
if (self_cell != -1)
{
// bring the self-cell into the beginning
size_t tmp = anom_lin.get(i).NN_subsub.get(0);
anom_lin.get(i).NN_subsub.get(0) = 0;
anom_lin.get(i).NN_subsub.get(self_cell) = tmp;
}
}
}
public: public:
domain_nn_calculator_cart() domain_nn_calculator_cart()
:are_domain_anom_computed(false),are_dom_cells_lin(false),are_dom_lin(false),are_anom_lin(false) :are_domain_anom_computed(false)
{} {
}
/*! \brief Get the domain Cells /*! \brief Set parameters to calculate the cell neighborhood
* *
* \param shift Shifting point * \param proc_box processor cells box
* \param gs grid extension
* \param proc_box processor bounding box
* \param loc_box set of local sub-domains
* *
* \return The set of domain cells */
void setParameters(const Box<dim,long int> & proc_box)
{
this->proc_box = proc_box;
}
/*! \brief Set parameters to calculate the cell neighborhood
*
* \param shift to apply in the linearization
* \param loc_box set of local sub-domains
* *
*/ */
openfpm::vector<size_t> & getDomainCells(grid_key_dx<dim> & shift, grid_key_dx<dim> & cell_shift, grid_sm<dim,void> & gs, Box<dim,size_t> & proc_box, openfpm::vector<::Box<dim, size_t>> & loc_box) void setNNParameters(openfpm::vector<::Box<dim, size_t>> & loc_box,
const grid_key_dx<dim> & shift,
const grid_sm<dim,void> & gs)
{ {
if (are_domain_anom_computed == false) if (are_domain_anom_computed == false)
{ {
CalculateDomAndAnomCells(anom,dom,dom_cells,proc_box,shift,loc_box); CalculateDomAndAnomCells(anom,dom,dom_cells,proc_box,loc_box);
are_domain_anom_computed = true; are_domain_anom_computed = true;
}
if (are_dom_cells_lin == false)
{
dom_cells_lin.clear(); dom_cells_lin.clear();
shift_calc_dom = shift;
gs_calc_dom = gs;
for (size_t i = 0 ; i < dom_cells.size() ; i++) for (size_t i = 0 ; i < dom_cells.size() ; i++)
dom_cells_lin.add(gs.LinId(dom_cells.get(i) - cell_shift)); dom_cells_lin.add(gs.LinId(dom_cells.get(i) + shift));
are_dom_cells_lin = true;
dom_lin.clear();
for (size_t i = 0 ; i < dom.size() ; i++)
dom_lin.add(gs.LinId(dom.get(i) + shift));
linearize_subsub(anom,anom_lin,shift,gs);
} }
}
/*! \brief Get the domain Cells
*
* \param loc_box set of local sub-domains
*
* \return The set of domain cells
*
*/
openfpm::vector<size_t> & getDomainCells()
{
return dom_cells_lin; return dom_cells_lin;
} }
/*! \brief Get the domain Cells /*! \brief Get the domain Cells
* *
* \param shift Shifting point
* \param gs grid extension
* \param proc_box processor bounding box
* \param loc_box set of local sub-domains * \param loc_box set of local sub-domains
* *
* \return The set of domain cells * \return The set of domain cells
* *
*/ */
openfpm::vector<size_t> & getCRSDomainCells(grid_key_dx<dim> & shift, grid_key_dx<dim> & cell_shift, grid_sm<dim,void> & gs, Box<dim,size_t> & proc_box, openfpm::vector<::Box<dim, size_t>> & loc_box) openfpm::vector<size_t> & getCRSDomainCells()
{ {
if (are_domain_anom_computed == false)
{
CalculateDomAndAnomCells(anom,dom,dom_cells,proc_box,shift,loc_box);
are_domain_anom_computed = true;
}
if (are_dom_lin == false)
{
dom_lin.clear();
shift_calc_dom = shift;
gs_calc_dom = gs;
for (size_t i = 0 ; i < dom.size() ; i++)
dom_lin.add(gs.LinId(dom.get(i) - cell_shift));
are_dom_lin = true;
}
return dom_lin; return dom_lin;
} }
/*! \brief Get the domain anomalous cells /*! \brief Get the domain anomalous cells
* *
* \param shift Shifting point
* \param gs grid extension
* \param proc_box processor bounding box
* \param loc_box set of local sub-domains * \param loc_box set of local sub-domains
* *
* \return The set of anomalous cells * \return The set of anomalous cells
* *
*/ */
openfpm::vector<subsub_lin<dim>> & getCRSAnomDomainCells(grid_key_dx<dim> & shift, grid_key_dx<dim> & cell_shift, grid_sm<dim,void> & gs, Box<dim,size_t> & proc_box, openfpm::vector<::Box<dim, size_t>> & loc_box) openfpm::vector<subsub_lin<dim>> & getCRSAnomDomainCells()
{ {
// if the neighborhood of each sub-sub-domains has not been calculated, calculate it
if (are_domain_anom_computed == false)
{
CalculateDomAndAnomCells(anom,dom,dom_cells,proc_box,shift,loc_box);
are_domain_anom_computed = true;
}
if (are_anom_lin == false)
{
anom_lin.clear();
shift_calc_anom = shift;
gs_calc_anom = gs;
for (size_t i = 0 ; i < anom.size() ; i++)
{
anom_lin.add();
anom_lin.last().subsub = gs.LinId(anom.get(i).subsub - cell_shift);
long int self_cell = -1;
for (size_t j = 0 ; j < anom.get(i).NN_subsub.size() ; j++)
{
anom_lin.get(i).NN_subsub.add((long int)gs.LinId(anom.get(i).NN_subsub.get(j) - cell_shift) - anom_lin.get(i).subsub);
// This indicate that for example in the neighborhood of one cell it-self is included in the list
// For example the cell 100 is in the neighborhood of the cell 100
if (anom_lin.get(i).NN_subsub.last() == 0)
self_cell = anom_lin.get(i).NN_subsub.size() - 1;
}
// if exist the self interacting cell (Example cell 100 neighborhood of cell 100), this cell MUST BE ALWAYS at the beginning
if (self_cell != -1)
{
// bring the self-cell into the beginning
size_t tmp = anom_lin.get(i).NN_subsub.get(0);
anom_lin.get(i).NN_subsub.get(0) = 0;
anom_lin.get(i).NN_subsub.get(self_cell) = tmp;
}
}
are_anom_lin = true;
}
return anom_lin; return anom_lin;
} }
/*! \brief In case you have to recompute the indexes
*
*
*/
void reset() void reset()
{ {
are_domain_anom_computed = false; are_domain_anom_computed = false;
are_dom_lin = false;
are_anom_lin = false;
} }
}; };
......
...@@ -260,7 +260,7 @@ void Test3D_decit(const Box<3,float> & domain, long int k) ...@@ -260,7 +260,7 @@ void Test3D_decit(const Box<3,float> & domain, long int k)
// create a grid iterator from the decomposition // create a grid iterator from the decomposition
grid_dist_id_iterator_dec<CartDecomposition<3,float>> it_dec(g_dist.getDecomposition(),sz,{0,0,0},{sz[0]-2,sz[1]-2,sz[2]-2}); grid_dist_id_iterator_dec<CartDecomposition<3,float>> it_dec(g_dist.getDecomposition(),sz,{0,0,0},{(long int)sz[0]-2,(long int)sz[1]-2,(long int)sz[2]-2});
while (dom.isNext()) while (dom.isNext())
{ {
......
LINKLIBS = $(OPENMP_LDFLAGS) $(LIBHILBERT_LIB) $(METIS_LIB) $(PTHREAD_LIBS) $(OPT_LIBS) $(BOOST_LDFLAGS) $(BOOST_IOSTREAMS_LIB) $(CUDA_LIBS) $(PETSC_LIB) $(HDF5_LDFLAGS) $(HDF5_LIBS) $(PARMETIS_LIB) $(BOOST_UNIT_TEST_FRAMEWORK_LIB) $(BOOST_CHRONO_LIB) $(BOOST_TIMER_LIB) $(BOOST_SYSTEM_LIB) $(LIBIFCORE) LINKLIBS = $(OPENMP_LDFLAGS) $(LIBHILBERT_LIB) $(METIS_LIB) $(PTHREAD_LIBS) $(OPT_LIBS) $(BOOST_LDFLAGS) $(BOOST_IOSTREAMS_LIB) $(CUDA_LIBS) $(PETSC_LIB) $(HDF5_LDFLAGS) $(HDF5_LIBS) $(PARMETIS_LIB) $(BOOST_UNIT_TEST_FRAMEWORK_LIB) $(BOOST_CHRONO_LIB) $(BOOST_TIMER_LIB) $(BOOST_SYSTEM_LIB) $(LIBIFCORE)