Attention une mise à jour du service Gitlab va être effectuée le mardi 30 novembre entre 17h30 et 18h00. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes. Cette mise à jour intermédiaire en version 14.0.12 nous permettra de rapidement pouvoir mettre à votre disposition une version plus récente.

Commit 2194e395 authored by ESTERIE Pierre's avatar ESTERIE Pierre
Browse files

Some work on particle container

parent 4542bd2a
......@@ -48,10 +48,12 @@ namespace scalfmm::container
using self_type = particle_container<Particle>;
using base_type = variadic_container_tuple<self_type, tuple_type>;
using particle_type = Particle;
// using value_type = Particle; // Compatibility with vector
using value_type = Particle;
using proxy_type = typename Particle::proxy_type;
using const_proxy_type = typename Particle::const_proxy_type;
// Forwarding constructors
using base_type::base_type;
// Forwarding constructors
using base_type::base_type;
/// @brief
///
......@@ -64,6 +66,20 @@ namespace scalfmm::container
std::advance(it, i);
return particle_type(*it);
}
[[nodiscard]] inline auto at(std::size_t i) -> proxy_type
{
auto it{std::begin(*this)};
std::advance(it, i);
return proxy_type(*it);
}
[[nodiscard]] inline auto at(std::size_t i) const -> const_proxy_type
{
auto it{std::begin(*this)};
std::advance(it, i);
return const_proxy_type(*it);
}
///
/// \brief size
/// \return the number of particles inside the container
......
......@@ -96,6 +96,7 @@ namespace scalfmm::container
using container_private_type =
std::conditional_t<std::is_base_of_v<VariadicAdaptor, DerivedVariadic>, VariadicAdaptor, DerivedVariadic>;
using vector_pointer_type = std::conditional_t<IsConst, container_private_type const*, container_private_type*>;
using derived_value_type = typename DerivedVariadic::value_type;
friend container_private_type;
vector_pointer_type vec_;
......
......@@ -13,6 +13,13 @@
#include <scalfmm/meta/is_valid.hpp>
#include <xsimd/types/xsimd_base.hpp>
// forward declare particle
namespace scalfmm::container
{
template<typename PositionType, std::size_t PositionDim, typename InputsType, std::size_t NInputs,
typename OutputsType, std::size_t MOutputs, typename... Variables>
struct particle;
}
// Traits
namespace scalfmm::meta
{
......@@ -310,6 +317,13 @@ namespace scalfmm::meta
template<typename T, std::size_t N> struct is_array<std::array<T,N>> : std::true_type{};
template<typename... Ts>
inline constexpr bool is_array_v = is_array<Ts...>::value;
template<typename T> struct is_particle : std::false_type{};
template<typename PositionType, std::size_t PositionDim, typename InputsType, std::size_t NInputs,
typename OutputsType, std::size_t MOutputs, typename... Variables>
struct is_particle<container::particle<PositionType,PositionDim,InputsType,NInputs,OutputsType,MOutputs,Variables...>> : std::true_type{};
template<typename T>
inline static constexpr bool is_particle_v = is_particle<T>::value;
} // namespace scalfmm::meta
#endif
......@@ -16,6 +16,7 @@
#include <tuple>
#include <type_traits>
#include <utility>
#include "scalfmm/meta/traits.hpp"
// Forward declaration for traits support
namespace scalfmm::container
......@@ -505,5 +506,18 @@ namespace scalfmm::meta
}
}
};
template<typename ParticleOrTuple>
auto inline as_tuple(ParticleOrTuple&& p)
{
if constexpr(is_particle_v<std::decay_t<ParticleOrTuple>>)
{
return std::forward<ParticleOrTuple>(p).as_tuple();
}
else if constexpr(is_tuple_v<std::decay_t<ParticleOrTuple>>)
{
return std::forward<ParticleOrTuple>(p);
}
}
} // namespace scalfmm::meta
#endif // SCALFMM_META_UTILS_HPP
......@@ -14,6 +14,7 @@
#include <numeric>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>
#include "scalfmm/operators/generic/tags.hpp"
......@@ -23,6 +24,7 @@
#include "scalfmm/tree/interaction_list.hpp"
#include "scalfmm/tree/utils.hpp"
#include "scalfmm/utils/sort.hpp"
#include "scalfmm/meta/utils.hpp"
namespace scalfmm::component
{
......@@ -477,7 +479,7 @@ namespace scalfmm::component
auto jump_to_particle = begin_container;
std::advance(jump_to_particle, source_index);
// copy the particle
*leaf_container_begin = *jump_to_particle;
*leaf_container_begin = meta::as_tuple(*jump_to_particle);
proxy_type particle_in_leaf(*leaf_container_begin);
// set the outputs to zero
for(std::size_t ii{0}; ii < particle_type::outputs_size; ++ii)
......@@ -517,7 +519,7 @@ namespace scalfmm::component
, m_box(box)
{
static_assert(
std::is_same_v<typename ParticleContainer::particle_type, particle_type>,
std::is_same_v<typename ParticleContainer::value_type, particle_type>,
"group_tree : Particles contain in leafs are not the same as the ones in the container passed "
"as argument to this constructor.");
......
......@@ -43,7 +43,7 @@ namespace scalfmm
{
std::get<1>(tuple_of_indexes[part]) = part;
std::get<0>(tuple_of_indexes[part]) =
scalfmm::index::get_morton_index(particle_container.position(part), box, level);
scalfmm::index::get_morton_index(particle_container.at(part).position(), box, level);
}
if(!data_already_sorted)
{
......
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