Commit 1135fdf1 authored by ESTERIE Pierre's avatar ESTERIE Pierre
Browse files

work on grouptree simplification almost done

parent e8093a5c
......@@ -313,5 +313,6 @@ auto main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[]) -> int
std::cout << "check 1/r^2 Kernel for dimension 2 and 3. Value is \n"
<< " 0 for dimension 2 "
<< " 1 for dimension 3 " << std::endl;
break;
}
}
......@@ -107,14 +107,22 @@ namespace scalfmm::container
// If all value types are references we instanciate a proxy. We remove the reference to pass the type to
// the proxy beacaus it will be passed to a std::reference_wrapper.
// In the other case i.e no references are passed, we create a simple particle holding all the values.
using base_type = std::conditional_t<
meta::all(std::is_reference_v<PositionType>, std::is_reference_v<InputsType>,
std::is_reference_v<OutputsType>, meta::all(std::is_reference_v<Variables>...)),
static constexpr bool is_referenced = meta::all(std::is_reference_v<PositionType>, std::is_reference_v<InputsType>,
std::is_reference_v<OutputsType>, meta::all(std::is_reference_v<Variables>...));
using base_type = std::conditional_t<is_referenced,
particle_proxy<std::remove_reference_t<PositionType>, PositionDim, std::remove_reference_t<InputsType>,
NInputs, std::remove_reference_t<OutputsType>, MOutputs,
std::remove_reference_t<Variables>...>,
particle_impl<PositionType, PositionDim, InputsType, NInputs, OutputsType, MOutputs, Variables...>>;
using proxy_type = std::conditional_t<!is_referenced, particle_proxy<std::remove_reference_t<PositionType>, PositionDim, std::remove_reference_t<InputsType>,
NInputs, std::remove_reference_t<OutputsType>, MOutputs,
std::remove_reference_t<Variables>...>, std::false_type>;
using const_proxy_type = std::conditional_t<!is_referenced, particle_proxy<std::add_const_t<PositionType>, PositionDim, std::add_const_t<InputsType>,
NInputs, std::add_const_t<OutputsType>, MOutputs,
std::add_const_t<Variables>...>, std::false_type>;
using base_type::base_type;
constexpr particle() = default;
constexpr particle(particle const&) = default;
......
......@@ -38,17 +38,27 @@ namespace scalfmm::container
meta::make_range_sequence<dimension_size + inputs_size, dimension_size + inputs_size + outputs_size>;
using variables_type = std::tuple<std::add_lvalue_reference_t<Variables>...>;
using const_variables_type = std::tuple<std::add_lvalue_reference_t<std::add_const_t<Variables>>...>;
static constexpr std::size_t variables_size = sizeof...(Variables);
using range_variables_type =
meta::make_range_sequence<dimension_size + inputs_size + outputs_size,
dimension_size + inputs_size + outputs_size + variables_size>;
static constexpr bool is_const_proxy =
meta::all(std::is_const_v<PositionType>, std::is_const_v<InputsType>, std::is_const_v<OutputsType>,
meta::all(std::is_const_v<Variables>...));
// tuple type from which we can construct the proxy.
using tuple_type =
typename meta::cat<typename meta::pack_expand_tuple<meta::pack<dimension_size, std::add_lvalue_reference_t<position_value_type>>,
meta::pack<inputs_size, std::add_lvalue_reference_t<inputs_value_type>>,
meta::pack<outputs_size, std::add_lvalue_reference_t<outputs_value_type>>>,
variables_type>::type;
using const_tuple_type =
typename meta::cat<typename meta::pack_expand_tuple<meta::pack<dimension_size, std::add_lvalue_reference_t<std::add_const_t<position_value_type>>>,
meta::pack<inputs_size, std::add_lvalue_reference_t<std::add_const_t<inputs_value_type>>>,
meta::pack<outputs_size, std::add_lvalue_reference_t<std::add_const_t<outputs_value_type>>>>,
const_variables_type>::type;
constexpr particle_proxy() = delete;
constexpr particle_proxy(particle_proxy const&) = default;
......@@ -57,6 +67,11 @@ namespace scalfmm::container
constexpr inline auto operator=(particle_proxy const&) -> particle_proxy& = default;
constexpr inline auto operator=(particle_proxy&&) noexcept -> particle_proxy& = default;
// TODO : missing = from const_proxy !
//constexpr inline auto operator=(particle_proxy const&) -> particle_proxy& = default;
//{
//}
~particle_proxy() = default;
particle_proxy(tuple_type& t)
......@@ -75,6 +90,22 @@ namespace scalfmm::container
{
}
// particle_proxy(const_tuple_type& t)
// : m_position(container::get_reference_sequence(meta::sub_tuple(t, range_position_type{})))
// , m_inputs{container::get_reference_sequence(meta::sub_tuple(t, range_inputs_type{}))}
// , m_outputs{container::get_reference_sequence(meta::sub_tuple(t, range_outputs_type{}))}
// , m_variables(meta::sub_tuple(t, range_variables_type{}))
//{
//}
//particle_proxy(const_tuple_type const& t)
// : m_position(container::get_reference_sequence(meta::sub_tuple(t, range_position_type{})))
// , m_inputs{container::get_reference_sequence(meta::sub_tuple(t, range_inputs_type{}))}
// , m_outputs{container::get_reference_sequence(meta::sub_tuple(t, range_outputs_type{}))}
// , m_variables(meta::sub_tuple(t, range_variables_type{}))
//{
//}
[[nodiscard]] constexpr inline auto as_tuple() const noexcept -> tuple_type
{
return std::tuple_cat(meta::to_tuple(m_position), meta::to_tuple(m_inputs), meta::to_tuple(m_outputs),
......
......@@ -80,6 +80,7 @@ namespace scalfmm::container
using value_type = std::decay_t<Arithmetic>;
/// Reference wrapper type
using reference_wrapper_type = std::reference_wrapper<Arithmetic>;
using const_reference_wrapper_type = std::reference_wrapper<std::add_const_t<Arithmetic>>;
/// Dimension type
using dimension_type = std::size_t;
/// Space dimension count
......@@ -107,6 +108,11 @@ namespace scalfmm::container
{
}
//explicit point_proxy(std::array<const_reference_wrapper_type, dimension> const& a)
// : base_type(a)
//{
//}
template<typename... Ts, std::enable_if_t<meta::all(std::is_same_v<value_type, Ts>...), int> = 0>
explicit point_proxy(std::tuple<Ts...>& a)
: base_type(get_reference_sequence(a))
......
......@@ -52,6 +52,16 @@ namespace scalfmm::component
{
}
template<typename S = symbolics_type>
explicit group(std::size_t starting_morton_idx, std::size_t ending_morton_idx, std::size_t number_of_component,
std::size_t index_global = 0, bool is_mine = true,
typename std::enable_if_t<meta::is_leaf_group_symbolics<S>::value>* /*unused*/ = nullptr)
: m_vector_of_component(number_of_component)
, m_symbolics{starting_morton_idx, ending_morton_idx, number_of_component, 0, index_global, is_mine}
, m_number_of_component{number_of_component}
{
}
[[nodiscard]] inline auto symbolics() -> symbolics_type& { return m_symbolics; }
[[nodiscard]] inline auto symbolics() const -> symbolics_type const& { return m_symbolics; }
[[nodiscard]] inline auto csymbolics() const -> symbolics_type const& { return m_symbolics; }
......@@ -123,11 +133,10 @@ namespace scalfmm::component
}
template<typename MortonIndex = std::size_t>
[[nodiscard]] inline auto component_index(MortonIndex morton_index) const
-> int
[[nodiscard]] inline auto component_index(MortonIndex morton_index) const -> int
{
int idx_left{0};
int idx_right{static_cast<int>(m_number_of_component)-1};
int idx_right{static_cast<int>(m_number_of_component) - 1};
while(idx_left <= idx_right)
{
const int idx_middle = (idx_left + idx_right) / 2;
......
......@@ -473,6 +473,36 @@ namespace scalfmm::index
return std::make_tuple(width_at_current_level, new_center);
}
/// @brief
///
/// @param vector_of_mortons
/// @param offset
/// @param dimension
///
/// @return
template<typename MortonType>
inline auto get_parent_morton_indices(std::vector<MortonType>& vector_of_mortons, std::size_t offset,
std::size_t dimension) -> void
{
for(std::size_t i = 0; i < vector_of_mortons.size(); ++i)
{
vector_of_mortons.at(i) = vector_of_mortons.at(i) >> dimension;
}
/// we have to remove some elements at the begining if start != 0
auto last = std::unique(vector_of_mortons.begin(), vector_of_mortons.end());
if(offset > 0)
{
std::vector<MortonType> new_cell_index(std::distance(vector_of_mortons.begin() + offset, last));
std::move(vector_of_mortons.begin() + offset, last, new_cell_index.begin());
vector_of_mortons = std::move(new_cell_index);
}
else
{
vector_of_mortons.erase(last, vector_of_mortons.end());
}
}
} // namespace scalfmm::index
#endif // SCALFMM_TREE_UITLS_HPP
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