Commit 41027137 authored by COULAUD Olivier's avatar COULAUD Olivier
Browse files

start particles distribution

parent 8bff5bfd
......@@ -5,12 +5,16 @@
find_package(Doxygen REQUIRED)
find_package(Sphinx REQUIRED)
file(GLOB_RECURSE SCALFMM_HEADERS ${CMAKE_SOURCE_DIR}/include/*.hpp)
file(GLOB_RECURSE SCALFMM_HEADERS
${CMAKE_SOURCE_DIR}/include/*.hpp
${CMAKE_SOURCE_DIR}/modules/internal/inria_tools/inria/*.hpp
)
set(DOXYGEN_INDEX_FILE ${CMAKE_CURRENT_SOURCE_DIR}/html/index.html)
set(DOXYGEN_INPUT_DIR ${PROJECT_SOURCE_DIR}/include)
set(DOXYGEN_EXAMPLES_DIR ${PROJECT_SOURCE_DIR}/examples)
set(DOXYGEN_MODULES_DIR ${PROJECT_SOURCE_DIR}/modules/internal/inria_tools/inria)
set(DOXYGEN_OUTPUT_DIR ${CMAKE_BINARY_DIR}/docs/doxygen)
set(DOXYGEN_INDEX_FILE ${DOXYGEN_OUTPUT_DIR}/html/index.html)
set(DOXYFILE_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
......
# Doxyfile 1.8.18
l# Doxyfile 1.8.18
# This file describes the settings to be used by the documentation system
# doxygen (www.doxygen.org) for a project.
......@@ -824,7 +824,8 @@ WARN_LOGFILE =
# Note: If this tag is empty the current directory is searched.
INPUT = @DOXYGEN_INPUT_DIR@ \
@DOXYGEN_EXAMPLES_DIR@
@DOXYGEN_EXAMPLES_DIR@ \
@DOXYGEN_MODULES_DIR@
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
......
......@@ -26,10 +26,14 @@ auto main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[]) -> int
constexpr int nb_inputs_far = 1;
constexpr int nb_outputs_far = 1;
using value_type = double;
using mortonIndex_type = std::size_t;
using globalIndex_type = std::size_t;
using particle_type = scalfmm::container::particle<value_type, dimension, value_type, nb_inputs_near, value_type,
nb_outputs_near, std::size_t>;
nb_outputs_near/*, mortonIndex_type, globalIndex_type*/>;
using read_particle_type = scalfmm::container::particle<value_type, dimension, value_type, nb_inputs_near, value_type,
0, std::size_t>; using container_type = scalfmm::container::particle_container<particle_type>;
0, mortonIndex_type, globalIndex_type>;
using container_type = scalfmm::container::particle_container<particle_type>;
using position_type = typename particle_type::position_type;
using cell_type =
scalfmm::component::cell<value_type, dimension, nb_inputs_far, nb_outputs_far, std::complex<value_type>>;
......@@ -93,6 +97,7 @@ auto main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[]) -> int
{
e = values_to_read[ii++];
}
// p.variables()
particles_set[idx] = p;
//container.push_particle(idx, p);
}
......@@ -115,10 +120,14 @@ auto main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[]) -> int
//
int rank = para.get_process_id();
scalfmm::tree::let::buildLetTree(para, loader, particles_set, box, tree_height, group_size, letGroupTree,
scalfmm::tree::let::buildLetTree(para, loader, particles_set, box, tree_height, group_size,
group_size, letGroupTree,
mortonCellDistribution, nb_block);
scalfmm::tree::print("rank(" + std::to_string(rank) + ") data distrib: ", mortonCellDistribution);
///
///////////////////////////////////////////////////////////////////////////////////////////////////////
......
......@@ -113,11 +113,13 @@ auto main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[]) -> int
using interpolator_type2 = scalfmm::interpolation::chebyshev_interpolator<value_type, dimension, matrix_kernel_type>;
using far_field_type = scalfmm::operators::far_field_operator<interpolator_type, true>;
using far_field_type2 = scalfmm::operators::far_field_operator<interpolator_type2, true>;
// pos, charge, pot + forces no variables
using particle_type =
scalfmm::container::particle<value_type, dimension, value_type, nb_inputs, value_type, nb_outputs_leaf, std::size_t>;
using container_type = scalfmm::container::particle_container<particle_type>;
using cell_type = scalfmm::component::cell<value_type, dimension, nb_inputs, nb_outputs, std::complex<value_type>>;
using cell_type = scalfmm::component::cell<value_type, dimension, nb_inputs, nb_outputs, value_type/*std::complex<value_type>*/>;
using leaf_type = scalfmm::component::leaf<particle_type>;
using position_type = typename particle_type::position_type;
//
......@@ -196,6 +198,11 @@ auto main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[]) -> int
static_cast<std::size_t>(tree_height),
box.width(0));
auto roots2_1d = cheb.roots(static_cast<std::size_t>(order));
interpolator_type2 chebychev(matrix_kernel_type{}, order,
static_cast<std::size_t>(tree_height),
box.width(0));
far_field_type2 far_cheb(chebychev);
std::cout << "roots: " << roots2_1d << std::endl;
///
/////////////////////////////////////////////////////////////////////////////
......
//
// ./examples/test_oc -th 3 -gs 1 --input-file empty.txt
//
#include "parameters.hpp"
#include "scalfmm/algorithms/sequential/sequential.hpp"
#include "scalfmm/container/particle.hpp"
#include "scalfmm/container/particle_container.hpp"
#include "scalfmm/kernels/count_kernel/count_kernel.hpp"
#include "scalfmm/matrix_kernels/laplace.hpp"
#include "scalfmm/meta/utils.hpp"
#include "scalfmm/tools/colorized.hpp"
#include "scalfmm/tree/box.hpp"
#include "scalfmm/tree/cell.hpp"
#include "scalfmm/tree/group_tree.hpp"
#include "scalfmm/tree/leaf.hpp"
#include "scalfmm/utils/tensor.hpp"
//#include <Files/FFmaGenericLoader.hpp>
#include <algorithm>
#include <bits/c++config.h>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <random>
#include <scalfmm/utils/timer.hpp>
#include <sstream>
#include <string>
#include <sys/types.h>
#include <thread>
#include <tuple>
#include <unistd.h>
#include <utility>
#include <xtensor/xarray.hpp>
#include <xtensor/xbuilder.hpp>
auto main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[]) -> int
{
// Parameter handling
args::cli.parse(argc, argv);
command_line_parameters params(args::cli);
// Getting command line parameters
const auto tree_height{params.tree_height};
const auto input_file{params.input_file};
const auto group_size{params.block_size};
static constexpr std::size_t dimension = 3;
static constexpr std::size_t number_of_physical_values = 1;
const auto runtime_order{params.order};
// ---------------------------------------
// scalfmm 3.0 tree tests and benchmarks.
// ---------------------------------------
using value_type = double;
using particle3_type = scalfmm::container::particle<double, dimension, double>;
using container3_type = scalfmm::container::particle_container<particle3_type>;
using position3_type = typename particle3_type::position_type;
using outputs3_type = std::tuple<double>;
using cell3_type = scalfmm::component::cell<double, dimension, number_of_physical_values>;
using leaf3_type = scalfmm::component::leaf<particle3_type, outputs3_type>;
using box3_type = scalfmm::component::box<position3_type>;
using group_tree3_type = scalfmm::component::group_tree<cell3_type, leaf3_type, box3_type>;
using interpolator_type = count_kernel::count_interpolator;
// Open particle file
value_type box_width{1.};
scalfmm::container::point<double, dimension> box3_center(0.); //{0., 0., 0.};
double step{box_width / scalfmm::math::pow(2, (tree_height - 1))};
std::cout << "Step = " << step << '\n';
auto cell_width = step;
auto number_of_values_per_dimension = std::size_t(scalfmm::math::pow(2, (tree_height - 1)));
std::cout << "Number of value per dimension = " << number_of_values_per_dimension << '\n';
xt::xarray<std::tuple<double, double, double, double>> particles(
std::vector(dimension, number_of_values_per_dimension));
std::cout << "linspace = "
<< xt::linspace(double(-box_width / 2.) + step * 0.5, double(box_width / 2.) - step * 0.5,
number_of_values_per_dimension)
<< '\n';
//
// Build Mesh grid with center of each leaf (the tree is full)
//
auto particle_generator = scalfmm::tensor::generate_meshgrid<dimension>(xt::linspace(
double(-box_width / 2.) + step * 0.5, double(box_width / 2.) - step * 0.5, number_of_values_per_dimension));
// New version
// We set between 1 and 6 particles per leaf. Each particle is randomly set in the leaf
std::random_device rd; // Will be used to obtain a seed for the random number engine
std::mt19937 gen(rd()); // Standard mersenne_twister_engine seeded with rd()
std::uniform_int_distribution<int> distrib(1, 5);
std::vector<int> nb_part_per_leaf(particles.size());
std::size_t number_of_particles = 0;
for(std::size_t i = 0; i < particles.size(); ++i)
{
nb_part_per_leaf[i] = distrib(gen);
number_of_particles += nb_part_per_leaf[i];
}
std::cout << " Total number of particles " << number_of_particles << std::endl;
// Generate the particles and put them in the container
container3_type container3(number_of_particles);
auto container3_it = std::begin(container3);
scalfmm::container::point<value_type, dimension> position{};
value_type physical_value{0.0};
scalfmm::utils::timer time{};
{
time.tic();
std::uniform_real_distribution<double> distribR(-cell_width / 2, cell_width / 2);
// the vectors of the centre of the leaves.
const auto centre_x = xt::flatten(std::get<0>(particle_generator));
const auto centre_y = xt::flatten(std::get<1>(particle_generator));
const auto centre_z = xt::flatten(std::get<2>(particle_generator));
for(std::size_t idxL = 0; idxL < particles.size(); ++idxL)
{
for(int idx = 0; idx < nb_part_per_leaf[idxL]; ++idx)
{
*container3_it = std::make_tuple(centre_x[idxL] + distribR(gen), centre_y[idxL] + distribR(gen),
centre_z[idxL] + distribR(gen), physical_value);
++container3_it;
}
}
}
//
box3_type box3(box_width, box3_center);
// Generate the tree
group_tree3_type gtree3(static_cast<std::size_t>(tree_height), runtime_order, box3,
static_cast<std::size_t>(group_size), container3);
interpolator_type interp; // runtime_order, static_cast<std::size_t>(tree_height));
scalfmm::algorithms::sequential(std::begin(gtree3), std::end(gtree3), interp);
scalfmm::component::for_each_leaf(std::begin(gtree3), std::end(gtree3), [](auto const& leaf) {
std::cout << scalfmm::colors::red << *std::begin(std::get<0>(leaf.coutputs())) << " ";
});
std::cout << scalfmm::colors::reset << '\n';
return 0;
}
......@@ -87,7 +87,6 @@ namespace scalfmm::interpolation
std::cout << " cos(n) " << (xt::cos(coeff * (xt::arange(int(order - 1), int(-1), -1) + 0.5))) << std::endl;
// const auto p = xt::eval(xt::cos(coeff * (xt::arange(int(order - 1), int(-1), -1) + 0.5)));
return xt::cos(coeff * (xt::arange(int(order - 1), int(-1), -1) + 0.5));
//return xt::linspace(value_type(-1.), value_type(1), order);
}
/**
* Chebyshev polynomials of first kind \f$ T_n(x) = \cos(n \arccos(x)) \f$
......@@ -127,9 +126,7 @@ namespace scalfmm::interpolation
return value_type(n * (sin(n * acos(x))) / sqrt(1 - x * x));
}
inline auto generate_interactions_matrixes_impl(value_type width, std::size_t tree_height) -> void
{}
inline auto generate_interactions_matrixes_impl(value_type width, std::size_t tree_height) -> void {}
template<typename TensorViewX, typename TensorViewY>
[[nodiscard]] inline auto generate_matrix_k_impl(TensorViewX&& X, TensorViewY&& Y, std::size_t order,
......
......@@ -19,9 +19,18 @@ class parallel_manager
int m_number_threads{}; ///< number of threads
#ifdef SCALFMM_USE_MPI
inria::mpi::communicator m_communicator;
#else
struct empty
{
};
#endif
public:
#ifdef SCALFMM_USE_MPI
using comm_type = inria::mpi::communicator;
#else
using comm_type = empty;
#endif
int get_num_threads() const { return m_number_threads; };
void set_num_threads(const int num)
{
......@@ -91,10 +100,13 @@ class parallel_manager
std::cout << " Fin version parallel" << std::endl;
#endif
}
inria::mpi::communicator get_communicator() const
comm_type get_communicator() const
{
#ifdef SCALFMM_USE_MPI
return m_communicator;
#else
return empty{};
#endif
}
};
......
Supports Markdown
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