34 int viscosity(
int i,
int j,
int k,
int flag,
int nmin,
int nmax,
35 double *rho_1D,
double * vx_1D,
double *vy_1D,
double *vz_1D,
36 double *pre_1D,
double *e_int_1D,
double *eng_1D,
int lefter,
37 double *rhodown,
double *rhoup,
double *rhofront,
double *rhoback,
38 double *vxdown,
double *vxup,
double *vxfront,
double *vxback,
39 double *vydown,
double *vyup,
double *vyfront,
double *vyback,
40 double *vzdown,
double *vzup,
double *vzfront,
double *vzback,
44 double viscosity_term;
45 double temperature_i, temperature_ii;
46 double term_x, term_y, term_z;
47 double term_x_1, term_y_1, term_z_1;
48 double term_x_2, term_y_2, term_z_2;
49 double dx, dm, dm0, dtbdx;
50 double *dxflux, *dyflux, *dzflux;
63 if (flag == 0) dx = (
xmax -
xmin) / (
double)
x;
64 if (flag == 1) dx = (
ymax -
ymin) / (
double)
y;
65 if (flag == 2) dx = (
zmax -
zmin) / (
double)
z;
67 for (n = nmin - 1; n <= nmax + 1; n++) {
82 temperature_i = pre_1D[n] / (
gasconstant * rho_1D[n]);
83 temperature_ii = pre_1D[n - 1] / (
gasconstant * rho_1D[n - 1]);
88 term_x = -viscosity_term / dx * (rho_1D[n]*(4.0 / 3.0)*(vx_1D[n] - vx_1D[n - 1]));
90 term_x_1 = (rhoup[n] + rhodown[n])*(2.0 / 3.0)*(vyup[n] - vydown[n])*0.5;
91 term_x_1 += (rhoup[n - 1] + rhodown[n - 1])*(2.0 / 3.0)*(vyup[n - 1] - vydown[n - 1])*0.5;
94 term_x_2 = (rhoback[n] + rhofront[n])*(2.0 / 3.0)*(vzfront[n] - vzback[n])*0.5;
95 term_x_2 += (rhoback[n - 1] + rhofront[n - 1])*(2.0 / 3.0)*(vzfront[n - 1] - vzback[n - 1])*0.5;
98 dxflux[n] = term_x - 0.25 * (term_x_1 + term_x_2);
103 term_y = -viscosity_term / dx * (rho_1D[n]*(4.0 / 3.0)*(vy_1D[n] - vy_1D[n - 1]));
104 term_y_1 = (rhoup[n] + rhodown[n])*(vxup[n] - vxdown[n])*0.5;
105 term_y_1 += (rhoup[n - 1] + rhodown[n - 1])*(vxup[n - 1] - vxdown[n - 1])*0.5;
107 dyflux[n] = term_y + 0.25 * term_y_1;
113 term_z = -viscosity_term / dx * (rho_1D[n]*(4.0 / 3.0)*(vz_1D[n] - vz_1D[n - 1]));
114 term_z_1 = (rhoback[n] - rhofront[n])*(vxback[n] - vxfront[n])*0.5;
115 term_z_1 += (rhoback[n - 1] + rhofront[n - 1])*(vxback[n - 1] - vxfront[n - 1])*0.5;
117 dzflux[n] = term_z + 0.25 * term_z_1;
123 for (n = nmin; n <= nmax; n++) {
128 vx_1D[n] = (vx_1D[n] * rho_1D[n] - dtbdx * (dxflux[n + 1] - dxflux[n])) * dm0;
129 vy_1D[n] = (vy_1D[n] * rho_1D[n] - dtbdx * (dyflux[n + 1] - dyflux[n])) * dm0;
130 vz_1D[n] = (vz_1D[n] * rho_1D[n] - dtbdx * (dzflux[n + 1] - dzflux[n])) * dm0;