Changeset 4714


Ignore:
Timestamp:
Sep 10, 2007, 4:12:43 PM (17 years ago)
Author:
ole
Message:

A small but obvious optimisation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/shallow_water/shallow_water_ext.c

    r4710 r4714  
    484484  double dz, hmin, alpha, h_diff;
    485485
    486   //Compute linear combination between w-limited stages and
    487   //h-limited stages close to the bed elevation.
     486  // Compute linear combination between w-limited stages and
     487  // h-limited stages close to the bed elevation.
    488488
    489489  for (k=0; k<N; k++) {
     
    497497    k3 = 3*k;
    498498
    499     //FIXME: Try with this one precomputed
     499   
    500500    dz = 0.0;
    501     hmin = hv[k3];
    502     for (i=0; i<3; i++) {
    503       if (tight_slope_limiters == 0) {
    504         dz = max(dz, fabs(zv[k3+i]-zc[k]));
    505       }
    506      
    507       hmin = min(hmin, hv[k3+i]);
     501    if (tight_slope_limiters == 0) {     
     502      // FIXME: Try with this one precomputed
     503      for (i=0; i<3; i++) {
     504        dz = max(dz, fabs(zv[k3+i]-zc[k]));
     505      }
    508506    }
    509507
    510 
    511     //Create alpha in [0,1], where alpha==0 means using the h-limited
    512     //stage and alpha==1 means using the w-limited stage as
    513     //computed by the gradient limiter (both 1st or 2nd order)
     508    // Calculate minimal depth across all three vertices
     509    hmin = min(hv[k3], min(hv[k3+1], hv[k3+2]));
    514510   
    515511   
     512
     513    // Create alpha in [0,1], where alpha==0 means using the h-limited
     514    // stage and alpha==1 means using the w-limited stage as
     515    // computed by the gradient limiter (both 1st or 2nd order)
    516516    if (tight_slope_limiters == 0) {     
    517       //If hmin > dz/alpha_balance then alpha = 1 and the bed will have no
    518       //effect
    519       //If hmin < 0 then alpha = 0 reverting to constant height above bed.
    520       //The parameter alpha_balance==2 by default
     517      // If hmin > dz/alpha_balance then alpha = 1 and the bed will have no
     518      // effect
     519      // If hmin < 0 then alpha = 0 reverting to constant height above bed.
     520      // The parameter alpha_balance==2 by default
    521521
    522522     
     
    524524        alpha = max( min( alpha_balance*hmin/dz, 1.0), 0.0 );     
    525525      } else {
    526         alpha = 1.0;  //Flat bed
     526        alpha = 1.0;  // Flat bed
    527527      }
    528528      //printf("Using old style limiter\n");
     
    530530    } else {
    531531
    532       // 2007 Balanced Limiter
     532      // Tight Slope Limiter (2007)
    533533   
    534534      // Make alpha as large as possible but still ensure that
     
    591591        wv[k3+i] = zv[k3+i] + (1-alpha)*hvbar[k3+i] + alpha*hv[k3+i];
    592592
    593         //Update momentum as a linear combination of
    594         //xmomc and ymomc (shallow) and momentum
    595         //from extrapolator xmomv and ymomv (deep).
    596         //FIXME (Ole): Is this really needed?
     593        // Update momentum as a linear combination of
     594        // xmomc and ymomc (shallow) and momentum
     595        // from extrapolator xmomv and ymomv (deep).
     596        // FIXME (Ole): Is this really needed?
    597597        xmomv[k3+i] = (1-alpha)*xmomc[k] + alpha*xmomv[k3+i];
    598598        ymomv[k3+i] = (1-alpha)*ymomc[k] + alpha*ymomv[k3+i];
     
    618618  double u, v, reduced_speed;
    619619
    620   //Protect against initesimal and negative heights
     620  // Protect against initesimal and negative heights
    621621  for (k=0; k<N; k++) {
    622622    hc = wc[k] - zc[k];
Note: See TracChangeset for help on using the changeset viewer.