26 int setgridsectioning(
int initialcall,
int timeorder,
int numtimeorders,
long int thenstep,
FTYPE thetime )
37 init_gridsectioning();
40 findandsetactivesection(initialcall, timeorder, numtimeorders, thenstep, thetime );
52 int init_gridsectioning(
void)
56 int badglobal_sectiondef;
57 int faketimeorder,fakenumtimeorders;
64 trifprintf(
"Initializing grid sectioning: BEGIN\n");
70 findandsetactivesection(1,faketimeorder,fakenumtimeorders,
nstep,
t );
76 badglobal_sectiondef=0;
79 badglobal_sectiondef=1;
82 if(badglobal_sectiondef){
83 trifprintf(
"Sectioning info mangled; regenerating it for current time t = %21.15g\n",
t );
84 findandsetactivesection(1,faketimeorder,fakenumtimeorders,
nstep,
t );
87 setactivesection( global_enerregiondef[
ACTIVEREGION], doprintout );
90 trifprintf(
"Initializing grid sectioning: END\n");
112 struct of_geom *ptrgeom=&geomdontuse;
124 dualfprintf(
fail_file,
"Should not be in bound_gridsectioning EVER: deprecated code\n");
129 dualfprintf(
fail_file,
"Should not be in bound_gridsectioning\n");
149 if(primdest != primsource) {
199 MACP0A1(ucons,i,j,k,pl) =
MACP0A1(primsource,i,j,k,pl)*(ptrgeom->EOMFUNCMAC(pl));
205 MACP0A1(ucons,i,j,k,pl) =
MACP0A1(primsource,i,j,k,pl)*(ptrgeom->EOMFUNCMAC(pl));
211 MACP0A1(ucons,i,j,k,pl) =
MACP0A1(primsource,i,j,k,pl)*(ptrgeom->EOMFUNCMAC(pl));
222 MYFUN(
get_state(
MAC(primsource,i,j,k), ptrgeom, &q),
"step_ch.c:advance()",
"get_state()", 1);
223 MYFUN(
primtoU(
UEVOLVE,
MAC(primsource,i,j,k), &q, ptrgeom, Unew, NULL),
"initbase.gridsectioning.c:bound_gridsectioning()",
"primtoU()", 1);
235 MYFUN(
get_state(
MAC(primsource,i,j,k), ptrgeom, &q),
"step_ch.c:advance()",
"get_state()", 1);
236 MYFUN(
primtoU(
UEVOLVE,
MAC(primsource,i,j,k), &q, ptrgeom, Unew, NULL),
"initbase.gridsectioning.c:bound_gridsectioning()",
"primtoU()", 1);
283 for (ii =
numprocs - 1; ii >= 0; ii--) {
285 for (i =
N1-1; i >= 0; i--) {
306 if(ii==myid && myid==0 && i==0){
330 if(xr >= r1 && xr < r2){
336 else if (fromwhere==2){
337 if(xr >= r1 && xr < r2){
356 MPI_Bcast(xi, 1, MPI_INT, MPIid[ii], MPI_COMM_GRMHD);
357 MPI_Bcast(xcpupos1, 1, MPI_INT, MPIid[ii], MPI_COMM_GRMHD);
360 if (*xi >= 0) gotit = 1;
373 dualfprintf(
fail_file,
"Never found grid cell corresponding to radius %21.15g : fromwhere=%d\n",xr,fromwhere);
382 if(1||fromwhere==0) {
383 trifprintf(
"xi: %d xcpupos1: %d\n", *xi, *xcpupos1);
385 dualfprintf(
log_file,
"xi: %d mycpupos[1]: %d xcpupos1: %d\n", *xi,
mycpupos[1], *xcpupos1);
387 trifprintf(
"end: find_horizon\n");
402 int findandsetactivesection(
int initialcall,
int timeorder,
int numtimeorders,
long int thenstep,
FTYPE thetime )
407 int updateeverynumsteps;
409 int doprintout,doset;
411 static int firsttimerealgridset=1;
414 #if( DOGRIDSECTIONING == 0 )
415 dualfprintf(
fail_file,
"Got inside findandsetactivesection() with DOGRIDSECTIONING == 0\n");
422 if(omp_in_parallel()){
423 dualfprintf(
fail_file,
"setgeneral_enerregion() called in parallel region\n");
446 setactivesection( sectiondef, doprintout );
460 theproblem_set_enerregionupdate(initialcall, timeorder, numtimeorders, thenstep, thetime, &updateeverynumsteps, &everynumsteps);
463 doset = (initialcall==-1 || (
nstep % updateeverynumsteps==0) && (timeorder==numtimeorders-1) );
464 if(!doset)
return(0);
468 doprintout = (
nstep % everynumsteps==0) && (timeorder==numtimeorders-1) || (firsttimerealgridset==1);
469 firsttimerealgridset=0;
478 theproblem_set_enerregiondef(initialcall, timeorder, numtimeorders, thenstep, thetime, sectiondef);
489 setactivesection( sectiondef, doprintout );
512 int setactivesection(
int (*sectiondef)[
NDIM],
int doprintout)
525 assert( sectiondef[
POINTDOWN][dimen] >= sectiondef[
POINTUP][dimen],
"setactivesection(): hi/lo indices out of order: dimen=%d losectiondef = %d, hisectiondef = %d\n", dimen, sectiondef[
POINTDOWN][dimen], sectiondef[
POINTUP][dimen] );
557 int setsashawind_set_enerregiondef(
int initialcall,
int timeorder,
int numtimeorders,
long int thenstep,
FTYPE thetime,
int (*enerregiondef)[NDIM] )
559 int cpupos1lo,cpupos1hi;
564 int extra_safe_cells;
569 extra_safe_cells =
MAXBND;
582 rhi = 3. * thetime + 3. * (2 * M_PI / 0.25);
597 iloabs = cpupos1lo *
N1 + ilo;
600 ihiabs = cpupos1hi *
N1 + ihi;
604 ihiabs += extra_safe_cells;
619 enerregiondef[
POINTUP][1]=ihiabs;
632 int sashawind_set_enerregionupdate(
int initialcall,
int timeorder,
int numtimeorders,
long int thenstep,
FTYPE thetime,
int *updateeverynumsteps,
int *everynumsteps)
640 *updateeverynumsteps=100;
642 *everynumsteps = *updateeverynumsteps;
651 int torus_set_enerregiondef(
int initialcall,
int timeorder,
int numtimeorders,
long int thenstep,
FTYPE thetime,
int (*enerregiondef)[NDIM] )
653 int cpupos1lo,cpupos1hi;
658 int extra_safe_cells;
673 extra_safe_cells =
MAXBND;
692 iloabs = cpupos1lo *
N1 + ilo;
695 ihiabs = cpupos1hi *
N1 + ihi;
699 ihiabs += extra_safe_cells;
708 enerregiondef[
POINTUP][1]=ihiabs;
724 int jet_set_enerregiondef(
int initialcall,
int timeorder,
int numtimeorders,
long int thenstep,
FTYPE thetime,
int (*enerregiondef)[NDIM] )
726 int cpupos1lo,cpupos1hi;
731 int extra_safe_cells;
736 FTYPE newDTref,ftemp;
777 extra_safe_cells =
MAXBND;
856 newDTref =
round(rlo*ftemp);
889 iloabs = cpupos1lo *
N1 + ilo;
893 ihiabs = cpupos1hi *
N1 + ihi;
945 enerregiondef[
POINTUP][1]=ihiabs;
968 if(doreport) trifprintf(
"Lower grid section moved beyond outer box face\n");
974 if(doreport) trifprintf(
"Upper grid section moved inside inner box face\n");
982 if(doreport) trifprintf(
"Lower grid section moved beyond upper grid section\n");
988 if(doreport) trifprintf(
"Lower radius of grid section moved beyond radius of upper grid section\n");
1011 int jet_set_myid(
void)
1043 int ranki,rankj,rankk,origid,newid;
1044 for(rankk=0;rankk<
ncpux3;rankk++){
1045 for(rankj=0;rankj<
ncpux2;rankj++){
1046 for(ranki=0;ranki<
ncpux1;ranki++){
1047 origid=ranki + rankj*ncpux1 + rankk*ncpux1*
ncpux2;
1049 newid=ranki + rankj*(ncpux1/2) + rankk*(ncpux1/2)*
ncpux2;
1051 MPIid[origid]=newid*2;
1053 else if(ranki>=ncpux1/2){
1054 newid=(ranki-ncpux1/2) + rankj*(ncpux1/2) + rankk*(ncpux1/2)*ncpux2;
1056 MPIid[origid]=newid*2+1;