Ignore:
Timestamp:
Sep 11, 2007, 4:21:48 PM (17 years ago)
Author:
ole
Message:

More minor optimisations of flux calculations.

File:
1 edited

Legend:

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

    r4726 r4727  
    3737  double q1, q2;
    3838
    39   //Shorthands
    40   q1 = q[1];  //uh momentum
    41   q2 = q[2];  //vh momentum
    42 
    43   //Rotate
     39  // Shorthands
     40  q1 = q[1];  // uh momentum
     41  q2 = q[2];  // vh momentum
     42
     43  // Rotate
    4444  q[1] =  n1*q1 + n2*q2;
    4545  q[2] = -n2*q1 + n1*q2;
     
    213213  double s_min, s_max, soundspeed_left, soundspeed_right;
    214214  double denom, z;
    215  
    216   // FIXME (Ole): Try making these static
    217   double q_left_rotated[3], q_right_rotated[3];
    218   double flux_right[3], flux_left[3];
     215
     216  // Workspace (allocate once, use many)
     217  static double q_left_rotated[3], q_right_rotated[3], flux_right[3], flux_left[3];
    219218
    220219  double h0 = H0*H0; // This ensures a good balance when h approaches H0.
     
    14021401                               
    14031402  // Local variables
    1404   double max_speed, length, area;
    1405  
    1406   // FIXME (Ole): Try making arrays static 
    1407   double normal[2], ql[3], qr[3], zl, zr;
    1408   double edgeflux[3]; // Work array for summing up fluxes
    1409 
     1403  double max_speed, length, area, zl, zr;
    14101404  int k, i, m, n;
    1411 
    14121405  int ki, nm=0, ki2; // Index shorthands
     1406 
     1407  // Workspace (making them static actually made function slightly slower (Ole)) 
     1408  double ql[3], qr[3], edgeflux[3]; // Work array for summing up fluxes
     1409
    14131410  static long call=1; // Static local variable flagging already computed flux
    14141411                               
     
    14401437      ql[1] = xmom_edge_values[ki];
    14411438      ql[2] = ymom_edge_values[ki];
    1442       zl =    bed_edge_values[ki];
     1439      zl = bed_edge_values[ki];
    14431440
    14441441      // Quantities at neighbour on nearest face
     
    14841481      // Outward pointing normal vector (domain.normals[k, 2*i:2*i+2])
    14851482      ki2 = 2*ki; //k*6 + i*2
    1486       normal[0] = normals[ki2];
    1487       normal[1] = normals[ki2+1];
    1488      
    14891483
    14901484      // Edge flux computation (triangle k, edge i)
    14911485      flux_function_central(ql, qr, zl, zr,
    1492                             normal[0], normal[1],
     1486                            normals[ki2], normals[ki2+1],
    14931487                            epsilon, H0, g,
    14941488                            edgeflux, &max_speed);
Note: See TracChangeset for help on using the changeset viewer.