14 namespace NavierStokesFlux
16 template<
typename GasT>
17 MFEM_HOST_DEVICE
inline static mfem::real_t
18 MaximumNormalWaveSpeed(
const GasT &gas,
19 const mfem::real_t *state1,
20 const mfem::real_t *state2,
21 const mfem::real_t *direction)
25 mfem::real_t velocity_dot_direction1 = 0.0;
26 mfem::real_t velocity_dot_direction2 = 0.0;
27 mfem::real_t direction_norm_squared = 0.0;
28 for (
int d = 0; d < gas.dim(); ++d)
30 velocity_dot_direction1 += gas.
velocity(S1, d) * direction[d];
31 velocity_dot_direction2 += gas.velocity(S2, d) * direction[d];
32 direction_norm_squared += direction[d] * direction[d];
34 const mfem::real_t direction_norm =
38 + gas.sound_speed(S1) * direction_norm,
40 + gas.sound_speed(S2) * direction_norm);
44 template<
typename GasT>
45 MFEM_HOST_DEVICE
inline static void
46 ComputeInviscidFluxKernel(
const GasT &gas,
47 const mfem::real_t *state,
53 const int dim = gas.dim();
54 const mfem::real_t
density = gas.density(S);
55 const mfem::real_t spec_vol = 1.0/
density;
57 for(
int idim = 0;idim < dim;idim++){
58 momentum[idim] = gas.
momentum(S, idim);
61 const mfem::real_t energy = gas.energy(S);
62 const mfem::real_t
pressure = gas.pressure(S);
63 const mfem::real_t ke = gas.kinetic_energy_density(S);
64 const int eq_mass = gas.L.eq_mass;
65 const int eq_mom0 = gas.L.eq_mom0;
66 const int eq_ener = gas.L.eq_energy;
67 const int eq_spec = gas.L.eq_scalar0;
69 const mfem::real_t H = (energy +
pressure)*spec_vol;
71 for (
int d = 0; d < dim; d++)
73 inv_flux[eq_mass][d] = momentum[d];
74 for (
int i = 0; i < dim; i++)
77 inv_flux[eq_mom0+i][d] = momentum[i]*momentum[d]*spec_vol;
81 inv_flux[eq_ener][d] = momentum[d]*H;
82 for(
int s = 0;s < gas.L.num_scalars;s++){
83 inv_flux[eq_spec+s][d] = gas.scalar(S, s) * momentum[d] * spec_vol;
94 template<
typename GasT>
95 MFEM_HOST_DEVICE
inline
96 static void ComputeViscousFluxKernel(
const GasT &gas,
97 const mfem::real_t *state,
98 const mfem::real_t *dprim_x,
99 const mfem::real_t *dprim_y,
100 const mfem::real_t *dprim_z,
102 bool axisymmetric =
false,
103 mfem::real_t radius = 0.0,
104 mfem::real_t *azimuthal_stress =
nullptr)
108 const int dim = gas.dim();
111 for(
int idir = 0;idir < dim;idir++){
112 visc_flux[q][idir] = 0.0;
119 const mfem::real_t mu = gas.viscosity(S);
120 const mfem::real_t kappa = gas.thermal_conductivity(S);
121 const mfem::real_t mu_bulk = gas.bulk_viscosity(S);
124 const int eq_mass = gas.L.eq_mass;
125 const int eq_mom0 = gas.L.eq_mom0;
126 const int eq_ener = gas.L.eq_energy;
127 const int nscalar = gas.L.num_scalars;
135 grad_rho[0] = dprim_x[eq_mass];
136 grad_vel[0][0] = dprim_x[eq_mom0];
137 grad_p[0] = dprim_x[eq_ener];
139 grad_rho[1] = dprim_y[eq_mass];
140 grad_vel[0][1] = dprim_y[eq_mom0];
141 grad_vel[1][0] = dprim_x[eq_mom0+1];
142 grad_vel[1][1] = dprim_y[eq_mom0+1];
143 grad_p[1] = dprim_y[eq_ener];
145 grad_rho[2] = dprim_z[eq_mass];
146 grad_vel[0][2] = dprim_z[eq_mom0];
147 grad_vel[1][2] = dprim_z[eq_mom0+1];
148 grad_vel[2][0] = dprim_x[eq_mom0+2];
149 grad_vel[2][1] = dprim_y[eq_mom0+2];
150 grad_vel[2][2] = dprim_z[eq_mom0+2];
151 grad_p[2] = dprim_z[eq_ener];
155 gas.grad_temperature(S, grad_rho, grad_p, grad_t);
157 mfem::real_t div_vel = 0.0;
158 for(
int i = 0;i < dim;i++){
160 div_vel += grad_vel[i][i];
162 mfem::real_t radial_rate = 0.0;
170 radial_rate = vel[radial] / radius;
174 radial_rate = grad_vel[radial][radial];
180 div_vel += radial_rate;
183 if (azimuthal_stress)
185 *azimuthal_stress = 0.0;
188 *azimuthal_stress = mu *
189 (2.0 * radial_rate - mu_bulk * div_vel);
198 for (
int dir = 0; dir < dim; ++dir)
201 for (
int mom = 0; mom < dim; ++mom)
203 mfem::real_t tau = 0.0;
208 tau = mu * (2.0 * grad_vel[mom][dir] - mu_bulk * div_vel);
212 tau = mu * (grad_vel[mom][dir] + grad_vel[dir][mom]);
215 visc_flux[eq_mom0 + mom][dir] = tau;
217 mfem::real_t eflux = kappa * grad_t[dir];
218 for(
int mom = 0;mom < dim;mom++)
220 eflux += vel[mom] * visc_flux[eq_mom0 + mom][dir];
222 visc_flux[eq_ener][dir] = eflux;
226 template<
typename GasT>
227 MFEM_HOST_DEVICE
inline
228 static void compute_ref_viscous_flux(
const GasT &gas,
231 const mfem::real_t *state,
232 const mfem::real_t *dqx,
233 const mfem::real_t *dqy,
234 const mfem::real_t *dqz,
235 const mfem::real_t *adj_row,
237 bool axisymmetric =
false,
238 mfem::real_t radius = 0.0)
243 ComputeViscousFluxKernel(gas, state, dqx, dqy, dqz, flux_phys,
244 axisymmetric, radius);
246 for (
int q = 0; q < neq; ++q)
249 for (
int j = 0; j < dim; ++j)
250 f_ref[q] += adj_row[j] * flux_phys[q][j];