diff --git a/bfps/cpp/fftw_interface.hpp b/bfps/cpp/fftw_interface.hpp index 4e86f63e531a592caf1aad3901ad4de30d5b1816..68eed567620bd1f56228a7d7024dcf26bc9a95ce 100644 --- a/bfps/cpp/fftw_interface.hpp +++ b/bfps/cpp/fftw_interface.hpp @@ -42,6 +42,16 @@ #include <algorithm> #include <cassert> #include <cstring> +#include <type_traits> + +// To mix unique ptr with allocation from fftw +struct fftw_free_deleter{ + template <typename T> + void operator()(T *p) const { + fftwf_free(const_cast<typename std::remove_const<T>::type*>(p)); + } +}; + #endif template <class realtype> @@ -62,7 +72,7 @@ public: int howmany; ptrdiff_t iblock; ptrdiff_t oblock; - std::shared_ptr<real> buffer; + std::unique_ptr<real[], fftw_free_deleter> buffer; plan plan_to_use; ptrdiff_t local_n0, local_0_start; @@ -424,7 +434,7 @@ public: int howmany; ptrdiff_t iblock; ptrdiff_t oblock; - std::shared_ptr<real> buffer; + std::unique_ptr<real[], fftw_free_deleter> buffer; plan plan_to_use; ptrdiff_t local_n0, local_0_start; diff --git a/bfps/cpp/particles/particles_distr_mpi.hpp b/bfps/cpp/particles/particles_distr_mpi.hpp index 485595181f69b9fe1cf204b06df550a9ca74215d..ebc24750017d5e20bdd5611b59e43e52d366593f 100644 --- a/bfps/cpp/particles/particles_distr_mpi.hpp +++ b/bfps/cpp/particles/particles_distr_mpi.hpp @@ -136,7 +136,7 @@ public: template <class computer_class, class field_class, int size_particle_positions, int size_particle_rhs> void compute_distr(computer_class& in_computer, - field_class& in_field, + const field_class& in_field, const partsize_t current_my_nb_particles_per_partition[], const real_number particles_positions[], real_number particles_current_rhs[], diff --git a/bfps/cpp/particles/particles_system.hpp b/bfps/cpp/particles/particles_system.hpp index 02767a8b433ecb8365f4a0577d1c0d6508c2bed1..081f4b4b7315c309638890d51d82e47d3c1033bd 100644 --- a/bfps/cpp/particles/particles_system.hpp +++ b/bfps/cpp/particles/particles_system.hpp @@ -29,7 +29,7 @@ class particles_system : public abstract_particles_system<partsize_t, real_numbe using computer_class = particles_field_computer<partsize_t, real_number, interpolator_class, interp_neighbours>; computer_class computer; - field_class default_field; + const field_class& default_field; std::unique_ptr<partsize_t[]> current_my_nb_particles_per_partition; std::unique_ptr<partsize_t[]> current_offset_particles_for_partition;