milupHPC documentation
  • src
  • sph
pressure.cu
Go to the documentation of this file.
1#include "../../include/sph/pressure.cuh"
2#include "../include/cuda_utils/cuda_launcher.cuh"
3
4
5namespace EOS {
6 __device__ void polytropicGas(Material *materials, Particles *particles, int index) {
7 //printf("polytropicGas...\n");
8 particles->p[index] = materials[particles->materialId[index]].eos.polytropic_K *
9 pow(particles->rho[index], materials[particles->materialId[index]].eos.polytropic_gamma);
10 //if (true /*particles->p[index] > 0.*/) {
11 // printf("pressure: p[%i] = %f, rho[%i] = %f, polyTropic_K = %f, polytropic_gamma = %f\n", index,
12 // particles->p[index], index, particles->rho[index], materials[particles->materialId[index]].eos.polytropic_K,
13 // materials[particles->materialId[index]].eos.polytropic_K);
14 //}
15 }
16
17 __device__ void isothermalGas(Material *materials, Particles *particles, int index) {
18 //printf("isothermalGas...\n");
19 particles->p[index] = 41255.407 * particles->rho[index];
20 }
21
22 __device__ void idealGas(Material *materials, Particles *particles, int index) {
23 //printf("idealGas...\n");
24 //if (index % 1000 == 0) {
25 // printf("polytropic gamma: %e\n", materials[particles->materialId[index]].eos.polytropic_gamma);
26 //}
27 particles->p[index] = (materials[particles->materialId[index]].eos.polytropic_gamma - 1) *
28 particles->rho[index] * particles->e[index];
29 if (particles->p[index] < 0) {
30 printf("negative pressure! p[%i] = %e, rho = %e, e = %e\n", index, particles->p[index], particles->rho[index], particles->e[index]);
31 }
32 //particles->p[index] = particles->cs[index] * particles->cs[index] * particles->rho[index];
33 }
34
35 __device__ void locallyIsothermalGas(Material *materials, Particles *particles, int index) {
36 //printf("locallyIsothermalGas...\n");
37 particles->p[index] = particles->cs[index] * particles->cs[index] * particles->rho[index];
38 }
39}
40
41namespace SPH {
42 namespace Kernel {
43 __global__ void calculatePressure(Material *materials, Particles *particles, int numParticles) {
44
45 register int i, inc;
46 register double eta, e, rho, mu, p1, p2;
47 int i_rho, i_e;
48 double pressure;
49
50 inc = blockDim.x * gridDim.x;
51 for (i = threadIdx.x + blockIdx.x * blockDim.x; i < numParticles; i += inc) {
52
53 pressure = 0.0;
54
55 //printf("calculatePressure: %i\n", materials[particles->materialId[i]].eos.type);
56 switch (materials[particles->materialId[i]].eos.type) {
57 case EquationOfStates::EOS_TYPE_POLYTROPIC_GAS: {
58 ::EOS::polytropicGas(materials, particles, i);
59 }
60 break;
61 case EquationOfStates::EOS_TYPE_ISOTHERMAL_GAS: {
62 ::EOS::isothermalGas(materials, particles, i);
63 }
64 break;
65 case EquationOfStates::EOS_TYPE_IDEAL_GAS: {
66 ::EOS::idealGas(materials, particles, i);
67 }
68 break;
69 case EquationOfStates::EOS_TYPE_LOCALLY_ISOTHERMAL_GAS: {
70 ::EOS::locallyIsothermalGas(materials, particles, i);
71 }
72 break;
73 default:
74 printf("not implemented!\n");
75 }
76
77 }
78 }
79
80 real Launch::calculatePressure(Material *materials, Particles *particles, int numParticles) {
81 ExecutionPolicy executionPolicy;
82 return cuda::launch(true, executionPolicy, ::SPH::Kernel::calculatePressure, materials,
83 particles, numParticles);
84 }
85 }
86}
87
ExecutionPolicy
Execution policy/instruction for CUDA kernel execution.
Definition: cuda_launcher.cuh:33
Material
Material parameters.
Definition: material.cuh:88
Material::eos
EqOfSt eos
Definition: material.cuh:115
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::materialId
integer * materialId
(pointer to) material identifier (array)
Definition: particles.cuh:111
Particles::rho
real * rho
(pointer to) density (array)
Definition: particles.cuh:133
Particles::p
real * p
(pointer to) pressure (array)
Definition: particles.cuh:135
Particles::cs
real * cs
(pointer to) sound of speed (array)
Definition: particles.cuh:129
pressure
Definition: pressure.cuh:20
EOS
Equation of states.
Definition: pressure.cuh:25
EOS::polytropicGas
__device__ void polytropicGas(Material *materials, Particles *particles, int index)
Polytropic gas.
Definition: pressure.cu:6
EOS::locallyIsothermalGas
__device__ void locallyIsothermalGas(Material *materials, Particles *particles, int index)
Definition: pressure.cu:35
EOS::idealGas
__device__ void idealGas(Material *materials, Particles *particles, int index)
Ideal gas.
Definition: pressure.cu:22
EOS::isothermalGas
__device__ void isothermalGas(Material *materials, Particles *particles, int index)
Isothermal gas.
Definition: pressure.cu:17
Kernel
Definition: device_rhs.cuh:7
ProfilerIds::Time::SPH::pressure
const char *const pressure
Definition: h5profiler.h:105
ProfilerIds::numParticles
const char *const numParticles
Definition: h5profiler.h:29
SPH::Kernel::Launch::calculatePressure
real calculatePressure(Material *materials, Particles *particles, int numParticles)
Wrapper for SPH::Kernel::calculatePressure().
Definition: pressure.cu:80
SPH::Kernel::calculatePressure
__global__ void calculatePressure(Material *materials, Particles *particles, int numParticles)
Calculate the pressure.
Definition: pressure.cu:43
SPH
SPH related functions and kernels.
Definition: density.cuh:23
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
EOS_TYPE_LOCALLY_ISOTHERMAL_GAS
@ EOS_TYPE_LOCALLY_ISOTHERMAL_GAS
ideal gas equation, set polytropic_gamma in material.cfg
Definition: parameter.h:248
EOS_TYPE_IDEAL_GAS
@ EOS_TYPE_IDEAL_GAS
this is pure molecular hydrogen at 10 K
Definition: parameter.h:245
EOS_TYPE_ISOTHERMAL_GAS
@ EOS_TYPE_ISOTHERMAL_GAS
polytropic EOS for gas, needs polytropic_K and polytropic_gamma in material.cfg file
Definition: parameter.h:239
EOS_TYPE_POLYTROPIC_GAS
@ EOS_TYPE_POLYTROPIC_GAS
Definition: parameter.h:236
EqOfSt::polytropic_K
real polytropic_K
Definition: material.cuh:77
EqOfSt::polytropic_gamma
real polytropic_gamma
Definition: material.cuh:78
EqOfSt::type
int type
Definition: material.cuh:76

milupHPC - src/sph/pressure.cu Source File
Generated on Wed Aug 31 2022 12:16:53 by Doxygen 1.9.3