forked from christophmschaefer/miluphcuda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlittle_helpers.cu
124 lines (111 loc) · 3.06 KB
/
little_helpers.cu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/**
* @author Christoph Schaefer cm.schaefer@gmail.com
*
* @section LICENSE
* Copyright (c) 2019 Christoph Schaefer
*
* This file is part of miluphcuda.
*
* miluphcuda is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* miluphcuda is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with miluphcuda. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "parameter.h"
#include "miluph.h"
#include "little_helpers.h"
#if USE_SIGNAL_HANDLER
extern volatile int terminate_flag;
// handles the SIGTERM
void signal_handler(int signum)
{
printf("Caught signal %d, trying to write particle data and exit...\n", signum);
terminate_flag = 1;
}
#endif
__global__ void checkNaNs(int *interactions)
{
int i, k, inc, j, numInteractions;
int d;
inc = blockDim.x * gridDim.x;
for (i = threadIdx.x + blockIdx.x * blockDim.x; i < numRealParticles; i += inc) {
assert(!isnan(p.e[i]));
assert(!isnan(p.p[i]));
assert(!isnan(p.rho[i]));
#if FRAGMENTATION
assert(!isnan(p.d[i]));
#endif
#if PALPHA_POROSITY
assert(!isnan(p.alpha_jutzi[i]));
#endif
assert(!isnan(p.x[i]));
#if DIM > 1
assert(!isnan(p.y[i]));
# if DIM > 2
assert(!isnan(p.z[i]));
# endif
#endif
for (d = 0; d < DIM*DIM; d++) {
#if TENSORIAL_CORRECTION
assert(!isnan(p_rhs.tensorialCorrectionMatrix[i*DIM*DIM+d]));
#endif
#if SOLID
assert(!isnan(p.S[i*DIM*DIM+d]));
assert(!isnan(p_rhs.sigma[i*DIM*DIM+d]));
#endif
}
#if PALPHA_POROSITY
assert(!isnan(p.dalphadt[i]));
#endif
#if INTEGRATE_ENERGY
assert(!isnan(p.dedt[i]));
#endif
#if INTEGRATE_DENSITY
assert(!isnan(p.drhodt[i]));
#endif
#if FRAGMENTATION
assert(!isnan(p.dddt[i]));
#endif
#if SOLID
for (d = 0; d < DIM*DIM; d++) {
assert(!isnan(p.dSdt[i*DIM*DIM+d]));
}
#endif
assert(!isnan(p.ax[i]));
#if DIM > 1
assert(!isnan(p.ay[i]));
# if DIM > 2
assert(!isnan(p.az[i]));
# endif
#endif
if (p.noi[i] == 0) {
printf("particle %d with no interactions...\n", i);
}
}
}
#if TENSORIAL_CORRECTION
__global__ void printTensorialCorrectionMatrix(int *interactions)
{
int i, k, inc, j, numInteractions;
int d, dd;
inc = blockDim.x * gridDim.x;
for (i = threadIdx.x + blockIdx.x * blockDim.x; i < numRealParticles; i += inc) {
printf("%d\n", i);
for (d = 0; d < DIM; d++) {
for (dd = 0; dd < DIM; dd++) {
printf("%.17lf \t", p_rhs.tensorialCorrectionMatrix[i*DIM*DIM+d*DIM+dd]);
}
printf("\n");
}
}
}
#endif