22#ifdef DIPOLAR_BARNES_HUT
27#include "communication.hpp"
31#include "system/System.hpp"
39 throw std::domain_error(
"Parameter 'itolsq' must be > 0");
42 throw std::domain_error(
"Parameter 'epssq' must be > 0");
57template <
class... Args,
class... ArgRef>
63 }
catch (std::runtime_error
const &err) {
69int DipolarBarnesHutGpu::initialize_data_structure() {
71 auto const n_part =
static_cast<int>(gpu.n_particles());
74 if (error_code ==
ES_OK) {
75 auto const positions_device = gpu.get_particle_positions_device();
76 auto const dipoles_device = gpu.get_particle_dipoles_device();
77 fill_bh_data(positions_device, dipoles_device, &m_bh_data);
90 gpu_particle_data.update();
92 if (initialize_data_structure() ==
ES_OK) {
93 auto forces_device = gpu_particle_data.get_particle_forces_device();
94 auto torques_device = gpu_particle_data.get_particle_torques_device();
96 forces_device, torques_device);
103 gpu_particle_data.update();
105 if (initialize_data_structure() ==
ES_OK) {
106 auto energy = &(gpu_particle_data.get_energy_device()->dipolar);
int call_kernel(void(*fp)(Args...), ArgRef &&...args)
void buildBoxBH(int blocks)
Building Barnes-Hut spatial min/max position box.
void setBHPrecision(float epssq, float itolsq)
Barnes-Hut parameters setter.
void energyBH(BHData *bh_data, float k, float *E)
Barnes-Hut energy calculation.
void forceBH(BHData *bh_data, float k, float *f, float *torque)
Barnes-Hut force calculation.
void initBHgpu(int blocks)
Barnes-Hut CUDA initialization.
void summarizeBH(int blocks)
Calculate octant cells masses and cell index counts. Determine cells centers of mass and total dipole...
void allocBHmemCopy(int nbodies, BHData *bh_data)
An allocation of the GPU device memory and an initialization where it is needed.
void sortBH(int blocks)
Sort particle indexes according to the Barnes-Hut tree representation. Crucial for the per-warp perfo...
void fill_bh_data(float const *r, float const *dip, BHData const *bh_data)
Copy Barnes-Hut data to bhpara and copy particle data.
void buildTreeBH(int blocks)
Building Barnes-Hut tree in a linear child array representation of octant cells and particles inside.
void set_prefactor(double new_prefactor)
double prefactor
Magnetostatics prefactor.
int this_node
The number of this node.
This file contains the defaults for ESPResSo.
#define ES_OK
error code if no error occurred
#define ES_ERROR
error code if an error occurred
This file contains the errorhandling code for severe errors, like a broken bond or illegal parameter ...
#define runtimeErrorMsg()
DipolarBarnesHutGpu(double prefactor, double epssq, double itolsq)
void on_activation() const
void add_long_range_forces()
static constexpr std::size_t force
static constexpr std::size_t torque
static constexpr std::size_t pos
static constexpr std::size_t dip