57 inline mfem::real_t
slipwall_pstar(
const StateView &S,
const GasModelT &gasModel)
59 const mfem::real_t rho = gasModel.density(S);
60 const mfem::real_t c = gasModel.sound_speed(S);
61 const mfem::real_t p = gasModel.pressure(S);
62 const mfem::real_t v = gasModel.velocity(S, 0);
63 const mfem::real_t gamma = gasModel.gamma(S);
64 const mfem::real_t gammaP1 = gamma + 1.;
65 const mfem::real_t gammaM1 = gamma - 1.;
66 const mfem::real_t gammaP1Inverse = 1.0/gammaP1;
67 const mfem::real_t gammaM1Inverse = 1.0/gammaM1;
69 return (p + 0.25*v*gammaP1*rho*
70 (v + std::sqrt(v*v + 8.0*gammaP1Inverse*p*(gammaM1*gammaP1Inverse+1.0)/rho)));
72 return p * std::pow(std::max(1.0 + 0.5*gammaM1*v/c, 0.0001), 2.0*gamma*gammaM1Inverse);
109 const GasModelT &gasModel)
112 const mfem::real_t p = gasModel.pressure(S);
113 const mfem::real_t gamma = gasModel.gamma(S);
114 const mfem::real_t cp = gasModel.cp(S);
115 const mfem::real_t gm1 = gamma - 1.0;
116 const mfem::real_t expo = gm1 / gamma;
118 mfem::real_t v2 = 2.0*cp*Ct.
T0*(1.0 - std::pow(p/Ct.
p0, expo));
119 v2 = std::max(0.0, v2);
120 const mfem::real_t cpT = cp * Ct.
T0 - 0.5*v2;
121 out.rho = (gamma / gm1)*p/cpT;
122 out.energy = p/gm1 + 0.5*v2*out.rho;
129 const GasModelT &gasModel)
131 const int dim = gasModel.dim();
132 const mfem::real_t rho_i = gasModel.density(Si);
133 const mfem::real_t rho_o = gasModel.density(So);
134 mfem::real_t Vn_i = gasModel.momentum(Si, 0)*n[0];
135 mfem::real_t Vn_o = gasModel.momentum(So, 0)*n[0];
137 Vn_i += gasModel.momentum(Si, 1)*n[1];
138 Vn_o += gasModel.momentum(So, 1)*n[1];
141 Vn_i += gasModel.momentum(Si, 2)*n[2];
142 Vn_o += gasModel.momentum(So, 2)*n[2];
148 const mfem::real_t p_i = gasModel.pressure(Si);
149 const mfem::real_t a_i = gasModel.sound_speed(Si);
150 const mfem::real_t p_o = gasModel.pressure(So);
151 const mfem::real_t a_o = gasModel.sound_speed(So);
153 const mfem::real_t gamma = gasModel.gamma(Si);
154 const mfem::real_t gm1 = gamma - 1.0;
155 const mfem::real_t gm1i = 1.0 / gm1;
156 const mfem::real_t gi = 1.0/gamma;
158 const bool ext_supersonic_n = (std::abs(Vn_o) >= a_o);
160 const mfem::real_t Rm =
161 (ext_supersonic_n && Vn_i >= 0.0)
162 ? (Vn_i - 2.0 * a_i * gm1i)
163 : (Vn_o - 2.0 * a_o * gm1i);
164 const mfem::real_t Rp =
165 (ext_supersonic_n && Vn_i < 0.0)
166 ? (Vn_o + 2.0 * a_o * gm1i)
167 : (Vn_i + 2.0 * a_i * gm1i);
169 const mfem::real_t Vn_b = 0.5 * (Rm + Rp);
170 const mfem::real_t a_b = 0.25*gm1*(Rp - Rm);
172 const mfem::real_t dVn_i = Vn_b - Vn_i;
173 const mfem::real_t dVn_o = Vn_b - Vn_o;
176 const auto rho_from_ref = [&](mfem::real_t rho_ref, mfem::real_t p_ref) {
178 const mfem::real_t factor = (a_b*a_b) * rho_ref / (gamma * p_ref);
179 return rho_ref * std::pow(factor, gm1i);
182 const bool inflow = (Vn_i < 0.0);
183 const mfem::real_t rho_b = inflow ? rho_from_ref(rho_o, p_o) : rho_from_ref(rho_i, p_i);
184 S2.set_mass(gasModel.L, rho_b);
185 const mfem::real_t p_b = (a_b * a_b) * rho_b * gi;
186 mfem::real_t vb[3] = {0., 0., 0.};
187 mfem::real_t vb2 = 0.0;
188 const mfem::real_t dVn = inflow ? dVn_o : dVn_i;
189 for(
int idim = 0;idim < dim;idim++){
190 const mfem::real_t base = inflow ? gasModel.velocity(So, idim) : gasModel.velocity(Si, idim);
191 vb[idim] = base + dVn*n[idim];
192 vb2 += (vb[idim]*vb[idim]);
193 S2.set_momentum(gasModel.L, idim, rho_b*vb[idim]);
195 S2.set_energy(gasModel.L, p_b * gm1i + 0.5 * rho_b * vb2);
199 MFEM_HOST_DEVICE
inline void PrimitiveToConserved(
const PrimStateView &prim, ConsStateView &cons,
const GasModelT &gasModel){
200 const mfem::real_t rho = prim.mass(gasModel.L);
201 const int dim = gasModel.dim();
203 const mfem::real_t gamma = gasModel.gamma(prim);
204 mfem::real_t v2 = prim.velocity(gasModel.L, 0)*prim.velocity(gasModel.L, 0);
205 cons.set_mass(gasModel.L, rho);
206 cons.set_momentum(gasModel.L, 0, rho*prim.velocity(gasModel.L, 0));
208 cons.set_momentum(gasModel.L, 1, rho*prim.velocity(gasModel.L, 1));
209 v2 += prim.velocity(gasModel.L, 1)*prim.velocity(gasModel.L, 1);
212 cons.set_momentum(gasModel.L, 2, rho*prim.velocity(gasModel.L, 2));
213 v2 += prim.velocity(gasModel.L, 2)*prim.velocity(gasModel.L,2);
215 cons.set_energy(gasModel.L, prim.pressure(gasModel.L) / (gamma-1.) + 0.5 * rho * v2);