ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
dipolar_direct_sum_gpu.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010-2022 The ESPResSo project
3 *
4 * This file is part of ESPResSo.
5 *
6 * ESPResSo is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * ESPResSo is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include "config/config.hpp"
21
22#ifdef DIPOLAR_DIRECT_SUM
23
26
27#include "BoxGeometry.hpp"
28#include "communication.hpp"
30#include "system/System.hpp"
31
32static void get_simulation_box(BoxGeometry const &box_geo, float *box,
33 int *per) {
34 for (unsigned int i = 0u; i < 3u; i++) {
35 box[i] = static_cast<float>(box_geo.length()[i]);
36 per[i] = box_geo.periodic(i);
37 }
38}
39
43
45 auto &gpu_particle_data = get_system().gpu;
46 gpu_particle_data.enable_property(GpuParticleData::prop::force);
47 gpu_particle_data.enable_property(GpuParticleData::prop::torque);
48 gpu_particle_data.enable_property(GpuParticleData::prop::pos);
49 gpu_particle_data.enable_property(GpuParticleData::prop::dip);
50}
51
53 auto &system = get_system();
54 auto &gpu = system.gpu;
55 gpu.update();
56 if (this_node != 0) {
57 return;
58 }
59 float box[3];
60 int periodicity[3];
61 get_simulation_box(*system.box_geo, box, periodicity);
62 auto const npart = static_cast<unsigned>(gpu.n_particles());
63 auto const forces_device = gpu.get_particle_forces_device();
64 auto const torques_device = gpu.get_particle_torques_device();
65 auto const positions_device = gpu.get_particle_positions_device();
66 auto const dipoles_device = gpu.get_particle_dipoles_device();
68 static_cast<float>(prefactor), npart, positions_device, dipoles_device,
69 forces_device, torques_device, box, periodicity);
70}
71
73 auto &system = get_system();
74 auto &gpu = system.gpu;
75 gpu.update();
76 if (this_node != 0) {
77 return;
78 }
79 float box[3];
80 int periodicity[3];
81 get_simulation_box(*system.box_geo, box, periodicity);
82 auto const npart = static_cast<unsigned>(gpu.n_particles());
83 auto const energy_device = &(gpu.get_energy_device()->dipolar);
84 auto const positions_device = gpu.get_particle_positions_device();
85 auto const dipoles_device = gpu.get_particle_dipoles_device();
86 DipolarDirectSum_kernel_wrapper_energy(static_cast<float>(prefactor), npart,
87 positions_device, dipoles_device, box,
88 periodicity, energy_device);
89}
90
91#endif
Utils::Vector3d const & length() const
Box length.
constexpr bool periodic(unsigned coord) const
Check periodicity in direction.
double prefactor
Magnetostatics prefactor.
int this_node
The number of this node.
This file contains the defaults for ESPResSo.
static void get_simulation_box(BoxGeometry const &box_geo, float *box, int *per)
void DipolarDirectSum_kernel_wrapper_energy(float k, unsigned int n, float *pos, float *dip, float box_l[3], int periodic[3], float *E)
void DipolarDirectSum_kernel_wrapper_force(float k, unsigned int n, float *pos, float *dip, float *f, float *torque, float box_l[3], int periodic[3])
DipolarDirectSumGpu(double prefactor)
static constexpr std::size_t force
static constexpr std::size_t torque
static constexpr std::size_t pos
static constexpr std::size_t dip