milupHPC documentation
  • src
  • integrator
device_explicit_euler.cu
Go to the documentation of this file.
1#include "../../include/integrator/device_explicit_euler.cuh"
2#include "../../include/cuda_utils/cuda_launcher.cuh"
3
4__global__ void ExplicitEulerNS::Kernel::update(Particles *particles, integer n, real dt) {
5
6 integer bodyIndex = threadIdx.x + blockIdx.x * blockDim.x;
7 integer stride = blockDim.x * gridDim.x;
8 integer offset = 0;
9
10 while (bodyIndex + offset < n) {
11
12 // calculating/updating the velocities
13 particles->vx[bodyIndex + offset] += dt * (particles->ax[bodyIndex + offset] + particles->g_ax[bodyIndex + offset]);
14#if DIM > 1
15 particles->vy[bodyIndex + offset] += dt * (particles->ay[bodyIndex + offset] + particles->g_ay[bodyIndex + offset]);
16#if DIM == 3
17 particles->vz[bodyIndex + offset] += dt * (particles->az[bodyIndex + offset] + particles->g_az[bodyIndex + offset]);
18#endif
19#endif
20
21 //if ((bodyIndex + offset) % 1000 == 0) {
22 // printf("vx[%i] += dt * (%f + %f) = %f\n", bodyIndex + offset, particles->ax[bodyIndex + offset],
23 // particles->g_ax[bodyIndex + offset], dt * (particles->ax[bodyIndex + offset] + particles->g_ax[bodyIndex + offset]));
24 //}
25
26 // calculating/updating the positions
27 particles->x[bodyIndex + offset] += dt * particles->vx[bodyIndex + offset];
28#if DIM > 1
29 particles->y[bodyIndex + offset] += dt * particles->vy[bodyIndex + offset];
30#if DIM == 3
31 particles->z[bodyIndex + offset] += dt * particles->vz[bodyIndex + offset];
32#endif
33#endif
34
35#if INTEGRATE_DENSITY
36 particles->rho[bodyIndex + offset] = particles->rho[bodyIndex + offset] + dt * particles->drhodt[bodyIndex + offset];
37 //particles->drhodt[i] = 0.5 * (predictor->drhodt[i] + particles->drhodt[i]);
38#endif
39#if INTEGRATE_ENERGY
40 particles->e[bodyIndex + offset] += dt * particles->dedt[bodyIndex + offset];
41 if (particles->e[bodyIndex + offset] < 1e-50) {
42 particles->e[bodyIndex + offset] = 1e-50;
43 }
44 //printf("e = %e + (%e * %e)\n", particles->e[bodyIndex + offset], dt, particles->dedt[bodyIndex + offset]);
45 //particles->dedt[i] = 0.5 * (predictor->dedt[i] + particles->dedt[i]);
46#endif
47#if INTEGRATE_SML
48 particles->sml[bodyIndex + offset] = particles->sml[bodyIndex + offset] + dt * particles->dsmldt[bodyIndex + offset];
49 //printf("dsmldt: sml += %e * (dsmldt[%i] = %e)\n", dt, bodyIndex + offset, particles->dsmldt[bodyIndex + offset]);
50#endif
51
52 offset += stride;
53 }
54}
55
56real ExplicitEulerNS::Kernel::Launch::update(Particles *particles, integer n, real dt) {
57
58 ExecutionPolicy executionPolicy;
59 return cuda::launch(true, executionPolicy, ::ExplicitEulerNS::Kernel::update, particles, n, dt);
60
61}
ExecutionPolicy
Execution policy/instruction for CUDA kernel execution.
Definition: cuda_launcher.cuh:33
Particles
Particle(s) class based on SoA (Structur of Arrays).
Definition: particles.cuh:50
Particles::e
real * e
(pointer to) internal energy (array)
Definition: particles.cuh:121
Particles::x
real * x
(pointer to) x position (array)
Definition: particles.cuh:62
Particles::rho
real * rho
(pointer to) density (array)
Definition: particles.cuh:133
Particles::drhodt
real * drhodt
(pointer to) time derivative of density (array)
Definition: particles.cuh:148
Particles::g_ay
real * g_ay
(pointer to) y gravitational acceleration (array)
Definition: particles.cuh:92
Particles::ay
real * ay
(pointer to) y acceleration (array)
Definition: particles.cuh:74
Particles::az
real * az
(pointer to) z acceleration (array)
Definition: particles.cuh:82
Particles::y
real * y
(pointer to) y position (array)
Definition: particles.cuh:70
Particles::ax
real * ax
(pointer to) x acceleration (array)
Definition: particles.cuh:66
Particles::g_ax
real * g_ax
(pointer to) x gravitational acceleration (array)
Definition: particles.cuh:88
Particles::sml
real * sml
(pointer to) smoothing length (array)
Definition: particles.cuh:113
Particles::dedt
real * dedt
(pointer to) time derivative of internal energy (array)
Definition: particles.cuh:123
Particles::z
real * z
(pointer to) z position (array)
Definition: particles.cuh:78
Particles::vz
real * vz
(pointer to) z velocity (array)
Definition: particles.cuh:80
Particles::g_az
real * g_az
(pointer to) z gravitational acceleration (array)
Definition: particles.cuh:96
Particles::vx
real * vx
(pointer to) x velocity (array)
Definition: particles.cuh:64
Particles::vy
real * vy
(pointer to) y velocity (array)
Definition: particles.cuh:72
ExplicitEulerNS::Kernel::Launch::update
real update(Particles *particles, integer n, real dt)
Wrapper for ExplicitEulerNS::Kernel::update().
Definition: device_explicit_euler.cu:56
ExplicitEulerNS::Kernel::update
__global__ void update(Particles *particles, integer n, real dt)
Update/move/advance particles.
Definition: device_explicit_euler.cu:4
cuda::launch
real launch(bool timeKernel, const ExecutionPolicy &policy, void(*f)(Arguments...), Arguments... args)
CUDA execution wrapper function.
Definition: cuda_launcher.cuh:114
real
double real
Definition: parameter.h:15
integer
int integer
Definition: parameter.h:17

milupHPC - src/integrator/device_explicit_euler.cu Source File
Generated on Wed Aug 31 2022 12:16:52 by Doxygen 1.9.3