Mentions légales du service

Skip to content
Snippets Groups Projects
Commit bceea6ef authored by Olivier COULAUD's avatar Olivier COULAUD
Browse files

The direct calculation is validated (verified from pyhton)

The Fmm calculation is incorrect
parent f4a18522
No related branches found
No related tags found
No related merge requests found
......@@ -7,11 +7,8 @@
#include "scalfmm/matrix_kernels/laplace.hpp"
#include "scalfmm/meta/utils.hpp"
#include "scalfmm/operators/fmm_operators.hpp"
#include "scalfmm/tree/box.hpp"
#include "scalfmm/tree/cell.hpp"
#include "scalfmm/tree/for_each.hpp"
#include "scalfmm/tree/group_tree_view.hpp"
#include "scalfmm/tree/leaf_view.hpp"
#include "scalfmm/tools/fma_loader.hpp"
#include "scalfmm/tree/tree.hpp"
#include "scalfmm/utils/accurater.hpp"
// cpp tools
......@@ -79,6 +76,7 @@ namespace local_args
}
} // namespace local_args
#define PART_VAR
template<typename ValueType, std::size_t Dimension, typename MatrixKernelType, typename ParserType>
auto run(ParserType const& parser) -> void
{
......@@ -89,8 +87,14 @@ auto run(ParserType const& parser) -> void
static constexpr std::size_t nb_inputs{matrix_kernel_type::km};
static constexpr std::size_t nb_outputs{matrix_kernel_type::kn};
#ifdef PART_VAR
using particle_type =
scalfmm::container::particle<value_type, dimension, value_type, nb_inputs, value_type, nb_outputs, std::size_t>;
scalfmm::container::particle<value_type, dimension, value_type, nb_inputs, value_type, nb_outputs, std::int64_t>;
#else
using particle_type =
scalfmm::container::particle<value_type, dimension, value_type, nb_inputs, value_type, nb_outputs>;
#endif
using position_type = typename particle_type::position_type;
using box_type = scalfmm::component::box<position_type>;
......@@ -120,8 +124,9 @@ auto run(ParserType const& parser) -> void
box_type box(box_width, box_center);
// random generator
std::random_device rd;
std::mt19937 gen(rd());
// std::random_device rd;
// std::mt19937 gen(rd());
std::mt19937 gen(123);
std::uniform_real_distribution<value_type> dis(0.0, 2.0);
auto random_r = [&dis, &gen]() { return dis(gen); };
......@@ -142,13 +147,18 @@ auto run(ParserType const& parser) -> void
{
e = value_type(0.);
}
#ifdef PART_VAR
p.variables(idx);
#endif
}
// construct the near field
near_field_type near_field{};
// a reference on the matrix_kernel of the near_field
auto near_mk = near_field.matrix_kernel();
near_mk.set_coeff(2.0);
// build the approximation used in the near field
interpolator_type interpolator(order, tree_height, box.width(0));
......@@ -164,10 +174,16 @@ auto run(ParserType const& parser) -> void
scalfmm::algorithms::full_direct(container, near_mk);
std::cout << " write direct computation in data_smmooth_direct.fma\n";
scalfmm::io::FFmaGenericWriter<value_type> writer("data_smmooth_direct.fma", false);
writer.writeDataFrom(container, box.center(), tree.box_width());
//
scalfmm::utils::accurater<value_type> error{};
#ifdef PART_VAR
container_type container_debug(container);
scalfmm::component::for_each_leaf(std::cbegin(tree), std::cend(tree),
[&container, &error](auto const& leaf)
[&container, &container_debug, &error](auto const& leaf)
{
// loop on the particles of the leaf
for(auto const p_ref: leaf)
......@@ -179,17 +195,25 @@ auto run(ParserType const& parser) -> void
auto const& output_ref = container[idx].outputs();
auto const& output = p.outputs();
std::cout << p << " ref " << container[idx] << std::endl;
for(std::size_t i{0}; i < nb_outputs; ++i)
{
container_debug[idx].outputs().at(i) = output.at(i);
error.add(output_ref.at(i), output.at(i));
}
}
});
std::cout << cpp_tools::colors::red;
std::cout << error << '\n';
std::cout << cpp_tools::colors::reset;
std::cout << " write fmm computation in data_smmooth_fmm_debug.fma\n";
scalfmm::io::FFmaGenericWriter<value_type> writer_d("data_smmooth_fmm_debug.fma", false);
writer_d.writeDataFrom(container_debug, box.center(), tree.box_width());
#endif
std::cout << " write fmm computation in data_smmooth_fmm.fma\n";
scalfmm::io::FFmaGenericWriter<value_type> writer2("data_smmooth_fmm.fma", false);
writer2.writeDataFromTree(tree, nb_particles);
}
template<typename... Args>
......@@ -220,10 +244,10 @@ auto main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[]) -> int
run<value_type, dimension, matrix_kernel_type>(parser);
}
{
using matrix_kernel_type = scalfmm::matrix_kernels::laplace::one_over_r;
run<value_type, dimension, matrix_kernel_type>(parser);
}
// {
// using matrix_kernel_type = scalfmm::matrix_kernels::laplace::one_over_r;
// run<value_type, dimension, matrix_kernel_type>(parser);
// }
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment