-
Notifications
You must be signed in to change notification settings - Fork 7
/
flux.c
3057 lines (2266 loc) · 111 KB
/
flux.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
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
// OPTMARK: Should redo flux's so that fluxes are accessed by MAC(F1,j,k,i) MAC(F2,k,i,j) MAC(F3,i,j,k) for faster differencing in advance.c
// Maybe not important
#include "decs.h"
static void leftrightcompute(int i, int j, int k, int dir, int is, int ie, int js, int je, int ks, int ke, int *computewithleft, int *computewithright);
// get whether should compute using left/right states
static void leftrightcompute(int i, int j, int k, int dir, int is, int ie, int js, int je, int ks, int ke, int *computewithleft, int *computewithright)
{
#if(MERGEDC2EA2CMETHOD)
// if doing merged method, then expanded "flux" calculation to get state in full (i.e. left,cent,right) in the "-1" and "N" cells
if(dir==1 && (i==is) || dir==2 && (j==js) || dir==3 && (k==ks)){ *computewithleft=0; *computewithright=1; }
else if(dir==1 && (i==ie) || dir==2 && (j==je) || dir==3 && (k==ke)){ *computewithleft=1; *computewithright=0; }
else{ *computewithleft=1; *computewithright=1; }
#else
// normal routine when always get final dissipative flux
*computewithleft=1; *computewithright=1;
#endif
}
// see fluxcompute.c for non-computer science, real physics calculations of flux
int fluxcalc(int stage,
int initialstep, int finalstep,
FTYPE (*pr)[NSTORE2][NSTORE3][NPR],
FTYPE (*pstag)[NSTORE2][NSTORE3][NPR],
FTYPE (*pl_ct)[NSTORE1][NSTORE2][NSTORE3][NPR2INTERP], FTYPE (*pr_ct)[NSTORE1][NSTORE2][NSTORE3][NPR2INTERP],
FTYPE (*vpot)[NSTORE1+SHIFTSTORE1][NSTORE2+SHIFTSTORE2][NSTORE3+SHIFTSTORE3],
FTYPE (*F1)[NSTORE2][NSTORE3][NPR],
FTYPE (*F2)[NSTORE2][NSTORE3][NPR],
FTYPE (*F3)[NSTORE2][NSTORE3][NPR],
FTYPE *CUf,
FTYPE *CUnew,
SFTYPE fluxdt,
SFTYPE fluxtime,
FTYPE *ndt1,
FTYPE *ndt2,
FTYPE *ndt3
)
{
int fluxcalc_flux(int stage, FTYPE (*pr)[NSTORE2][NSTORE3][NPR], FTYPE (*pstag)[NSTORE2][NSTORE3][NPR], FTYPE (*pl_ct)[NSTORE1][NSTORE2][NSTORE3][NPR2INTERP], FTYPE (*pr_ct)[NSTORE1][NSTORE2][NSTORE3][NPR2INTERP], int *Nvec, FTYPE (*dqvec[NDIM])[NSTORE2][NSTORE3][NPR2INTERP], FTYPE (*fluxvec[NDIM])[NSTORE2][NSTORE3][NPR], FTYPE (*fluxvecEM[NDIM])[NSTORE2][NSTORE3][NPR], FTYPE CUf, SFTYPE time, FTYPE *ndtvec[NDIM], struct of_loop *cent2faceloop);
void fix_flux(FTYPE (*pr)[NSTORE2][NSTORE3][NPR],FTYPE (*F1)[NSTORE2][NSTORE3][NPR], FTYPE (*F2)[NSTORE2][NSTORE3][NPR], FTYPE (*F3)[NSTORE2][NSTORE3][NPR]) ;
FTYPE (*dqvec[NDIM])[NSTORE2][NSTORE3][NPR2INTERP];
FTYPE (*fluxvec[NDIM])[NSTORE2][NSTORE3][NPR];
FTYPE (*fluxvecEM[NDIM])[NSTORE2][NSTORE3][NPR];
FTYPE (**ptrfluxvec)[NSTORE2][NSTORE3][NPR];
FTYPE *ndtvec[NDIM];
int Nvec[NDIM];
int flux_point2avg(int stage, int whichmaorem, FTYPE (*pr)[NSTORE2][NSTORE3][NPR], int *Nvec, FTYPE (*fluxvec[NDIM])[NSTORE2][NSTORE3][NPR], FTYPE (*fluxvecother[NDIM])[NSTORE2][NSTORE3][NPR]);
void preinterp_flux_point2avg(void);
int i,j,k;
int pl,pliter;
int dir;
int fluxEM2flux4EMF(int *Nvec, FTYPE (*fluxvec[NDIM])[NSTORE2][NSTORE3][NPR], FTYPE (*fluxvecEM[NDIM])[NSTORE2][NSTORE3][NPR]);
int fluxsum(int *Nvec, FTYPE (*fluxvec[NDIM])[NSTORE2][NSTORE3][NPR], FTYPE (*fluxvecEM[NDIM])[NSTORE2][NSTORE3][NPR]);
int cleanup_fluxes(int *Nvec, FTYPE (*fluxvec[NDIM])[NSTORE2][NSTORE3][NPR]);
int zero_out_fluxes(int *Nvec, FTYPE (*fluxvec[NDIM])[NSTORE2][NSTORE3][NPR]);
int zero_out_emf_fluxes(int *Nvec, FTYPE (*fluxvec[NDIM])[NSTORE2][NSTORE3][NPR]);
// face2faceloop[dir=facedir] and face2cornloop[EMFdir=edgedir][EMFodir1][EMFodir2]
// face2centloop separately used during separate part of advance()
struct of_loop cent2faceloop[NDIM],face2cornloop[NDIM][NDIM][NDIM];
/////////////////////////
//
// SETUP dimensionality
//
/////////////////////////
fluxvec[1]=F1;
fluxvec[2]=F2;
fluxvec[3]=F3;
fluxvecEM[1]=GLOBALPOINT(F1EM); // more temporary than F1,F2,F3, so don't pass to here and just keep global
fluxvecEM[2]=GLOBALPOINT(F2EM);
fluxvecEM[3]=GLOBALPOINT(F3EM);
dqvec[1]=GLOBALPOINT(dq1);
dqvec[2]=GLOBALPOINT(dq2);
dqvec[3]=GLOBALPOINT(dq3);
ndtvec[1]=ndt1;
ndtvec[2]=ndt2;
ndtvec[3]=ndt3;
Nvec[1]=N1;
Nvec[2]=N2;
Nvec[3]=N3;
if(splitmaem) ptrfluxvec=fluxvecEM;
else ptrfluxvec=fluxvec;
///////////////////////////////////////////////
//
// Zero-out fluxes so can easily update full region in advance.c without special conditions
//
///////////////////////////////////////////////
// zero_out_fluxes(Nvec,ptrfluxvec); // NOT FOR NOW
// Below no longer needed since always zero-out all fluxes (reverted)
// zero-out EMFs if evolving/tracking vector potential so boundary regions appear simple in DUMPS when showing boundary cells
if(TRACKVPOT && FULLOUTPUT!=0){
zero_out_emf_fluxes(Nvec,ptrfluxvec);
}
///////////////////////////////////////////////
//
// some pre-interplation flux averaging setups
//
///////////////////////////////////////////////
preinterp_flux_point2avg();
///////////////////////////////////////////////
//
// Compute normal flux at face
// Involves interpolating CENT -> FACE1,2,3
// Final p_l p_r results of interpolation are stored in pl_ct pr_ct if needed by SPLITNPR or FLUXB==FLUXCTSTAG
// Wavespeeds may also be stored globally if STOREWAVESPEEDS>0
// In all cases wavespeed constraint on timestep is set here
//
// assume fluxvec is MA only if splitmaem==1
//
///////////////////////////////////////////////
// CUf[2]=current dt to be used on flux
fluxcalc_flux(stage, pr, pstag, pl_ct, pr_ct, Nvec, dqvec, fluxvec, fluxvecEM, CUf[2], fluxtime, ndtvec, cent2faceloop);
#if(0)
// DEBUG:
if(Nvec[1]>1) FULLLOOP PLOOP(pliter,pl) MACP1A1(fluxvec,1,i,j,k,pl)+=MACP1A1(fluxvecEM,1,i,j,k,pl);
if(Nvec[2]>1) FULLLOOP PLOOP(pliter,pl) MACP1A1(fluxvec,2,i,j,k,pl)+=MACP1A1(fluxvecEM,2,i,j,k,pl);
if(Nvec[3]>1) FULLLOOP PLOOP(pliter,pl) MACP1A1(fluxvec,3,i,j,k,pl)+=MACP1A1(fluxvecEM,3,i,j,k,pl);
#endif
//////////////////////////////
//
// FIXFLUX
//
/////////////////////////////
if(FIXUPFLUX && splitmaem==0){ // for now can't use fix_flux with splitmaem since it resets field part to 0 that I'm using as diagonal gas pressure term
fix_flux(pr, fluxvec[1], fluxvec[2], fluxvec[3]);
if(splitmaem) fix_flux(pr, fluxvecEM[1], fluxvecEM[2], fluxvecEM[3]);
#if(PRODUCTION==0)
trifprintf( "x");
#endif
}
//////////////////////////////
//
// FLUXCTSTAG -- overwrite field fluxes (emf's) with correct CORN1,2,3 points values
//
// assumes fluxcalc_flux() above called fluxcalc_standard_4fluxctstag() so pl_ct and pr_ct are set with FACE1,2,3 values of all quantities (including field along dir that comes from pstagscratch[] in this case)
//
/////////////////////////////
if(FLUXB==FLUXCTSTAG){
#if(STOREWAVESPEEDS==0 || USESTOREDSPEEDSFORFLUX==0)
dualfprintf(fail_file,"STOREWAVESPEEDS,USESTOREDSPEEDSFORFLUX must be >0 when FLUXB==FLUXCTSTAG\n");
// must store because vchar() cannot be computed at CORN since only have partial velocities and partial fields and no densities
// really only STOREWAVESPEEDS must be >0, but for now assume both
myexit(175106);
#endif
MYFUN(fluxcalc_fluxctstag(stage, initialstep, finalstep, pr, pstag, pl_ct, pr_ct, GLOBALPOINT(pvbcorninterp), GLOBALPOINT(wspeed), GLOBALPOINT(prc), GLOBALPOINT(pleft), GLOBALPOINT(pright), GLOBALPOINT(fluxstatecent), GLOBALPOINT(fluxstate), GLOBALPOINT(geomcornglobal), Nvec, dqvec, ptrfluxvec, vpot, CUf, CUnew, fluxdt, fluxtime, cent2faceloop, face2cornloop),"flux.c:fluxcalc()", "fluxcalc_fluxctstag", 0);
}// end if staggered method where can update A_i directly
#if(PRODUCTION==0)
trifprintf( "c");
#endif
#if(0)
// DEBUG:
FULLLOOP{
DIMENLOOP(dir){
if(Nvec[dir]>1){
PLOOP(pliter,pl){
if(pl>=B1 && pl<=B2){
if(!isfinite(MACP1A1(fluxvec,dir,i,j,k,pl))){
dualfprintf(fail_file,"GOD FLUXA: dir=%d pl=%d i=%d j=%d k=%d\n",dir,pl,i,j,k,MACP1A1(fluxvec,dir,i,j,k,pl));
}
}
}
}
}
}
#endif
//////////////////////////////
//
// convert point FLUXES to surface-averaged fluxes (for field, if FLUXB==FLUXCTSTAG, then should do line integral of emf ENOMARK)
//
/////////////////////////////
if((interporder[avgscheme[1]]>3) || (interporder[avgscheme[2]]>3) || (interporder[avgscheme[3]]>3)){
if(splitmaem){
// assume fluxvec is MA only if splitmaem==1
//flux_point2avg(stage, ISMAONLY, pr, Nvec, fluxvec,NULL);
// below version forces summation of MA+EM for stencil
flux_point2avg(stage, ISMAONLY, pr, Nvec, fluxvec,fluxvecEM);
flux_point2avg(stage, ISEMONLY, pr, Nvec, fluxvecEM, NULL);
}
else{
flux_point2avg(stage, ISMAANDEM, pr, Nvec, fluxvec,NULL);
}
}
#if(0)
// DEBUG: // also helped after flux_point2avg() but not before! -- so higher order code is problem or fed bad data
// bound_flux(-1,F1,F2,F3);
#endif
//////////////////////////////
//
// FLUXCT : must come after modifying fluxes so that divb=0 is preserved to machine error
// i.e. flux_ct modifies fluxes in special way just before updating field so that divb=0 is conserved
// Method is only 2nd order at best since assumes volume average is same as surface average
//
/////////////////////////////
if((FLUXB==ATHENA1)||(FLUXB==ATHENA2)||(FLUXB==FLUXCTTOTH)||(FLUXB==FLUXCD)){
MYFUN(flux_ct(stage, initialstep, finalstep, pr, GLOBALPOINT(emf), GLOBALPOINT(vconemf), GLOBALPOINT(dq1), GLOBALPOINT(dq2), GLOBALPOINT(dq3), ptrfluxvec[1], ptrfluxvec[2], ptrfluxvec[3], vpot, Nvec, CUf, CUnew, fluxdt, fluxtime),"step_ch.c:advance()", "flux_ct",1);
}
//////////////////////
//
// sum up MA+EM
// if splitmaem==1, then MA and EM split up to this point
//
///////////////////////
if(splitmaem) fluxsum(Nvec, fluxvec,fluxvecEM);
//////////////////
//
// now fluxvec has MA+EM and fluxvecEM is no longer needed
//
//////////////////
//////////////////////////////
//
// Merged c2e-c2a method
//
/////////////////////////////
if(MERGEDC2EA2CMETHOD){
mergedc2ea2cmethod_compute(Nvec,fluxvec);
}
//////////////////////////////
//
// Clean-up fluxes so zero outside well-defined computational box
// Turns out to be easier to clean-up rather than ensure computed in right places
//
/////////////////////////////
cleanup_fluxes(Nvec,ptrfluxvec);
//////////////////////////////
//
// DEBUG:
//
/////////////////////////////
#if(FLUXDUMP)
// this accounts for final flux
FULLLOOP{
DIMENLOOP(dir){
if(Nvec[dir]>1){
PLOOP(pliter,pl) GLOBALMACP0A1(fluxdump,i,j,k,4*NPR + (dir-1)*NPR*5 + NPR*0 + pl)=MACP1A1(fluxvec,dir,i,j,k,pl);
}
else{
PLOOP(pliter,pl) GLOBALMACP0A1(fluxdump,i,j,k,4*NPR + (dir-1)*NPR*5 + NPR*0 + pl)=0.0;
}
}
}
#endif
// DEBUG: // helped!
// bound_prim(-1,F1,NULL,NULL,1);
// bound_prim(-1,F2,NULL,NULL,1);
// DEBUG: // also helped!
//bound_flux(-1,F1,F2,F3);
return(0);
}
// ensure fluxes only exist on well-defined computational box
// makes advance.c, GRIDSECTIONING, and adaptive time-stepping easier to code for
// Note that the branch prediction penalty for these conditions inside the LOOP is low since just zero out nearby memory elements
int cleanup_fluxes(int *Nvec, FTYPE (*fluxvec[NDIM])[NSTORE2][NSTORE3][NPR])
{
// for nowait to matter, has to be on inner loop but outer (dir) loop must be inside the parallel construct since a parallel construct has an impassible barrier. If one put the parallel region inside the outer (dir) loop, the nowait would be useless. Then interior things that depend upon "dir" must be made private, including "dir" itself
#pragma omp parallel
{
int i,j,k;
int dir;
int pl,pliter;
int is,ie,js,je,ks,ke;
int B1is,B1ie,B1js,B1je,B1ks,B1ke;
int B2is,B2ie,B2js,B2je,B2ks,B2ke;
int B3is,B3ie,B3js,B3je,B3ks,B3ke;
int loop[NUMFLUXLOOPNUMBERS];
// int odir1,odir2;
OPENMP3DLOOPVARSDEFINE; OPENMP3DLOOPSETUPFULL; // doesn't depend upon dir, so can be outside DIMENLOOP. However, blockijk must be private, so go ahead and put inside parallel region
// pick reference loop as where evolve conserved quantities
// must shift since indices not used as arguments to LOOP
loop[FIS]=Uconsevolveloop[FIS]+SHIFTX1DN;
loop[FIE]=Uconsevolveloop[FIE]+SHIFTX1UP;
loop[FJS]=Uconsevolveloop[FJS]+SHIFTX2DN;
loop[FJE]=Uconsevolveloop[FJE]+SHIFTX2UP;
loop[FKS]=Uconsevolveloop[FKS]+SHIFTX3DN;
loop[FKE]=Uconsevolveloop[FKE]+SHIFTX3UP;
DIMENLOOP(dir){
if(Nvec[dir]>1){
// get_odirs(dir,&odir1,&odir2);
is=loop[FIS];
ie=loop[FIE]+(dir==1)*SHIFT1;
js=loop[FJS];
je=loop[FJE]+(dir==2)*SHIFT2;
ks=loop[FKS];
ke=loop[FKE]+(dir==3)*SHIFT3;
if(FLUXB==FLUXCTSTAG){
// E1: Needed: i==0..N1-1 j=0..N2 k=0..N3
// E2: Needed: i==0..N1 j=0..N2-1 k=0..N3
// E3: Needed: i==0..N1 j=0..N2 k=0..N3-1
// Note Fi[Bi]=0 always and should already be set everywhere
// B1
B1is=loop[FIS];
B1ie=loop[FIE]+(dir==1 || dir==2 || dir==3)*SHIFT1; // for F1[B1],F2[B1]=E3,F3[B1]=E2
B1js=loop[FJS];
B1je=loop[FJE]+(dir==1 || dir==2)*SHIFT2; // for F1[B1],F2[B1]=E3
B1ks=loop[FKS];
B1ke=loop[FKE]+(dir==1 || dir==3)*SHIFT3; // for F1[B1],F3[B1]=E2
// B2
B2is=loop[FIS];
B2ie=loop[FIE]+(dir==1 || dir==2)*SHIFT1; // for F1[B2]=E3,F2[B2],F3[B2]=E1
B2js=loop[FJS];
B2je=loop[FJE]+(dir==1 || dir==2 || dir==3)*SHIFT2; // for F1[B2]=E3,F2[B2],F3[B2]=E1
B2ks=loop[FKS];
B2ke=loop[FKE]+(dir==2 || dir==3)*SHIFT3; // for F2[B2],F3[B2]=E1
// B3
B3is=loop[FIS];
B3ie=loop[FIE]+(dir==1 || dir==3)*SHIFT1; // for F1[B3]=E2,F3[B3]
B3js=loop[FJS];
B3je=loop[FJE]+(dir==2 || dir==3)*SHIFT2; // for F1[B3]=E2,F2[B3]=E1,F3[B3]
B3ks=loop[FKS];
B3ke=loop[FKE]+(dir==1 || dir==2 || dir==3)*SHIFT3; // for F1[B3]=E2,F2[B3]=E1,F3[B3]
}
else{
B1is=B2is=B3is=is;
B1ie=B2ie=B3ie=ie;
B1js=B2js=B3js=js;
B1je=B2je=B3je=je;
B1ks=B2ks=B3ks=ks;
B1ke=B2ke=B3ke=ke;
}
// dualfprintf(fail_file,"dir=%d Clean1: is=%d ie=%d js=%d je=%d ks=%d ke=%d\n",dir,is,ie,js,je,ks,ke);
// dualfprintf(fail_file,"CleanB1: B1is=%d B1ie=%d B1js=%d B1je=%d B1ks=%d B1ke=%d\n",B1is,B1ie,B1js,B1je,B1ks,B1ke);
// dualfprintf(fail_file,"CleanB2: B2is=%d B2ie=%d B2js=%d B2je=%d B2ks=%d B2ke=%d\n",B2is,B2ie,B2js,B2je,B2ks,B2ke);
// dualfprintf(fail_file,"CleanB3: B3is=%d B3ie=%d B3js=%d B3je=%d B3ks=%d B3ke=%d\n",B3is,B3ie,B3js,B3je,B3ks,B3ke);
//// COMPFULLLOOP{
#pragma omp for schedule(OPENMPSCHEDULE(),OPENMPCHUNKSIZE(blocksize)) nowait // can nowait since each fluxvec[dir] is set separately
OPENMP3DLOOPBLOCK{
OPENMP3DLOOPBLOCK2IJK(i,j,k);
// below means we are not within the computational block
if(! (i>=is && i<=ie && j>=js && j<=je && k>=ks && k<=ke) ){
PLOOPNOB1(pl) MACP1A1(fluxvec,dir,i,j,k,pl)=0.0;
PLOOPNOB2(pl) MACP1A1(fluxvec,dir,i,j,k,pl)=0.0;
}
if(! (i>=B1is && i<=B1ie && j>=B1js && j<=B1je && k>=B1ks && k<=B1ke) ){
pl=B1; MACP1A1(fluxvec,dir,i,j,k,pl)=0.0;
}
if(! (i>=B2is && i<=B2ie && j>=B2js && j<=B2je && k>=B2ks && k<=B2ke) ){
pl=B2; MACP1A1(fluxvec,dir,i,j,k,pl)=0.0;
}
if(! (i>=B3is && i<=B3ie && j>=B3js && j<=B3je && k>=B3ks && k<=B3ke) ){
pl=B3; MACP1A1(fluxvec,dir,i,j,k,pl)=0.0;
}
}// end 3D loop
}// end if doing this dimen
}// end over dimens
}// end parallel region (no need for added barrier since parallel region has impassible barrier)
return(0);
}
// zero-out fluxes in COMPFULLLOOP so advance.c updates all possible quantities and does so with simple non-conditional code
// it's ok to zero-out beyond standard+-1 box a bit. Just ensure zero out enough
int zero_out_fluxes(int *Nvec, FTYPE (*fluxvec[NDIM])[NSTORE2][NSTORE3][NPR])
{
#pragma omp parallel
{
int i,j,k,pl,pliter;
int dir;
OPENMP3DLOOPVARSDEFINE; OPENMP3DLOOPSETUPFULL;
DIMENLOOP(dir){
if(Nvec[dir]>1){
#pragma omp for schedule(OPENMPSCHEDULE(),OPENMPCHUNKSIZE(blocksize)) nowait // can nowait since each fluxvec[dir] is set separately
OPENMP3DLOOPBLOCK{
OPENMP3DLOOPBLOCK2IJK(i,j,k);
////COMPFULLLOOP
PLOOP(pliter,pl) MACP1A1(fluxvec,dir,i,j,k,pl)=0.0;
}// end over 3D loop
}// if dir
}// over dirs
}// end parallel region (no need for added barrier since parallel region has impassible barrier)
return(0);
}
// zero-out fluxes that correspond to EMFs if evolving/tracking A_i since want boundary values to be plottable in SM or whatever
// This is necessary since also use fluxes for other purposes in-between steps
// GODMARK: If in BCs have partial EMF and not full EMF for updating A_i, then may also cause A_i to appear funny
int zero_out_emf_fluxes(int *Nvec, FTYPE (*fluxvec[NDIM])[NSTORE2][NSTORE3][NPR])
{
#pragma omp parallel
{
int i,j,k,pl,pliter;
int dir;
OPENMP3DLOOPVARSDEFINE; OPENMP3DLOOPSETUPFULL;
DIMENLOOP(dir){
if(Nvec[dir]>1){
#pragma omp for schedule(OPENMPSCHEDULE(),OPENMPCHUNKSIZE(blocksize)) nowait // can nowait since each fluxvec[dir] is set separately
OPENMP3DLOOPBLOCK{
OPENMP3DLOOPBLOCK2IJK(i,j,k);
////COMPFULLLOOP
PLOOPBONLY(pl) MACP1A1(fluxvec,dir,i,j,k,pl)=0.0;
}// end over 3D loop
}// if dir
}// over dirs
}// end parallel region (no need for added barrier since parallel region has impassible barrier)
return(0);
}
// fill EM version if necessary when having new CT EMFs
int fluxEM2flux4EMF(int *Nvec, FTYPE (*fluxvec[NDIM])[NSTORE2][NSTORE3][NPR], FTYPE (*fluxvecEM[NDIM])[NSTORE2][NSTORE3][NPR])
{
#pragma omp parallel
{
int i,j,k,pl,pliter;
int dir;
if(splitmaem){
OPENMP3DLOOPVARSDEFINE; OPENMP3DLOOPSETUPFULL;
DIMENLOOP(dir){
if(Nvec[dir]>1){
#pragma omp for schedule(OPENMPSCHEDULE(),OPENMPCHUNKSIZE(blocksize)) nowait // can nowait since each fluxvec[dir] is set separately
OPENMP3DLOOPBLOCK{
OPENMP3DLOOPBLOCK2IJK(i,j,k);
//// COMPFULLLOOP
PLOOPBONLY(pl) MACP1A1(fluxvecEM,dir,i,j,k,pl)=MACP1A1(fluxvec,dir,i,j,k,pl);
}// end over 3D loop
}// if dir
}// over dirs
}// end if splitmaem
}// end parallel region
return(0);
}
// sums MA and EM fluxes
int fluxsum_old(int *Nvec, FTYPE (*fluxvec[NDIM])[NSTORE2][NSTORE3][NPR], FTYPE (*fluxvecEM[NDIM])[NSTORE2][NSTORE3][NPR])
{
#pragma omp parallel
{
int i,j,k,pl,pliter;
int dir;
if(splitmaem){
OPENMP3DLOOPVARSDEFINE; OPENMP3DLOOPSETUPFULL;
DIMENLOOP(dir){
if(Nvec[dir]>1){
#pragma omp for schedule(OPENMPSCHEDULE(),OPENMPCHUNKSIZE(blocksize)) nowait // can nowait since each fluxvec[dir] is set separately
OPENMP3DLOOPBLOCK{
OPENMP3DLOOPBLOCK2IJK(i,j,k);
////COMPFULLLOOP
PLOOP(pliter,pl) MACP1A1(fluxvec,dir,i,j,k,pl)+=MACP1A1(fluxvecEM,dir,i,j,k,pl);
}// end over 3D loop
}// end if dir
}// end over dirs
}// end if splitmaem
}// end parallel region
return(0);
}
// sums MA (with FLUXSPLITMA(dir) containing flux[UU+dir] component) and EM fluxes
int fluxsum(int *Nvec, FTYPE (*fluxvec[NDIM])[NSTORE2][NSTORE3][NPR], FTYPE (*fluxvecEM[NDIM])[NSTORE2][NSTORE3][NPR])
{
#pragma omp parallel
{
int i,j,k,pl,pliter;
int dir;
if(splitmaem){
OPENMP3DLOOPVARSDEFINE; OPENMP3DLOOPSETUPFULL;
DIMENLOOP(dir){
if(Nvec[dir]>1){
#pragma omp for schedule(OPENMPSCHEDULE(),OPENMPCHUNKSIZE(blocksize)) nowait // can nowait since each fluxvec[dir] is set separately
OPENMP3DLOOPBLOCK{
OPENMP3DLOOPBLOCK2IJK(i,j,k);
//// COMPFULLLOOP{
#if(SPLITPRESSURETERMINFLUXMA)
// add diagonal pressure term back to normal FLUX term
MACP1A1(fluxvec,dir,i,j,k,UU+dir)+=MACP1A1(fluxvec,dir,i,j,k,FLUXSPLITPMA(dir));
// reset temporary storage
MACP1A1(fluxvec,dir,i,j,k,FLUXSPLITPMA(dir))=0.0;
#endif
#if(SPLITPRESSURETERMINFLUXEM)
// add diagonal pressure term back to normal FLUX term
MACP1A1(fluxvec,dir,i,j,k,UU+dir)+=MACP1A1(fluxvecEM,dir,i,j,k,FLUXSPLITPEM(dir));
// reset temporary storage
MACP1A1(fluxvecEM,dir,i,j,k,FLUXSPLITPEM(dir))=0.0;
#endif
// now do normal addition
PLOOP(pliter,pl) MACP1A1(fluxvec,dir,i,j,k,pl)+=MACP1A1(fluxvecEM,dir,i,j,k,pl);
}// over 3D LOOP
}// if dir
}// over dirs
}// end if splitmaem
}// end parallel region
return(0);
}
// wrapper for CENT_to_FACE1,2,3 used to compute flux at face
int fluxcalc_flux(int stage, FTYPE (*pr)[NSTORE2][NSTORE3][NPR], FTYPE (*pstag)[NSTORE2][NSTORE3][NPR], FTYPE (*pl_ct)[NSTORE1][NSTORE2][NSTORE3][NPR2INTERP], FTYPE (*pr_ct)[NSTORE1][NSTORE2][NSTORE3][NPR2INTERP], int *Nvec, FTYPE (*dqvec[NDIM])[NSTORE2][NSTORE3][NPR2INTERP], FTYPE (*fluxvec[NDIM])[NSTORE2][NSTORE3][NPR], FTYPE (*fluxvecEM[NDIM])[NSTORE2][NSTORE3][NPR], FTYPE CUf, SFTYPE time, FTYPE *ndtvec[NDIM], struct of_loop *cent2faceloop)
{
int fluxcalc_flux_1d(int stage, FTYPE (*pr)[NSTORE2][NSTORE3][NPR], FTYPE (*pstag)[NSTORE2][NSTORE3][NPR], FTYPE (*pl_ct)[NSTORE1][NSTORE2][NSTORE3][NPR2INTERP], FTYPE (*pr_ct)[NSTORE1][NSTORE2][NSTORE3][NPR2INTERP], int dir, SFTYPE time, int is, int ie, int js, int je, int ks, int ke, int idel, int jdel, int kdel, int face, FTYPE (*dq)[NSTORE2][NSTORE3][NPR2INTERP], FTYPE (*F)[NSTORE2][NSTORE3][NPR], FTYPE (*FEM)[NSTORE2][NSTORE3][NPR], FTYPE CUf, FTYPE *ndt, struct of_loop *cent2faceloop, int *didassigngetstatecentdata );
int dir;
int idel, jdel, kdel, face;
int is, ie, js, je, ks, ke;
int didassigngetstatecentdata;
///////////////////////////////////////////////
//
// LOOP OVER DIMENSIONS interpolating within each dimension separately for that flux -- assumes flux determined by 1-D Riemann problem
//
///////////////////////////////////////////////
didassigngetstatecentdata=0;
// OPENMPOPTMARK: Can actually do each direction independently, so able to parallelize this! (But would required, e.g., an array per dir for (e.g.) pleft/pright,wspeedtemp (global variable used inside for temp space for rescale(). *ndt is done per-dir, so that's ok (it would be fine already since using "critical" that applies to *all* threads not just one team))).
// Note also ok to do each dir separately with FLUXB==FLUXCTSTAG.
// OPENMPOPTMARK: Otherwise, looks doable.
DIMENLOOP(dir){
// set dimension having no influence on dt by default
*(ndtvec[dir])=BIG;
// don't skip dimension if doesn't exist, will be taken care of inside fluxcalc_flux_1d()
// get loop details
idel = fluxloop[dir][FIDEL];
jdel = fluxloop[dir][FJDEL];
kdel = fluxloop[dir][FKDEL];
face = fluxloop[dir][FFACE];
//loop over the interfaces where fluxes are computed -- atch, useCOMPZSLOOP( is, ie, js, je, ks, ke ) { ... }
is=fluxloop[dir][FIS];
ie=fluxloop[dir][FIE];
js=fluxloop[dir][FJS];
je=fluxloop[dir][FJE];
ks=fluxloop[dir][FKS];
ke=fluxloop[dir][FKE];
MYFUN(fluxcalc_flux_1d(stage, pr, pstag, pl_ct, pr_ct, dir, time, is, ie, js, je, ks, ke, idel, jdel, kdel, face, dqvec[dir], fluxvec[dir], fluxvecEM[dir], CUf, ndtvec[dir], ¢2faceloop[dir], &didassigngetstatecentdata),"flux.c:fluxcalc()", "fluxcalc_flux_1d", dir);
#if(PRODUCTION==0)
trifprintf("%d",dir);
#endif
}// end DIMENLOOP(dir)
///////////////////
//
// set per-cell minimum for dt
//
///////////////////
if(PERCELLDT){
FTYPE ndtveclocal[NDIM];
{
int dimen;
// set dimension having no influence on dt by default
DIMENLOOP(dimen){
*(ndtvec[dimen])=BIG;
ndtveclocal[dimen]=BIG;
}
}
// whether dimension is relevant
int doingdimen[NDIM];
doingdimen[1]=N1NOT1;
doingdimen[2]=N2NOT1;
doingdimen[3]=N3NOT1;
int dimenorig=1; // choose one dimension to stick things into
#pragma omp parallel
{
int i,j,k;
FTYPE wavedt;
int dimen;
OPENMP3DLOOPVARSDEFINE; OPENMP3DLOOPSETUP(WITHINACTIVESECTIONEXPAND1IS,WITHINACTIVESECTIONEXPAND1IE,WITHINACTIVESECTIONEXPAND1JS,WITHINACTIVESECTIONEXPAND1JE,WITHINACTIVESECTIONEXPAND1KS,WITHINACTIVESECTIONEXPAND1KE);
#pragma omp for schedule(OPENMPSCHEDULE(),OPENMPCHUNKSIZE(blocksize))
OPENMP3DLOOPBLOCK{
OPENMP3DLOOPBLOCK2IJK(i,j,k);
// get dt for each dimension at each grid point -- but only if dimension is relevant (otherwise stays as BIG and doesn't affect wavedt)
DIMENLOOP(dimen) if(doingdimen[dimen]) ndtveclocal[dimen]=GLOBALMACP0A1(dtijk,i,j,k,dimen);
// set local per-cell dt
// sum of inverses is proper for unsplit scheme based upon split interpolations/fluxes.
wavedt = 1. / (1. / ndtveclocal[1] + 1. / ndtveclocal[2] + 1. / ndtveclocal[3]);
// use dimen=1 to store result
dimen=dimenorig;
#pragma omp critical
{
if (wavedt < *(ndtvec[dimen]) ){
*ndtvec[dimen] = wavedt;
// below are global so can report when other dt's are reported in advance.c
waveglobaldti[dimen]=i;
waveglobaldtj[dimen]=j;
waveglobaldtk[dimen]=k;
}
}// end critical region
}//end over 3dloopblock
}// end over parallel region
// store result in all of ndt1,ndt2,ndt3 so have result no matter how many dimensions working on, and just use correctly later.
{
int dimen;
DIMENLOOP(dimen){
if(doingdimen[dimen]){
*ndtvec[dimen]=*ndtvec[dimenorig];
waveglobaldti[dimen]=waveglobaldti[dimenorig];
waveglobaldtj[dimen]=waveglobaldtj[dimenorig];
waveglobaldtk[dimen]=waveglobaldtk[dimenorig];
}
}
}
}// end over doing PERCELLDT
return(0);
}
// wrapper for different standard 1-D flux calculators
// 1-D interpolate and get flux for that direction (assumes purely 1-D Riemann problem)
int fluxcalc_flux_1d(int stage, FTYPE (*pr)[NSTORE2][NSTORE3][NPR], FTYPE (*pstag)[NSTORE2][NSTORE3][NPR], FTYPE (*pl_ct)[NSTORE1][NSTORE2][NSTORE3][NPR2INTERP], FTYPE (*pr_ct)[NSTORE1][NSTORE2][NSTORE3][NPR2INTERP], int dir, SFTYPE time, int is, int ie, int js, int je, int ks, int ke, int idel, int jdel, int kdel, int face, FTYPE (*dq)[NSTORE2][NSTORE3][NPR2INTERP], FTYPE (*F)[NSTORE2][NSTORE3][NPR], FTYPE (*FEM)[NSTORE2][NSTORE3][NPR], FTYPE CUf, FTYPE *ndt, struct of_loop *cent2faceloop, int *didassigngetstatecentdata )
{
int fluxcalc_standard(int stage, FTYPE (*pr)[NSTORE2][NSTORE3][NPR], FTYPE (*pstag)[NSTORE2][NSTORE3][NPR], FTYPE (*pl_ct)[NSTORE1][NSTORE2][NSTORE3][NPR2INTERP], FTYPE (*pr_ct)[NSTORE1][NSTORE2][NSTORE3][NPR2INTERP], int dir, SFTYPE time, int is, int ie, int js, int je, int ks, int ke, int idel, int jdel, int kdel, int face, FTYPE (*dq)[NSTORE2][NSTORE3][NPR2INTERP], FTYPE (*F)[NSTORE2][NSTORE3][NPR], FTYPE (*FEM)[NSTORE2][NSTORE3][NPR], FTYPE CUf, FTYPE *ndt, struct of_loop *cent2faceloop, int *didassigngetstatecentdata);
int fluxcalc_standard_4fluxctstag(int stage, FTYPE (*pr)[NSTORE2][NSTORE3][NPR], FTYPE (*pstag)[NSTORE2][NSTORE3][NPR], FTYPE (*pl_ct)[NSTORE1][NSTORE2][NSTORE3][NPR2INTERP], FTYPE (*pr_ct)[NSTORE1][NSTORE2][NSTORE3][NPR2INTERP], int dir, SFTYPE time, int is, int ie, int js, int je, int ks, int ke, int idel, int jdel, int kdel, int face, FTYPE (*dq)[NSTORE2][NSTORE3][NPR2INTERP], FTYPE (*F)[NSTORE2][NSTORE3][NPR], FTYPE (*FEM)[NSTORE2][NSTORE3][NPR], FTYPE CUf, FTYPE *ndt, struct of_loop *cent2faceloop, int *didassigngetstatecentdata);
// int fluxcalc_fluxspliteno(int stage, FTYPE (*pr)[NSTORE2][NSTORE3][NPR], int dir, int is, int ie, int js, int je, int ks, int ke, int idel, int jdel, int kdel, int face, FTYPE (*F)[NSTORE2][NSTORE3][NPR], FTYPE (*FEM)[NSTORE2][NSTORE3][NPR], FTYPE *ndt);
int Nvec[NDIM];
int i,j,k,pl,pliter;
int odir1,odir2;
if(DOENOFLUX!=ENOFLUXSPLIT){
if(FLUXB==FLUXCTSTAG){
MYFUN(fluxcalc_standard_4fluxctstag(stage,pr,pstag,pl_ct, pr_ct, dir,time, is, ie, js, je, ks, ke,idel,jdel,kdel,face,dq,F,FEM,CUf,ndt,cent2faceloop,didassigngetstatecentdata),"flux.c:fluxcalc_flux_1d()", "fluxcalc_standard_4fluxctstag()", 1);
}
else{
// use older code that doesn't store into pl_ct and pr_ct since not needed and then waste of memory
MYFUN(fluxcalc_standard(stage,pr,pstag,pl_ct, pr_ct, dir,time,is, ie, js, je, ks, ke,idel,jdel,kdel,face,dq,F,FEM,CUf,ndt,cent2faceloop,didassigngetstatecentdata),"flux.c:fluxcalc_flux_1d()", "fluxcalc_standard()", 1);
}
}
else{
//MYFUN(fluxcalc_fluxspliteno(stage,pr,dir,is, ie, js, je, ks, ke,idel,jdel,kdel,face,dq,F,FEM,CUf,ndt),"flux.c:fluxcalc_flux_1d()", "fluxcalc_fluxspliteno()", 1);
}
////////////////////////////////////
//
// ensure flux of field set correctly to 0 in 1D
//
// if 1D in z and x, then no Ey so no F3[B1]
// if 1D in z and y, then no Ex so no F3[B2]
//
// Stupid: This is automatically done since if no z-dir, then F3 not even used
//
////////////////////////////////////
/*
Nvec[1]=N1;
Nvec[2]=N2;
Nvec[3]=N3;
odir1=dir%3+1;
odir2=(dir+1)%3+1;
if(splitmaem==0){
if(Nvec[dir]==1 && Nvec[odir1]==1) COMPFULLLOOP MACP0A1(F,i,j,k,B1-1+odir1)=0.0;
if(Nvec[dir]==1 && Nvec[odir2]==1) COMPFULLLOOP MACP0A1(F,i,j,k,B1-1+odir2)=0.0;
COMPFULLLOOP MACP0A1(F,i,j,k,B1-1+dir)=0.0; // flux along field is always 0 due to antisymmetry of Faraday/Maxwell
}
else{
// only need to change FEM since above F doesn't contain this EMF in this case
if(Nvec[dir]==1 && Nvec[odir1]==1) COMPFULLLOOP MACP0A1(FEM,i,j,k,B1-1+odir1)=0.0;
if(Nvec[dir]==1 && Nvec[odir2]==1) COMPFULLLOOP MACP0A1(FEM,i,j,k,B1-1+odir2)=0.0;
COMPFULLLOOP MACP0A1(FEM,i,j,k,B1-1+dir)=0.0; // flux along field is always 0 due to antisymmetry of Faraday/Maxwell
// don't reset field part of MA flux since using that for other purposes (diagonal pressure term for now)
}
*/
return(0);
}
void set_normal_realisinterp(int *realisinterp)
{
// real means normal primitive list = {rho,u,v1,v2,v3,B1,B2,B3} with v^i as WHICHVEL velocity
// check:
if(npr2interpstart==0 && npr2interpend==7 &&
npr2interplist[RHO]==RHO &&
npr2interplist[UU]==UU &&
npr2interplist[U1]==U1 &&
npr2interplist[U2]==U2 &&
npr2interplist[U3]==U3 &&
npr2interplist[B1]==B1 &&
npr2interplist[B2]==B2 &&
npr2interplist[B3]==B3
){
// 1 here stands for NPR2INTERP type of loop
// only do if some type of interpolation to be done
*realisinterp=(RESCALEINTERP==0 || VARTOINTERP==PRIMTOINTERP);
}
else{
*realisinterp=0; // must be forced to be zero
}
}
// wrapper for rescale()
void rescale_calc_full(int dir,FTYPE (*pr)[NSTORE2][NSTORE3][NPR],FTYPE (*p2interp)[NSTORE2][NSTORE3][NPR])
{
////COMPFULLLOOP{
#pragma omp parallel OPENMPGLOBALPRIVATEFORSTATEANDGEOMINTERP // generally requires full information
{
int i,j,k;
struct of_geom geomdontuse;
struct of_geom *ptrgeom=&geomdontuse;
OPENMP3DLOOPVARSDEFINE; OPENMP3DLOOPSETUPFULL;
// generally ptr's are different inside parallel block
ptrgeom=&geomdontuse;
#pragma omp for schedule(OPENMPSCHEDULE(),OPENMPCHUNKSIZE(blocksize))
OPENMP3DLOOPBLOCK{
OPENMP3DLOOPBLOCK2IJK(i,j,k);
// get geometry for center pre-interpolated values
get_geometry(i, j, k, CENT, ptrgeom);
// assume no need for a guess to p2interp to get pr (consistent with no unrescale being done after interpolation)
if(npr2interpstart<=npr2interpend) rescale(1,dir,MAC(pr,i,j,k),ptrgeom,MAC(p2interp,i,j,k));
}// end COMPFULLLOOP
}// end parallel region
}
// original flux calculator that gets F in "dir". At end global pleft,pright,dq also set and if STOREWAVESPEEDS>0 then wavespeeds stored globally
int fluxcalc_standard(int stage, FTYPE (*pr)[NSTORE2][NSTORE3][NPR], FTYPE (*pstag)[NSTORE2][NSTORE3][NPR], FTYPE (*pl_ct)[NSTORE1][NSTORE2][NSTORE3][NPR2INTERP], FTYPE (*pr_ct)[NSTORE1][NSTORE2][NSTORE3][NPR2INTERP], int dir, SFTYPE time,int is, int ie, int js, int je, int ks, int ke, int idel, int jdel, int kdel, int face, FTYPE (*dq)[NSTORE2][NSTORE3][NPR2INTERP], FTYPE (*F)[NSTORE2][NSTORE3][NPR], FTYPE (*FEM)[NSTORE2][NSTORE3][NPR], FTYPE CUf, FTYPE *ndt, struct of_loop *cent2faceloop, int *didassigngetstatecentdata)
{
void slope_lim(int dointerpolation, int realisinterp, int dir, int idel, int jdel, int kdel, FTYPE (*primreal)[NSTORE2][NSTORE3][NPR], FTYPE (*p2interp)[NSTORE2][NSTORE3][NPR2INTERP], FTYPE (*dq)[NSTORE2][NSTORE3][NPR2INTERP], FTYPE (*pleft)[NSTORE2][NSTORE3][NPR2INTERP], FTYPE (*pright)[NSTORE2][NSTORE3][NPR2INTERP], struct of_loop *cent2faceloop);
int getplpr(int dir, SFTYPE time, int idel, int jdel, int kdel, int i, int j, int k, struct of_geom *geom, FTYPE (*pr)[NSTORE2][NSTORE3][NPR], FTYPE (*pstag)[NSTORE2][NSTORE3][NPR], FTYPE (*p2interp)[NSTORE2][NSTORE3][NPR2INTERP], FTYPE (*dq)[NSTORE2][NSTORE3][NPR2INTERP], FTYPE (*pleft)[NSTORE2][NSTORE3][NPR2INTERP], FTYPE (*pright)[NSTORE2][NSTORE3][NPR2INTERP], FTYPE *p2interp_l, FTYPE *p2interp_r, FTYPE *p_l, FTYPE *p_r);
FTYPE (*p2interp)[NSTORE2][NSTORE3][NPR2INTERP];
// int odir1,odir2;
int Nvec[NDIM];
int realisinterp;
int dointerpolation;
void do_noninterpolation_dimension(int whichfluxcalc, int dointerpolation, int realisinterp, int dir, int idel, int jdel, int kdel, FTYPE (*pr)[NSTORE2][NSTORE3][NPR], FTYPE (*pl_ct)[NSTORE1][NSTORE2][NSTORE3][NPR2INTERP], FTYPE (*pr_ct)[NSTORE1][NSTORE2][NSTORE3][NPR2INTERP], struct of_loop *cent2faceloop, int *didassigngetstatecentdata);
void compute_and_store_fluxstate(int dimen, int isleftright, int i, int j, int k, struct of_geom *geom, FTYPE *pr);
///////////////////////////////////////////////
//
// setup 1D reduction of EMF,flux calculation
// here dir is face dir
// odir1=dir%3+1;
// odir2=(dir+1)%3+1;
Nvec[1]=N1;
Nvec[2]=N2;
Nvec[3]=N3;
set_normal_realisinterp(&realisinterp);
////////////////////////////////////////////
//
// skip to next dir if no such dimension
//
/////////////////////////////////////////////
// if nothing to interpolate, then quit
if(npr2interpstart<=npr2interpend && Nvec[dir]>1){
dointerpolation=1;
}
else{
// just get loops and copy over to gp_?
dointerpolation=0;
//do limited number of things when not interpolating that dimension
do_noninterpolation_dimension(ORIGINALFLUXCALC, dointerpolation, realisinterp, dir, idel, jdel, kdel, pr, pl_ct, pr_ct, cent2faceloop, didassigngetstatecentdata);
// skip real interpolation since no variation in that direction
return(0);
}
/////////////////////////////
//
// setup wavedt
//
/////////////////////////////
waveglobaldti[dir]=-100;
waveglobaldtj[dir]=-100;
waveglobaldtk[dir]=-100;
//////////////////////////
//
// rescale before interpolation
//
////////////////////////////
#if(RESCALEINTERP)
if(npr2interpstart<=npr2interpend){
// assume if DOEXTRAINTERP==1, then must get here
p2interp=GLOBALPOINT(prc); // it's different
}
rescale_calc_full(dir,pr,p2interp);
#else
p2interp=pr; // it's itself
#endif
// STOREWAVESPEEDS==0 : use very local estimate at fluxes FACE?
// STOREWAVESPEEDS==1 : use original pre-computed (just below) wavespeed at CENT that is "max-averaged" to FACE?
// STOREWAVESPEEDS==2 : use very local estimate at fluxes FACE?, but compute and store during loop