Commit 89dc83b7 authored by ESTERIE Pierre's avatar ESTERIE Pierre
Browse files

simplified calls of operators and passes by removing order argument

parent 3f83830c
......@@ -60,7 +60,7 @@ namespace scalfmm::algorithms::pass
assertm(leaf.csymbolics().morton_index == cell.symbolics().morton_index,
"Bottom pass : morton indexes of leaf and cell does not match.");
p2m(std::forward<Interpolator>(interpolator), leaf, cell, cell.order());
p2m(std::forward<Interpolator>(interpolator), leaf, cell);
++leaf_begin;
++cell_begin;
......
......@@ -46,7 +46,7 @@ namespace scalfmm::algorithms::pass
{
auto const& source_cell = (*group_of_cell_begin)->ccomponent(leaf_index);
auto& target_leaf = (*group_of_leaf_begin)->component(leaf_index);
l2p(far_field /*fmm_operator*/, source_cell, target_leaf, source_cell.order());
l2p(far_field /*fmm_operator*/, source_cell, target_leaf);
}
}
......
......@@ -85,8 +85,7 @@ namespace scalfmm::algorithms::pass
std::for_each(std::begin(indexes_of_childs), std::end(indexes_of_childs),
[&parent_cell, &interpolator](auto indexes) {
l2l(interpolator, parent_cell, std::get<0>(indexes), *std::get<1>(indexes),
parent_cell.order());
l2l(interpolator, parent_cell, std::get<0>(indexes), *std::get<1>(indexes));
});
++cell_begin;
......
......@@ -81,7 +81,7 @@ namespace scalfmm::algorithms::pass
for(std::size_t index{0}; index < cell_symbolics.existing_neighbors; ++index)
{
m2l(std::forward<Approximation>(approximation), *interaction_iterators.at(index),
static_cast<std::size_t>(interaction_positions.at(index)), target_cell, target_cell.order(),
static_cast<std::size_t>(interaction_positions.at(index)), target_cell,
cell_symbolics.level, buffer);
};
/// post-processing the leaf if necessary
......
......@@ -85,13 +85,12 @@ namespace scalfmm::algorithms::pass
std::for_each(std::cbegin(indexes_of_childs), std::cend(indexes_of_childs),
[&parent_cell, &interpolator](auto indexes) {
m2m(interpolator, *std::get<1>(indexes), std::get<0>(indexes), parent_cell,
parent_cell.order());
m2m(interpolator, *std::get<1>(indexes), std::get<0>(indexes), parent_cell);
});
if(!indexes_of_childs.empty())
{
interpolator.apply_multipoles_preprocessing(parent_cell, parent_cell.order());
interpolator.apply_multipoles_preprocessing(parent_cell);
}
++cell_begin;
}
......
......@@ -157,16 +157,16 @@ namespace scalfmm::interpolation
[[nodiscard]] inline auto m2l_interactions() const noexcept { return m_m2l_interactions; }
[[nodiscard]] inline auto roots(std::size_t order) const { return this->derived_cast().roots_impl(order); }
[[nodiscard]] inline auto roots() const { return this->derived_cast().roots_impl(); }
template<typename ComputationType>
[[nodiscard]] inline auto polynomials(ComputationType x, std::size_t /*order*/, std::size_t n) const
[[nodiscard]] inline auto polynomials(ComputationType x, std::size_t n) const
{
return this->derived_cast().template polynomials_impl<ComputationType>(x, n);
}
template<typename ComputationType>
[[nodiscard]] inline auto derivative(ComputationType x, std::size_t order, std::size_t n) const
[[nodiscard]] inline auto derivative(ComputationType x, std::size_t n) const
{
return this->derived_cast().template derivative_impl<ComputationType>(x, n);
}
......@@ -187,13 +187,13 @@ namespace scalfmm::interpolation
}
template<typename Cell>
auto apply_multipoles_preprocessing(Cell& current_cell, std::size_t order) const -> void
auto apply_multipoles_preprocessing(Cell& current_cell) const -> void
{
return this->derived_cast().template apply_multipoles_preprocessing_impl<Cell>(current_cell, order);
return this->derived_cast().template apply_multipoles_preprocessing_impl<Cell>(current_cell);
}
template<typename Cell>
auto apply_m2l(Cell const& source_cell, Cell& target_cell, std::size_t neighbor_idx, std::size_t order,
auto apply_m2l(Cell const& source_cell, Cell& target_cell, std::size_t neighbor_idx,
std::size_t tree_level, [[maybe_unused]] buffer_type& products) const -> void
{
std::size_t level{};
......@@ -210,7 +210,7 @@ namespace scalfmm::interpolation
}
return this->derived_cast().template apply_m2l_impl<Cell>(
source_cell, target_cell, m_interactions_matrixes.at(level * m_m2l_interactions + neighbor_idx),
m_far_field.scale_factor(target_cell.width()), order, tree_level, products);
m_far_field.scale_factor(target_cell.width()), tree_level, products);
}
template<typename Cell>
......@@ -222,17 +222,17 @@ namespace scalfmm::interpolation
}
template<typename Cell>
auto apply_locals_preprocessing(Cell& current_cell, std::size_t order) const -> void
auto apply_locals_preprocessing(Cell& current_cell) const -> void
{
return this->derived_cast().template apply_locals_preprocessing_impl<Cell>(current_cell, order);
return this->derived_cast().template apply_locals_preprocessing_impl<Cell>(current_cell);
}
template<typename Cell>
auto apply_locals_postprocessing(Cell& current_cell, std::size_t order) const -> void
auto apply_locals_postprocessing(Cell& current_cell) const -> void
{
return this->derived_cast().template apply_locals_preprocessing_impl<Cell>(current_cell, order);
return this->derived_cast().template apply_locals_preprocessing_impl<Cell>(current_cell);
}
private:
......@@ -322,7 +322,7 @@ namespace scalfmm::interpolation
const map_loc_glob<array_type> mapper_lg(childs_centers, childs_width);
// Get roots
array_type inter_roots(roots(m_order));
array_type inter_roots(roots());
// global positions
array_type g_pos(child_sized_shape);
......@@ -349,12 +349,12 @@ namespace scalfmm::interpolation
xt::view(m_child_parent_interpolators, level, xt::all(), xt::all(), o1 * m_order + o2);
auto v_child_coords = xt::view(child_coords, xt::all(), xt::all(), o1);
auto call_polynomials = [this](value_type x, std::size_t o, std::size_t n) -> value_type {
return polynomials(x, o, n);
auto call_polynomials = [this](value_type x, std::size_t n) -> value_type {
return polynomials(x, n);
};
auto v_get_polynomials = xt::vectorize(call_polynomials);
v_interpolators = v_get_polynomials(v_child_coords, m_order, o2);
v_interpolators = v_get_polynomials(v_child_coords, o2);
}
}
}
......
......@@ -84,15 +84,15 @@ namespace scalfmm::interpolation
auto operator=(uniform_interpolator&&) noexcept -> uniform_interpolator& = default;
~uniform_interpolator() = default;
[[nodiscard]] inline auto roots_impl(std::size_t order) const
[[nodiscard]] inline auto roots_impl() const
{
return xt::linspace(value_type(-1.), value_type(1), order);
return xt::linspace(value_type(-1.), value_type(1), this->order());
}
template<typename ComputationType>
[[nodiscard]] inline auto polynomials_impl(ComputationType x, std::size_t n) const
{
auto order{this->order()};
const auto order{this->order()};
using value_type = ComputationType;
// assert(xsimd::any(xsimd::abs(x) - 1. < 10. * std::numeric_limits<value_type>::epsilon()));
......@@ -142,7 +142,7 @@ namespace scalfmm::interpolation
template<typename ComputationType>
[[nodiscard]] inline auto derivative_impl(ComputationType x, std::size_t n) const
{
auto order{this->order()};
const auto order{this->order()};
using value_type = ComputationType;
// assert(xsimd::any(xsimd::abs(x) - 1. < 10. * std::numeric_limits<value_type>::epsilon()));
......@@ -154,7 +154,7 @@ namespace scalfmm::interpolation
value_type DdL(1.); // init denominator
value_type tmpNdL{};
auto roots(roots_impl(order));
auto roots(roots_impl());
for(unsigned int p = 0; p < order; ++p)
{
......@@ -190,12 +190,13 @@ namespace scalfmm::interpolation
// Preprocessing function for applying ffts on multipoles
// This function is called as soon as the multipoles are computed and available
template<typename Cell>
inline auto apply_multipoles_preprocessing_impl(Cell& current_cell, std::size_t order) const -> void
inline auto apply_multipoles_preprocessing_impl(Cell& current_cell) const -> void
{
using multipoles_container = typename Cell::multipoles_container;
using fft_type = container::get_variadic_adaptor_t<xt::xarray<typename multipoles_container::value_type>,
Cell::inputs_size>;
const auto order{this->order()};
// Get the multipoles and transformed mutlipoles tensors
auto const& multipoles = current_cell.cmultipoles();
auto& mtilde = current_cell.transformed_multipoles();
......@@ -227,7 +228,7 @@ namespace scalfmm::interpolation
// m2l operator impl
template<typename Cell, typename TupleScaleFactor>
inline auto apply_m2l_impl(Cell const& source_cell, Cell& target_cell, interaction_matrix_type const& k,
TupleScaleFactor scale_factor, std::size_t order, std::size_t tree_level,
TupleScaleFactor scale_factor, std::size_t tree_level,
[[maybe_unused]] buffer_type& products) const -> void
{
// get the transformed multipoles
......@@ -251,7 +252,7 @@ namespace scalfmm::interpolation
inline auto apply_multipoles_postprocessing_impl(Cell& current_cell,
[[maybe_unused]] buffer_type const& products) const -> void
{
auto order{current_cell.order()};
const auto order{this->order()};
auto& target_expansion = current_cell.locals();
// applying kn inverse real ffts
......@@ -323,7 +324,7 @@ namespace scalfmm::interpolation
// non_homogenous -> X is the [-cell_width_at_level/2, cell_width_at_level/2]
// X is a multidimensional grid generator returning a grid for X, another one for Y,...
// X is a multidimensional grid of points scaled on the size of cell
auto X_gen = tensor::generate_meshgrid<dimension>(half_width * this->roots(this->order()));
auto X_gen = tensor::generate_meshgrid<dimension>(half_width * this->roots());
// we evaluate the generator
auto X = std::apply(
[](auto&&... xs) { return std::make_tuple(xt::eval(std::forward<decltype(xs)>(xs))...); }, X_gen);
......
......@@ -28,8 +28,7 @@ namespace scalfmm::operators
// l2p operator
// -------------------------------------------------------------
template<typename FarField, typename Locals, typename Leaf>
inline void apply_l2p(FarField const& far_field, Locals const& local_expansion, Leaf& target_leaf,
std::size_t order)
inline void apply_l2p(FarField const& far_field, Locals const& local_expansion, Leaf& target_leaf)
{
// Interpolator type
using Interpolator = typename FarField::approximation_type;
......@@ -52,7 +51,6 @@ namespace scalfmm::operators
using simd_position_type = container::point<simd_type, dimension>;
// simd_vector size -> 8 in double for AVX512 for example
const std::size_t inc = simd_type::size;
//
// number of particles in the leaf
const std::size_t leaf_size{target_leaf.size()};
......@@ -61,6 +59,7 @@ namespace scalfmm::operators
const std::size_t vec_size = leaf_size - leaf_size % inc;
auto const& interp = far_field.approximation();
const auto order{interp.order()};
//
simd_position_type simd_width(simd_type(target_leaf.width()));
simd_position_type simd_center{};
......@@ -81,7 +80,7 @@ namespace scalfmm::operators
// Resulting S, also in simd
std::vector<value_type, XSIMD_DEFAULT_ALLOCATOR(value_type)> S(nnodes * inc);
auto call_polynomials = [&interp](auto x, std::size_t o, std::size_t n) { return interp.polynomials(x, o, n); };
auto call_polynomials = [&interp](auto x, std::size_t n) { return interp.polynomials(x, n); };
std::array<std::size_t, position_type::dimension> stops{};
stops.fill(order);
......@@ -100,7 +99,7 @@ namespace scalfmm::operators
for(std::size_t o = 0; o < order; ++o)
{
poly_of_part[o] =
simd::apply_f<simd_position_type::dimension>(call_polynomials, local_position, order, o);
simd::apply_f<simd_position_type::dimension>(call_polynomials, local_position, o);
}
// Assembling S
......@@ -168,7 +167,7 @@ namespace scalfmm::operators
for(std::size_t o = 0; o < order; ++o)
{
poly_of_part_scal[o] =
simd::apply_f<position_type::dimension>(call_polynomials, local_position, order, o);
simd::apply_f<position_type::dimension>(call_polynomials, local_position, o);
}
// Assembling S
......@@ -207,8 +206,7 @@ namespace scalfmm::operators
};
template<bool ComputeGradien, typename FarField, typename Locals, typename Leaf>
inline void apply_l2p_der(FarField const& far_field, Locals const& local_expansion, Leaf& target_leaf,
std::size_t order)
inline void apply_l2p_der(FarField const& far_field, Locals const& local_expansion, Leaf& target_leaf)
{
// Interpolator type
using Interpolator = typename FarField::approximation_type;
......@@ -237,6 +235,7 @@ namespace scalfmm::operators
/////
///// HERE
auto const& interp = far_field.approximation();
const auto order{interp.order()};
static constexpr bool compute_gradient = FarField::compute_gradient;
static constexpr int number_of_output = particle_type::outputs_size;
//// if true we compute the potential. If the gradient is false we always
......@@ -277,8 +276,8 @@ namespace scalfmm::operators
meta::for_each(S_der, [nnodes, inc](auto& c) { c.resize(nnodes * inc); });
}
auto call_polynomials = [&interp](auto x, std::size_t o, std::size_t n) { return interp.polynomials(x, o, n); };
auto call_derivative = [&interp](auto x, std::size_t o, std::size_t n) { return interp.derivative(x, o, n); };
auto call_polynomials = [&interp](auto x, std::size_t o, std::size_t n) { return interp.polynomials(x, n); };
auto call_derivative = [&interp](auto x, std::size_t o, std::size_t n) { return interp.derivative(x, n); };
// here, we process simd_size (i.e. inc) particles at each loop turn
for(std::size_t part = 0; part < vec_size; part += inc)
......@@ -295,12 +294,12 @@ namespace scalfmm::operators
for(std::size_t o = 0; o < order; ++o)
{
poly_of_part[o] =
simd::apply_f<simd_position_type::dimension>(call_polynomials, local_position, order, o);
simd::apply_f<simd_position_type::dimension>(call_polynomials, local_position, o);
if constexpr(ComputeGradien == true)
{
der_poly_of_part[o] =
simd::apply_f<simd_position_type::dimension>(call_derivative, local_position, order, o);
simd::apply_f<simd_position_type::dimension>(call_derivative, local_position, o);
}
}
......@@ -422,12 +421,12 @@ namespace scalfmm::operators
for(std::size_t o = 0; o < order; ++o)
{
poly_of_part_scal[o] =
simd::apply_f<position_type::dimension>(call_polynomials, local_position, order, o);
simd::apply_f<position_type::dimension>(call_polynomials, local_position, o);
if constexpr(ComputeGradien == true)
{
der_poly_of_part_scal[o] =
simd::apply_f<position_type::dimension>(call_derivative, local_position, order, o);
simd::apply_f<position_type::dimension>(call_derivative, local_position, o);
}
}
......@@ -496,11 +495,10 @@ namespace scalfmm::operators
}
template<typename FmmFarField, typename Cell, typename Leaf, bool ComputeForces = false>
inline void l2p(FmmFarField const& far_field /*fmm_operator*/, Cell const& source_cell, Leaf& target_leaf,
std::size_t order)
inline void l2p(FmmFarField const& far_field /*fmm_operator*/, Cell const& source_cell, Leaf& target_leaf)
{
// auto const& far_field = fmm_operator.far_field();
apply_l2p(far_field, source_cell.clocals(), target_leaf, order);
apply_l2p(far_field, source_cell.clocals(), target_leaf);
}
} // namespace scalfmm::operators
......
......@@ -11,10 +11,10 @@ namespace scalfmm::operators
{
template<typename Approximation, typename Cell>
inline void m2l(Approximation const& approximation, Cell const& source_cell, std::size_t neighbor_idx,
Cell& target_cell, std::size_t order, std::size_t current_tree_level,
Cell& target_cell, std::size_t current_tree_level,
typename Approximation::buffer_type& buffer)
{
approximation.apply_m2l(source_cell, target_cell, neighbor_idx, order, current_tree_level, buffer);
approximation.apply_m2l(source_cell, target_cell, neighbor_idx, current_tree_level, buffer);
}
} // namespace scalfmm::operators
......
......@@ -111,11 +111,11 @@ namespace scalfmm::operators
// -------------------------------------------------------------
template<typename Interpolator, typename Multipoles>
inline void apply_m2m(Interpolator const& interp, Multipoles const& child_expansion, std::size_t child_index,
Multipoles& parent_expansion, std::size_t order, std::size_t tree_level)
Multipoles& parent_expansion, std::size_t tree_level)
{
// applying generic operator throught compile time generation and tag dispatching
return impl::apply_op(
interp.cinterpolator_tensor(), child_expansion, child_index, parent_expansion, order, tree_level,
interp.cinterpolator_tensor(), child_expansion, child_index, parent_expansion, interp.order(), tree_level,
std::make_index_sequence<meta::tuple_size<typename std::decay_t<Multipoles>>::value>{}, impl::tag_m2m{});
}
......@@ -124,26 +124,26 @@ namespace scalfmm::operators
// -------------------------------------------------------------
template<typename Interpolator, typename Locals>
inline void apply_l2l(Interpolator const& interp, Locals const& parent_local_expansion, std::size_t child_index,
Locals& child_local_expansion, std::size_t order, std::size_t tree_level)
Locals& child_local_expansion, std::size_t tree_level)
{
// applying generic operator throught compile time generation and tag dispatching
return impl::apply_op(
interp.cinterpolator_tensor(), parent_local_expansion, child_index, child_local_expansion, order, tree_level,
interp.cinterpolator_tensor(), parent_local_expansion, child_index, child_local_expansion, interp.order(), tree_level,
std::make_index_sequence<meta::tuple_size<typename std::decay_t<Locals>>::value>{}, impl::tag_l2l{});
}
template<typename Interpolator, typename Cell>
inline void l2l(Interpolator const& interp, Cell const& parent_cell, std::size_t child_index, Cell& child_cell,
std::size_t order, std::size_t tree_level = 2)
std::size_t tree_level = 2)
{
apply_l2l(interp, parent_cell.clocals(), child_index, child_cell.locals(), order, tree_level);
apply_l2l(interp, parent_cell.clocals(), child_index, child_cell.locals(), tree_level);
}
template<typename Interpolator, typename Cell>
inline void m2m(Interpolator const& interp, Cell const& child_cell, std::size_t child_index, Cell& parent_cell,
std::size_t order, std::size_t tree_level = 2)
std::size_t tree_level = 2)
{
apply_m2m(interp, child_cell.cmultipoles(), child_index, parent_cell.multipoles(), order, tree_level);
apply_m2m(interp, child_cell.cmultipoles(), child_index, parent_cell.multipoles(), tree_level);
}
} // namespace scalfmm::operators
......
......@@ -23,8 +23,7 @@ namespace scalfmm::operators
// P2M operator
// -------------------------------------------------------------
template<typename Interpolator, typename Leaf, typename Multipoles>
inline void apply_p2m(Interpolator const& interp, Leaf const& source_leaf, Multipoles& multipoles_expansion,
std::size_t order)
inline void apply_p2m(Interpolator const& interp, Leaf const& source_leaf, Multipoles& multipoles_expansion)
{
// Leaf type
using leaf_type = Leaf;
......@@ -46,7 +45,7 @@ namespace scalfmm::operators
const std::size_t leaf_size{source_leaf.size()};
// vectorizable particles
const std::size_t vec_size = leaf_size - leaf_size % inc;
const auto order = interp.order();
// mapping operator in simd
const interpolation::map_glob_loc<simd_position_type> mapping_part_position(
source_leaf.center(), simd_position_type(simd_type(source_leaf.width())));
......@@ -65,7 +64,7 @@ namespace scalfmm::operators
std::array<std::size_t, position_type::dimension> stops{};
stops.fill(order);
auto call_polynomials = [&interp](auto x, std::size_t o, std::size_t n) { return interp.polynomials(x, o, n); };
auto call_polynomials = [&interp](auto x, std::size_t n) { return interp.polynomials(x, n); };
// here, we process simd_size (i.e. inc) particles at each loop turn
for(std::size_t part = 0; part < vec_size; part += inc)
{
......@@ -80,7 +79,7 @@ namespace scalfmm::operators
{
// polynomials_f_type polynomials{};
poly_of_part[o] =
simd::apply_f<simd_position_type::dimension>(call_polynomials, local_position, order, o);
simd::apply_f<simd_position_type::dimension>(call_polynomials, local_position, o);
}
// Assembling S
......@@ -150,7 +149,7 @@ namespace scalfmm::operators
{
// polynomials_f_type_scal polynomials{};
poly_of_part_scal[o] =
simd::apply_f<position_type::dimension>(call_polynomials, local_position, order, o);
simd::apply_f<position_type::dimension>(call_polynomials, local_position, o);
}
// Assembling S
......@@ -182,10 +181,10 @@ namespace scalfmm::operators
}
template<typename Interpolator, typename Leaf, typename Cell>
inline void p2m(Interpolator const& interp, Leaf const& source_leaf, Cell& target_cell, std::size_t order)
inline void p2m(Interpolator const& interp, Leaf const& source_leaf, Cell& target_cell)
{
apply_p2m(interp, source_leaf, target_cell.multipoles(), order);
interp.apply_multipoles_preprocessing(target_cell, order);
apply_p2m(interp, source_leaf, target_cell.multipoles());
interp.apply_multipoles_preprocessing(target_cell);
}
} // namespace scalfmm::operators
......
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