Commit 7334e19a authored by ESTERIE Pierre's avatar ESTERIE Pierre
Browse files

some doc on cell, leaf, etc

parent c3e870e2
......@@ -22,6 +22,9 @@
namespace scalfmm::component
{
/// @brief The cell type stores the mutipoles and the local expansions
///
/// @tparam Storage : the storage type that gives the interface the storage of the cell.
template<typename Storage>
class cell : public Storage
{
......@@ -33,6 +36,7 @@ namespace scalfmm::component
using coordinate_type = typename symbolics_type::coordinate_type;
using position_type = typename symbolics_type::position_type;
// Constructors generated
cell() = default;
cell(cell const&) = default;
cell(cell&&) noexcept = default;
......@@ -40,6 +44,11 @@ namespace scalfmm::component
inline auto operator=(cell&&) noexcept -> cell& = default;
~cell() = default;
/// @brief Constructor
///
/// @param center : the center of the cell
/// @param width : the width of the cell
/// @param order : the order of the approximation
explicit cell(position_type const& center, value_type width, std::size_t order)
: storage_type(order)
, m_center(center)
......@@ -48,6 +57,14 @@ namespace scalfmm::component
{
}
/// @brief Constructor
///
/// @param center : the center of the cell
/// @param width : the width of the cell
/// @param order : the order of the approximation
/// @param level : the level of the cell
/// @param morton_index : the morton index of the cell
/// @param coordinate_in_tree : the coordinate of the cell in the tree
explicit cell(position_type const& center, value_type width, std::size_t order, std::size_t level,
std::size_t morton_index, coordinate_type const& coordinate_in_tree)
: storage_type(order)
......@@ -58,14 +75,35 @@ namespace scalfmm::component
{
}
/// @brief Access to the symbolic type
///
/// @return a symbolics_type reference
[[nodiscard]] inline auto symbolics() -> symbolics_type& { return m_symbolics; }
/// @brief Access to the symbolic type
///
/// @return a const symbolics_type reference
[[nodiscard]] inline auto symbolics() const -> symbolics_type const& { return m_symbolics; }
/// @brief Access to the symbolic type
///
/// @return a const symbolics_type reference
[[nodiscard]] inline auto csymbolics() const -> symbolics_type const& { return m_symbolics; }
/// @brief Returns the width of the leaf
///
/// @return value_type
[[nodiscard]] inline auto width() const noexcept -> value_type { return m_width; }
/// @brief Returns the center of the leaf
///
/// @return position_type
[[nodiscard]] inline auto center() const noexcept -> position_type const& { return m_center; }
/// @brief Returns the order of the approximation
///
/// @return std::size_t
[[nodiscard]] inline auto order() const noexcept -> std::size_t { return m_order; }
/// @brief Returns the morton index of the cell
///
/// @return std::size_t
[[nodiscard]] inline auto index() const noexcept -> std::size_t { return m_symbolics.morton_index; }
private:
......@@ -75,30 +113,56 @@ namespace scalfmm::component
symbolics_type m_symbolics{};
};
/// @brief The symbolics type stores information about the cell
/// It represents a generic that also exists on the leaves
///
/// @tparam P
template<typename S>
struct symbolics_data<cell<S>>
{
// the storage type
using storage_type = S;
// the group type
using group_type = group<cell<S>>;
// the cell type
using component_type = cell<S>;
// the position value type
using position_value_type = typename storage_type::value_type;
// the position type
using position_type = container::point<position_value_type, component_type::dimension>;
// the coordinate type to store the coordinate in the tree
using coordinate_type = container::point<std::int64_t, component_type::dimension>;
// the number of interactions of the cell
static constexpr std::size_t number_of_interactions{math::pow(6, component_type::dimension) -
math::pow(3, component_type::dimension)};
// type of the array storing the indexes of the theoritical interaction list
using interaction_index_array_type = std::array<std::size_t, number_of_interactions>;
// type of the array storing the linear position of the interaction.
using interaction_position_array_type =
std::array<typename coordinate_type::value_type, number_of_interactions>;
// type of the array storing the iterators to all the interacting cells
using iterator_array_type = std::array<typename group_type::iterator_type, number_of_interactions>;
// the level of the cell
std::size_t level{0};
// the morton index of the cell
std::size_t morton_index{0};
// the coordinate in the tree
coordinate_type coordinate_in_tree{};
// the array storing the indexes of the theoritical interaction list
interaction_index_array_type interaction_indexes{};
// type of the array storing the linear position of the interaction, this is necessary to get the corresponding
// interaction matrix.
interaction_position_array_type interaction_positions{};
// the array storing the iterators to all the existing interacting cells
iterator_array_type interaction_iterators{};
// theoretical number of neighbors
std::size_t number_of_neighbors{0};
// existing number of neighbors
std::size_t existing_neighbors{0};
// flagged if the theoretical interaction list exists
bool interaction_list_exists{false};
// flagged if the array of iterators exists
bool interaction_list_iterators_exists{false};
};
......@@ -108,10 +172,14 @@ namespace scalfmm::component
using storage_type = S;
using group_type = group<cell<S>>;
using component_type = cell<S>;
// the starting morton index in the group
std::size_t starting_index{0};
// the ending morton index in the group
std::size_t ending_index{0};
// number of cells in the group
std::size_t number_of_component_in_group{0};
std::size_t idx_global{0}; ///< Global index of the group in the Octree
// Global index of the group in the Octree
std::size_t idx_global{0};
bool is_mine{false};
};
......
......@@ -27,9 +27,14 @@ namespace scalfmm::component
template<typename IndexType = std::size_t>
struct out_of_block_interaction
{
// interaction between A and B
// morton index of leaf A inside the group
IndexType inside_index{};
// morton index of leaf B outside of the group
IndexType outside_index{};
// index in the group of leaf A inside the group
IndexType inside_index_in_block{};
// index in the group of leaf B inside the group
IndexType outside_index_in_block{};
};
......@@ -37,10 +42,10 @@ namespace scalfmm::component
///
/// @ingroup update_interaction_list
/// @brief This function takes a component and its level in the tree
/// @brief This function takes a leaf and its level in the tree
/// and updates the component's symbolics information : the morton indices
/// of its neighbors, the position of its neighbors in the neighorhood and
/// the number of neighbors
/// of its neighbors and the number of neighbors. It returns the theoretical
/// interaction list of the leaf.
///
/// @tparam Tag : operator tag to select specific overload of @ref get_interaction_neighbors
/// @param component : the component in which the list will be updated i.e its symbolics component
......@@ -63,6 +68,18 @@ namespace scalfmm::component
component_symbolics.interaction_list_exists = true;
}
/// @ingroup update_interaction_list
/// @brief This function takes a cell and its level in the tree
/// and updates the component's symbolics information : the morton indices
/// of its neighbors and the number of neighbors. It returns the theoretical
/// interaction list of the leaf.
///
/// @tparam Component
/// @param t
/// @param component
/// @param tree_height
///
/// @return
template<typename Component>
inline auto build_symbolic_interaction_list(operators::impl::tag_m2l t, Component& component,
std::size_t tree_height) -> void
......
......@@ -29,18 +29,31 @@
namespace scalfmm::component
{
/// @brief This is the leaf type stored at the bottom of the tree.
/// Its stores the particle container and some symbolics informations.
///
/// @tparam Particle : the type of particle to store.
template<typename Particle>
class leaf
{
public:
// static dimension of the particle
static constexpr std::size_t dimension = Particle::dimension;
// self type
using self_type = leaf<Particle>;
// Symbolic types : the type storing informations about the leaf component
using symbolics_type = symbolics_data<self_type>;
// the particle type stored in the container
using particle_type = Particle;
// the position type extract from the symbolic information
using position_type = typename symbolics_type::position_type;
// the position value type
using value_type = typename position_type::value_type;
// the particle container type
using particle_container_type = container::particle_container<particle_type>;
// rule of five generated by the compiler
leaf() = default;
leaf(leaf const&) = default;
leaf(leaf&&) noexcept = default;
......@@ -48,12 +61,22 @@ namespace scalfmm::component
inline auto operator=(leaf&&) noexcept -> leaf& = default;
~leaf() = default;
/// @brief Constuctors from center and width
///
/// @param center : the center of the leaf
/// @param width : the width of the feaf
explicit leaf(position_type const& center, value_type width)
: m_center(center)
, m_width(width)
{
}
/// @brief Constuctors from number of particles, center, width and a morton index
///
/// @param nb_particles : number of particles in the container
/// @param center : the center of the leaf
/// @param width : the width of the feaf
/// @param morton_index : the morton index of the leaf
explicit leaf(std::size_t nb_particles, position_type const& center, value_type width, std::size_t morton_index)
: m_particles(nb_particles)
, m_symbolics{morton_index}
......@@ -63,6 +86,15 @@ namespace scalfmm::component
{
}
/// @brief
/// Constuctors from a container of particles, center, width and a morton index
/// It takes an rvalue reference to the container allowing you to move the container inside the leaf.
///
/// @param container : rvalue ref to the container
/// @param nb_particles : number of particles
/// @param center : the center of the leaf
/// @param width : the width of the leaf
/// @param morton_index : the morton index of the leaf
explicit leaf(particle_container_type&& container, std::size_t nb_particles, position_type const& center,
value_type width, std::size_t morton_index)
: m_particles(container)
......@@ -73,6 +105,14 @@ namespace scalfmm::component
{
}
/// @brief Constuctors from a container of particles with iterators, center, width and a morton index
///
/// @param begin : iterator on the begin of the particle container to copy
/// @param end : iterator on the end of the particle container to copy
/// @param nb_particles : number of particles
/// @param center : the center of the leaf
/// @param width : the width of the leaf
/// @param morton_index : the morton index of the leaf
explicit leaf(typename particle_container_type::const_iterator begin,
typename particle_container_type::const_iterator end, std::size_t nb_particles,
position_type const& center, value_type width, std::size_t morton_index)
......@@ -85,26 +125,73 @@ namespace scalfmm::component
std::copy(begin, end, std::begin(m_particles));
}
/// @brief Returns the center of the leaf
///
/// @return position_type
[[nodiscard]] inline auto center() const noexcept -> position_type const& { return m_center; }
/// @brief Returns the width of the leaf
///
/// @return value_type
[[nodiscard]] inline auto width() const noexcept -> value_type { return m_width; }
/// @brief Return the number of particles
///
/// @return std::size_t
[[nodiscard]] inline auto size() const noexcept -> std::size_t { return m_nb_particles; }
/// @brief Non const accessor on the container
///
/// @return a reference on the particle_container_type
[[nodiscard]] inline auto particles() -> particle_container_type& { return m_particles; }
/// @brief Const accessor on the container
///
/// @return a const reference on the particle_container_type
[[nodiscard]] inline auto particles() const -> particle_container_type const& { return m_particles; }
/// @brief Const accessor on the container
///
/// @return a const reference on the particle_container_type
[[nodiscard]] inline auto cparticles() const -> particle_container_type const& { return m_particles; }
[[nodiscard]] inline auto particles(std::size_t i) -> particle_container_type& { return m_particles.at(i); }
[[nodiscard]] inline auto particles(std::size_t i) const -> particle_container_type const&
/// @brief Indexed accessor on the particle container
///
/// @param i : the index at which the access is performed.
///
/// @return a particle_type reference
[[nodiscard]] inline auto particles(std::size_t i) -> particle_type& { return m_particles.at(i); }
/// @brief Indexed accessor on the particle container
///
/// @param i : the index at which the access is performed.
///
/// @return a particle_type const reference
[[nodiscard]] inline auto particles(std::size_t i) const -> particle_type const&
{
return m_particles.at(i);
}
/// @brief Access to the symbolic type
///
/// @return a symbolics_type reference
[[nodiscard]] inline auto symbolics() -> symbolics_type& { return m_symbolics; }
/// @brief Access to the symbolic type
///
/// @return a const symbolics_type reference
[[nodiscard]] inline auto symbolics() const -> symbolics_type const& { return m_symbolics; }
/// @brief Access to the symbolic type
///
/// @return a const symbolics_type reference
[[nodiscard]] inline auto csymbolics() const -> symbolics_type const& { return m_symbolics; }
/// @brief Returns the morton index of the leaf
///
/// @return std::size_t
[[nodiscard]] inline auto index() const noexcept -> std::size_t { return m_symbolics.morton_index; }
/// @brief Insert a particle at the index
///
/// @param part : the particle to insert
/// @param index : the position to insert the particle
///
/// @return void
inline auto insert_particle(particle_type const& part, std::size_t index) -> void
{
assertm(index < m_nb_particles, "Inserting particle out of range in leaf.");
......@@ -112,6 +199,12 @@ namespace scalfmm::component
*it = part.as_tuple();
}
/// @brief Insert a particle at the index
///
/// @param part : the tuple corresponding to the particle to insert
/// @param index : the position to insert the particle
///
/// @return void
template<typename... Types>
inline auto insert_particle(std::tuple<Types...> const& part, std::size_t index) -> void
{
......@@ -120,6 +213,7 @@ namespace scalfmm::component
std::advance(it, index);
*it = part;
}
///
/// \brief reset_outputs reset outputs in the leaf
///
......@@ -130,49 +224,86 @@ namespace scalfmm::component
}
private:
// The particle container
particle_container_type m_particles{};
// The symbolic type
symbolics_type m_symbolics{};
// The number of particles
std::size_t m_nb_particles{};
// Position of the center
position_type m_center{};
// The width of the leaf
value_type m_width{};
};
/// @brief The symbolics type stores information about the leaf
/// It represents a generic that also exists on the cells
///
/// @tparam P
template<typename P>
struct symbolics_data<leaf<P>>
{
// the group type
using group_type = group<leaf<P>>;
// the leaf type
using component_type = leaf<P>;
// the position value type
using position_value_type = typename P::position_value_type;
// the position type
using position_type = container::point<position_value_type, component_type::dimension>;
// the coordinate type to store the coordinate in the tree
using coordinate_type =
decltype(index::get_coordinate_from_morton_index<component_type::dimension>(std::size_t{}));
// the number of interactions of the leaf
static constexpr std::size_t number_of_interactions{math::pow(3, component_type::dimension) - 1};
// type of the array storing the indexes of the theoritical interaction list
using interaction_index_array_type = std::array<std::size_t, number_of_interactions>;
using interaction_position_array_type =
std::array<typename coordinate_type::value_type, number_of_interactions>;
// type of the array storing the iterators of the interacting leaves available in the current group
using iterator_array_type = std::array<typename group_type::iterator_type, number_of_interactions>;
// the morton index of the leaf
std::size_t morton_index{0};
// the array storing the indexes of the theoritical interaction list
interaction_index_array_type interaction_indexes{};
// the array storing the iterators of the interacting leaves available in the current group
iterator_array_type interaction_iterators{};
// the theoretical number of neighbors.
std::size_t number_of_neighbors{0};
// the number of numbers available in the group of the leaf
std::size_t existing_neighbors_in_group{0};
// flagged if the theoretical interaction list exists
bool interaction_list_exists{false};
// flagged if the array of iterators exists
bool interaction_list_iterators_exists{false};
};
/// @brief The Symbolics type that stores information about the groupe of leaves
///
/// @tparam P
template<typename P>
struct symbolics_data<group<leaf<P>>>
{
// the group type
using group_type = group<leaf<P>>;
// the leaf type
using component_type = leaf<P>;
// the starting morton index in the group
std::size_t starting_index{0};
// the ending morton index in the group
std::size_t ending_index{0};
// number of leaves in the group
std::size_t number_of_component_in_group{0};
// number of particles in group
std::size_t number_of_particles_in_group{0};
// index of the group
std::size_t idx_global{0};
//
bool is_mine{false};
// vector storing the out_of_block_interaction structure to handle the outside interactions
std::vector<out_of_block_interaction<std::size_t>> outside_interactions{};
// flagged if the vector is constucted
bool outside_interactions_exists{false};
// flagged if the vector is sorted
bool outside_interactions_sorted{false};
};
......
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