21 int init(
int *argc,
char **argv[])
24 extern int pre_init(
int *argc,
char **argv[]);
30 extern void filterffde(
int i,
int j,
int k,
FTYPE *
pr);
31 extern void filter_coldgrmhd(
int i,
int j,
int k,
FTYPE *pr);
40 int faketimeorder,fakenumtimeorders;
46 stderrfprintf(
"Start init\n"); fflush(stderr);
101 init_placeongrid_griddecomposition();
121 trifprintf(
"start restart_init: proc=%04d\n",myid);
123 dualfprintf(
fail_file,
"main:restart_init: failure\n");
126 trifprintf(
"end restart_init: proc=%04d\n",myid);
175 #define NUMSELFGRAVITER 3 // MINIMUM of 2 iterations should be done for metric to computed once
179 #define NUMSELFGRAVITER 1 // NO CHOICE
190 trifprintf(
"begin iteration over metric: selfgraviter=%d\n",selfgraviter);
195 trifprintf(
"new metric with self-gravity: selfgraviter=%d\n",selfgraviter);
197 compute_new_metric_and_prims(0,
MBH,
a,
QBH,
EP3,
THETAROT,
GLOBALPOINT(pglobal),
GLOBALPOINT(pstagglobal),
GLOBALPOINT(unewglobal),
GLOBALPOINT(vpotarrayglobal),
GLOBALPOINT(Bhatglobal),
GLOBALPOINT(gp_l),
GLOBALPOINT(gp_r),
GLOBALPOINT(F1),
GLOBALPOINT(F2),
GLOBALPOINT(F3),
GLOBALPOINT(emf),
GLOBALPOINT(ulastglobal));
198 trifprintf(
"done with computing new metric with self-gravity dt=%21.15g selfgraviter=%d\n",
dt,selfgraviter);
208 MYFUN(
init_primitives(
GLOBALPOINT(pglobal),
GLOBALPOINT(pstagglobal),
GLOBALPOINT(unewglobal),
GLOBALPOINT(vpotarrayglobal),
GLOBALPOINT(Bhatglobal),
GLOBALPOINT(panalytic),
GLOBALPOINT(pstaganalytic),
GLOBALPOINT(vpotanalytic),
GLOBALPOINT(Bhatanalytic),
GLOBALPOINT(F1),
GLOBALPOINT(F2),
GLOBALPOINT(F3),
GLOBALPOINT(emf)),
"initbase.c:init()",
"init_primitives()", 0);
239 trifprintf(
"System filtered to FFDE\n");
242 filterffde(i,j,k,
GLOBALMAC(pglobal,i,j,k));
247 trifprintf(
"System filtered to cold GRMHD\n");
250 filter_coldgrmhd(i,j,k,
GLOBALMAC(pglobal,i,j,k));
262 trifprintf(
"System Fixup and Bound\n");
300 if (dump(9000) >= 1){
301 dualfprintf(
fail_file,
"unable to print dump file\n");
305 else if(selfgraviter==2){
307 if (dump(9001) >= 1){
308 dualfprintf(
fail_file,
"unable to print dump file\n");
312 else if(selfgraviter==3){
314 if (dump(9002) >= 1){
315 dualfprintf(
fail_file,
"unable to print dump file\n");
340 if (dump(9100) >= 1){
341 dualfprintf(
fail_file,
"unable to print dump file\n");
345 else if(selfgraviter==2){
347 if (dump(9101) >= 1){
348 dualfprintf(
fail_file,
"unable to print dump file\n");
352 else if(selfgraviter==3){
354 if (dump(9102) >= 1){
355 dualfprintf(
fail_file,
"unable to print dump file\n");
363 trifprintf(
"end iteration over metric: selfgraviter=%d\n",selfgraviter);
381 restart_init_simple_checks(2);
385 trifprintf(
"before pre_fixup() during restart: proc=%04d\n",myid);
387 trifprintf(
"after pre_fixup() during restart: proc=%04d\n",myid);
390 trifprintf(
"before fixup() during restart: proc=%04d\n",myid);
392 trifprintf(
"after fixup() during restart: proc=%04d\n",myid);
407 trifprintf(
"before bound_prim() during restart: proc=%04d\n",myid);
415 trifprintf(
"after bound_prim() during restart: proc=%04d\n",myid);
418 restart_init_simple_checks(3);
435 trifprintf(
"before ucons2upointppoint during restart: proc=%04d\n",myid);
437 trifprintf(
"after ucons2upointppoint during restart: proc=%04d\n",myid);
452 bound_vpot(
STAGEM1, finalstep,
t, boundvartype,
GLOBALPOINT(vpotarrayglobal),doboundmpi,doboundnonmpi);
457 restart_init_simple_checks(4);
461 trifprintf(
"before post_init and post_init_specific_init during restart: proc=%04d\n",myid);
465 trifprintf(
"after post_init and post_init_specific_init during restart: proc=%04d\n",myid);
469 restart_init_simple_checks(5);
474 trifprintf(
"new metric with self-gravity\n");
475 compute_new_metric_and_prims(0,
MBH,
a,
QBH,
EP3,
THETAROT,
GLOBALPOINT(pglobal),
GLOBALPOINT(pstagglobal),
GLOBALPOINT(unewglobal),
GLOBALPOINT(vpotarrayglobal),
GLOBALPOINT(Bhatglobal),
GLOBALPOINT(gp_l),
GLOBALPOINT(gp_r),
GLOBALPOINT(F1),
GLOBALPOINT(F2),
GLOBALPOINT(F3),
GLOBALPOINT(emf),
GLOBALPOINT(ulastglobal));
476 trifprintf(
"done with computing new metric with self-gravity dt=%21.15g\n",
dt);
480 trifprintf(
"before restart_init_checks() during restart: proc=%04d\n",myid);
482 dualfprintf(
fail_file,
"main:restart_init_checks: failure\n");
485 trifprintf(
"after restart_init_checks() during restart: proc=%04d\n",myid);
488 trifprintf(
"proc: %d restart completed: failed=%d\n", myid,
failed);
534 recompute_fluxpositions(3,faketimeorder,fakenumtimeorders,
nstep,
t);
541 trifprintf(
"dt=%21.15g at t=%21.15g at nstep=%ld at realnstep=%ld\n",
dt,
t,
nstep,
realnstep);
556 restart_init_simple_checks(6);
563 trifprintf(
"end init.c\n");
584 if(restartmode==1) trifprintf(
"proc: %d post_par_set completed: failed=%d\n", myid,
failed);
590 if(restartmode==1) trifprintf(
"proc: %d grid restart completed: failed=%d\n", myid,
failed);
595 if(restartmode==1) trifprintf(
"proc: %d set_box_grid_parameters completed: failed=%d\n", myid,
failed);
598 init_grid_post_set_grid(
GLOBALPOINT(pglobal),
GLOBALPOINT(pstagglobal),
GLOBALPOINT(unewglobal),
GLOBALPOINT(vpotarrayglobal),
GLOBALPOINT(Bhatglobal),
GLOBALPOINT(panalytic),
GLOBALPOINT(pstaganalytic),
GLOBALPOINT(vpotanalytic),
GLOBALPOINT(Bhatanalytic),
GLOBALPOINT(F1),
GLOBALPOINT(F2),
GLOBALPOINT(F3),
GLOBALPOINT(emf));
600 if(restartmode==1) trifprintf(
"proc: %d init_grid_post_set_grid completed: failed=%d\n", myid,
failed);
603 trifprintf(
"MCOORD=%d\n",
MCOORD);
604 trifprintf(
"COMPDIM=%d\n",
COMPDIM);
605 trifprintf(
"MAXBND=%d\n",
MAXBND);
606 trifprintf(
"FLUXB=%d\n",
FLUXB);
616 #if(ANALYTICMEMORY==0)
617 dualfprintf(
fail_file,
"Shouldn't be setting analytic with ANALYTICMEMORY==0\n");
631 #pragma omp for schedule(OPENMPSCHEDULE(),OPENMPCHUNKSIZE(blocksize)) nowait // next vpot assignment does not depend upon this loop completing
649 #pragma omp for schedule(OPENMPSCHEDULE(),OPENMPCHUNKSIZE(blocksize)) nowait // next vpot assignment is independent
681 #include "initbase.defaultnprlists.c"
701 set_defaults_performance_checks_prepreinit();
705 set_file_versionnumbers();
714 set_default_nprlists();
803 void set_defaults_performance_checks_prepreinit(
void)
834 void set_defaults_performance_checks_preinit(
void)
914 void set_file_versionnumbers(
void)
970 void setup_nprlocalist(
int whichprimtype,
int *nprlocalstart,
int *nprlocalend,
int *nprlocallist,
int *numprims)
979 *numprims=NPR2INTERP;
998 int dir,pl,pliter,sc,fl,floor,enerregion;
1003 extern void set_arrays(
void);
1005 int faketimeorder,fakenumtimeorders;
1011 init_MPI_GRMHD(argc, argv);
1014 set_defaults_performance_checks_preinit();
1026 report_systeminfo(stderr);
1060 fakenumtimeorders=-1;
1061 recompute_fluxpositions(1,faketimeorder,fakenumtimeorders,
nstep,
t);
1116 PALLLOOP(pl) GLOBALMACP0A1(failfloordu,i,j,k,pl)=0.0;
1120 #if(CALCFARADAYANDCURRENTS)
1122 for(pl=0;pl<
NDIM;pl++)
FULLLOOP GLOBALMACP0A1(jcon,i,j,k,pl)=0.0;
1188 restartsteps[0] = 0;
1189 restartsteps[1] = 0;
1399 trifprintf(
"Using %s 3D polar boundary conditions\n", (
special3dspc)?(
"full"):(
"limited") );
1415 rsun=695500.0*1E3*1E2;
1423 amu=1.660538782E-24;
1459 arad=8.*pow(M_PI,5.0)*pow(
kb,4.0)/(15*C*C*C*
H*
H*
H);
1528 trifprintf(
"begin: post_init\n");
1539 dualfprintf(
fail_file,
"inconsistent periodic settings\n");
1552 if (error_check(3)) {
1553 dualfprintf(
fail_file,
"error_check detected failure at main:1\n");
1554 dualfprintf(
fail_file,
"Bad initial conditions\n");
1564 setfailresponse(restartonfail);
1570 compute_currents_t0(prim,faraday);
1575 trifprintf(
"end: post_init\n");
1586 int faketimeorder,fakenumtimeorders;
1591 trifprintf(
"Rhor=%21.15g Risco=%21.15g MBH=%21.15g a=%21.15g QBH=%21.15g EP3=%21.15g THETAROT=%21.15g\n",
Rhor,
Risco,
MBH,
a,
QBH,
EP3,
THETAROT);
1601 fakenumtimeorders=-1;
1602 recompute_fluxpositions(2,faketimeorder,fakenumtimeorders,
nstep,
t);
1614 #if(CALCFARADAYANDCURRENTS)
1624 current_calc(faraday);
1629 if(WHICHCURRENTCALC==1){
1651 int i,
j,k,pliter,pl;
1662 if(! (pl==
B1 || pl==
B2 || pl==
B3) ){
1663 GLOBALMACP0A1(udump,i,j,k,pl)=0.0;
1671 PLOOP(pliter,pl) GLOBALMACP0A1(udump,i,j,k,pl)=0.0;
1675 #if(CALCFARADAYANDCURRENTS)
1676 DLOOPA(jj) GLOBALMACP0A1(jcon,i,j,k,jj)=0.0;
1677 for(pl=0;pl<
NUMFARADAY;pl++) GLOBALMACP0A1(fcon,i,j,k,pl)=0.0;
1694 int interp_loop_set(
void);
1695 int orders_set(
void);
1696 void check_bnd_num(
void);
1739 trifprintf(
"Setting orders\n");
1742 trifprintf(
"Boundary number checks\n");
1745 trifprintf(
"Setting interp loop\n");
1748 trifprintf(
"Reporting bound loop\n");
1749 report_bound_loop();
1760 void check_bnd_num(
void)
1763 int get_num_bnd_zones_used(
int dir);
1766 int doingdimen[
NDIM];
1784 if(!doingdimen[dimen]){
1790 totalo=get_num_bnd_zones_used(dimen);
1794 if(totalo==bndnum[dimen] || !doingdimen[dimen]){
1797 else if(totalo>bndnum[dimen]){
1798 dualfprintf(
fail_file,
"Not enough: dimen=%d totalo=%d MAXBND=%d bndnum=%d for avgscheme interporder[%d]=%d or lim interporder[%d]=%d extrazones4emf=%d\n",dimen,totalo,
MAXBND,bndnum[dimen],
avgscheme[dimen],
interporder[
avgscheme[dimen]],
lim[dimen],
interporder[
lim[dimen]],
extrazones4emf);
1804 dualfprintf(
fail_file,
"WARNING: MAXBND excessive\n");
1805 dualfprintf(
fail_file,
"WARNING: dimen=%d totalo=%d MAXBND=%d and bndnum=%d for avgscheme interporder[%d]=%d or lim interporder[%d]=%d extrazones4emf=%d\n",dimen,totalo,
MAXBND,bndnum[dimen],
avgscheme[dimen],
interporder[
avgscheme[dimen]],
lim[dimen],
interporder[
lim[dimen]],
extrazones4emf);
1818 trifprintf("Changed do_{conserved/
source/transverse_flux}_integration to 0 since
avgscheme[1]=%d avgscheme[2]=%d avgscheme[3]=%d\n
",avgscheme[1],avgscheme[2],avgscheme[3]);
1823 // checks on parameters so user doesn't do something stupid
1824 if(FULLOUTPUT&&USEMPI&&(numprocs>1 || mpicombine==1)){
1826 myexit(ERRORCODEBELOWCLEANFINISH+200);
1829 if(DOEVOLVEMETRIC&& (ANALYTICCONNECTION||ANALYTICSOURCE)){
1830 dualfprintf(fail_file,"Unlikely you have metric in time analytically\n
");
1831 myexit(ERRORCODEBELOWCLEANFINISH+201);
1835 if(DOSELFGRAVVSR && (ANALYTICCONNECTION||ANALYTICSOURCE||ANALYTICGCON)){
1836 dualfprintf(fail_file,"Unlikely you have metric analytically with
self gravity\n
");
1837 myexit(ERRORCODEBELOWCLEANFINISH+202);
1841 if(ISSPCMCOORDNATIVE(MCOORD)){
1845 dualfprintf(fail_file,"GDETVOLDIFF==1 not setup
for non-SPC metrics\n
");
1846 myexit(ERRORCODEBELOWCLEANFINISH+203);
1850 if(DOSELFGRAVVSR==0 && (MCOORD==KS_BH_TOV_COORDS || MCOORD==KS_TOV_COORDS || MCOORD==BL_TOV_COORDS) ){
1851 dualfprintf(fail_file,"DOSELFGRAVVSR==0 with
MCOORD=%d is not likely what you want\n
",MCOORD);
1852 dualfprintf(fail_file,"Continuing....\n
");
1858 if(HIGHERORDERMEM==0 && DOENOFLUX != NOENOFLUX){
1859 dualfprintf(fail_file,"Need to turn on HIGHERORDERMEM when doing higher order methods (i.e.
DOENOFLUX(=%d)!=
NOENOFLUX)\n
",DOENOFLUX);
1860 myexit(ERRORCODEBELOWCLEANFINISH+204);
1864 dualfprintf(fail_file,"Code not setup
for anything but
COMPDIM==3\n
");
1865 myexit(ERRORCODEBELOWCLEANFINISH+205);
1869 if(FIELDSTAGMEM==0 && FLUXB==FLUXCTSTAG){
1870 dualfprintf(fail_file,"FIELDSTAGMEM should be 1
if FLUXB==FLUXCTSTAG\n
");
1871 myexit(ERRORCODEBELOWCLEANFINISH+206);
1874 if(FIELDSTAGMEM==1 && FLUXB!=FLUXCTSTAG){
1875 dualfprintf(fail_file,"WARNING: FIELDSTAGMEM==1 will be slower with non-stag method\n
");
1878 if(FIELDTOTHMEM==0 && FLUXB==FLUXCTTOTH){
1879 dualfprintf(fail_file,"FIELDTOTHMEM should be 1
if FLUXB==FLUXCTTOTH\n
");
1880 myexit(ERRORCODEBELOWCLEANFINISH+207);
1884 if(ISSPCMCOORDNATIVE(MCOORD)){
1885 // if( (N1%2>0 && N1>1) || (N2%2>0 && N2>1) || (N3%2>0 && N3>1) ){
1886 if( (N2%2>0 && N2>1) || (N3%2>0 && N3>1) ){
1887 dualfprintf(fail_file,"N1,
N2,
N3 should be even since some parts of code assume so
for SPC.\n
");
1888 myexit(ERRORCODEBELOWCLEANFINISH+208);
1892 // if(N1%2 && N1>1 || N2%2 && N2>1 || N3%2 && N3>1){
1893 // if(N2%2 && N2>1 || N3%2 && N3>1){
1894 // dualfprintf(fail_file,"Need even
N1,
N2,
N3 AFAIK N1=%d N2=%d
N3=%d\n
",N1,N2,N3);
1895 // myexit(ERRORCODEBELOWCLEANFINISH+19846286);
1900 if(SUPERLONGDOUBLE){
1901 dualfprintf(fail_file,"If doing
SUPERLONGDOUBLE, then should have compiled as such\n
");
1904 if(ROEAVERAGEDWAVESPEED || ATHENAROE){
1905 dualfprintf(fail_file,"ATHENA stuff only
for non-rel setup and
while was tested hasn
't been used or kept up to date\n");
1906 myexit(ERRORCODEBELOWCLEANFINISH+209);
1909 if(STOREWAVESPEEDS==0 && FLUXB==FLUXCTSTAG){
1910 dualfprintf(fail_file,"Must set STOREWAVESPEEDS==1 when doing FLUXCTSTAG\n");
1911 myexit(ERRORCODEBELOWCLEANFINISH+210);
1914 if(LIMADJUST!=LIMITERFIXED){
1915 dualfprintf(fail_file,"LIMADJUST old code\n");
1916 myexit(ERRORCODEBELOWCLEANFINISH+211);
1920 if(FLUXADJUST!=FLUXFIXED){
1921 dualfprintf(fail_file,"FLUXADJUST old code\n");
1922 myexit(ERRORCODEBELOWCLEANFINISH+212);
1925 if(DOEVOLVEMETRIC&& (WHICHEOM!=WITHGDET )){
1926 dualfprintf(fail_file,"conn2 not computed for time-dependent metric yet\n");
1927 myexit(ERRORCODEBELOWCLEANFINISH+213);
1930 if(CONNMACHINEBODY){
1932 if(WHICHEOM!=WITHGDET){
1933 dualfprintf(fail_file,"Not setup for body correction when f is not detg\n");
1934 myexit(ERRORCODEBELOWCLEANFINISH+215);
1938 if(CONNMACHINEBODY&&(DOENOFLUX!=NOENOFLUX || MERGEDC2EA2CMETHOD)){
1939 dualfprintf(fail_file,"WARNING: MACHINEBODY with higher order scheme makes no sense\n");
1944 if(CONTACTINDICATOR!=0){
1945 dualfprintf(fail_file,"Contact not recommended\n");
1949 dualfprintf(fail_file,"FLUXDUMP ACTIVE -- lots of extra output\n");
1953 dualfprintf(fail_file,"NUMPOTHER ACTIVE -- lots of extra memory used\n");
1956 if(LIMIT_FLUXC2A_PRIM_CHANGE){
1957 dualfprintf(fail_file,"LIMIT_FLUXC2A_PRIM_CHANGE doesn't work according to Sasha, so don
't use\n");
1958 myexit(ERRORCODEBELOWCLEANFINISH+216);
1964 doingenough *= (interporder[avgscheme[dimen]]>=interporder[WENO5BNDPLUSMIN] || doingdimen[dimen]==0);
1967 if(WENO_EXTRA_A2C_MINIMIZATION==1 && doingenough==0){
1968 dualfprintf(fail_file,"WENO_EXTRA_A2C_MINIMIZATION==1 and interporder=%d %d %d invalid\n",interporder[avgscheme[1]],interporder[avgscheme[2]],interporder[avgscheme[3]]);
1969 myexit(ERRORCODEBELOWCLEANFINISH+217);
1975 if(avgscheme[dimen]!=DONOR){ // using DONOR just turns off and assume standard way to turn off so no need to message user
1976 if(avgscheme[dimen]<FIRSTWENO || avgscheme[dimen]>LASTWENO){
1977 dualfprintf(fail_file,"Choice of avgscheme[%d]=%d has no effect\n",dimen,avgscheme[dimen]);
1983 // if( (FLUXB==FLUXCTHLL || FLUXB==FLUXCTTOTH || (FLUXB==FLUXCTSTAG && extrazones4emf==1 && )) && EVOLVEWITHVPOT){ // avoid complicated conditional
1984 if(EVOLVEWITHVPOT && !(FLUXB==FLUXCTSTAG && extrazones4emf==0) ){
1985 // Even with FV or FLUXRECON method that relies on updating non-point fields, can't evolve with A_i since truncation error different rather than just machine error different. This leads to large errors -- especially at boundaries? GODMARK -- not 100% sure
this is the problem
for test=1102 and
EVOLVEWITHVPOT
1986 dualfprintf(
fail_file,
"Cannot evolve field using A_i for FLUXB==FLUXCTHLL or FLUXB==FLUXCTHLL since no single A_i evolved forward in time. And cannot use with non-point field method since while single A_i updated, the update diverges at truncation error between updating A_i and updating the non-point-field -- this is especially bad for periodic boundary conditions where one must have machine error correct behavior at boundaries\n");
1992 dualfprintf(
fail_file,
"To use SPLITPRESSURE must turn on splitmaem, which requires FLUXRECON\n");
1997 dualfprintf(
fail_file,
"Noticed some tests are more accurate if don't split (splitmaem==0), like test=1102 in init.sasha.c when doing non-point field FLUXRECON method the density error is smaller by factor of 2 with splitmaem==0\n");
2006 dualfprintf(
fail_file,
"Warning: if polar axis or r=0 singularity don't have \\detg=0 you should force it -- normally ACCURATESINCOS==1 does a good job of this, but still should have code to check\n");
2014 dualfprintf(
fail_file,
"lumvsr requires no boundary zones outputted so dump and lumvsr file can be used together\n");
2018 dualfprintf(
fail_file,
"dissvsr requires no boundary zones outputted so dump and dissvsr file can be used together\n");
2026 if(2*N1<N1BND || N1BND!=0 && N1==1 || periodicx1==1 && ncpux1>1 &&
N1<
N1BND){
2027 dualfprintf(
fail_file,
"Code not setup to handle boundary cells N1BND=%d with only N1=%d\n",
N1BND,
N1);
2030 if(2*N2<N2BND || N2BND!=0 && N2==1 || periodicx2==1 && ncpux2>1 &&
N2<
N2BND){
2031 dualfprintf(
fail_file,
"Code not setup to handle boundary cells N2BND=%d with only N2=%d\n",
N2BND,
N2);
2034 if(2*N3<N3BND || N3BND!=0 && N3==1 || periodicx3==1 && ncpux3>1 &&
N3<
N3BND){
2035 dualfprintf(
fail_file,
"Code not setup to handle boundary cells N3BND=%d with only N3=%d\n",
N3BND,
N3);
2042 dualfprintf(
fail_file,
"WARNING: With SENSITIVE!=LONGDOUBLETYPE you may have problems for some integral or counting quantities (e.g. DTd too small or many zones to integrate over)\n");
2047 #if(MERGEDC2EA2CMETHOD==1)
2054 #if(MERGEDC2EA2CMETHOD==1 && STOREFLUXSTATE==0)
2055 dualfprintf(
fail_file,
"Must store flux state (STOREFLUXSTATE 1) if doing merged method\n");
2059 #if(STOREFLUXSTATE==0 && STORESHOCKINDICATOR==1)
2060 dualfprintf(
fail_file,
"Must store flux state (STOREFLUXSTATE 1) if storing shock indicator\n");
2068 dualfprintf(
fail_file,
"NOTE: With PRODUCTION>0, higher-order staggered field method won't compute ener file value of divB correctly because turned off diagnostic bounding to avoid excessive MPI calls to bound unew. dump file will still be correct for MPI boundaries but not for real boundaries since unew not defined to be bounded by user\n");
2074 dualfprintf(
fail_file,
"WARNING: PRODUCTION set to 0, code may be slower\n");
2078 dualfprintf(
fail_file,
"WARNING: LIMITDTWITHSOURCETERM set to 1, code may be slower\n");
2087 dualfprintf(
fail_file,
"WARNING: DODISS/DOLUMVSR/DODISSVSR/DOENTROPY!=DONOENTROPY set to 1, code may be slower\n");
2091 dualfprintf(
fail_file,
"WARNING: CHECKONINVERSION set to 1, code may be slower\n");
2096 dualfprintf(
fail_file,
"WARNING: CHECKSOLUTION set to 1, code may be slower\n");
2102 dualfprintf(
fail_file,
"WARNING: interporder[dimen=%d lim=%d]=%d -1 > TIMEORDER=%d is unstable in region where Courant condition setting dt\n",dimen,
lim[dimen],
interporder[
lim[dimen]],
TIMEORDER);
2107 dualfprintf(
fail_file,
"WARNING: DOINGLIAISON==1 but USEMPI==0\n");
2125 dualfprintf(
fail_file,
"Cannot do merged method with older weno-type c2a/a2c methods\n");
2137 dualfprintf(
fail_file,
"Must have even N3 (N3=%d) if special3dspc==1 && ncpux3=1\n",
N3);
2143 dualfprintf(
fail_file,
"WARNING: FV method does not allow accurate tracking of dissipation as code is currently written. Overestimates compared to actual dissipation.\n");
2148 dualfprintf(
fail_file,
"IF3DSPCTHENMPITRANSFERATPOLE==1 with N3>1 requires COORDSINGFIX>0 and SINGSMALL>0.0 in order for B2 to be evolved properly at the pole\n");
2153 dualfprintf(
fail_file,
"WARNING: No need to have COORDSINGFIX==1 with non-staggered field\n");
2157 dualfprintf(
fail_file,
"WARNING: No need to have COORDSINGFIX==1 with 2D\n");
2161 dualfprintf(
fail_file,
"Must have N?>1 if ncpux?>1 for code to recognize that dimension\n");
2168 dualfprintf(
fail_file,
"Need to turn on WENOMEMORY when lim or avgscheme = eno or weno\n");
2175 dualfprintf(
fail_file,
"WARNING: MYFUN function tracing for failures turned off because not allowed inside OpenMP constructs\n");
2182 dualfprintf(
fail_file,
"WARNING: If not using Kaz EOS, then setting ALLOWKAZEOS==1 will introduce more OpenMP overhead\n");
2186 dualfprintf(
fail_file,
"WARNING: Using only 1 OpenMP thread: Excessive overhead due to pragma's: Recommend turning off USEOPENMP in makehead.inc.\n");
2190 dualfprintf(
fail_file,
"******SUPERWARNING******: If reveal region with Toth method, then divb can't be preserved due to how fluxes are averaged.\n");
2194 dualfprintf(
fail_file,
"******SUPERWARNING******: divb won't be zero for absorbed regions when using AVOIDADVANCESHIFTX???==1 as required since need those regions to inject solution with arbitrary velocity profile.\n");
2198 dualfprintf(
fail_file,
"******SUPERWARNING******: If far from black hole, even with apparently g^{t\\phi}\\sim 0 at the 10^{-34} level, still leads to exponential spurious growth in u^3 u_3 and B^3 to catastrophic levels!! For KS metric with a\\neq 0, best to use analytical gcon that leads to exactly g^{t\\phi}=0 and so \\beta[\\phi]=0.\n");
2202 dualfprintf(
fail_file,
"WARNING: Using inaccurate CONNDERTYPE can lead to problems, such as force errors near poles can lead to secular errors growing.\n");
2205 dualfprintf(
fail_file,
"WARNING: Using DIFFNUMREC can be very slow, but more accurate than DIFFGAMMIE.\n");
2209 dualfprintf(
fail_file,
"WARNING: WHICHEOM==WITHGDET is inferior to WHICHEOM==WITHNOGDET and setting NOGDETU1=NOGDETU2=1 near the poles where force balance is difficult to ensure. If pressure constant, then NOGDET method ensures force balance between flux and source terms.\n");
2213 dualfprintf(
fail_file,
"WARNING: STOREWAVESPEEDS==1 has been found to be unstable due to how Riemann solver uses max-averaged wavespeeds. You should use STOREWAVESPEEDS==2 or 0 .\n");
2218 dualfprintf(
fail_file,
"ERROR: Must have DOENTROPY enabled to use EOMENTROPYGRMHD\n");
2223 dualfprintf(
fail_file,
"ERROR: Must have DOENTROPY enabled to use HOT2ENTROPY\n");
2229 dualfprintf(
fail_file,
"SUPERWARNING: Old 5D method often fails to find solution where solution to inversion does exist. This can readily lead to completely wrong solutions due to failure fixups.\n");
2235 dualfprintf(
fail_file,
"For COLD GRMHD, turn off Kaz EOS\n");
2240 dualfprintf(
fail_file,
"For COLD GRMHD with fake entropy tracking, ensure WHICHEOS==COLDEOS\n");
2246 dualfprintf(
fail_file,
"Must turn on TRACKVPOT if EVOLVEWITHVPOT==1\n");
2252 dualfprintf(
fail_file,
"Generally must set CONNAXISYMM==0 and DOMIXTHETAPHI==1 if ALLOWMETRICROT==1 -- only special cases would override this.\n");
2258 dualfprintf(
fail_file,
"You seem to have not turned on radiation, causing URAD0<0 and so not part of a normal evolved quantity\n");
2264 dualfprintf(
fail_file,
"With radiation, need to use shock flattener with para and TIMEORDER=3 to avoid unphysical oscillations that lead to bad evolution and no radiation inversion.\n");
2272 dualfprintf(
fail_file,
"Cannot use text output with ROMIO\n");
2287 int get_num_bnd_zones_used(
int dimen)
2292 int doingdimen[
NDIM];
2304 if(doingdimen[dimen]){
2313 if(doingdimen[dimen]){
2324 if(doingdimen[dimen]){
2329 totalo=avgo+interpo+extraavgo;
2345 int interp_loop_set(
void)
2348 int doingdimen[
NDIM];
2353 int odimen1,odimen2;
2368 if(doingdimen[dimen]){
2373 trifprintf(
"dimen=%d lim=%d avgo=%d\n",dimen,
lim[dimen],avgo[dimen]);
2413 fluxloop[dimen][
FIDEL]=0;
2415 fluxloop[dimen][
FKDEL]=0;
2425 fluxloop[dimen][
FIDEL]=0;
2426 fluxloop[dimen][
FJDEL]=0;
2507 avgoperdir[dir][dimen]=avgo[dir]*(dimen==dir);
2514 odimen2=(dimen+1)%3+1;
2710 int get_loop(
int pointorlinetype,
int interporflux,
int dir,
struct of_loop *loop)
2713 set_interpalltypes_loop_ranges(pointorlinetype, interporflux, dir,
CENT, 0, &(loop->
intdir), &(loop->
is), &(loop->
ie), &(loop->
js), &(loop->
je), &(loop->
ks), &(loop->
ke), &(loop->
di), &(loop->
dj), &(loop->
dk), &(loop->
bs), &(loop->
ps), &(loop->
pe), &(loop->
be));
2723 int set_interpalltypes_loop_ranges(
int pointorlinetype,
int interporflux,
int dir,
int loc,
int continuous,
int *intdir,
int *is,
int *ie,
int *js,
int *je,
int *ks,
int *ke,
int *di,
int *dj,
int *dk,
int *bs,
int *ps,
int *pe,
int *be)
2728 set_interppoint_loop_ranges(interporflux, dir, loc, continuous, is, ie, js, je, ks, ke, di, dj, dk);
2739 set_interp_loop_gen(withshifts, interporflux, dir, loc, continuous, intdir, is, ie, js, je, ks, ke, di, dj, dk, bs, ps, pe, be);
2745 else if(*intdir==2){
2749 else if(*intdir==3){
2755 dualfprintf(
fail_file,
"No such pointorlinetype=%d\n",pointorlinetype);
2779 #pragma omp parallel
2782 struct of_geom *ptrgeom,*ptrgeomf;
2792 #pragma omp for schedule(OPENMPSCHEDULE(),OPENMPCHUNKSIZE(blocksize))
2802 MYFUN(
get_state(
MAC(prim,i,j,k), ptrgeom, &q),
"initbasec:pi2Uavg()",
"get_state()", 1);
2803 MYFUN(
primtoU(
UEVOLVE,
MAC(prim,i,j,k), &q, ptrgeom, Utemp, NULL),
"initbase.c:pi2Uavg()",
"primtoU()", 1);
2811 MACP0A1(Upoint,i,j,k,pl)=
MACP0A1(pstag,i,j,k,pl)*(ptrgeomf->gdet);
2829 initial_averageu_fv(fieldfrompotential, prim, Upoint, Uavg);
2832 initial_averageu_fluxrecon(fieldfrompotential, prim, Upoint, Uavg);
2839 #pragma omp parallel
2848 #pragma omp for schedule(OPENMPSCHEDULE(),OPENMPCHUNKSIZE(blocksize))
2870 #if( USINGMPIAVOIDMKDIR )
2877 if(USEMPI && (!MPIAVOIDFORK) || USEMPI==0){
2878 system(
"mkdir dumps");
2879 system(
"mkdir images");
2886 mkdir(
"dumps",0700);
2887 mkdir(
"images",0700);
2889 stderrfprintf(
"WIN32: User must create dumps and images\n");
2896 MPI_Barrier(MPI_COMM_GRMHD);
2898 #endif //USINGMPIAVOIDMKDIR
2903 #include<sys/stat.h>
2912 int addremovefromanynpr(
int doadd,
int *whichpltoavg,
int *ifnotavgthencopy,
int *anynprstart,
int *anynprend,
int *anynprlist,
int *nprlocalstart,
int *nprlocalend,
int *nprlocallist,
FTYPE (*in)[
NSTORE2][
NSTORE3][NPR],
FTYPE (*out)[
NSTORE2][
NSTORE3][NPR]);
2915 addremovefromanynpr(doadd, whichpltoavg, ifnotavgthencopy, &
nprstart, &
nprend,
nprlist, nprlocalstart, nprlocalend, nprlocallist, in, out);
2923 int addremovefromanynpr(
int doadd,
int *whichpltoavg,
int *ifnotavgthencopy,
int *anynprstart,
int *anynprend,
int *anynprlist,
int *nprlocalstart,
int *nprlocalend,
int *nprlocallist,
FTYPE (*in)[
NSTORE2][
NSTORE3][NPR],
FTYPE (*out)[
NSTORE2][
NSTORE3][NPR])
2936 *nprlocalstart=*anynprstart;
2937 *nprlocalend=*anynprend;
2940 if(anynprlist==
nprlist) num=NPR;
2944 dualfprintf(
fail_file,
"No such type of list in addremovefromanynpr\n");
2950 for(pl3=0;pl3<num;pl3++){
2951 for(pl= *anynprstart;pl<= *anynprend;pl++){
2952 if(whichpltoavg[pl3]==0 && anynprlist[pl]==pl3){
2954 if(ifnotavgthencopy[pl3] && in!=NULL && out!=NULL) copy_3d_onepl_fullloop(pl3,in,out);
2955 for(pl2=pl+1;pl2<= *anynprend;pl2++) anynprlist[pl2-1]=anynprlist[pl2];
2969 *anynprstart= *nprlocalstart;
2970 *anynprend= *nprlocalend;
2991 if (
bl2met2metp2v(whichvel,whichcoord,
MAC(
p,i,j,k), i,j,k) >= 1)
FAILSTATEMENT(
"initbase.c:transform_primitive_vB()",
"bl2ks2ksp2v()", 1);
3011 va_start (arglist, s);
3013 if( 0 != is_bad_val ) {
3015 stderrfprintf(
"tried to print to null file pointer: %s\n",s);
3019 dualfprintf(
fail_file,
"Assertion failed: " );
3020 vfprintf (fileptr, s, arglist);
3024 vfprintf (stderr, s, arglist);
3037 void set_array(
void *inbufptr,
int num, MPI_Datatype datatype,
long double value)
3043 unsigned char *buf1;
3045 long long int *buf8i;
3047 long double *inbuf16;
3050 unsigned char *inbuf1;
3052 long long int *inbuf8i;
3054 int sizeofdatatype=getsizeofdatatype(datatype);
3057 if(datatype==MPI_UNSIGNED_CHAR){ buf1=(
unsigned char *)bufptr; inbuf1=(
unsigned char *)inbufptr;
for(i=0;i<num;i++) inbuf1[i]=(
unsigned char)value; }
3058 else if(datatype==MPI_FLOAT){ buf4=(
float *)bufptr; inbuf4=(
float *)inbufptr;
for(i=0;i<num;i++) inbuf4[i]=(
float)value; }
3059 else if(datatype==MPI_DOUBLE){ buf8=(
double*)bufptr; inbuf8=(
double*)inbufptr;
for(i=0;i<num;i++) inbuf8[i]=(
double)value; }
3060 else if(datatype==MPI_LONG_DOUBLE){ buf16=(
long double*)bufptr; inbuf16=(
long double*)inbufptr;
for(i=0;i<num;i++) inbuf16[i]=(
long double)value; }
3061 else if(datatype==MPI_INT){ buf4i=(
int *)bufptr; inbuf4i=(
int *)inbufptr;
for(i=0;i<num;i++) inbuf4i[i]=(
int)value; }
3062 else if(datatype==MPI_LONG_LONG_INT){ buf8i=(
long long int *)bufptr; inbuf8i=(
long long int *)inbufptr;
for(i=0;i<num;i++) inbuf8i[i]=(
long long int) value; }
3068 void debugdivb(
void)
3077 struct of_geom *ptrgeom=&geomdontuse;
3081 GLOBALMACP0A1(pstagglobal,i,j,k,
B1)=GLOBALMACP0A1(unewglobal,i,j,k,
B1)/ptrgeom->gdet;
3083 GLOBALMACP0A1(pstagglobal,i,j,k,
B2)=GLOBALMACP0A1(unewglobal,i,j,k,
B2)/ptrgeom->gdet;
3085 GLOBALMACP0A1(pstagglobal,i,j,k,
B3)=GLOBALMACP0A1(unewglobal,i,j,k,
B3)/ptrgeom->gdet;
3097 FTYPE divbmax=0,divbavg=0;
3099 dualfprintf(
fail_file,
"GOD0: %g %g\n",divbmax,divbavg);
3108 dualfprintf(
fail_file,
"GOD1: %g %g\n",divbmax,divbavg);