1#include "../../include/sph/viscosity.cuh"
2#include "../include/cuda_utils/cuda_launcher.cuh"
5__global__
void SPH::Kernel::calculate_shear_stress_tensor(
::SPH::SPH_kernel kernel,
Material *materials,
Particles *particles,
int *interactions,
int numRealParticles) {
7 inc = blockDim.x * gridDim.x;
9 for (i = threadIdx.x + blockIdx.x * blockDim.x; i < numRealParticles; i += inc) {
24__global__
void SPH::Kernel::calculate_kinematic_viscosity(
::SPH::SPH_kernel kernel,
Material *materials,
Particles *particles,
int *interactions,
int numRealParticles) {
30 inc = blockDim.x * gridDim.x;
31 for (i = threadIdx.x + blockIdx.x * blockDim.x; i < numRealParticles; i += inc) {
37 real dWdr, dWdrj, W, Wj;
40 for (k = 0; k <
DIM *
DIM; k++) {
41 particles->Tshear[i*
DIM*
DIM+k] = 0.0;
44 for (k = 0; k < particles->
noi[i]; k++) {
48 dv[0] = particles->
vx[i] - particles->
vx[j];
50 dv[1] = particles->
vy[i] - particles->
vy[j];
52 dv[2] = particles->
vz[i] - particles->
vz[j];
56 dr[0] = particles->
x[i] - particles->
x[j];
58 dr[1] = particles->
y[i] - particles->
y[j];
60 dr[2] = particles->
z[i] - particles->
z[j];
65 for (e = 0; e <
DIM; e++) {
73 sml = particles->
sml[i];
75#if (VARIABLE_SML || INTEGRATE_SML)
76 sml = 0.5*(particles->
sml[i] + particles->
sml[j]);
79 kernel(&W, dWdx, &dWdr, dr, sml);
83 for (e = 0; e <
DIM; e++) {
84# if (SPH_EQU_VERSION == 1)
85 trace += particles->
mass[j]/particles->
rho[i] * (-dv[e])*dWdx[e] ;
86# elif (SPH_EQU_VERSION == 2)
87 trace += particles->
mass[j]/particles->
rho[j] * (-dv[e])*dWdx[e] ;
91 for (e = 0; e <
DIM; e++) {
92 for (f = 0; f <
DIM; f++) {
93# if (SPH_EQU_VERSION == 1)
94 particles->Tshear[i*
DIM*
DIM+e*
DIM+f] += particles->
mass[j]/particles->
rho[i] * (-dv[e]*dWdx[f] - dv[f]*dWdx[e]);
95# elif (SPH_EQU_VERSION == 2)
96 particles->Tshear[i*
DIM*
DIM+e*
DIM+f] += particles->
mass[j]/particles->
rho[j] * (-dv[e]*dWdx[f] - dv[f]*dWdx[e]);
100# if (SPH_EQU_VERSION == 1)
101 particles->Tshear[i*
DIM*
DIM+e*
DIM+f] -= 2./3 * trace;
102# elif (SPH_EQU_VERSION == 2)
103 particles->Tshear[i*
DIM*
DIM+e*
DIM+f] -= 2./3 * trace;
Particle(s) class based on SoA (Structur of Arrays).
integer * noi
(pointer to) number of interactions (array)
real * x
(pointer to) x position (array)
real * rho
(pointer to) density (array)
real * y
(pointer to) y position (array)
real * sml
(pointer to) smoothing length (array)
real * mass
(pointer to) mass (array)
real * z
(pointer to) z position (array)
real * vz
(pointer to) z velocity (array)
real * vx
(pointer to) x velocity (array)
real * vy
(pointer to) y velocity (array)
#define cudaTerminate(...)
void(* SPH_kernel)(real *W, real dWdx[DIM], real *dWdr, real dx[DIM], real h)
Function pointer to generic SPH kernel function.
__device__ real sqrt(real a)
Square root of a floating point value.
#define MAX_NUM_INTERACTIONS
#define DIM
Dimension of the problem.