70 static double AX_VEC (
double x,
double y,
double z);
71 static double AY_VEC (
double x,
double y,
double z);
72 static double AZ_VEC (
double x,
double y,
double z);
74 static double ta = 0.0,
tb = 0.0;
78 void Init (
double *us,
double x1,
double x2,
double x3)
83 static int first_call = 1;
85 double x, y, z, kx, ky,kz;
87 double vx, vy, vz,
Bx, By, Bz, rho, pr;
99 if (
prank == 0) printf (
"ta = %f; tb = %f\n",
ta, tb);
102 x = x1; y = x2; z = x3;
109 ca = 1.0/sqrt(
ta*
ta + 1.0);
110 cb = 1.0/sqrt(
tb*
tb + 1.0);
114 phi =
D_EXPAND(kx*x, + ky*y, + kz*z);
121 vy = fabs(eps)*sin(phi);
122 vz = fabs(eps)*cos(phi);
124 By = eps*sqrt(rho)*sin(phi);
125 Bz = eps*sqrt(rho)*cos(phi);
133 cg = 1.0/sqrt(tg*tg + 1.0);
sg =
cg*tg;
140 us[
BX1] = Bx*cg*ca - By*sa - Bz*
sg*
ca;
141 us[
BX2] = Bx*cg*sa + By*ca - Bz*
sg*
sa;
158 double bmag, err[3], gerr[3], Vtot, dV;
159 double ***
Bx, ***By, ***Bz;
160 double *dx, *dy, *dz;
161 static double ***Bx0, ***By0, ***Bz0;
171 print1 (
"ANALYSIS: Initializing bmag\n");
173 Bx0[
k][
j][
i] = Bx[
k][
j][
i];
174 By0[
k][
j][
i] = By[
k][
j][
i];
175 Bz0[
k][
j][
i] = Bz[
k][
j][
i];
180 for (i = 0; i < 3; i++) err[i] = 0.0;
182 dV =
D_EXPAND(dx[i], *dy[j], *dz[k]);
183 err[0] += fabs(Bx[k][j][i] - Bx0[k][j][i])*dV;
184 err[1] += fabs(By[k][j][i] - By0[k][j][i])*dV;
185 err[2] += fabs(Bz[k][j][i] - Bz0[k][j][i])*dV;
193 for (i = 0; i < 3; i++) err[i] /= Vtot;
196 MPI_Allreduce (err, gerr, 3, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
197 for (i = 0; i < 3; i++) err[i] = gerr[i];
198 MPI_Barrier (MPI_COMM_WORLD);
203 errtot = sqrt(err[0]*err[0] + err[1]*err[1] + err[2]*err[2]);
204 fp = fopen(
"bmag.dat",
"w");
205 printf (
"analysis: writing to disk...\n");
206 fprintf (fp,
"%d %10.3e\n", (
int)(1.0/dx[
IBEG]), errtot);
218 double AX_VEC (
double x,
double y,
double z)
220 double xn, yn, zn,
eps;
221 double kx, ky, kz, phi;
222 double kxn, kyn, kzn;
223 double Axn, Ayn, Azn;
230 phi =
D_EXPAND(kx*x, + ky*y, + kz*z);
237 kyn = -
sa*kx +
ca*ky;
241 Ayn = eps*sin(phi)/kxn;
242 Azn = eps*cos(phi)/kxn + yn;
247 double AY_VEC (
double x,
double y,
double z)
249 double xn, yn, zn,
eps;
250 double kx, ky, kz, phi;
251 double kxn, kyn, kzn;
252 double Axn, Ayn, Azn;
259 phi =
D_EXPAND(kx*x, + ky*y, + kz*z);
266 kyn = -
sa*kx +
ca*ky;
270 Ayn = eps*sin(phi)/kxn;
271 Azn = eps*cos(phi)/kxn + yn;
275 double AZ_VEC (
double x,
double y,
double z)
277 double xn, yn, zn,
eps;
278 double kx, ky, kz, phi;
279 double kxn, kyn, kzn;
280 double Axn, Ayn, Azn;
287 phi =
D_EXPAND(kx*x, + ky*y, + kz*z);
294 kyn = -
sa*kx +
ca*ky;
298 Ayn = eps*sin(phi)/kxn;
299 Azn = eps*cos(phi)/kxn + yn;
301 return(Axn*
sg + Azn*
cg);
void UserDefBoundary(const Data *d, RBox *box, int side, Grid *grid)
void print1(const char *fmt,...)
long int NX2_TOT
Total number of zones in the X2 direction (boundaries included) for the local processor.
double **** Vc
The main four-index data array used for cell-centered primitive variables.
#define ARRAY_3D(nx, ny, nz, type)
static double AX_VEC(double x, double y, double z)
double g_inputParam[32]
Array containing the user-defined parameters.
long int NX3_TOT
Total number of zones in the X3 direction (boundaries included) for the local processor.
static double AZ_VEC(double x, double y, double z)
double g_domBeg[3]
Lower limits of the computational domain.
D_EXPAND(tot/[n]=(double) grid[IDIR].np_int_glob;, tot/[n]=(double) grid[JDIR].np_int_glob;, tot/[n]=(double) grid[KDIR].np_int_glob;)
double g_domEnd[3]
Upper limits of the computational domain.
static double AY_VEC(double x, double y, double z)
long int NX1_TOT
Total number of zones in the X1 direction (boundaries included) for the local processor.
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)