- Timestamp:
- Jun 19, 2011, 3:51:16 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_work/development/2010-projects/anuga_1d/pipe/pipe_domain_ext.c
r8186 r8187 12 12 void compute_flux_godunov(double[], double[], double, double, double, double, double[]); 13 13 void compute_flux_wb(double[], double[], double, double, double, double, double[]); 14 double forcingterm_press_naive(double[], double[], double); 15 double forcingterm_fs_naive(double[], double[], double); 14 double forcingterm_formula_press_naive(double[], double[], double); 15 double forcingterm_formula_fs_naive(double[], double[], double); 16 double compute_forcingterm(double[], double[], double); 16 17 int _flux_function_pipe(double *, double *, double *, double *, double, double, double, double *, double *); 17 18 … … 23 24 #define flux_formula1 flux_formula_press1 24 25 #define compute_flux compute_flux_godunov 25 #define forcingterm forcingterm_press_naive 26 26 #define forcingterm_formula_press forcingterm_formula_press_naive 27 #define forcingterm_formula_fs forcingterm_formula_fs_naive 28 #define compute_forcingterm compute_forcingterm_press 27 29 28 30 // Some formulae … … 97 99 // ********************************************************************* 98 100 99 100 // ********************************************************************* 101 // Forcing terms 101 // ********************************************************************* 102 // Forcing term formulae 102 103 103 104 // Pressurised forcing terms 104 105 // Naive version 105 double forcingterm_press_naive(double *q_m, double *q_p, double g) { 106 double forcingterm_formula_press_naive(double *q_m, double *q_p, double g) { 107 108 return g * (0.5*(q_m[3]+q_p[3]) - 0.5*(q_m[6]+q_p[6])) * (q_m[5]-q_p[5]) + g * (0.5*(q_m[3]+q_p[3]) - 0.5*(q_m[6]+q_p[6])) * 0.5*(q_m[5]+q_p[5]) * (q_m[6]-q_p[6]) * 1/(0.5*(q_m[6]+q_p[6])); 109 } 110 111 // Free surface forcing terms 112 // Naive version 113 double forcingterm_formula_fs_naive(double *q_m, double *q_p, double g) { 114 return -0.5*0.5 * g * (q_m[3] + q_p[3]) * (q_m[5] + q_p[5]) * (q_m[2] - q_p[2]) + 0.5 * g * (q_m[3] + q_p[3]) * (q_m[3] + q_p[3]) * 0.5*0.5 * (q_m[5] - q_p[5]); 115 } 116 // ********************************************************************* 117 118 // ********************************************************************* 119 // Forcing term computation 120 121 // Pressurised forcing terms computation 122 double compute_forcingterm_press(double *q_m, double *q_p, double g) { 106 123 double ret; 107 108 ret = g * (0.5*(q_m[3]+q_p[3]) - 0.5*(q_m[6]+q_p[6])) * (q_m[5]-q_p[5]) + g * (0.5*(q_m[3]+q_p[3]) - 0.5*(q_m[6]+q_p[6])) * 0.5*(q_m[5]+q_p[5]) * (q_m[6]-q_p[6]) * 1/(0.5*(q_m[6]+q_p[6])); 109 110 // Add in the free surface pressure term with h=t 111 // Does this overwite q_p,q_m in the caller? If so, we don't want that! 124 double h_m, h_p; 125 126 // Compute pressurised forcing term 127 ret = forcingterm_formula_press(q_m, q_p, g); 128 129 // Add in free surface forcing term with h = t 130 // This is a hack: We temporarily change h (q[3]) to t (q[6]) 131 // then call fs forcing term, then change h back. 132 h_p = q_p[3]; 133 h_m = q_m[3]; 112 134 q_p[3] = q_p[6]; 113 135 q_m[3] = q_m[6]; 114 ret += forcingterm_fs_naive(q_m, q_p, g); 136 ret += forcingterm_formula_fs(q_m, q_p, g); 137 q_p[3] = h_p; 138 q_m[3] = h_m; 115 139 116 140 return ret; 117 141 } 118 142 119 // Free surface forcing terms 120 // Naive version 121 double forcingterm_fs_naive(double *q_m, double *q_p, double g) { 122 return -0.5*0.5 * g * (q_m[3] + q_p[3]) * (q_m[5] + q_p[5]) * (q_m[2] - q_p[2]) + 0.5 * g * (q_m[3] + q_p[3]) * (q_m[3] + q_p[3]) * 0.5*0.5 * (q_m[5] - q_p[5]); 143 // Free surface forcing terms computation 144 double compute_forcingterm_fs(double *q_m, double *q_p, double g) { 145 return forcingterm_formula_fs(q_m, q_p, g); 123 146 } 124 147 // ********************************************************************* … … 174 197 175 198 // Add in Forcing terms 176 edgeflux[1] -= forcingterm(q_rightm, q_leftp, g);199 edgeflux[1] -= compute_forcingterm(q_rightm, q_leftp, g); 177 200 178 201 // Maximal wavespeed
Note: See TracChangeset
for help on using the changeset viewer.