72 void Init (
double *us,
double x1,
double x2,
double x3)
77 static int first_call = 1;
78 double rnd,
s,
c, R, r, z;
79 double H, c0, cs, Bphi;
92 us[
RHO] = exp((s-1.0)/(c0*c0))/(R*sqrt(R));
94 us[
iVTH] = 1.e-4*cs*cos(8.0*x3)*exp(-2.0*z*z/(H*H));
95 us[
iVPHI] = 1.0/sqrt(r)*(1.0 - 2.5*c0*c0/
s);
96 us[PRS] = cs*cs*us[
RHO];
103 us[
AX3] *= 3.5e-4*exp(-pow(z/H,4.0))*exp(-pow((R-6.0)/2.0,4.0));
104 if (fabs(z/H) > 2.5 || R < 2.5) us[
AX3] = 0.0;
116 static int first_call = 1;
118 double *r, *th, *dVr, *dVth, *dVphi, vol;
121 static double voltot;
136 MPI_Allreduce (&voltot, &kin, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
137 MPI_Barrier (MPI_COMM_WORLD);
148 vol = dVr[
i]*dVth[
j]*dVphi[
k]/voltot;
150 for (nv =
NVAR; nv--; ) v[nv] = d->
Vc[nv][k][j][i];
155 Tmtot += v[
BX1]*v[
BX3]*vol;
160 MPI_Allreduce (&pmtot, &vol, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
163 MPI_Allreduce (&Tmtot, &vol, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
166 MPI_Barrier (MPI_COMM_WORLD);
177 static double tpos = -1.0;
179 fp = fopen(
"averages.dat",
"w");
180 fprintf (fp,
"#%s %12s %12s %12s\n",
181 " t",
"dt",
"<B^2>/2",
"<Tm>");
185 fp = fopen(
"averages.dat",
"r");
186 while (fgets(sline, 512, fp)) {}
187 sscanf(sline,
"%lf\n",&tpos);
190 fp = fopen(
"averages.dat",
"a");
193 fprintf (fp,
"%12.6e %12.6e %12.6e %12.6e\n",
209 double c0, cs, qx, qy, qz,
s, v[256];
210 double *r, *th, *phi;
223 for (nv = 0; nv <
NVAR; nv++) d->
Vc[nv][k][j][i]= d->
Vc[nv][k][j][
IBEG];
225 d->
Vc[
iVPHI][
k][
j][
i] = 1.0/sqrt(r[i])*(1.0 - 2.5*c0*c0/
s);
242 for (nv = 0; nv <
NVAR; nv++) d->
Vc[nv][k][j][i]= d->
Vc[nv][k][j][
IEND];
244 d->
Vc[
iVPHI][
k][
j][
i] = 1.0/sqrt(r[i])*(1.0 - 2.5*c0*c0/
s);
261 Init (v, r[i], th[j], phi[k]);
262 cs = c0/sqrt(r[i]*sin(th[j]));
264 v[PRS] = v[
RHO]*cs*cs;
265 for (nv = 0; nv <
NVAR; nv++) d->
Vc[nv][k][j][i]= v[nv];
282 Init (v, r[i], th[j], phi[k]);
283 cs = c0/sqrt(r[i]*sin(th[j]));
285 v[PRS] = v[
RHO]*cs*cs;
286 for (nv = 0; nv <
NVAR; nv++) d->
Vc[nv][k][j][i]= v[nv];
300 #if (BODY_FORCE & VECTOR)
302 void BodyForceVector(
double *v,
double *g,
double x1,
double x2,
double x3)
309 g[
IDIR] = -1.0/(x1*x1);
315 #if (BODY_FORCE & POTENTIAL)
#define X1_BEG
Boundary region at X1 beg.
double **** Vs
The main four-index data array used for face-centered staggered magnetic fields.
void UserDefBoundary(const Data *d, RBox *box, int side, Grid *grid)
int vpos
Location of the variable inside the cell.
#define BOX_LOOP(B, k, j, i)
double **** Vc
The main four-index data array used for cell-centered primitive variables.
double g_dt
The current integration time step.
double g_smallPressure
Small value for pressure fix.
#define X1_END
Boundary region at X1 end.
long int g_stepNumber
Gives the current integration step number.
#define X2_END
Boundary region at X2 end.
double g_inputParam[32]
Array containing the user-defined parameters.
long int IEND
Upper grid index of the computational domain in the the X1 direction for the local processor...
double * xgc
Cell volumetric centroid (!= x when geometry != CARTESIAN).
double g_time
The current integration time.
double BodyForcePotential(double x, double y, double z)
#define X2_BEG
Boundary region at X2 beg.
long int IBEG
Lower grid index of the computational domain in the the X1 direction for the local processor...
void Analysis(const Data *d, Grid *grid)
void Init(double *v, double x1, double x2, double x3)
void BodyForceVector(double *v, double *g, double x, double y, double z)