Commit b814f5b1 authored by COULAUD Olivier's avatar COULAUD Olivier
Browse files

Use distribute tree in buildLet

parent 40f33c9b
......@@ -118,7 +118,11 @@ auto main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[]) -> int
bool use_particle_distribution{parser.exists<local_args::PartDistrib>()};
bool use_leaf_distribution{!use_particle_distribution};
bool use_both_distribution{parser.exists<local_args::PartLeafDistrib>()};
if(parser.exists<local_args::PartLeafDistrib>())
{
use_leaf_distribution = true;
use_particle_distribution = true;
}
//
//
......@@ -151,7 +155,6 @@ auto main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[]) -> int
}
// p.variables()
particles_set[idx] = p;
// container.push_particle(idx, p);
}
///
///////////////////////////////////////////////////////////////////////////////////////////////////////
......@@ -165,9 +168,6 @@ auto main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[]) -> int
/// 1) sort the particles according to their Morton index
/// 2) construct the tree athen the let
///
using MortonIndex = std::size_t;
int nb_block;
std::vector<MortonIndex> mortonCellDistribution;
group_tree_type* letGroupTree = nullptr;
//
......@@ -176,7 +176,7 @@ auto main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[]) -> int
int leaf_level = tree_height - 1;
scalfmm::tree::let::buildLetTree(para, number_of_particles, particles_set, box, leaf_level, group_size, group_size,
letGroupTree, mortonCellDistribution, nb_block, order);
letGroupTree, order, use_leaf_distribution, use_particle_distribution);
#ifdef SCALFMM_USE_MPI
para.get_communicator().barrier();
......@@ -185,7 +185,7 @@ auto main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[]) -> int
{
letGroupTree->print_distrib(std::cout);
}
std::this_thread::sleep_for(std::chrono::seconds(2));
// std::this_thread::sleep_for(std::chrono::seconds(2));
#endif
///
......
......@@ -23,7 +23,8 @@ namespace scalfmm::component
{
public:
using morton_type = std::int64_t;
using data_distrib_type = std::array<morton_type, 2>;
using data_distrib_value_type = std::array<morton_type, 2>;
using data_distrib_type = std::vector<data_distrib_value_type>;
using base_type = group_tree<Cell, Leaf, Box>;
/// Constructor
template<typename ParticleContainer>
......@@ -36,13 +37,15 @@ namespace scalfmm::component
m_cell_distrib.resize(tree_height);
}
void set_leaf_distribution(const std::vector<data_distrib_type>& in_leaf_distrib)
void set_leaf_distribution(const data_distrib_type& in_leaf_distrib)
{
// std::copy(in_leaf_distrib.begin(), in_leaf_distrib.end(), m_leaf_distrib.begin());
m_leaf_distrib = in_leaf_distrib;
}
void set_cell_distribution(const int in_level, const std::vector<data_distrib_type>& in_cell_distrib)
void set_cell_distribution(const int in_level, const data_distrib_type& in_cell_distrib)
{
// std::copy(in_cell_distrib.begin(), in_cell_distrib.end(), m_cell_distrib[in_level].begin());
m_cell_distrib[in_level] = in_cell_distrib;
}
......@@ -66,8 +69,8 @@ namespace scalfmm::component
}
private:
std::vector<std::vector<data_distrib_type>> m_cell_distrib;
std::vector<data_distrib_type> m_leaf_distrib;
std::vector<data_distrib_type> m_cell_distrib;
data_distrib_type m_leaf_distrib;
};
} // namespace scalfmm::component
......
......@@ -1365,21 +1365,21 @@ namespace scalfmm::tree
// @param[in] box size of the simulation box
// @param[in] TreeHeight Height of the tree
// @param[inout] localGroupTree the LET of the octree
// @param[out] m_idx_distribution Distribution of the leaves on the
// @param[in] order order of the approximation to build the tree
// @param[in] use_leaf_distribution to say if you consider the leaf distribution
// @param[in] use_particle_distribution to say if you consider the particle distributio
// processors
// @param[out] nb_blocks
template</*typename Loader_type,*/ typename Index_type, typename Vector_type, typename Tree_type,
typename Box_type>
template<typename Vector_type, typename Tree_type, typename Box_type>
void buildLetTree(parallel_manager& manager, const std::size_t& number_of_particles,
Vector_type& particle_container, const Box_type& box, const int& leaf_level,
const int groupSizeLeaves, const int groupSizeCells, Tree_type*& localGroupTree,
std::vector<Index_type>& m_idx_distribution, int& nb_blocks, const int order)
const int order, const bool use_leaf_distribution, const bool use_particle_distribution)
{
std::cout << scalfmm::colors::green << " --> Begin let::group_let() " << scalfmm::colors::reset
<< std::endl;
//
using morton_type = std::int64_t;
constexpr int dimension = Box_type::dimension;
using morton_type = std::int64_t; // typename Tree_type::
//
int rank = manager.get_process_id();
auto nb_part = particle_container.size();
......@@ -1430,11 +1430,16 @@ namespace scalfmm::tree
///
/// A morton index should be own by only one process
///
using morton_distrib_type = typename Tree_type::data_distrib_type;
auto tmp(leafMortonIdx); // a copy of the Morton index
///
/// Build a uniform distribution of the leaves/cells
///
auto leaves_distrib = std::move(scalfmm::tree::distrib::balanced_leaves(manager, leafMortonIdx));
morton_distrib_type leaves_distrib;
if(use_leaf_distribution)
{
leaves_distrib = std::move(scalfmm::tree::distrib::balanced_leaves(manager, leafMortonIdx));
}
//// End
////////////////////////////////////////////////////////////////////////////////////////////
///
......@@ -1445,8 +1450,20 @@ namespace scalfmm::tree
///
/// A morton index should be own by only one process
///
auto particles_distrib = std::move(
scalfmm::tree::distrib::balanced_particles(manager, particle_container, tmp, number_of_particles));
morton_distrib_type particles_distrib;
if(use_particle_distribution)
{
particles_distrib = std::move(
scalfmm::tree::distrib::balanced_particles(manager, particle_container, tmp, number_of_particles));
if(!use_leaf_distribution)
{
std::copy(particles_distrib.begin(), particles_distrib.end(), leaves_distrib.begin());
}
}
else
{
particles_distrib = leaves_distrib;
}
//// End
////////////////////////////////////////////////////////////////////////////////////////////
///
......@@ -1512,6 +1529,7 @@ namespace scalfmm::tree
///
/// Find and add the leaves to add at the leaves level
build_let_leaves(manager, *localGroupTree, leafMortonIdx, particles_distrib, leaves_distrib);
localGroupTree->set_leaf_distribution(leaves_distrib);
/// If the distribution is not the same for the leaf and the cell we have to redistribute the
......
......@@ -85,13 +85,13 @@ namespace scalfmm
namespace out
{
template<typename T, std::size_t N>
///
/// \brief operator << for array std::array<T,N>
/// print array [a_1, ..., a_N]
/// \param os ostream
/// \param array to print
///
template<typename T, std::size_t N>
inline auto operator<<(std::ostream& os, const std::array<T, N>& array) -> std::ostream&
{
os << "[";
......
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