-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmesh_cuda_kernel.h
1292 lines (1177 loc) · 39.5 KB
/
mesh_cuda_kernel.h
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
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#ifndef MESH_CUDA_KERNEL_H
#define MESH_CUDA_KERNEL_H
#include "cuda_runtime.h"
#include "mpi.h"
typedef void (* flux_func_ptr)(float * q, float * f, int dir,
float alpha0, float gamma, float zmin, float dz,
int nz, int layer, float R);
typedef float (* fptr)(float p, float D, float Sx, float Sy, float Sz,
float tau, float gamma, float * gamma_up);
__constant__ float beta_d[3];
unsigned int nextPow2(unsigned int x);
/** check to see whether float a is a nan
*/
__host__ __device__ bool nan_check(float a);
/**
Using Brent's method, return the root of a function or functor func known
to lie between x1 and x2. The root will be regined until its accuracy is
tol.
\param func
function pointer to shallow water or compressible flux function.
\param x1, x2
limits of root
\param tol
tolerance to which root shall be calculated to
\param D, Sx, Sy, Sz, tau
conserved variables
\param gamma
adiabatic index
*/
__host__ __device__ float zbrent(fptr func, const float x1, const float x2,
const float tol,
float D, float Sx, float Sy, float Sz, float tau, float gamma,
float * gamma_up);
/**
Checks to see if the integer returned by an mpi function, mpi_err, is an MPI error. If so, it prints out some useful stuff to screen.
*/
void check_mpi_error(int mpi_err);
/**
Return the number of kernels needed to run the problem given its size and the constraints of the GPU.
\param nx, ny, nz
dimensions of problem
\param ng
number of ghost cells
\param maxBlocks, maxThreads
maximum number of blocks and threads possible for device(s)
\param n_processes
number of MPI processes
\param kernels
number of kernels per process
\param cumulative_kernels
cumulative total of kernels per process
*/
void getNumKernels(int nx, int ny, int nz, int ng, int n_processes, int *maxBlocks, int *maxThreads, dim3 *kernels, int *cumulative_kernels);
/**
Returns the number of blocks and threads required for each kernel given the size of the problem and the constraints of the device.
\param nx, ny, nz
dimensions of problem
\param ng
number of ghost cells
\param maxBlocks, maxThreads
maximum number of blocks and threads possible for device(s)
\param n_processes
number of MPI processes
\param kernels, blocks, threads
number of kernels, blocks and threads per process / kernel
*/
void getNumBlocksAndThreads(int nx, int ny, int nz, int ng, int maxBlocks, int maxThreads, int n_processes, dim3 *kernels, dim3 *blocks, dim3 *threads);
/**
Enforce boundary conditions on section of grid.
\param grid
grid of data
\param nx, ny, nz
dimensions of grid
\param ng
number of ghost cells
\param vec_dim
dimension of state vector
\param periodic
do we use periodic or outflow boudary conditions?
*/
void bcs_fv(float * grid, int nx, int ny, int nz, int ng, int vec_dim, bool periodic);
/**
Enforce boundary conditions across processes / at edges of grid.
Loops have been ordered in a way so as to try and keep memory accesses as contiguous as possible.
Need to do non-blocking send, blocking receive then wait.
\param grid
grid of data
\param nx, ny, nz
dimensions of grid
\param vec_dim
dimension of state vector
\param ng
number of ghost cells
\param comm
MPI communicator
\param status
status of MPI processes
\param rank, n_processes
rank of MPI process and total number of MPI processes
\param y_size
size of grid in y direction running on each process (except the last one)
\param do_z
true if need to implement bcs in vertical direction as well
\param periodic
do we use periodic or outflow boudary conditions?
*/
void bcs_mpi(float * grid, int nx, int ny, int nz, int vec_dim, int ng, MPI_Comm comm, MPI_Status status, int rank, int n_processes, int y_size, bool do_z, bool periodic);
__host__ __device__ float W_swe(float * q, float * gamma_up); /**< calculate Lorentz factor for conserved swe state vector */
/**
calculate superbee slope limiter Phi(r)
*/
__host__ __device__ float phi(float r);
/**
Finds r given Phi.
*/
__host__ __device__ float find_height(float ph, float R);
/**
Finds Phi given r.
*/
__device__ float find_pot(float r, float R);
/**
calculate rhoh using p for gamma law equation of state
*/
__device__ float rhoh_from_p(float p, float rho, float gamma);
/**
calculate p using rhoh for gamma law equation of state
*/
__device__ float p_from_rhoh(float rhoh, float rho, float gamma);
/**
calculate p using rho and epsilon for gamma law equation of state
*/
__device__ __host__ float p_from_rho_eps(float rho, float eps, float gamma);
/**
Calculate the metric potential Phi given p for gamma law equation of
state
\param p, rho
pressure and density
\param gamma
adiabatic index
\param A
constant used in Phi to p conversion
*/
__device__ __host__ float phi_from_p(float p, float rho, float gamma, float A);
/**
Function of p whose root is to be found when doing conserved to
primitive variable conversion
\param p
pressure
\param D, Sx, Sy, Sz, tau
components of conserved state vector
\param gamma
adiabatic index
*/
__host__ __device__ float f_of_p(float p, float D, float Sx, float Sy,
float Sz, float tau, float gamma,
float * gamma_up);
/**
Calculates the time derivative of the height given the shallow water
variable phi at current time and previous timestep
NOTE: this is an upwinded approximation of hdot - there may be a better
way to do this which will more accurately give hdot at current time.
\param phi
Phi at current timestep
\param old_phi
Phi at previous timestep
\param dt
timestep
*/
__device__ float h_dot(float phi, float old_phi, float dt, float R);
/**
Calculate the heating rate per unit mass from the shallow water variables
\param rho
densities of layers
\param p
pressure
\param gamma
adiabatic index
\param Y
species fraction
\param Cv
specific heat in constant volume
*/
__device__ float calc_Q_swe(float rho, float p, float gamma, float Y, float Cv);
/**
Calculate the heating rate per unit mass.
\param rho
densities of layers
\param q_cons
conservative state vector
\param nx, ny, nz
dimensions of grid
\param gamma
adiabatic index
\param Q
array that shall contain heating rate per unit mass
\param Cv
specific heat in constant volume
\param gamma_up
spatial metric
*/
void calc_Q(float * rho, float * q_cons, int nx, int ny, int nz,
float gamma, float * Q, float Cv, float * gamma_up);
/**
Calculates the As used to calculate the pressure given Phi, given
the pressure at the sea floor
\param rhos
densities of layers
\param phis
Vector of Phi for different layers
\param A
vector of As for layers
\param nlayers
number of layers
\param gamma
adiabatic index
\param surface_phi
Phi at surface
\param surface_rho
density at surface
*/
__device__ void calc_As(float * rhos, float * phis, float * A,
int nlayers, float gamma,
float surface_phi, float surface_rho);
__device__ void find_constant_p_surfaces(float * p_const, float gamma,
float * q_comp, float * q_swe, float zmin, float dz,
int * nxs, int * nys, int * nzs, int clevel,
int kx_offset, int ky_offset, int * matching_indices);
__device__ void enforce_hse_d(float * q_comp, float * q_swe,
int kx_offset, int ky_offset,
int * nxs, int * nys, int * nzs, int ng,
int level, int clevel, float zmin, float dz,
int * matching_indices_d, float gamma,
float R, float alpha0);
void enforce_hse(float * q_comp, float * q_swe,
int * nxs, int * nys, int * nzs, int ng,
int level, int clevel, float zmin, float dz,
int * matching_indices, float gamma);
/**
Convert compressible conserved variables to primitive variables
\param q_cons
state vector of conserved variables
\param q_prim
state vector of primitive variables
\param gamma
adiabatic index
*/
__device__ void cons_to_prim_comp_d(float * q_cons, float * q_prim,
float gamma, float * gamma_up);
/**
Convert compressible conserved variables to primitive variables
\param q_cons
grid of conserved variables
\param q_prim
grid where shall put the primitive variables
\param nxf, nyf, nz
grid dimensions
\param gamma
adiabatic index
\param gamma_up
spatial metric
*/
void cons_to_prim_comp(float * q_cons, float * q_prim, int nxf, int nyf,
int nz, float gamma, float * gamma_up);
/**
Calculate the flux vector of the shallow water equations
\param q
state vector
\param f
grid where fluxes shall be stored
\param dir
0 if calculating flux in x-direction, 1 if in y-direction
\param alpha
lapse function
\param gamma
adiabatic index
*/
__device__ void shallow_water_fluxes(float * q, float * f, int dir,
float alpha0, float gamma, float zmin, float dz, float nz, float layer, float R);
/**
Calculate the flux vector of the compressible GR hydrodynamics equations
\param q
state vector
\param f
grid where fluxes shall be stored
\param dir
0 if calculating flux in x-direction, 1 if in y-direction,
2 if in z-direction
\param alpha
lapse function
\param gamma
adiabatic index
*/
__device__ void compressible_fluxes(float * q, float * f, int dir,
float alpha0, float gamma, float zmin, float dz, float nz, float layer, float R);
/**
Calculate p using SWE conserved variables
\param q
state vector
\param p
grid where pressure shall be stored
\param nx, ny, nz
grid dimensions
\param rho
density
\param gamma
adiabatic index
\param A
variable required in p(Phi) calculation
\param gamma_up
spatial metric
*/
void p_from_swe(float * q, float * p, int nx, int ny, int nz,
float rho, float gamma, float A, float * gamma_up);
/**
Calculates p and returns using SWE conserved variables
\param q
state vector
\param rho
density
\param gamma
adiabatic index
\param W
Lorentz factor
\param A
variable required in p(Phi) calculation
*/
__device__ float p_from_swe(float * q, float rho,
float gamma, float W, float A);
/**
Calculates the compressible state vector from the SWE variables.
\param q
grid of SWE state vector
\param q_comp
grid where compressible state vector to be stored
\param nxs, nys, nzs
grid dimensions
\param rho, gamma
density and adiabatic index
\param kx_offset, ky_offset
kernel offsets in the x and y directions
\param dt
timestep
\param old_phi
Phi at previous timestep
\param level
index of level
*/
__global__ void compressible_from_swe(float * q, float * q_comp,
int * nxs, int * nys, int * nzs,
float * rho, float gamma,
int kx_offset, int ky_offset, float dt,
float * old_phi, int level, float R);
/**
Calculates slope limited verticle gradient at layer_frac between middle and amiddle.
Left, middle and right are from row n, aleft, amiddle and aright are from row above it (n-1)
*/
__device__ float slope_limit(float layer_frac, float left, float middle, float right, float aleft, float amiddle, float aright);
/**
Reconstruct fine grid variables from compressible variables on coarse grid
\param q_comp
compressible variables on coarse grid
\param q_f
fine grid state vector
\param q_c
coarse grid swe state vector
\param nxs, nys, nzs
grid dimensions
\param ng
number of ghost cells
\param dz
coarse grid vertical spacing
\param matching_indices_d
position of fine grid wrt coarse grid
\param kx_offset, ky_offset
kernel offsets in the x and y directions
\param coarse_level
index of coarser level
*/
__global__ void prolong_reconstruct_comp_from_swe(float * q_comp,
float * q_f, float * q_c,
int * nxs, int * nys, int * nzs, int ng,
float dz, float zmin,
int * matching_indices_d,
int kx_offset, int ky_offset, int coarse_level, bool boundaries, float R);
/**
Prolong coarse grid data to fine grid
\param kernels, threads, blocks
number of kernels, threads and blocks for each process/kernel
\param cumulative_kernels
cumulative number of kernels in mpi processes of r < rank
\param q_cd, q_fd
coarse and fine grids of state vectors
\param nxs, nys, nzs
dimensions of grids
\param ng
number of ghost cells
\param dz
coarse grid cell vertical spacing
\param dt
timestep
\param zmin
height of sea floor
\param rho, gamma
density and adiabatic index
\param matching_indices_d
position of fine grid wrt coarse grid
\param ng
number of ghost cells
\param rank
rank of MPI process
\param qc_comp
grid of compressible variables on coarse grid
\param old_phi_d
Phi at previous timstep
\param coarse_level
index of coarser level
*/
void prolong_swe_to_comp(dim3 * kernels, dim3 * threads, dim3 * blocks,
int * cumulative_kernels, float * q_cd, float * q_fd,
int * nxs, int * nys, int * nzs,
float dz, float dt, float zmin,
float * rho, float gamma,
int * matching_indices_d, int ng, int rank, float * qc_comp,
float * old_phi_d, int coarse_level, float R);
/**
Reconstruct fine grid variables from compressible variables on coarse grid
\param q_comp
compressible variables on coarse grid
\param q_f
fine grid state vector
\param q_c
coarse grid swe state vector
\param nxs, nys, nzs
grid dimensions
\param ng
number of ghost cells
\param matching_indices_d
position of fine grid wrt coarse grid
\param kx_offset, ky_offset
kernel offsets in the x and y directions
\param clevel
index of coarser level
*/
__global__ void prolong_reconstruct_comp(float * q_f, float * q_c,
int * nxs, int * nys, int * nzs, int ng,
int * matching_indices_d,
int kx_offset, int ky_offset, int clevel);
/**
Prolong coarse grid data to fine grid
\param kernels, threads, blocks
number of kernels, threads and blocks for each process/kernel
\param cumulative_kernels
cumulative number of kernels in mpi processes of r < rank
\param q_cd, q_fd
coarse and fine grids of state vectors
\param nxs, nys, nzs
dimensions of grids
\param matching_indices_d
position of fine grid wrt coarse grid
\param ng
number of ghost cells
\param rank
rank of MPI process
\param coarse_level
index of coarser level
*/
void prolong_comp_to_comp(dim3 * kernels, dim3 * threads, dim3 * blocks,
int * cumulative_kernels, float * q_cd, float * q_fd,
int * nxs, int * nys, int * nzs,
int * matching_indices_d, int ng, int rank, int coarse_level);
/**
Reconstruct multilayer swe fine grid variables from single layer swe variables on coarse grid
\param q_f
fine grid state vector
\param q_c
coarse grid swe state vector
\param nxs, nys, nzs
grid dimensions
\param ng
number of ghost cells
\param matching_indices_d
position of fine grid wrt coarse grid
\param kx_offset, ky_offset
kernel offsets in the x and y directions
\param clevel
index of coarser level
*/
__global__ void prolong_reconstruct_swe_from_swe(float * qf, float * qc,
int * nxs, int * nys, int * nzs, int ng,
int * matching_indices_d,
int kx_offset, int ky_offset, int clevel);
/**
Prolong coarse grid single layer swe data to fine multilayer swe grid.
\param kernels, threads, blocks
number of kernels, threads and blocks for each process/kernel
\param cumulative_kernels
cumulative number of kernels in mpi processes of r < rank
\param q_cd, q_fd
coarse and fine grids of state vectors
\param nxs, nys, nzs
dimensions of grids
\param matching_indices_d
position of fine grid wrt coarse grid
\param ng
number of ghost cells
\param rank
rank of MPI process
\param coarse_level
index of coarser level
*/
void prolong_swe_to_swe(dim3 * kernels, dim3 * threads, dim3 * blocks,
int * cumulative_kernels, float * q_cd, float * q_fd,
int * nxs, int * nys, int * nzs,
int * matching_indices_d, int ng, int rank,
int coarse_level);
/**
Reconstruct multilayer swe fine grid variables from multilayer swe variables on coarse grid
\param q_f
fine grid state vector
\param q_c
coarse grid swe state vector
\param nxs, nys, nzs
grid dimensions
\param ng
number of ghost cells
\param matching_indices_d
position of fine grid wrt coarse grid
\param kx_offset, ky_offset
kernel offsets in the x and y directions
\param clevel
index of coarser level
*/
__global__ void prolong_reconstruct_multiswe_from_multiswe(float * qf, float * qc,
int * nxs, int * nys, int * nzs, int ng,
int * matching_indices_d,
int kx_offset, int ky_offset, int clevel);
/**
Prolong coarse grid multilayer swe data to fine multilayer swe grid.
\param kernels, threads, blocks
number of kernels, threads and blocks for each process/kernel
\param cumulative_kernels
cumulative number of kernels in mpi processes of r < rank
\param q_cd, q_fd
coarse and fine grids of state vectors
\param nxs, nys, nzs
dimensions of grids
\param matching_indices_d
position of fine grid wrt coarse grid
\param ng
number of ghost cells
\param rank
rank of MPI process
\param coarse_level
index of coarser level
*/
void prolong_multiswe_to_multiswe(dim3 * kernels, dim3 * threads, dim3 * blocks,
int * cumulative_kernels, float * q_cd, float * q_fd,
int * nxs, int * nys, int * nzs,
int * matching_indices_d, int ng, int rank,
int coarse_level);
/**
Calculates the SWE state vector from the compressible variables.
\param q
grid of compressible state vector
\param q_swe
grid where SWE state vector to be stored
\param nxs, nys, nzs
grid dimensions
\param rho, gamma
density and adiabatic index
\param kx_offset, ky_offset
kernel offsets in the x and y directions
\param qc
coarse grid
\param matching_indices
indices of fine grid wrt coarse grid
\param coarse_level
index of coarser grid
*/
__global__ void calc_comp_prim(float * q, int * nxs, int * nys, int * nzs,
float gamma, int kx_offset, int ky_offset,
int coarse_level, float zmin, float dz,
float R, float alpha0);
__global__ void swe_from_compressible(float * q_prim, float * q_swe,
int * nxs, int * nys, int * nzs,
float * rho, float gamma,
int kx_offset, int ky_offset,
float * qc,
int * matching_indices,
int coarse_level, float zmin, float dz,
float alpha0, float R);
/**
Interpolate SWE variables on fine grid to get them on coarse grid.
\param p_const
pressure on SWE surfaces
\param
adiabatic index
\param q_comp
primitive compressible state vector on grid
\param q_swe
conserved SWE state vector on grid
\param zmin
height of bottom layer
\param dz
compressible grid separation
\param nxs, nys, nzs
grid dimensions
\param matching_indices
position of fine grid wrt coarse grid
\param kx_offset, ky_offset
kernel offsets in the x and y directions
\param coarse_level
index of coarser level
*/
__global__ void restrict_interpolate_swe(float * p_const, float gamma,
float * q_comp, float * q_swe, float zmin, float dz,
int * nxs, int * nys, int * nzs, int clevel,
int kx_offset, int ky_offset, int * matching_indices,
float R, float alpha0);
/**
Restrict fine grid data to coarse grid
\param kernels, threads, blocks
number of kernels, threads and blocks for each process/kernel
\param cumulative_kernels
cumulative number of kernels in mpi processes of r < rank
\param q_cd, q_fd
coarse and fine grids of state vectors
\param nxs, nys, nzs
dimensions of grids
\param matching_indices
position of fine grid wrt coarse grid
\param rho, gamma
density and adiabatic index
\param ng
number of ghost cells
\param rank
rank of MPI process
\param qf_swe
grid of SWE variables on fine grid
\param coarse_level
index of coarser level
*/
void restrict_comp_to_swe(dim3 * kernels, dim3 * threads, dim3 * blocks,
int * cumulative_kernels, float * q_cd, float * q_fd,
int * nxs, int * nys, int * nzs,
float dz, float zmin, int * matching_indices,
float * rho, float gamma,
int ng, int rank, float * qf_swe,
int coarse_level, float * p_const, float R, float alpha0);
/**
Interpolate fine grid compressible variables to get them on coarser compressible grid.
\param qf
variables on fine grid
\param qc
coarse grid state vector
\param nxs, nys, nzs
grid dimensions
\param ng
number of ghost cells
\param matching_indices
position of fine grid wrt coarse grid
\param kx_offset, ky_offset
kernel offsets in the x and y directions
\param clevel
index of coarser level
*/
__global__ void restrict_interpolate_comp(float * qf, float * qc,
int * nxs, int * nys, int * nzs, int ng,
int * matching_indices,
int kx_offset, int ky_offset,
int clevel);
/**
Restrict fine compressible grid data to coarse compressible grid.
\param kernels, threads, blocks
number of kernels, threads and blocks for each process/kernel
\param cumulative_kernels
cumulative number of kernels in mpi processes of r < rank
\param q_cd, q_fd
coarse and fine grids of state vectors
\param nxs, nys, nzs
dimensions of grids
\param matching_indices
position of fine grid wrt coarse grid
\param ng
number of ghost cells
\param rank
rank of MPI process
\param coarse_level
index of coarser level
*/
void restrict_comp_to_comp(dim3 * kernels, dim3 * threads, dim3 * blocks,
int * cumulative_kernels, float * q_cd, float * q_fd,
int * nxs, int * nys, int * nzs,
int * matching_indices,
int ng, int rank,
int coarse_level);
/**
Interpolate multilayer SWE variables on fine grid to get them on single layer SWE coarse grid.
\param qf
variables on fine grid
\param qc
coarse grid state vector
\param nxs, nys, nzs
grid dimensions
\param ng
number of ghost cells
\param matching_indices
position of fine grid wrt coarse grid
\param kx_offset, ky_offset
kernel offsets in the x and y directions
\param clevel
index of coarser level
*/
__global__ void restrict_interpolate_swe_to_swe(float * qf, float * qc,
int * nxs, int * nys, int * nzs, int ng,
int * matching_indices,
int kx_offset, int ky_offset,
int clevel);
/**
Restrict fine multilayer swe grid data to coarse single layer swe grid.
\param kernels, threads, blocks
number of kernels, threads and blocks for each process/kernel
\param cumulative_kernels
cumulative number of kernels in mpi processes of r < rank
\param q_cd, q_fd
coarse and fine grids of state vectors
\param nxs, nys, nzs
dimensions of grids
\param matching_indices
position of fine grid wrt coarse grid
\param ng
number of ghost cells
\param rank
rank of MPI process
\param coarse_level
index of coarser level
*/
void restrict_swe_to_swe(dim3 * kernels, dim3 * threads, dim3 * blocks,
int * cumulative_kernels, float * q_cd, float * q_fd,
int * nxs, int * nys, int * nzs,
int * matching_indices,
int ng, int rank,
int coarse_level);
/**
Interpolate multilayer SWE variables on fine grid to get them on multilayer SWE coarse grid.
\param qf
variables on fine grid
\param qc
coarse grid state vector
\param nxs, nys, nzs
grid dimensions
\param ng
number of ghost cells
\param matching_indices
position of fine grid wrt coarse grid
\param kx_offset, ky_offset
kernel offsets in the x and y directions
\param clevel
index of coarser level
*/
__global__ void restrict_interpolate_multiswe_to_multiswe(float * qf, float * qc,
int * nxs, int * nys, int * nzs, int ng,
int * matching_indices,
int kx_offset, int ky_offset,
int clevel);
/**
Restrict fine multilayer swe grid data to coarse multilayer swe grid.
\param kernels, threads, blocks
number of kernels, threads and blocks for each process/kernel
\param cumulative_kernels
cumulative number of kernels in mpi processes of r < rank
\param q_cd, q_fd
coarse and fine grids of state vectors
\param nxs, nys, nzs
dimensions of grids
\param matching_indices
position of fine grid wrt coarse grid
\param ng
number of ghost cells
\param rank
rank of MPI process
\param coarse_level
index of coarser level
*/
void restrict_multiswe_to_multiswe(dim3 * kernels, dim3 * threads, dim3 * blocks,
int * cumulative_kernels, float * q_cd, float * q_fd,
int * nxs, int * nys, int * nzs,
int * matching_indices,
int ng, int rank,
int coarse_level);
void interpolate_rhos(float * rho_column, float * rho_grid,
float zmin, float zmax, float dz, float * phs, int nx, int ny, int nz);
/**
First part of evolution through one timestep using finite volume methods.
Reconstructs state vector to cell boundaries using slope limiter
and calculates fluxes there.
NOTE: we assume that beta is smooth so can get value at cell boundaries with simple averaging
\param Un_d
state vector at each grid point in each layer
\param flux_func
pointer to function to be used to calulate fluxes
\param qx_plus_half, qx_minus_half
state vector reconstructed at right and left boundaries
\param qy_plus_half, qy_minus_half
state vector reconstructed at top and bottom boundaries
\param fx_plus_half, fx_minus_half
flux vector at right and left boundaries
\param fy_plus_half, fy_minus_half
flux vector at top and bottom boundaries
\param nx, ny, nz
dimensions of grid
\param alpha, gamma
lapse function and adiabatic index
\param kx_offset, ky_offset
x, y offset for current kernel
*/
__global__ void evolve_fv(float * Un_d, flux_func_ptr flux_func,
float * qx_plus_half, float * qx_minus_half,
float * qy_plus_half, float * qy_minus_half,
float * fx_plus_half, float * fx_minus_half,
float * fy_plus_half, float * fy_minus_half,
int nx, int ny, int nz, int vec_dim, float alpha0,
float gamma, float zmin, float dz, float R,
int kx_offset, int ky_offset);
/**
First part of evolution through one timestep using finite volume methods.
Reconstructs state vector to cell boundaries using slope limiter
and calculates fluxes there.
NOTE: we assume that beta is smooth so can get value at cell boundaries with simple averaging
\param Un_d
state vector at each grid point in each layer
\param flux_func
pointer to function to be used to calculate fluxes
\param qz_plus_half, qz_minus_half
state vector reconstructed at top and bottom boundaries
\param fz_plus_half, fz_minus_half
flux vector at top and bottom boundaries
\param nx, ny, nz
dimensions of grid
\param vec_dim
dimension of state vector
\param alpha, gamma
lapse function and adiabatic index
\param kx_offset, ky_offset
x, y offset for current kernel
*/
__global__ void evolve_z(float * Un_d, flux_func_ptr flux_func,
float * qz_plus_half, float * qz_minus_half,
float * fz_plus_half, float * fz_minus_half,
int nx, int ny, int nz, int vec_dim, float alpha0,
float gamma, float zmin, float dz, float R,
int kx_offset, int ky_offset);
/**
Calculates fluxes in finite volume evolution by solving the Riemann
problem at the cell boundaries.
\param F
flux vector at each point in grid and each layer
\param qx_plus_half, qx_minus_half
state vector reconstructed at right and left boundaries
\param qy_plus_half, qy_minus_half
state vector reconstructed at top and bottom boundaries
\param fx_plus_half, fx_minus_half
flux vector at right and left boundaries
\param fy_plus_half, fy_minus_half
flux vector at top and bottom boundaries
\param nx, ny, nz
dimensions of grid
\param vec_dim
dimension of state vector
\param alpha
lapse function
\param dx, dy, dt
gridpoint spacing and timestep spacing
\param kx_offset, ky_offset
x, y offset for current kernel
*/
__global__ void evolve_fv_fluxes(float * F,
float * qx_plus_half, float * qx_minus_half,
float * qy_plus_half, float * qy_minus_half,
float * fx_plus_half, float * fx_minus_half,
float * fy_plus_half, float * fy_minus_half,
int nx, int ny, int nz, int vec_dim, float alpha0,
float dx, float dy, float dz, float dt, float zmin, float R,
int kx_offset, int ky_offset);
/**
Calculates fluxes in finite volume evolution by solving the Riemann
problem at the cell boundaries in z direction.
\param F
flux vector at each point in grid and each layer
\param qz_plus_half, qz_minus_half
state vector reconstructed at right and left boundaries
\param fz_plus_half, fz_minus_half
flux vector at top and bottom boundaries
\param nx, ny, nz
dimensions of grid
\param vec_dim
dimension of state vector