Changeset 8276


Ignore:
Timestamp:
Dec 8, 2011, 3:04:04 PM (12 years ago)
Author:
paul
Message:

Should have been included in revision 8274

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_work/development/2010-projects/anuga_1d/utilities/solver.h

    r8255 r8276  
    278278**********************************************************/
    279279// Declarations
    280 double domain_compute_fluxes_generic(struct domain *D);
     280double domain_compute_fluxes_cells_generic(struct domain *D);
     281double domain_compute_fluxes_edges_generic(struct domain *D);
    281282struct cell* sqpipe_domain_get_cell(struct domain *D, int i, struct cell *c);
    282283double* edge_flux_function_godunov (struct edge *c, struct params *p, double *edgeflux, int num_eqns);
     
    287288// Computational function for flux computation
    288289// This iterates over cells.
    289 double domain_compute_fluxes_generic (struct domain *D) {
     290double domain_compute_fluxes_cells_generic (struct domain *D) {
    290291  double flux[D->number_of_equations];
    291292  double max_speed;
     
    322323}
    323324
     325// Computational function for flux computation
     326// This iterates over edges.
     327double domain_compute_fluxes_edges_generic (struct domain *D) {
     328  double flux[D->number_of_equations];
     329  double max_speed;
     330  int k, i;
     331  // pre-create 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
    324361struct cell* domain_get_cell_generic(struct domain *D, int k, struct cell *c) {
    325362  int i, ki, n, m, nm;
     
    349386double* edge_flux_function_godunov (struct edge *e, struct params *p, double *edgeflux, int num_eqns) {
    350387  int i;
    351   double flux_left[num_eqns], flux_right[num_eqns];
     388  double flux_in[num_eqns], flux_out[num_eqns];
    352389  double denom;
    353390
    354   // Flux contribution from left side of  edge
    355   quantity_flux_formula(e->qin, e->normal, p, flux_left);
    356 
    357   // Flux contribution from right side of edge
    358   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);
    359396
    360397  // Flux computation
     
    364401  } else {
    365402    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];
    367404      edgeflux[i] += e->smax*e->smin * (quantity_get_conserved(e->qout, i, e->normal) - quantity_get_conserved(e->qin, i, e->normal));
    368405      edgeflux[i] /= denom;
Note: See TracChangeset for help on using the changeset viewer.