1#include "../../include/integrator/device_predictor_corrector_euler.cuh"
2#include "../../include/cuda_utils/cuda_launcher.cuh"
34 shared->
set(forces, courant, artVisc);
49 forces, courant, artVisc);
91 namespace BlockSharedNS {
93 blockShared->
set(forces, courant, artVisc);
109 forces, courant, artVisc);
134 for (i = threadIdx.x + blockIdx.x * blockDim.x; i <
numParticles; i+= blockDim.x * gridDim.x) {
157 particles->
x[i] = particles->
x[i] + dt/2 * (
predictor->vx[i] + particles->
vx[i]);
162 particles->
vx[i] = particles->
vx[i] + dt/2 * (
predictor->ax[i] + particles->
ax[i] + 2 * particles->
g_ax[i]);
167 particles->
ax[i] = 0.5 * (
predictor->ax[i] + particles->
ax[i]) + particles->
g_ax[i];
172 particles->
y[i] = particles->
y[i] + dt/2 * (
predictor->vy[i] + particles->
vy[i]);
173 particles->
vy[i] = particles->
vy[i] + dt/2 * (
predictor->ay[i] + particles->
ay[i] + 2 * particles->
g_ay[i]);
174 particles->
ay[i] = 0.5 * (
predictor->ay[i] + particles->
ay[i]) + particles->
g_ay[i];
176 particles->
z[i] = particles->
z[i] + dt/2 * (
predictor->vz[i] + particles->
vz[i]);
177 particles->
vz[i] = particles->
vz[i] + dt/2 * (
predictor->az[i] + particles->
az[i] + 2 * particles->
g_az[i]);
178 particles->
az[i] = 0.5 * (
predictor->az[i] + particles->
az[i]) + particles->
g_az[i];
194 particles->
e[i] = particles->
e[i] + dt/2 * (
predictor->dedt[i] + particles->
dedt[i]);
195 if (particles->
e[i] < 1e-6) {
196 particles->
e[i] = 1e-6;
206 particles->
sml[i] = particles->
sml[i] + dt * particles->dsmldt[i];
209 particles->
sml[i] = particles->
sml[i] + dt/2 * (
predictor->dsmldt[i] + particles->dsmldt[i]);
210 particles->dsmldt[i] = 0.5 * (
predictor->dsmldt[i] + particles->dsmldt[i]);
227 for (i = threadIdx.x + blockIdx.x * blockDim.x; i <
numParticles; i+= blockDim.x * gridDim.x) {
229 predictor->x[i] = particles->
x[i] + dt * particles->
vx[i];
230 predictor->vx[i] = particles->
vx[i] + dt * (particles->
ax[i] + particles->
g_ax[i]);
232 predictor->y[i] = particles->
y[i] + dt * particles->
vy[i];
233 predictor->vy[i] = particles->
vy[i] + dt * (particles->
ay[i] + particles->
g_ay[i]);
235 predictor->z[i] = particles->
z[i] + dt * particles->
vz[i];
236 predictor->vz[i] = particles->
vz[i] + dt * (particles->
az[i] + particles->
g_az[i]);
256 predictor->sml[i] = particles->
sml[i] + dt * particles->dsmldt[i];
290#define SAFETY_FIRST 0.1
324 for (i = threadIdx.x + blockIdx.x * blockDim.x; i <
numParticles; i+= blockDim.x * gridDim.x) {
363 ax += particles->
g_ax[i];
365 ay += particles->
g_ay[i];
367 az += particles->
g_az[i];
372 ax += particles->
ax[i];
374 ay += particles->
ay[i];
376 az += particles->
az[i];
391 sml = particles->
sml[i];
398 temp = sml / particles->
cs[i];
403 dtartvisc =
min(dtartvisc, temp);
409 particles->
vy[i] * particles->
vy[i]);
412 particles->
vy[i] * particles->
vy[i] +
413 particles->
vz[i] * particles->
vz[i]);
422 if (particles->
drhodt[i] != 0) {
424 double rhomin_d = 0.01;
442 sharedForces[i] = forces;
443 sharedCourant[i] = courant;
445 sharedrho[i] = dtrho;
446 sharedArtVisc[i] = dtartvisc;
447 sharedVmax[i] = vmax;
454 sharedCourant[i] = courant =
cuda::math::min(courant, sharedCourant[k]);
457 sharedArtVisc[i] = dtartvisc =
cuda::math::min(dtartvisc, sharedArtVisc[k]);
464 blockShared->
forces[k] = forces;
465 blockShared->
courant[k] = courant;
466 blockShared->
e[k] = dte;
467 blockShared->
rho[k] = dtrho;
468 blockShared->
artVisc[k] = dtartvisc;
469 blockShared->
vmax[k] = vmax;
473 if (m == atomicInc((
unsigned int *)blockCount, m)) {
475 for (j = 0; j <= m; j++) {
488 if (vmax > 0. && searchRadius > 0.) {
505 if (*simulationTime->
dt > *simulationTime->
dt_max) {
506 *simulationTime->
dt = *simulationTime->
dt_max;
538 materials, particles, blockShared, blockCount, searchRadius,
numParticles);
Execution policy/instruction for CUDA kernel execution.
ArtificialViscosity artificialViscosity
Particle(s) class based on SoA (Structur of Arrays).
real * e
(pointer to) internal energy (array)
integer * materialId
(pointer to) material identifier (array)
real * x
(pointer to) x position (array)
real * rho
(pointer to) density (array)
real * drhodt
(pointer to) time derivative of density (array)
real * g_ay
(pointer to) y gravitational acceleration (array)
real * ay
(pointer to) y acceleration (array)
real * az
(pointer to) z acceleration (array)
real * p
(pointer to) pressure (array)
real * cs
(pointer to) sound of speed (array)
real * y
(pointer to) y position (array)
real * ax
(pointer to) x acceleration (array)
real * g_ax
(pointer to) x gravitational acceleration (array)
real * sml
(pointer to) smoothing length (array)
real * dedt
(pointer to) time derivative of internal energy (array)
real * z
(pointer to) z position (array)
real * vz
(pointer to) z velocity (array)
real * muijmax
(pointer) to max(mu_ij) (array) needed for artificial viscosity and determining timestp
real * g_az
(pointer to) z gravitational acceleration (array)
real * vx
(pointer to) x velocity (array)
real * vy
(pointer to) y velocity (array)
#define CUDA_CALLABLE_MEMBER
void setE(BlockShared *blockShared, real *e)
void setVmax(BlockShared *blockShared, real *vmax)
void setRho(BlockShared *blockShared, real *e)
void set(BlockShared *blockShared, real *forces, real *courant, real *artVisc)
__global__ void setVmax(BlockShared *blockShared, real *vmax)
__global__ void set(BlockShared *blockShared, real *forces, real *courant, real *artVisc)
__global__ void setRho(BlockShared *blockShared, real *e)
__global__ void setE(BlockShared *blockShared, real *e)
real setTimeStep(int multiProcessorCount, SimulationTime *simulationTime, Material *materials, Particles *particles, BlockShared *blockShared, int *blockCount, real searchRadius, int numParticles)
Wrapper for PredictorCorrectorEulerNS::Kernel::setTimeStep().
real predictor(Particles *particles, IntegratedParticles *predictor, real dt, int numParticles)
Wrapper for PredictorCorrectorEulerNS::Kernel::predictor().
real pressureChangeCheck()
real corrector(Particles *particles, IntegratedParticles *predictor, real dt, int numParticles)
Wrapper for PredictorCorrectorEulerNS::Kernel::corrector().
__global__ void corrector(Particles *particles, IntegratedParticles *predictor, real dt, int numParticles)
Corrector step.
__global__ void setTimeStep(SimulationTime *simulationTime, Material *materials, Particles *particles, BlockShared *blockShared, int *blockCount, real searchRadius, int numParticles)
__global__ void setTimeStep(SimulationTime *simulationTime, Material *materials, Particles *particles, BlockShared *blockShared, int *blockCount, int numParticles)
Setting correct time step.
__global__ void predictor(Particles *particles, IntegratedParticles *predictor, real dt, int numParticles)
Predictor step.
void set(Shared *shared, real *forces, real *courant, real *artVisc)
void setRho(Shared *shared, real *rho)
void setE(Shared *shared, real *e)
void setVmax(Shared *shared, real *vmax)
__global__ void setRho(Shared *shared, real *rho)
__global__ void setVmax(Shared *shared, real *vmax)
__global__ void setE(Shared *shared, real *e)
__global__ void set(Shared *shared, real *forces, real *courant, real *artVisc)
predictor corrector euler (Heun) integrator
const char *const numParticles
__device__ real min(real a, real b)
Minimum value out of two floating point values.
__device__ real sqrt(real a)
Square root of a floating point value.
__device__ real abs(real a)
Absolute value of a floating point value.
__device__ real max(real a, real b)
Maximum value out of two floating point values.
void set(T *d_var, T val, std::size_t count=1)
Set device memory to a specific value.
real launch(bool timeKernel, const ExecutionPolicy &policy, void(*f)(Arguments...), Arguments... args)
CUDA execution wrapper function.
#define NUM_THREADS_LIMIT_TIME_STEP
#define INTEGRATE_DENSITY
integrate density equation
#define DIM
Dimension of the problem.
real alpha
Artificial viscosity .
real beta
Artificial viscosity .
CUDA_CALLABLE_MEMBER void setRho(real *rho)
CUDA_CALLABLE_MEMBER ~BlockShared()
CUDA_CALLABLE_MEMBER void set(real *forces, real *courant, real *artVisc)
CUDA_CALLABLE_MEMBER void setE(real *e)
CUDA_CALLABLE_MEMBER void setVmax(real *vmax)
CUDA_CALLABLE_MEMBER BlockShared()
CUDA_CALLABLE_MEMBER Shared()
CUDA_CALLABLE_MEMBER void setVmax(real *vmax)
CUDA_CALLABLE_MEMBER void setE(real *e)
CUDA_CALLABLE_MEMBER ~Shared()
CUDA_CALLABLE_MEMBER void setRho(real *rho)
CUDA_CALLABLE_MEMBER void set(real *forces, real *courant, real *artVisc)