HydroCODE_2D 0.1
This is a implementation of fully explict forward Euler scheme for 2-D Euler equations of motion on Eulerian coordinate
roe_hll_solver.c
浏览该文件的文档.
1
6#include <stdio.h>
7#include <stdlib.h>
8#include <math.h>
9
10#include "../include/var_struc.h"
11
12
28void Roe_HLL_solver(double *V_mk, double *F, double * lambda_max, const struct i_f_var *ifv_L, const struct i_f_var *ifv_R, const double delta)
29{
30 const double gamma = ifv_L->gamma;
31 const double P_L = ifv_L->P, P_R = ifv_R->P;
32 const double RHO_L = ifv_L->RHO, RHO_R = ifv_R->RHO;
33 const double U_L = ifv_L->U, U_R = ifv_R->U;
34 const double V_L = ifv_L->V, V_R = ifv_R->V;
35
36 // double const Q_user = 2.0;
37
38 double C_L, C_R;
39 C_L = sqrt(gamma*P_L/RHO_L);
40 C_R = sqrt(gamma*P_R/RHO_R);
41 // double z = 0.5 * (gamma-1.0) / gamma;
42
43 /*
44 double Q, P_pvrs, P_max, P_min, RHO_bar, C_bar;
45 P_min = fmin(P_L,P_R);
46 P_max = fmax(P_L,P_R);
47 Q = P_max/P_min;
48 RHO_bar = 0.5*(RHO_L+RHO_R);
49 C_bar = 0.5*(C_L+C_R);
50 P_pvrs = 0.5*(P_L+P_R)+0.5*(U_L-U_R)*RHO_bar*C_bar;
51
52 double A_L,A_R,B_L,B_R;
53 A_L = 2.0/(gamma+1.0)/RHO_L;
54 A_R = 2.0/(gamma+1.0)/RHO_R;
55 B_L = (gamma-1)/(gamma+1)*P_L;
56 B_R = (gamma-1)/(gamma+1)*P_R;
57
58 double P_star, U_star, U_star_L, U_star_R, RHO_star_L, RHO_star_R, C_star_L, C_star_R, P_0, g_L_0, g_R_0, lambda_L_1, lambda_R_1, lambda_L_3, lambda_R_3;
59
60 if(Q<Q_user&&P_min<P_pvrs&&P_pvrs<P_max) //PVRS
61 {
62 P_star = fmax(0,P_pvrs);
63 U_star = 0.5*(U_L+U_R)+0.5*(P_L-P_R)/(RHO_bar*C_bar);
64 RHO_star_L = RHO_L + (U_L-U_star)*RHO_bar/C_bar;
65 RHO_star_R = RHO_R + (U_star - U_R)*RHO_bar/C_bar;
66 C_star_L = sqrt(gamma*P_star/RHO_star_L);
67 C_star_R = sqrt(gamma*P_star/RHO_star_R);
68 U_star_L = U_star;
69 U_star_R = U_star;
70 }
71 else if(P_pvrs<P_min) //TRRS
72 {
73 P_star = pow((C_L + C_R - (gamma-1.0)/2.0*(U_R - U_L))/(C_L/pow(P_L,z) + C_R/pow(P_R,z)), 1.0/z);
74 C_star_L = C_L * pow(P_star/P_L, z);
75 U_star_L = U_L + 2.0/(gamma - 1.0)*(C_L - C_star_L);
76 C_star_R = C_R * pow(P_star/P_R, z);
77 U_star_R = U_R + 2.0/(gamma - 1.0)*(C_star_R - C_R);
78 }
79 else //TSRS
80 {
81 P_0 = fmax(0,P_pvrs);
82 g_L_0 = sqrt(A_L/(P_0+B_L));
83 g_R_0 = sqrt(A_R/(P_0+B_R));
84 P_star = (g_L_0*P_L+g_R_0*P_R-(U_R-U_L))/(g_L_0+g_R_0);
85 U_star = 0.5*(U_R+U_L)+0.5*((P_star-P_R)*g_R_0-(P_star-P_L)*g_L_0);
86 RHO_star_L = RHO_L*(P_star/P_L+(gamma-1.0)/(gamma+1.0))/((gamma-1.0)*P_star/(gamma+1.0)/P_L+1.0);
87 RHO_star_R = RHO_R*(P_star/P_R+(gamma-1.0)/(gamma+1.0))/((gamma-1.0)*P_star/(gamma+1.0)/P_R+1.0);
88 C_star_L = sqrt(gamma*P_star/RHO_star_L);
89 C_star_R = sqrt(gamma*P_star/RHO_star_R);
90 U_star_L = U_star;
91 U_star_R = U_star;
92 }
93
94 lambda_L_1 = U_L - C_L;
95 lambda_R_1 = U_star_L - C_star_L;
96 lambda_L_3 = U_star_R + C_star_R;
97 lambda_R_3 = U_R + C_R;
98 */
99
100 double H_L, H_R;
101 H_L = gamma/(gamma-1.0)*P_L/RHO_L + 0.5*(U_L*U_L);
102 H_R = gamma/(gamma-1.0)*P_R/RHO_R + 0.5*(U_R*U_R);
103
104 double E_L;
105 // double E_R;
106 E_L = 1.0/(gamma-1.0)*P_L/RHO_L + 0.5*(U_L*U_L);
107 // E_R = 1.0/(gamma-1.0)*P_R/RHO_R + 0.5*(U_R*U_R);
108
109 double U[3];
110 U[0] = RHO_L;
111 U[1] = RHO_L*U_L;
112 U[2] = RHO_L*E_L;
113
114 double RHO_S, U_S, H_S, C_S;
115 RHO_S = sqrt(RHO_L*RHO_R);
116 U_S = (U_L*sqrt(RHO_L)+U_R*sqrt(RHO_R)) / (sqrt(RHO_L)+sqrt(RHO_R));
117 H_S = (H_L*sqrt(RHO_L)+H_R*sqrt(RHO_R)) / (sqrt(RHO_L)+sqrt(RHO_R));
118 C_S = sqrt((gamma-1.0)*(H_S-0.5*U_S*U_S));
119
120 double R[3][3];
121 double lambda[3], W[3];
122 R[0][0] = 1.0;
123 R[0][1] = 1.0;
124 R[0][2] = 1.0;
125 R[1][0] = U_S - C_S;
126 R[1][1] = U_S;
127 R[1][2] = U_S + C_S;
128 R[2][0] = H_S - U_S*C_S;
129 R[2][1] = 0.5*(U_S*U_S);
130 R[2][2] = H_S + U_S*C_S;
131
132 int i, j;
133
134 W[0] = 0.5*((P_R-P_L)-RHO_S*C_S*(U_R-U_L))/(C_S*C_S);
135 W[1] = (RHO_R-RHO_L)-(P_R-P_L)/(C_S*C_S);
136 W[2] = 0.5*((P_R-P_L)+RHO_S*C_S*(U_R-U_L))/(C_S*C_S);
137
138 lambda[0] = U_S - C_S;
139 lambda[1] = U_S;
140 lambda[2] = U_S + C_S;
141
142 *lambda_max = fabs(U_S) + C_S;
143
144 /*
145 if(lambda_L_1<0&&lambda_R_1>0)
146 {
147 for(i = 0; i < 3; i++)
148 {
149 U[i] += (lambda_R_1-(U_S-C_S))/(lambda_R_1-lambda_L_1)*W[0]*R[i][0];
150 }
151 }
152 else if(lambda_L_3<0&&lambda_R_3>0)
153 {
154 U[0] = RHO_R;
155 U[1] = RHO_R*U_R;
156 U[2] = RHO_R*E_R;
157 for(i = 0; i < 3; i++)
158 {
159 U[i] += -((U_S+C_S)-lambda_L_3)/(lambda_R_3-lambda_L_3)*W[2]*R[i][2];
160 }
161 }
162 else
163 {
164 */ for(j = 0; j < 3; j++)
165 {
166 if(lambda[j]<=0)
167 {
168 for(i = 0; i < 3 ; i++)
169 {
170 U[i] += W[j]*R[i][j];
171 }
172 }
173 }
174 // }
175
176 F[0] = U[0];
177 F[1] = U[1]/U[0];
178 F[2] = (U[2]/U[0] - 0.5*F[1]*F[1])*(gamma-1.0)*F[0];
179
180 double S_L, S_R;
181 S_L=fmin(U_S-C_S,U_L-C_L);
182 S_R=fmax(U_S+C_S,U_R+C_R);
183 S_L=fmin(0,S_L);
184 S_R=fmax(0,S_R);
185
186 *V_mk=(RHO_R*(S_R-U_R)*V_R-RHO_L*(S_L-U_L)*V_L)/(RHO_R*(S_R-U_R)-RHO_L*(S_L-U_L));
187}
void Roe_HLL_solver(double *V_mk, double *F, double *lambda_max, const struct i_f_var *ifv_L, const struct i_f_var *ifv_R, const double delta)
An approxiamate Riemann solver hybridizing the Roe flux and the HLL flux for unsteady compressible in...
Interfacial Fluid VARiables.
Definition: var_struc.h:116
double V
primitive variable values at t_{n}.
Definition: var_struc.h:122
double RHO
Definition: var_struc.h:122
double U
Definition: var_struc.h:122
double gamma
specific heat ratio.
Definition: var_struc.h:121
double P
Definition: var_struc.h:122