Changeset 8276
 Timestamp:
 Dec 8, 2011, 3:04:04 PM (8 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/anuga_work/development/2010projects/anuga_1d/utilities/solver.h
r8255 r8276 278 278 **********************************************************/ 279 279 // Declarations 280 double domain_compute_fluxes_generic(struct domain *D); 280 double domain_compute_fluxes_cells_generic(struct domain *D); 281 double domain_compute_fluxes_edges_generic(struct domain *D); 281 282 struct cell* sqpipe_domain_get_cell(struct domain *D, int i, struct cell *c); 282 283 double* edge_flux_function_godunov (struct edge *c, struct params *p, double *edgeflux, int num_eqns); … … 287 288 // Computational function for flux computation 288 289 // This iterates over cells. 289 double domain_compute_fluxes_ generic (struct domain *D) {290 double domain_compute_fluxes_cells_generic (struct domain *D) { 290 291 double flux[D>number_of_equations]; 291 292 double max_speed; … … 322 323 } 323 324 325 // Computational function for flux computation 326 // This iterates over edges. 327 double domain_compute_fluxes_edges_generic (struct domain *D) { 328 double flux[D>number_of_equations]; 329 double max_speed; 330 int k, i; 331 // precreate a cell object to use in the loop 332 // so we need only allocate memory once 333 struct cell *c = domain_new_cell(D); 334 335 for (k=0; k<D>number_of_elements; k++) { 336 c = domain_get_cell(D, k, c); 337 338 // Compute sound speeds (this updates c) and update timestep 339 max_speed = cell_extreme_sound_speeds(c, D>params); 340 if (max_speed > D>params>epsilon) { 341 D>timestep = min(D>timestep, 0.5*D>params>cfl * D>areas[k]/max_speed); 342 } 343 344 // Compute flux and store in explicit_update 345 cell_flux_function(c, D>params, flux, D>number_of_equations); 346 for (i=0; i<D>number_of_equations; i++) { 347 flux[i] /= D>areas[k]; 348 } 349 quantities_update(D>explicit_update, flux, k); 350 351 //Keep track of maximal speeds 352 D>max_speed_array[k]=max_speed; 353 } 354 355 cell_destroy(c); 356 357 return D>timestep; 358 } 359 360 324 361 struct cell* domain_get_cell_generic(struct domain *D, int k, struct cell *c) { 325 362 int i, ki, n, m, nm; … … 349 386 double* edge_flux_function_godunov (struct edge *e, struct params *p, double *edgeflux, int num_eqns) { 350 387 int i; 351 double flux_ left[num_eqns], flux_right[num_eqns];388 double flux_in[num_eqns], flux_out[num_eqns]; 352 389 double denom; 353 390 354 // Flux contribution from leftside of edge355 quantity_flux_formula(e>qin, e>normal, p, flux_ left);356 357 // Flux contribution from rightside of edge358 quantity_flux_formula(e>qout, e>normal, p, flux_ right);391 // Flux contribution from inside of edge 392 quantity_flux_formula(e>qin, e>normal, p, flux_in); 393 394 // Flux contribution from outside of edge 395 quantity_flux_formula(e>qout, e>normal, p, flux_out); 359 396 360 397 // Flux computation … … 364 401 } else { 365 402 for (i=0; i<num_eqns; i++) { 366 edgeflux[i] = e>smax*flux_ left[i]  e>smin*flux_right[i];403 edgeflux[i] = e>smax*flux_in[i]  e>smin*flux_out[i]; 367 404 edgeflux[i] += e>smax*e>smin * (quantity_get_conserved(e>qout, i, e>normal)  quantity_get_conserved(e>qin, i, e>normal)); 368 405 edgeflux[i] /= denom;
Note: See TracChangeset
for help on using the changeset viewer.