-
Notifications
You must be signed in to change notification settings - Fork 7
/
copyandinit_functions.c
863 lines (600 loc) · 27.3 KB
/
copyandinit_functions.c
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
#include "decs.h"
/////////////////////////
//
// Various mostly general copy and initialization functions that operate on 3D Loop
//
/////////////////////////
// loop range for inversion or final centered field primitive
void get_inversion_startendindices(int *loop, int *is,int *ie,int *js,int *je,int *ks,int *ke)
{
#if(0)
// define loop range
// +SHIFT? is for IF3DSPCTHENMPITRANSFERATPOLE
// with cleanup_fluxes() in flux.c so that fluxes are zeroed-out outside well-defined computational box, then *always* update +-1 from "normal" conservatives so that all possible fluxes are accounted in changes due to interior and some exterior cells
// This way all advance.c is simple and just expanded by 1 cell effectively
// This allows use of adaptive time-stepping such that surrounding cells are properly updated and keep pace with the effective time of the RK-stepping
// Also ensures divb=0 and flux conservation under any case since always take into account fluxes through the well-defined computational box
// must constrain result since this is final centered value of field and only have enough information to be well-defined on the current computational box over a finite range
// Only expand if on outer edge of not-evolved region in order to (primarily) preserve divb=0
// must constrain result since this is final centered value of field and only have enough information to be well-defined on the current computational box over a finite range
// Only expand if on outer edge of not-evolved region in order to (primarily) preserve divb=0
// 1|| because realized don't want to adjust "boundary cells". Want to keep them fixed. Violates conservation (and divb=0) unless separately evolve that other region. This is ok sinc just approximating evolution in non-evolved region when moving full boundary.
// if(subgrid inner boundary>global active grid inner boundary)
if(AVOIDADVANCESHIFTX1DN||enerposreg[ACTIVEREGION][X1DN]>enerposreg[ACTIVEREGION][X1DN]) *is=Uconsevolveloop[FIS];
else *is=Uconsevolveloop[FIS]-SHIFT1;
if(AVOIDADVANCESHIFTX1UP||enerposreg[ACTIVEREGION][X1UP]<enerposreg[ACTIVEREGION][X1UP]) *ie=Uconsevolveloop[FIE];
else *ie=Uconsevolveloop[FIE]+SHIFT1;
if(AVOIDADVANCESHIFTX2DN||enerposreg[ACTIVEREGION][X2DN]>enerposreg[ACTIVEREGION][X2DN]) *js=Uconsevolveloop[FJS];
else *js=Uconsevolveloop[FJS]-SHIFT2;
if(AVOIDADVANCESHIFTX2UP||enerposreg[ACTIVEREGION][X2UP]<enerposreg[ACTIVEREGION][X2UP]) *je=Uconsevolveloop[FJE];
else *je=Uconsevolveloop[FJE]+SHIFT2;
if(AVOIDADVANCESHIFTX3DN||enerposreg[ACTIVEREGION][X3DN]>enerposreg[ACTIVEREGION][X3DN]) *ks=Uconsevolveloop[FKS];
else *ks=Uconsevolveloop[FKS]-SHIFT3;
if(AVOIDADVANCESHIFTX3UP||enerposreg[ACTIVEREGION][X3UP]<enerposreg[ACTIVEREGION][X3UP]) *ke=Uconsevolveloop[FKE];
else *ke=Uconsevolveloop[FKE]+SHIFT3;
#else
// this loop range must be equal to that used in copy_tempucum_finalucum() for centered quantities there (i.e. ignore FLUXB==FLUXCTSTAG in that function as compared to here).
*is=loop[FIS]-SHIFT1*(AVOIDADVANCESHIFTX1DN==0);
*ie=loop[FIE]+SHIFT1*(AVOIDADVANCESHIFTX1UP==0);
*js=loop[FJS]-SHIFT2*(AVOIDADVANCESHIFTX2DN==0);
*je=loop[FJE]+SHIFT2*(AVOIDADVANCESHIFTX2UP==0);
*ks=loop[FKS]-SHIFT3*(AVOIDADVANCESHIFTX3DN==0);
*ke=loop[FKE]+SHIFT3*(AVOIDADVANCESHIFTX3UP==0);
// new method is always centered inversion or primitive for field
//*is=loop[FIS];
// *ie=loop[FIE];
// *js=loop[FJS];
// *je=loop[FJE];
// *ks=loop[FKS];
// *ke=loop[FKE];
#endif
}
// determine loop range for ustagpoint2pstag() in fluxctstag.c
void get_stag_startendindices(int *loop, int dir, int *is,int *ie,int *js,int *je,int *ks,int *ke)
{
// must constrain result since this is final centered value of field and only have enough information to be well-defined on the current computational box over a finite range
// Only expand if on outer edge of not-evolved region in order to (primarily) preserve divb=0
// 1|| for same reason as for centered quantities as discussed above.
// if(subgrid inner boundary>global active grid inner boundary)
if(AVOIDADVANCESHIFTX1DN||enerposreg[ACTIVEREGION][X1DN]>enerposreg[ACTIVEREGION][X1DN]) *is=loop[FIS];
else *is=loop[FIS]-SHIFT1;
if(AVOIDADVANCESHIFTX1UP||enerposreg[ACTIVEREGION][X1UP]<enerposreg[ACTIVEREGION][X1UP]) *ie=loop[FIE]+SHIFT1*(dir==1);
else *ie=loop[FIE]+SHIFT1;
if(AVOIDADVANCESHIFTX2DN||enerposreg[ACTIVEREGION][X2DN]>enerposreg[ACTIVEREGION][X2DN]) *js=loop[FJS];
else *js=loop[FJS]-SHIFT2;
if(AVOIDADVANCESHIFTX2UP||enerposreg[ACTIVEREGION][X2UP]<enerposreg[ACTIVEREGION][X2UP]) *je=loop[FJE]+SHIFT2*(dir==2);
else *je=loop[FJE]+SHIFT2;
if(AVOIDADVANCESHIFTX3DN||enerposreg[ACTIVEREGION][X3DN]>enerposreg[ACTIVEREGION][X3DN]) *ks=loop[FKS];
else *ks=loop[FKS]-SHIFT3;
if(AVOIDADVANCESHIFTX3UP||enerposreg[ACTIVEREGION][X3UP]<enerposreg[ACTIVEREGION][X3UP]) *ke=loop[FKE]+SHIFT3*(dir==3);
else *ke=loop[FKE]+SHIFT3;
}
// determine loop range for *using* fluxes
// shifts extra +1 to get field update.
// Assumes applied to temporary ucum and that final ucum more controlled
// This forces flux update so face fields included, but final ucum/pf still only updated at center.
// +SHIFT1/2/3 required in particular for IF3DSPCTHENMPITRANSFERATPOLE. In all other cases turns out wouldn't have needed this, but still ok to do it in general -- especially for AMR
// Notes from above:
// then always use +-1 expanded loop even for inversion
// This overdoes corner cells for inversion for centered U, but just cycles through existing values so ok
// Even ok if extends to true boundary cell
// with cleanup_fluxes() in flux.c so that fluxes are zeroed-out outside well-defined computational box, then *always* update +-1 from "normal" conservatives so that all possible fluxes are accounted in changes due to interior and some exterior cells
// This way all advance.c is simple and just expanded by 1 cell effectively
// This allows use of adaptive time-stepping such that surrounding cells are properly updated and keep pace with the effective time of the RK-stepping
// Also ensures divb=0 and flux conservation under any case since always take into account fluxes through the well-defined computational box
// must constrain result since this is final centered value of field and only have enough information to be well-defined on the current computational box over a finite range
// Only expand if on outer edge of not-evolved region in order to (primarily) preserve divb=0
void get_flux_startendindices(int *loop, int *is,int *ie,int *js,int *je,int *ks,int *ke)
{
// this loop range must be equal or larger than that used in copy_tempucum_finalucum()
*is=loop[FIS]-SHIFT1*(AVOIDADVANCESHIFTX1DN==0);
*ie=loop[FIE]+SHIFT1*(AVOIDADVANCESHIFTX1UP==0);
*js=loop[FJS]-SHIFT2*(AVOIDADVANCESHIFTX2DN==0);
*je=loop[FJE]+SHIFT2*(AVOIDADVANCESHIFTX2UP==0);
*ks=loop[FKS]-SHIFT3*(AVOIDADVANCESHIFTX3DN==0);
*ke=loop[FKE]+SHIFT3*(AVOIDADVANCESHIFTX3UP==0);
if(FLUXB==FLUXCTSTAG){
// generic shift upwards to compute necessary things for staggered field. In end presume however shifted here, ucum and final primitives are computed on highly controlled locations only
// overrides:
*ie=loop[FIE]+SHIFT1;
*je=loop[FJE]+SHIFT2;
*ke=loop[FKE]+SHIFT3;
}
else{
// default is good
}
}
// copy tempucum -> ucum so ucum only has updates where wanted for each pl.
// avoids NaN or out of bounds assignments into ucum (which shows up in, e.g., dump diagnostics)
// Also ensures that final unewglobal values are only updated within the well-defined computational box
// Note that inversion U->p is also within well-defined computational box.
// Note that ustag->pstag occurs in fluxctstag.c in well-defined computational box [with extra face for each B1,B2,B3 as required]
// So overall prim,pstag,unew are only updated where desired -- no leakage unlike fluxes, temp primitives, and other things.
void copy_tempucum_finalucum(int *loop, FTYPE (*tempucum)[NSTORE2][NSTORE3][NPR], FTYPE (*ucum)[NSTORE2][NSTORE3][NPR])
{
#pragma omp parallel // just copying, only need PLOOP even for ucum_check()
{
int i,j,k;
int pl,pliter;
int is,ie,js,je,ks,ke;
extern void ucum_check(int i, int j, int k, int loc, int pl, FTYPE *ucum);
// loop range where final ucum is set from scratch ucum that may have been set outside desired region for simplicity of loop structures
is=loop[FIS]-SHIFT1*(AVOIDADVANCESHIFTX1DN==0);
ie=loop[FIE]+SHIFT1*(AVOIDADVANCESHIFTX1UP==0);
js=loop[FJS]-SHIFT2*(AVOIDADVANCESHIFTX2DN==0);
je=loop[FJE]+SHIFT2*(AVOIDADVANCESHIFTX2UP==0);
ks=loop[FKS]-SHIFT3*(AVOIDADVANCESHIFTX3DN==0);
ke=loop[FKE]+SHIFT3*(AVOIDADVANCESHIFTX3UP==0);
if(FLUXB==FLUXCTSTAG){
// do non-field quantities
copy_3d_nofield_nowait(is, ie, js, je, ks, ke, tempucum,ucum);
#if(PRODUCTION==0)
#pragma omp barrier // force barrier since otherwise nowait will leak into here with undefined values in general
COMPZSLOOP(is,ie,js,je,ks,ke){
PLOOPNOB1(pl) ucum_check(i,j,k,CENT,pl, MAC(ucum,i,j,k));
PLOOPNOB2(pl) ucum_check(i,j,k,CENT,pl, MAC(ucum,i,j,k));
}
#endif
// do pl==B1
pl=B1;
is=loop[FIS]-SHIFT1*(AVOIDADVANCESHIFTX1DN==0);
ie=loop[FIE]+SHIFT1*(AVOIDADVANCESHIFTX1UP==0);
js=loop[FJS]-SHIFT2*(AVOIDADVANCESHIFTX2DN==0);
je=loop[FJE]+SHIFT2*(AVOIDADVANCESHIFTX2UP==0);
ks=loop[FKS]-SHIFT3*(AVOIDADVANCESHIFTX3DN==0);
ke=loop[FKE]+SHIFT3*(AVOIDADVANCESHIFTX3UP==0);
ie=loop[FIE]+SHIFT1; // always shift - override
copy_3d_onepl_nowait(is, ie, js, je, ks, ke, pl, tempucum, ucum );
#if(PRODUCTION==0)
#pragma omp barrier // force barrier since otherwise nowait will leak into here with undefined values in general
COMPZSLOOP(is,ie,js,je,ks,ke){
ucum_check(i,j,k,FACE1,pl, MAC(ucum,i,j,k));
}
#endif
// do pl==B2
pl=B2;
is=loop[FIS]-SHIFT1*(AVOIDADVANCESHIFTX1DN==0);
ie=loop[FIE]+SHIFT1*(AVOIDADVANCESHIFTX1UP==0);
js=loop[FJS]-SHIFT2*(AVOIDADVANCESHIFTX2DN==0);
je=loop[FJE]+SHIFT2*(AVOIDADVANCESHIFTX2UP==0);
ks=loop[FKS]-SHIFT3*(AVOIDADVANCESHIFTX3DN==0);
ke=loop[FKE]+SHIFT3*(AVOIDADVANCESHIFTX3UP==0);
je=loop[FJE]+SHIFT2;
copy_3d_onepl_nowait(is, ie, js, je, ks, ke, pl, tempucum, ucum );
#if(PRODUCTION==0)
#pragma omp barrier // force barrier since otherwise nowait will leak into here with undefined values in general
COMPZSLOOP(is,ie,js,je,ks,ke){
ucum_check(i,j,k,FACE2,pl, MAC(ucum,i,j,k));
}
#endif
// do pl==B3
pl=B3;
is=loop[FIS]-SHIFT1*(AVOIDADVANCESHIFTX1DN==0);
ie=loop[FIE]+SHIFT1*(AVOIDADVANCESHIFTX1UP==0);
js=loop[FJS]-SHIFT2*(AVOIDADVANCESHIFTX2DN==0);
je=loop[FJE]+SHIFT2*(AVOIDADVANCESHIFTX2UP==0);
ks=loop[FKS]-SHIFT3*(AVOIDADVANCESHIFTX3DN==0);
ke=loop[FKE]+SHIFT3*(AVOIDADVANCESHIFTX3UP==0);
ke=loop[FKE]+SHIFT3;
copy_3d_onepl_nowait(is, ie, js, je, ks, ke, pl, tempucum, ucum );
#if(PRODUCTION==0)
#pragma omp barrier // force barrier since otherwise nowait will leak into here with undefined values in general
COMPZSLOOP(is,ie,js,je,ks,ke){
ucum_check(i,j,k,FACE3,pl, MAC(ucum,i,j,k));
}
#endif
// now ucum is assigned only where should be changed
}
else{
// nothing to do since tempucum is ucum and all at CENT
// just check
#if(PRODUCTION==0)
#pragma omp barrier // force barrier since otherwise nowait will leak into here with undefined values in general
COMPZSLOOP(is,ie,js,je,ks,ke){
PLOOP(pliter,pl) ucum_check(i,j,k,CENT,pl, MAC(ucum,i,j,k));
}
#endif
}
}// end parallel region (with implicit barrier)
}
// like copy_tempucum_finalucum() but for field only
// Used for setting up point value of field in advance.c
void copy_tempucum_finalucum_fieldonly(int *loop, FTYPE (*tempucum)[NSTORE2][NSTORE3][NPR], FTYPE (*ucum)[NSTORE2][NSTORE3][NPR])
{
#pragma omp parallel // just copying, only need PLOOP even for ucum_check()
{
int i,j,k;
int pl,pliter;
int is,ie,js,je,ks,ke;
extern void ucum_check(int i, int j, int k, int loc, int pl, FTYPE *ucum);
// loop range where final ucum is set from scratch ucum that may have been set outside desired region for simplicity of loop structures
is=loop[FIS]-SHIFT1*(AVOIDADVANCESHIFTX1DN==0);
ie=loop[FIE]+SHIFT1*(AVOIDADVANCESHIFTX1UP==0);
js=loop[FJS]-SHIFT2*(AVOIDADVANCESHIFTX2DN==0);
je=loop[FJE]+SHIFT2*(AVOIDADVANCESHIFTX2UP==0);
ks=loop[FKS]-SHIFT3*(AVOIDADVANCESHIFTX3DN==0);
ke=loop[FKE]+SHIFT3*(AVOIDADVANCESHIFTX3UP==0);
if(FLUXB==FLUXCTSTAG){
// do pl==B1
pl=B1;
ie=loop[FIE]+SHIFT1; // always shift - override
copy_3d_onepl_nowait(is, ie, js, je, ks, ke, pl, tempucum, ucum );
#if(PRODUCTION==0)
COMPZSLOOP(is,ie,js,je,ks,ke){
ucum_check(i,j,k,FACE1,pl, MAC(ucum,i,j,k));
}
#endif
// do pl==B2
pl=B2;
je=loop[FJE]+SHIFT2;
copy_3d_onepl_nowait(is, ie, js, je, ks, ke, pl, tempucum, ucum );
#if(PRODUCTION==0)
COMPZSLOOP(is,ie,js,je,ks,ke){
ucum_check(i,j,k,FACE2,pl, MAC(ucum,i,j,k));
}
#endif
// do pl==B3
pl=B3;
ke=loop[FKE]+SHIFT3;
copy_3d_onepl_nowait(is, ie, js, je, ks, ke, pl, tempucum, ucum );
#if(PRODUCTION==0)
COMPZSLOOP(is,ie,js,je,ks,ke){
ucum_check(i,j,k,FACE3,pl, MAC(ucum,i,j,k));
}
#endif
// now ucum is assigned only where should be changed
}
else{
// nothing to do since tempucum is ucum and all at CENT
// just check
#if(PRODUCTION==0)
COMPZSLOOP(is,ie,js,je,ks,ke){
PLOOPBONLY(pl) ucum_check(i,j,k,CENT,pl, MAC(ucum,i,j,k));
}
#endif
}
}// end parallel region (with implicit barrier)
}
// general purpose copy machine for 3D arrays with only size NPR appended onto the end of array
// put as function because then wrap-up OpenMP stuff
void copy_3dnpr(int is, int ie, int js, int je, int ks, int ke,FTYPE (*source)[NSTORE2][NSTORE3][NPR],FTYPE (*dest)[NSTORE2][NSTORE3][NPR])
{
#pragma omp parallel
{
int i,j,k,pl,pliter;
OPENMP3DLOOPVARSDEFINE; OPENMP3DLOOPSETUP(is,ie,js,je,ks,ke);
#pragma omp for schedule(OPENMPFULLNOVARYSCHEDULE())
OPENMP3DLOOPBLOCK{
OPENMP3DLOOPBLOCK2IJK(i,j,k);
//// COMPZSLOOP(is,ie,js,je,ks,ke){
PLOOP(pliter,pl){
MACP0A1(dest,i,j,k,pl)=MACP0A1(source,i,j,k,pl);
}
}// end 3D loop
}// end parallel region
}
// general purpose copy machine for 3D arrays with only size NPR appended onto the end of array
// put as function because then wrap-up OpenMP stuff
void copy_3dnpr_fullloop(FTYPE (*source)[NSTORE2][NSTORE3][NPR],FTYPE (*dest)[NSTORE2][NSTORE3][NPR])
{
int is=-N1BND;
int ie=N1-1+N1BND;
int js=-N2BND;
int je=N2-1+N2BND;
int ks=-N3BND;
int ke=N3-1+N3BND;
copy_3dnpr(is, ie, js, je, ks, ke,source, dest);
}
// general purpose copy machine for 3D arrays with only size NPR appended onto the end of array
// put as function because then wrap-up OpenMP stuff
void copy_3d_nofield(int is, int ie, int js, int je, int ks, int ke,FTYPE (*source)[NSTORE2][NSTORE3][NPR],FTYPE (*dest)[NSTORE2][NSTORE3][NPR])
{
#pragma omp parallel
{
int i,j,k,pl,pliter;
OPENMP3DLOOPVARSDEFINE; OPENMP3DLOOPSETUP(is,ie,js,je,ks,ke);
#pragma omp for schedule(OPENMPFULLNOVARYSCHEDULE())
OPENMP3DLOOPBLOCK{
OPENMP3DLOOPBLOCK2IJK(i,j,k);
// COMPZSLOOP(is,ie,js,je,ks,ke){
PLOOPNOB1(pl) MACP0A1(dest,i,j,k,pl)=MACP0A1(source,i,j,k,pl);
PLOOPNOB2(pl) MACP0A1(dest,i,j,k,pl)=MACP0A1(source,i,j,k,pl);
}// end 3D loop
}// end parallel region
}
// general purpose copy machine for 3D arrays with only size NPR appended onto the end of array
// put as function because then wrap-up OpenMP stuff
void copy_3d_fieldonly(int is, int ie, int js, int je, int ks, int ke,FTYPE (*source)[NSTORE2][NSTORE3][NPR],FTYPE (*dest)[NSTORE2][NSTORE3][NPR])
{
#pragma omp parallel
{
int i,j,k,pl,pliter;
OPENMP3DLOOPVARSDEFINE; OPENMP3DLOOPSETUP(is,ie,js,je,ks,ke);
#pragma omp for schedule(OPENMPFULLNOVARYSCHEDULE())
OPENMP3DLOOPBLOCK{
OPENMP3DLOOPBLOCK2IJK(i,j,k);
// COMPZSLOOP(is,ie,js,je,ks,ke){
PLOOPBONLY(pl) MACP0A1(dest,i,j,k,pl)=MACP0A1(source,i,j,k,pl);
}// end 3D loop
}// end parallel region
}
// general purpose copy machine for 3D arrays with only size NPR appended onto the end of array
// put as function because then wrap-up OpenMP stuff
void copy_3d_fieldonly_fullloop(FTYPE (*source)[NSTORE2][NSTORE3][NPR],FTYPE (*dest)[NSTORE2][NSTORE3][NPR])
{
int is=-N1BND;
int ie=N1-1+N1BND;
int js=-N2BND;
int je=N2-1+N2BND;
int ks=-N3BND;
int ke=N3-1+N3BND;
copy_3d_fieldonly(is, ie, js, je, ks, ke, source, dest);
}
// general purpose copy machine for 3D arrays with only size NPR appended onto the end of array
// put as function because then wrap-up OpenMP stuff
// Presumes parallel region is outside function
void copy_3d_nofield_nowait(int is, int ie, int js, int je, int ks, int ke,FTYPE (*source)[NSTORE2][NSTORE3][NPR],FTYPE (*dest)[NSTORE2][NSTORE3][NPR])
{
int i,j,k,pl,pliter;
// already inside parallel region
OPENMP3DLOOPVARSDEFINE; OPENMP3DLOOPSETUP(is,ie,js,je,ks,ke);
#pragma omp for schedule(OPENMPFULLNOVARYSCHEDULE()) nowait
OPENMP3DLOOPBLOCK{
OPENMP3DLOOPBLOCK2IJK(i,j,k);
// COMPZSLOOP(is,ie,js,je,ks,ke){
PLOOPNOB1(pl) MACP0A1(dest,i,j,k,pl)=MACP0A1(source,i,j,k,pl);
PLOOPNOB2(pl) MACP0A1(dest,i,j,k,pl)=MACP0A1(source,i,j,k,pl);
}// end 3D loop
}
// general purpose copy machine for 3D arrays with only size NPR appended onto the end of array
// put as function because then wrap-up OpenMP stuff
// Presumes parallel region is outside function
void copy_3d_fieldonly_nowait(int is, int ie, int js, int je, int ks, int ke,FTYPE (*source)[NSTORE2][NSTORE3][NPR],FTYPE (*dest)[NSTORE2][NSTORE3][NPR])
{
int i,j,k,pl,pliter;
// already inside parallel region
OPENMP3DLOOPVARSDEFINE; OPENMP3DLOOPSETUP(is,ie,js,je,ks,ke);
#pragma omp for schedule(OPENMPFULLNOVARYSCHEDULE()) nowait
OPENMP3DLOOPBLOCK{
OPENMP3DLOOPBLOCK2IJK(i,j,k);
// COMPZSLOOP(is,ie,js,je,ks,ke){
PLOOPBONLY(pl) MACP0A1(dest,i,j,k,pl)=MACP0A1(source,i,j,k,pl);
}// end 3D loop
}
// general purpose copy machine for 3D arrays with only size NPR appended onto the end of array
// put as function because then wrap-up OpenMP stuff
void copy_3d_onepl(int is, int ie, int js, int je, int ks, int ke, int pl, FTYPE (*source)[NSTORE2][NSTORE3][NPR],FTYPE (*dest)[NSTORE2][NSTORE3][NPR])
{
#pragma omp parallel
{
int i,j,k;
OPENMP3DLOOPVARSDEFINE; OPENMP3DLOOPSETUP(is,ie,js,je,ks,ke);
#pragma omp for schedule(OPENMPFULLNOVARYSCHEDULE())
OPENMP3DLOOPBLOCK{
OPENMP3DLOOPBLOCK2IJK(i,j,k);
// COMPZSLOOP(is,ie,js,je,ks,ke){
MACP0A1(dest,i,j,k,pl)=MACP0A1(source,i,j,k,pl);
}// end 3D loop
}// end parallel region
}
// general purpose copy machine for 3D arrays with only size NPR appended onto the end of array
// put as function because then wrap-up OpenMP stuff
// Presumes parallel region is outside function
void copy_3d_onepl_nowait(int is, int ie, int js, int je, int ks, int ke, int pl, FTYPE (*source)[NSTORE2][NSTORE3][NPR],FTYPE (*dest)[NSTORE2][NSTORE3][NPR])
{
int i,j,k;
// already inside parallel region
OPENMP3DLOOPVARSDEFINE; OPENMP3DLOOPSETUP(is,ie,js,je,ks,ke);
#pragma omp for schedule(OPENMPFULLNOVARYSCHEDULE())
OPENMP3DLOOPBLOCK{
OPENMP3DLOOPBLOCK2IJK(i,j,k);
// COMPZSLOOP(is,ie,js,je,ks,ke){
MACP0A1(dest,i,j,k,pl)=MACP0A1(source,i,j,k,pl);
}// end 3D loop
}
// general purpose copy machine for 3D arrays with only size NPR appended onto the end of array
// put as function because then wrap-up OpenMP stuff
void copy_3d_onepl_fullloop(int pl, FTYPE (*source)[NSTORE2][NSTORE3][NPR],FTYPE (*dest)[NSTORE2][NSTORE3][NPR])
{
int is=-N1BND;
int ie=N1-1+N1BND;
int js=-N2BND;
int je=N2-1+N2BND;
int ks=-N3BND;
int ke=N3-1+N3BND;
copy_3d_onepl(is, ie, js, je, ks, ke, pl, source, dest);
}
// general purpose copy machine for 3D arrays with only size NPR appended onto the end of array
// put as function because then wrap-up OpenMP stuff
// Presumes parallel region is outside function
void copy_3d_onepl_fullloop_nowait(int pl, FTYPE (*source)[NSTORE2][NSTORE3][NPR],FTYPE (*dest)[NSTORE2][NSTORE3][NPR])
{
int is=-N1BND;
int ie=N1-1+N1BND;
int js=-N2BND;
int je=N2-1+N2BND;
int ks=-N3BND;
int ke=N3-1+N3BND;
copy_3d_onepl_nowait(is, ie, js, je, ks, ke, pl, source, dest);
}
// general purpose copy machine for 3D arrays with only size NPR appended onto the end of array
// put as function because then wrap-up OpenMP stuff
void init_3dnpr(int is, int ie, int js, int je, int ks, int ke,FTYPE initvalue, FTYPE (*dest)[NSTORE2][NSTORE3][NPR])
{
#pragma omp parallel
{
int i,j,k,pl,pliter;
OPENMP3DLOOPVARSDEFINE; OPENMP3DLOOPSETUP(is,ie,js,je,ks,ke);
#pragma omp for schedule(OPENMPFULLNOVARYSCHEDULE())
OPENMP3DLOOPBLOCK{
OPENMP3DLOOPBLOCK2IJK(i,j,k);
// COMPZSLOOP(is,ie,js,je,ks,ke){
PLOOP(pliter,pl){
MACP0A1(dest,i,j,k,pl)=initvalue;
}
}// end 3D loop
}// end parallel region
}
void init_3dnpr_fullloop(FTYPE initvalue, FTYPE (*dest)[NSTORE2][NSTORE3][NPR])
{
int is=-N1BND;
int ie=N1-1+N1BND;
int js=-N2BND;
int je=N2-1+N2BND;
int ks=-N3BND;
int ke=N3-1+N3BND;
init_3dnpr(is,ie,js,je,ks,ke,initvalue,dest);
}
// initialize single pre-component of the vpot type array
void init_3dvpot(int is, int ie, int js, int je, int ks, int ke,FTYPE initvalue, FTYPE (*dest)[NSTORE2+SHIFTSTORE2][NSTORE3+SHIFTSTORE3])
{
#pragma omp parallel
{
int i,j,k;
OPENMP3DLOOPVARSDEFINE; OPENMP3DLOOPSETUP(is,ie,js,je,ks,ke);
#pragma omp for schedule(OPENMPFULLNOVARYSCHEDULE())
OPENMP3DLOOPBLOCK{
OPENMP3DLOOPBLOCK2IJK(i,j,k);
MAC(dest,i,j,k)=initvalue;
}// end 3D loop
}// end parallel region
}
// initialize single pre-component of the vpot type array
void init_3dvpot_fullloopp1(FTYPE initvalue, FTYPE (*dest)[NSTORE2+SHIFTSTORE2][NSTORE3+SHIFTSTORE3])
{
int is=-N1BND;
int ie=N1-1+N1BND+SHIFT1;
int js=-N2BND;
int je=N2-1+N2BND+SHIFT2;
int ks=-N3BND;
int ke=N3-1+N3BND+SHIFT3;
init_3dvpot(is,ie,js,je,ks,ke,initvalue,dest);
}
// initialize single pre-component of the vpot type array
void copy_3dvpot(int is, int ie, int js, int je, int ks, int ke, FTYPE (*source)[NSTORE2+SHIFTSTORE2][NSTORE3+SHIFTSTORE3], FTYPE (*dest)[NSTORE2+SHIFTSTORE2][NSTORE3+SHIFTSTORE3])
{
#pragma omp parallel
{
int i,j,k;
OPENMP3DLOOPVARSDEFINE; OPENMP3DLOOPSETUP(is,ie,js,je,ks,ke);
#pragma omp for schedule(OPENMPFULLNOVARYSCHEDULE())
OPENMP3DLOOPBLOCK{
OPENMP3DLOOPBLOCK2IJK(i,j,k);
MAC(dest,i,j,k)=MAC(source,i,j,k);
}// end 3D loop
}// end parallel region
}
// initialize single pre-component of the vpot type array
void copy_3dvpot_fullloopp1(FTYPE (*source)[NSTORE2+SHIFTSTORE2][NSTORE3+SHIFTSTORE3], FTYPE (*dest)[NSTORE2+SHIFTSTORE2][NSTORE3+SHIFTSTORE3])
{
int is=-N1BND;
int ie=N1-1+N1BND+SHIFT1;
int js=-N2BND;
int je=N2-1+N2BND+SHIFT2;
int ks=-N3BND;
int ke=N3-1+N3BND+SHIFT3;
copy_3dvpot(is,ie,js,je,ks,ke,source,dest);
}
// general purpose copy machine for 3D arrays with only size NPR appended onto the end of array
// put as function because then wrap-up OpenMP stuff
void init_3dnpr_2ptrs(int is, int ie, int js, int je, int ks, int ke,FTYPE initvalue, FTYPE (*dest1)[NSTORE2][NSTORE3][NPR],FTYPE (*dest2)[NSTORE2][NSTORE3][NPR])
{
#pragma omp parallel
{
int i,j,k,pl,pliter;
OPENMP3DLOOPVARSDEFINE; OPENMP3DLOOPSETUP(is,ie,js,je,ks,ke);
#pragma omp for schedule(OPENMPFULLNOVARYSCHEDULE())
OPENMP3DLOOPBLOCK{
OPENMP3DLOOPBLOCK2IJK(i,j,k);
// COMPZSLOOP(is,ie,js,je,ks,ke){
PLOOP(pliter,pl){
MACP0A1(dest1,i,j,k,pl)=MACP0A1(dest2,i,j,k,pl)=initvalue;
}
}// end 3D loop
}// end parallel region
}
// general purpose copy machine for 3D arrays with only size NPR appended onto the end of array
// put as function because then wrap-up OpenMP stuff
void copy_3dnpr_2ptrs(int is, int ie, int js, int je, int ks, int ke,FTYPE (*source)[NSTORE2][NSTORE3][NPR],FTYPE (*dest1)[NSTORE2][NSTORE3][NPR],FTYPE (*dest2)[NSTORE2][NSTORE3][NPR])
{
#pragma omp parallel
{
int i,j,k,pl,pliter;
OPENMP3DLOOPVARSDEFINE; OPENMP3DLOOPSETUP(is,ie,js,je,ks,ke);
#pragma omp for schedule(OPENMPFULLNOVARYSCHEDULE())
OPENMP3DLOOPBLOCK{
OPENMP3DLOOPBLOCK2IJK(i,j,k);
// COMPZSLOOP(is,ie,js,je,ks,ke){
PLOOP(pliter,pl){
MACP0A1(dest1,i,j,k,pl)=MACP0A1(dest2,i,j,k,pl)=MACP0A1(source,i,j,k,pl);
}
}// end 3D loop
}// end parallel region
}
// general purpose copy machine for 3D arrays with only size NPR appended onto the end of array
// put as function because then wrap-up OpenMP stuff
void copy_3dpftype_special(int is, int ie, int js, int je, int ks, int ke,PFTYPE (*source)[NSTORE2][NSTORE3][NUMPFLAGS],PFTYPE (*destspecial)[NSTORE2][NSTORE3])
{
#pragma omp parallel
{
int i,j,k;
OPENMP3DLOOPVARSDEFINE; OPENMP3DLOOPSETUP(is,ie,js,je,ks,ke);
#pragma omp for schedule(OPENMPFULLNOVARYSCHEDULE())
OPENMP3DLOOPBLOCK{
OPENMP3DLOOPBLOCK2IJK(i,j,k);
MACP0A0(destspecial,i,j,k)=MACP0A1(source,i,j,k,FLAGUTOPRIMFAIL); // only copy fail flag
}// end 3D loop
}// end parallel region
}
// general purpose copy machine for 3D arrays with only size NPR appended onto the end of array
// put as function because then wrap-up OpenMP stuff
void copy_3dpftype_special_fullloop(PFTYPE (*source)[NSTORE2][NSTORE3][NUMPFLAGS],PFTYPE (*destspecial)[NSTORE2][NSTORE3])
{
int is=-N1BND;
int ie=N1-1+N1BND;
int js=-N2BND;
int je=N2-1+N2BND;
int ks=-N3BND;
int ke=N3-1+N3BND;
// override
get_inversion_startendindices(Uconsevolveloop,&is,&ie,&js,&je,&ks,&ke);
// +-1 extra so can do check
is += -SHIFT1;
ie += +SHIFT1;
js += -SHIFT2;
je += +SHIFT2;
ks += -SHIFT3;
ke += +SHIFT3;
copy_3dpftype_special(is, ie, js, je, ks, ke,source, destspecial);
}
// general purpose copy machine for 3D arrays with only size NPR appended onto the end of array
// put as function because then wrap-up OpenMP stuff
void copy_3dnpr2interp_2ptrs(int is, int ie, int js, int je, int ks, int ke,FTYPE (*source)[NSTORE2][NSTORE3][NPR2INTERP],FTYPE (*dest1)[NSTORE2][NSTORE3][NPR2INTERP],FTYPE (*dest2)[NSTORE2][NSTORE3][NPR2INTERP])
{
#pragma omp parallel OPENMPGLOBALPRIVATEPLOOPINTERPONLY
{
int i,j,k,pl,pliter;
OPENMP3DLOOPVARSDEFINE; OPENMP3DLOOPSETUP(is,ie,js,je,ks,ke);
#pragma omp for schedule(OPENMPFULLNOVARYSCHEDULE())
OPENMP3DLOOPBLOCK{
OPENMP3DLOOPBLOCK2IJK(i,j,k);
// COMPZSLOOP(is,ie,js,je,ks,ke){
PINTERPLOOP(pliter,pl){
MACP0A1(dest1,i,j,k,pl)=MACP0A1(dest2,i,j,k,pl)=MACP0A1(source,i,j,k,pl);
}
}// end 3D loop
}// end parallel region
}
// general purpose copy machine for 3D arrays with only size NPR appended onto the end of array
// put as function because then wrap-up OpenMP stuff
void copy_3dnpr2interp_2ptrs_fullloop(FTYPE (*source)[NSTORE2][NSTORE3][NPR2INTERP],FTYPE (*dest1)[NSTORE2][NSTORE3][NPR2INTERP],FTYPE (*dest2)[NSTORE2][NSTORE3][NPR2INTERP])
{
int i,j,k,pl,pliter;
int is=-N1BND;
int ie=N1-1+N1BND;
int js=-N2BND;
int je=N2-1+N2BND;
int ks=-N3BND;
int ke=N3-1+N3BND;
copy_3dnpr2interp_2ptrs(is, ie, js, je, ks, ke,source, dest1, dest2);
}