-
Notifications
You must be signed in to change notification settings - Fork 6
/
Kernels.cu
660 lines (503 loc) · 21.6 KB
/
Kernels.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
/*MIT License
Copyright (c) 2019 Xavier Martinez
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#define NBTHREADS 256
#define EMPTYCELL INT_MAX-1
#define PROBERADIUS (1.4f)
#define EPSILON (0.001f)
#include <thrust/binary_search.h>
#include "operators.cu"
#include "MarchingCubes.cu"
struct compare_int2 {
__host__ __device__ __forceinline__ bool operator()(int2 a, int2 b) {return a.x < b.x;}
};
struct compare_int {
__host__ __device__ __forceinline__ bool operator()(int a, int b) {return a < b;}
};
struct compare_int3 {
__host__ __device__ bool operator()(int3 a, int3 b) {
if (a.x <= b.x && a.y <= b.y && a.z < b.z) return true;
else if (a.x <= b.x && a.y < b.y) return true;
else if (a.x < b.x) return true;
else return false;
}
};
struct sameint3 {
__host__ __device__ bool operator()(int3 a, int3 b) {
if (a.x != b.x)
return false;
if (a.y != b.y)
return false;
if (a.z != b.z)
return false;
return true;
}
};
typedef thrust::tuple<float,float, float> vec3;
struct add_uint2 {
__device__
uint2 operator()(const uint2& a, const uint2& b) const {
uint2 r;
r.x = a.x + b.x;
r.y = a.y + b.y;
return r;
}
};
struct is_notempty
{
__host__ __device__
bool operator()(const int &x) const
{
return x != EMPTYCELL;
}
};
__global__ void memsetCudaFloat(float *data, float val, int N){
unsigned int index = blockDim.x * blockIdx.x + threadIdx.x;
if (index >= N) {
return;
}
data[index] = val;
}
__global__ void memsetCudaInt(int *data, int val, int N) {
unsigned int index = blockDim.x * blockIdx.x + threadIdx.x;
if (index >= N) {
return;
}
data[index] = val;
}
__global__ void memsetCudaInt2(int2 *data, int2 val, int N) {
unsigned int index = blockDim.x * blockIdx.x + threadIdx.x;
if (index >= N) {
return;
}
data[index] = val;
}
__global__ void memsetCudaUInt2(uint2 *data, uint2 val, int N) {
unsigned int index = blockDim.x * blockIdx.x + threadIdx.x;
if (index >= N) {
return;
}
data[index] = val;
}
__host__ __device__ int3 spaceToGrid(float3 pos3D, float3 originGrid, float dx) {
float3 tmp = ((pos3D - originGrid) / dx);
return make_int3(tmp.x, tmp.y, tmp.z);
}
__host__ __device__ float3 gridToSpace(int3 cellPos, float3 originGrid, float dx) {
return (originGrid + (make_float3(cellPos.x, cellPos.y, cellPos.z) * dx) );
//return originGrid + (convert_float3(cellPos) * dx) + (dx / 2.0f);
}
__host__ __device__ int flatten3DTo1D(int3 id3d, int3 gridDim) {
return (gridDim.y * gridDim.z * id3d.x) + (gridDim.z * id3d.y) + id3d.z;
}
// __host__ __device__ int flatten3DTo1D(int3 id3d, int3 gridDim) {
// // return id3d.x + gridDim.x * (id3d.y + gridDim.z * id3d.z);
// return id3d.x + id3d.y * gridDim.x + id3d.z * gridDim.x * gridDim.y;
// }
__host__ __device__ int3 unflatten1DTo3D(int index, int3 gridDim) {
int3 res;
// res.x = index % gridDim.x;
// res.y = (index / gridDim.x) % gridDim.y;
// res.z = index / (gridDim.x * gridDim.y);
res.x = index / (gridDim.y * gridDim.z); //Note the integer division . This is x
res.y = (index - res.x * gridDim.y * gridDim.z) / gridDim.z; //This is y
res.z = index - res.x * gridDim.y * gridDim.z - res.y * gridDim.z; //This is z
return res;
}
inline __host__ __device__ float fast_distance(float3 p1, float3 p2) {
float x = (p1.x - p2.x) * (p1.x - p2.x);
float y = (p1.y - p2.y) * (p1.y - p2.y);
float z = (p1.z - p2.z) * (p1.z - p2.z);
return sqrt( x + y + z);
}
inline __host__ __device__ float sqr_distance(float3 p1, float3 p2) {
float x = (p1.x - p2.x) * (p1.x - p2.x);
float y = (p1.y - p2.y) * (p1.y - p2.y);
float z = (p1.z - p2.z) * (p1.z - p2.z);
return x + y + z;
}
inline __host__ __device__ float3 clamp(float3 f, float a, float b)
{
return make_float3(max(a, min(f.x, b)),
max(a, min(f.y, b)),
max(a, min(f.z, b))
);
}
inline __host__ __device__ int3 clamp(int3 f, int a, int b)
{
return make_int3(max(a, min(f.x, b)),
max(a, min(f.y, b)),
max(a, min(f.z, b))
);
}
inline __host__ __device__ int clamp(int f, int a, int b)
{
return max(a, min(f, b));
}
// calculate cell address as the hash value for each atom
__global__ void hashAtoms(unsigned int natoms,
float4* xyzr,
int3 gridDim,
float4 originGridDDx,
int2 * atomHashIndex,
unsigned natomsnextPow2) {
unsigned int index = blockDim.x * blockIdx.x + threadIdx.x;
if (index >= natomsnextPow2)
return;
if (index >= natoms) {
atomHashIndex[index].x = INT_MAX;
atomHashIndex[index].y = INT_MAX;
return;
}
float4 atom = xyzr[index];// read atom coordinate and radius
float3 pos = make_float3(atom.x, atom.y, atom.z);
// compute cell index, clamped to fall within grid bounds
float3 originGrid = make_float3(originGridDDx.x, originGridDDx.y, originGridDDx.z);
float dx = originGridDDx.w;
int3 cell = spaceToGrid(pos, originGrid, dx);
int hash = flatten3DTo1D(cell, gridDim);
atomHashIndex[index].x = hash;// atoms hashed to cell address
atomHashIndex[index].y = index; // original atom index
}
//https://github.com/FROL256/opencl_bitonic_sort_by_key/blob/master/bitonic_sort_gpu.h
inline __device__ int getKey(int2 v) { return v.x; }
inline __device__ int getVal(int2 v) { return v.y; }
inline __device__ bool compare(int2 a, int2 b) { return getKey(a) < getKey(b); }
__global__ void bitonic_pass_kernel(int2* theArray, int stage, int passOfStage, int a_invertModeOn)
{
int j = blockDim.x * blockIdx.x + threadIdx.x;
const int r = 1 << (passOfStage);
const int lmask = r - 1;
const int left = ((j >> passOfStage) << (passOfStage + 1)) + (j & lmask);
const int right = left + r;
const int2 a = theArray[left];
const int2 b = theArray[right];
const bool cmpRes = compare(a, b);
const int2 minElem = cmpRes ? a : b;
const int2 maxElem = cmpRes ? b : a;
const int oddEven = j >> stage;
const bool isSwap = (oddEven & 1) & a_invertModeOn;
const int minId = isSwap ? right : left;
const int maxId = isSwap ? left : right;
theArray[minId] = minElem;
theArray[maxId] = maxElem;
}
__global__ void bitonic_512( int2* theArray, int stage, int passOfStageBegin, int a_invertModeOn)
{
int tid = blockDim.x * blockIdx.x + threadIdx.x;
int lid = threadIdx.x;
int blockId = (tid / 256);
__shared__ int2 s_array[512];
s_array[lid + 0] = theArray[blockId * 512 + lid + 0];
s_array[lid + 256] = theArray[blockId * 512 + lid + 256];
__syncthreads();
for (int passOfStage = passOfStageBegin; passOfStage >= 0; passOfStage--)
{
const int j = lid;
const int r = 1 << (passOfStage);
const int lmask = r - 1;
const int left = ((j >> passOfStage) << (passOfStage + 1)) + (j & lmask);
const int right = left + r;
const int2 a = s_array[left];
const int2 b = s_array[right];
const bool cmpRes = compare(a, b);
const int2 minElem = cmpRes ? a : b;
const int2 maxElem = cmpRes ? b : a;
const int oddEven = tid >> stage; // (j >> stage)
const bool isSwap = (oddEven & 1) & a_invertModeOn;
const int minId = isSwap ? right : left;
const int maxId = isSwap ? left : right;
s_array[minId] = minElem;
s_array[maxId] = maxElem;
__syncthreads();
}
theArray[blockId * 512 + lid + 0] = s_array[lid + 0];
theArray[blockId * 512 + lid + 256] = s_array[lid + 256];
}
__global__ void sortCell(unsigned int natoms, float4 *xyzr, int2 *atomHashIndex,
float4 *sorted_xyzr,
int2 *cellStartEnd) {
int hash;
int id;
// __local int local_hash[NBTHREADS + 1];
unsigned int index = blockDim.x * blockIdx.x + threadIdx.x;
if (index >= natoms)
return;
hash = atomHashIndex[index].x;
id = atomHashIndex[index].y;
int hashm1;
if (index != 0)
hashm1 = atomHashIndex[index - 1].x;
else
hashm1 = hash;
if (index == 0 || hash != hashm1) {
cellStartEnd[hash].x = index; // set start
if (index > 0)
cellStartEnd[hashm1].y = index; // set end
}
if (index == natoms - 1) {
cellStartEnd[hash].y = index + 1; // set end
}
// Reorder atoms according to sorted indices
sorted_xyzr[index] = xyzr[id];
}
inline __host__ __device__ float computeInOrOut(int3 id3DNeigh, int2 *cellStartEnd, float4 *sorted_xyzr, float3 spacePosSES, float dx, int3 gridDimNeighbor) {
//Loop over neighbors to compute if the cell is:
// 1) - ouside => result = PROBERADIUS
// 2) - inside => result = -dx
// 3) - at the border => result = 0.0
int3 curgridId;
float result = PROBERADIUS;
bool nearProbe = false;
// #pragma unroll
for (int x = -1; x <= 1; x++) {
curgridId.x = clamp(id3DNeigh.x + x, 0, gridDimNeighbor.x - 1);
// #pragma unroll
for (int y = -1; y <= 1; y++) {
curgridId.y = clamp(id3DNeigh.y + y, 0, gridDimNeighbor.x - 1);
// #pragma unroll
for (int z = -1; z <= 1; z++) {
curgridId.z = clamp(id3DNeigh.z + z, 0, gridDimNeighbor.x - 1);
int neighcellhash = flatten3DTo1D(curgridId, gridDimNeighbor);
int idStart = cellStartEnd[neighcellhash].x;
int idStop = cellStartEnd[neighcellhash].y;
if (idStart < EMPTYCELL) {
for (int id = idStart; id < idStop; id++) {
float4 xyzr = sorted_xyzr[id];
float rad = xyzr.w;
float3 pos = make_float3(xyzr.x, xyzr.y, xyzr.z);
// float d = sqr_distance(pos, spacePosSES);
float d = fast_distance(pos, spacePosSES);
// minDist = min(d, minDist);
// if (d < rad * rad)
if (d < rad - dx)
return -dx;
// if (d < (PROBERADIUS + rad) * (PROBERADIUS + rad))
if (d < (PROBERADIUS + rad) )
nearProbe = true;
}
}
}
}
}
//float result = (1 - nearProbe) * PROBERADIUS;
if (nearProbe)
result = 0.0f;
return result;
}
__global__ void probeIntersection(int * checkFill,
int2 * atomHashIndex,
int3 gridDimNeighbor,
float4 originGridNeighborDDx,
int3 gridDimSES,
int3 sliceGridDimSES,
// int3 smallsliceGridDimSES,
float4 originGridSESDx,
int2 *cellStartEnd,
float4 * sorted_xyzr,
float *gridValues,
int3 offsetGrid,
unsigned int N,
int sliceNb) {
// Get global position in X direction
unsigned int i = (threadIdx.x + blockIdx.x * blockDim.x);
// Get global position in Y direction
unsigned int j = (threadIdx.y + blockIdx.y * blockDim.y);
// Get global position in Z direction
unsigned int k = (threadIdx.z + blockIdx.z * blockDim.z);
int3 ijk = make_int3(i, j, k);
if (i >= sliceGridDimSES.x - 1)
return;
if (j >= sliceGridDimSES.y - 1)
return;
if (k >= sliceGridDimSES.z - 1)
return;
int hash = flatten3DTo1D(ijk, sliceGridDimSES);
// if(hash >= sliceNb)
// return;
int3 ijkOffset = make_int3(i + offsetGrid.x, j + offsetGrid.y, k + offsetGrid.z);
int hashOffset = flatten3DTo1D(ijkOffset, gridDimSES);
if (ijkOffset.x >= gridDimSES.x - 1)
return;
if (ijkOffset.y >= gridDimSES.y - 1)
return;
if (ijkOffset.z >= gridDimSES.z - 1)
return;
float3 originGridNeighbor = make_float3(originGridNeighborDDx.x, originGridNeighborDDx.y, originGridNeighborDDx.z);
float dxNeighbor = originGridNeighborDDx.w;
float dxSES = originGridSESDx.w;
float3 spacePos3DCellSES = gridToSpace(ijkOffset, originGridNeighbor, dxSES);
// id of the current cell in the neighbor grid
int3 gridPos3DCellNeighbor = spaceToGrid(spacePos3DCellSES, originGridNeighbor, dxNeighbor);
//Loop over neighbors to compute if the cell is:
// 1) - ouside => result = PROBERADIUS
// 2) - inside => result = -dx
// 3) - at the border => result = 0.0
float result = computeInOrOut(gridPos3DCellNeighbor, cellStartEnd, sorted_xyzr, spacePos3DCellSES, dxSES, gridDimNeighbor);
//If should process => record id, if not record a large number
int fill = EMPTYCELL;
int range = (int)ceil(PROBERADIUS / dxSES);
if (abs(result) < EPSILON){
fill = hash;
// if(i < range || j < range || k < range || i > smallsliceGridDimSES.x + range || j > smallsliceGridDimSES.y + range || k > smallsliceGridDimSES.z + range){
// fill = EMPTYCELL;
// }
}
checkFill[hash] = fill;
gridValues[hash] = result;
}
__global__ void distanceFieldRefine(int * checkFill, int2 * atomHashIndex, int3 gridDimNeighbor,
float4 originGridNeighborDDx, int3 gridDimSES, int3 sliceGridDimSES,
float4 originGridSESDx, int2 * cellStartEnd, float4 * sorted_xyzr,
float *gridValues, unsigned int totalCells, unsigned int notEmptyCells,
int3 offsetGrid, unsigned int of) {
int id = (threadIdx.x + blockIdx.x * blockDim.x) + of;
if (id >= notEmptyCells) {
return;
}
int hash = checkFill[id];
int3 ijk = unflatten1DTo3D(hash, sliceGridDimSES);
//From slice to real id in the full size grid
int3 ijkOffset = make_int3(ijk.x + offsetGrid.x, ijk.y + offsetGrid.y, ijk.z + offsetGrid.z);
int hashOffset = flatten3DTo1D(ijkOffset, gridDimSES);
float3 originGridSES = make_float3(originGridSESDx.x, originGridSESDx.y, originGridSESDx.z);
float dxSES = originGridSESDx.w;
float3 spacePos3DCellSES = gridToSpace(ijkOffset, originGridSES, dxSES);
float newresult = -dxSES;
const int idSESRangeToSearch = (int)ceil(PROBERADIUS / dxSES);
const float pme = PROBERADIUS - EPSILON;
float minDist = 100000.0f;
int3 curgridSESId;
//Find the closest outside SES cell in the range [-probeRadius, +probeRadius]
// #pragma unroll
for (int x = -idSESRangeToSearch; x <= idSESRangeToSearch; x++) {
curgridSESId.x = clamp(ijk.x + x , 0, sliceGridDimSES.x - 1);
// #pragma unroll
for (int y = -idSESRangeToSearch; y <= idSESRangeToSearch; y++) {
curgridSESId.y = clamp(ijk.y + y , 0, sliceGridDimSES.y - 1);
// #pragma unroll
for (int z = -idSESRangeToSearch; z <= idSESRangeToSearch; z++) {
curgridSESId.z = clamp(ijk.z + z , 0, sliceGridDimSES.z - 1);
int curgrid1DSESId = flatten3DTo1D(curgridSESId, sliceGridDimSES);
if (gridValues[curgrid1DSESId] > pme) {//Outside
int3 curgrid3DSESIdOffset = make_int3(curgridSESId.x + offsetGrid.x,
curgridSESId.y + offsetGrid.y,
curgridSESId.z + offsetGrid.z);
float3 spacePosSES = gridToSpace(curgrid3DSESIdOffset, originGridSES, dxSES);
//Distance from our current grid cell to the outside grid cell
float d = fast_distance(spacePosSES, spacePos3DCellSES);
minDist = min(d, minDist);
}
}
}
}
if (minDist < 999.0f)
newresult = PROBERADIUS - minDist;
gridValues[hash] = newresult;
}
inline __host__ __device__ int computeClosestAtom(float3 vert, int3 id3DNeigh, int2 *cellStartEnd, float4 *sorted_xyzr, int3 gridDimNeighbor) {
int closestId = -1;
float minD = 999999.0f;
int3 curgridId;
// #pragma unroll
for (int x = -1; x <= 1; x++) {
curgridId.x = clamp(id3DNeigh.x + x, 0, gridDimNeighbor.x - 1);
// #pragma unroll
for (int y = -1; y <= 1; y++) {
curgridId.y = clamp(id3DNeigh.y + y, 0, gridDimNeighbor.x - 1);
// #pragma unroll
for (int z = -1; z <= 1; z++) {
curgridId.z = clamp(id3DNeigh.z + z, 0, gridDimNeighbor.x - 1);
int neighcellhash = flatten3DTo1D(curgridId, gridDimNeighbor);
int idStart = cellStartEnd[neighcellhash].x;
int idStop = cellStartEnd[neighcellhash].y;
if (idStart < EMPTYCELL) {
for (int id = idStart; id < idStop; id++) {
float4 xyzr = sorted_xyzr[id];
float3 pos = make_float3(xyzr.x, xyzr.y, xyzr.z);
// float d = sqr_distance(pos, vert);
float d = fast_distance(pos, vert);
if(d < minD){
minD = d;
closestId = id;
}
}
}
}
}
}
return closestId;
}
__global__ void closestAtomPerVertex(int *atomIdPerVert, float3 *vertices, unsigned int Nvert, int3 gridDimNeighbor,
float4 originGridNeighborDDx,
float4 originGridSESDx, int2 * cellStartEnd, float4 * sorted_xyzr) {
int id = (threadIdx.x + blockIdx.x * blockDim.x);
if(id >= Nvert)
return;
float3 vert = vertices[id];
float3 originGridNeighbor = make_float3(originGridNeighborDDx.x, originGridNeighborDDx.y, originGridNeighborDDx.z);
float dxNeighbor = originGridNeighborDDx.w;
int3 gridPos3DCellNeighbor = spaceToGrid(vert, originGridNeighbor, dxNeighbor);
atomIdPerVert[id] = computeClosestAtom(vert, gridPos3DCellNeighbor, cellStartEnd, sorted_xyzr, gridDimNeighbor);
}
__global__ void resetGridValuesSlice(const int3 offset, const int rangeSearchRefine, const int3 sliceGridDimSES, float *gridValues){
// Get global position in X direction
unsigned int i = (threadIdx.x + blockIdx.x * blockDim.x);
// Get global position in Y direction
unsigned int j = (threadIdx.y + blockIdx.y * blockDim.y);
// Get global position in Z direction
unsigned int k = (threadIdx.z + blockIdx.z * blockDim.z);
int3 ijk = make_int3(i, j, k);
if (i >= sliceGridDimSES.x - 1)
return;
if (j >= sliceGridDimSES.y - 1)
return;
if (k >= sliceGridDimSES.z - 1)
return;
int hash = flatten3DTo1D(ijk, sliceGridDimSES);
if(i >= sliceGridDimSES.x - rangeSearchRefine)
gridValues[hash] = PROBERADIUS;
if(j >= sliceGridDimSES.y - rangeSearchRefine)
gridValues[hash] = PROBERADIUS;
if(k >= sliceGridDimSES.z - rangeSearchRefine)
gridValues[hash] = PROBERADIUS;
if(offset.x != 0){
if(i < rangeSearchRefine)
gridValues[hash] = PROBERADIUS;
}
else{
if(i >= sliceGridDimSES.x - rangeSearchRefine * 2)
gridValues[hash] = PROBERADIUS;
}
if(offset.y != 0){
if(j < rangeSearchRefine)
gridValues[hash] = PROBERADIUS;
}
else{
if(j >= sliceGridDimSES.y - rangeSearchRefine * 2)
gridValues[hash] = PROBERADIUS;
}
if(offset.z != 0){
if(k < rangeSearchRefine)
gridValues[hash] = PROBERADIUS;
}
else{
if(k >= sliceGridDimSES.z - rangeSearchRefine * 2)
gridValues[hash] = PROBERADIUS;
}
}