Commit 3f83830c authored by ESTERIE Pierre's avatar ESTERIE Pierre
Browse files

Fix bug in new tree constructor + comments/doc

parent bdb7efa9
......@@ -177,7 +177,7 @@ auto run(const std::string& input_file, const int& tree_height, const int& group
time.tic();
box_type box(box_width, box_center);
group_tree_type tree(static_cast<std::size_t>(tree_height), order, box, static_cast<std::size_t>(group_size),
*container);
static_cast<std::size_t>(group_size), *container);
time.tac();
std::cout << scalfmm::colors::yellow << "Group tree created in " << time.elapsed() << "ms\n"
<< scalfmm::colors::reset;
......
......@@ -275,7 +275,7 @@ namespace scalfmm::component
///
// template<typename ParticleContainer>
template<typename ParticleContainer>
group_tree(std::size_t tree_height, std::size_t order, box_type const& box,
[[deprecated]] group_tree(std::size_t tree_height, std::size_t order, box_type const& box,
std::size_t number_of_component_per_group, ParticleContainer const& particle_container,
bool particles_are_sorted = false, int in_top_level = 2, int in_left_limit = -1)
: m_tree_height(tree_height)
......@@ -378,7 +378,6 @@ namespace scalfmm::component
auto source_index = std::get<1>(*begin_of_particle);
auto jump_to_particle = begin_container;
std::advance(jump_to_particle, source_index);
sorted_leaf_to_move_in_block.insert_particle(*jump_to_particle, index_part);
++begin_of_particle;
}
......@@ -548,7 +547,7 @@ namespace scalfmm::component
return number_of_particles_per_leaves;
}
/// @brief
/// @brief It builds the groups of leaves for the leaf level.
///
/// @tparam MortonType : the type of the morton index stored in the vector
/// @param vector_of_mortons : a vector holding indices for permutation of size number_of_leaves
......@@ -577,7 +576,6 @@ namespace scalfmm::component
// get the starting and ending morton indices i.e the first and last leaves morton indices
auto starting_morton_index{vector_of_mortons.at(start_index)};
auto ending_morton_index{vector_of_mortons.at(end_index)};
// we create the group and stores the pointer in the vector of groups
m_group_of_leaf.at(g) = std::move(
std::make_shared<group_of_leaf_type>(starting_morton_index, ending_morton_index+1,
......@@ -603,13 +601,15 @@ namespace scalfmm::component
}
}
/// @brief
/// @brief This function builds the groups of cells at the specified level
///
/// @param vector_of_mortons
/// @param level
/// @tparam MortonIndex : the type of the morton index
/// @param vector_of_mortons : the vector holding the morton indices of the cells at the specified level
/// @param level : the level to build the group
///
/// @return
auto build_groups_of_cells_at_level(std::vector<std::size_t> const& vector_of_mortons,
/// @return void
template<typename MortonIndex>
auto build_groups_of_cells_at_level(std::vector<MortonIndex> const& vector_of_mortons,
std::size_t level) -> void
{
auto number_of_cells{vector_of_mortons.size()};
......@@ -680,7 +680,6 @@ namespace scalfmm::component
leaf = std::move(leaf_type(number_of_particles_per_leaves.at(leaf_index), std::get<1>(width_center),
std::get<0>(width_center), morton_index_of_leaf));
// accumulate for set the number of particle in group.
group_symbolics.number_of_particles_in_group += number_of_particles_per_leaves.at(leaf_index);
++leaf_index;
......@@ -688,6 +687,14 @@ namespace scalfmm::component
}
}
/// @brief This function builds the cells in the groups at the specified level
///
/// @tparam MortonType : the type of the morton index
/// @param vector_of_mortons : a vector holding the morton indices of the cells at the specified level
/// @param box : the box simulation
/// @param level : the level to construct the groups
///
/// @return void
template<typename MortonType>
auto build_cells_in_groups_at_level(std::vector<MortonType> const& vector_of_mortons,
box_type const& box, std::size_t level)
......@@ -744,38 +751,39 @@ namespace scalfmm::component
// copy the particle in the leaf
for(std::size_t index_part = 0; index_part < leaf.size(); ++index_part)
{
auto source_index = std::get<1>(tuple_of_indexes.at(leaf_index));
// get the source index in the source container
auto source_index = std::get<1>(tuple_of_indexes.at(leaf_index++));
// jump to the index in the source container
auto jump_to_particle = begin_container;
std::advance(jump_to_particle, source_index);
// copy the particle
*leaf_container_begin = *jump_to_particle;
proxy_type particle_in_leaf(*leaf_container_begin);
std::cout << std::get<0>(*leaf_container_begin) << '\n';
std::cout << std::get<3>(*leaf_container_begin) << '\n';
// set the outputs to zero
for(std::size_t ii{0}; ii < particle_type::outputs_size; ++ii)
{
particle_in_leaf.outputs(ii) = outputs_value_type(0.);
}
++leaf_container_begin;
}
++leaf_index;
}
}
}
public:
/// @brief
/// @brief Constructor of the group tree.
/// It initialized all levels with leaves and cells from the particle container passed.
///
/// @tparam ParticleContainer
/// @param tree_height
/// @param order
/// @param box
/// @param number_of_leaves_per_group
/// @param number_of_cells_per_group
/// @param particle_container
/// @param particles_are_sorted
/// @param in_top_level
/// @tparam ParticleContainer : the type of the particle container
/// @param tree_height : the height of the tree
/// @param order : order of the simulation
/// @param box : the box of the simulation
/// @param number_of_leaves_per_group : blocking on the leaves
/// @param number_of_cells_per_group : blocking on the cells
/// @param particle_container : the container holding the particles
/// @param particles_are_sorted : true if the particles are sorted, false either
/// @param in_top_level : last level of cells
template<typename ParticleContainer>
group_tree(std::size_t tree_height, std::size_t order, box_type const& box,
std::size_t number_of_leaves_per_group, std::size_t number_of_cells_per_group,
......@@ -812,10 +820,8 @@ namespace scalfmm::component
std::vector<std::size_t> vector_of_mortons(tuple_of_indexes.size());
std::transform(std::begin(tuple_of_indexes), std::end(tuple_of_indexes), std::begin(vector_of_mortons),
[](auto const& t) { return std::get<0>(t); });
std::cout << tuple_of_indexes.size() << '\n';
// vector to store the number of particles per leaves
auto number_of_particles_per_leaves{get_leaves_distribution(vector_of_mortons)};
std::cout << vector_of_mortons.size() << '\n';
// we build the first level of group for the leaves
build_groups_of_leaves(vector_of_mortons);
......@@ -825,19 +831,20 @@ namespace scalfmm::component
// then, we fill each leaf with its particle
fill_leaves_with_particles(tuple_of_indexes, particle_container);
// construct group of cells at leaf level
build_groups_of_cells_at_level(vector_of_mortons, leaf_level);
// construct cells in group of leaf level
build_cells_in_groups_at_level(vector_of_mortons, box, leaf_level);
// loop on levels
for(std::size_t level{m_tree_height-1}; level>=m_top_level; --level)
for(std::size_t level{m_tree_height-2}; level>=m_top_level; --level)
{
// update vector_of_mortons for upper level
index::get_parent_morton_indices(vector_of_mortons, 0, dimension);
// construct group of cells at current level
build_groups_of_cells_at_level(vector_of_mortons, level);
// construct cells in group of current level
build_cells_in_groups_at_level(vector_of_mortons, box, level);
// update vector_of_mortons for upper level
index::get_parent_morton_indices(vector_of_mortons, 0, dimension);
for(auto e : vector_of_mortons)
{ std::cout << e << ' '; }
std::cout << '\n';
}
}
......
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