Changeset 515


Ignore:
Timestamp:
Nov 9, 2004, 10:41:43 PM (20 years ago)
Author:
ole
Message:

Identified potential optimisation in Manning friction using Taylor expansion

Location:
inundation/ga/storm_surge/pyvolution
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • inundation/ga/storm_surge/pyvolution/quantity_ext.c

    r514 r515  
    169169  double denominator, x;
    170170
     171 
    171172  //Divide semi_implicit update by conserved quantity 
    172173  for (k=0; k<N; k++) { 
  • inundation/ga/storm_surge/pyvolution/run_profile.py

    r479 r515  
    2020#
    2121
    22 N = 32
     22N = 16
    2323
    2424print 'Creating domain'
  • inundation/ga/storm_surge/pyvolution/shallow_water.py

    r514 r515  
    819819   
    820820    for k in range(N):
    821         if h[k] >= eps:
    822             S = -g * eta[k]**2 * sqrt((uh[k]**2 + vh[k]**2))
    823             S /= h[k]**(7.0/3)
    824 
    825             #Update momentum
    826             xmom_update[k] += S*uh[k]
    827             ymom_update[k] += S*vh[k]
     821        if eta[k] >= eps:
     822            if h[k] >= eps:
     823                S = -g * eta[k]**2 * sqrt((uh[k]**2 + vh[k]**2))
     824                S /= h[k]**(7.0/3)
     825
     826                #Update momentum
     827                xmom_update[k] += S*uh[k]
     828                ymom_update[k] += S*vh[k]
    828829           
    829830       
     
    838839    w = domain.quantities['level'].centroid_values
    839840    z = domain.quantities['elevation'].centroid_values
    840     h = w-z
     841   
    841842    uh = xmom.centroid_values
    842843    vh = ymom.centroid_values
     
    851852
    852853    from shallow_water_ext import manning_friction
    853     manning_friction(g, eps, h, uh, vh, eta, xmom_update, ymom_update)
     854    manning_friction(g, eps, w, z, uh, vh, eta, xmom_update, ymom_update)
    854855       
    855856
  • inundation/ga/storm_surge/pyvolution/shallow_water_ext.c

    r502 r515  
    156156       
    157157void _manning_friction(double g, double eps, int N,
    158                        double* h, double* uh, double* vh,
     158                       double* w, double* z,
     159                       double* uh, double* vh,
    159160                       double* eta, double* xmom, double* ymom) {     
    160161
    161162  int k;
    162   double S;
     163  double S, h;
    163164 
    164165  for (k=0; k<N; k++) {
    165     if (h[k] >= eps) {
    166       S = -g * eta[k]*eta[k] * sqrt((uh[k]*uh[k] + vh[k]*vh[k]));
    167       S /= pow(h[k], 7.0/3);     
    168 
    169       //Update momentum
    170       xmom[k] += S*uh[k];
    171       ymom[k] += S*vh[k];
     166    if (eta[k] > eps) {
     167      h = w[k]-z[k];
     168      if (h >= eps) {
     169        S = -g * eta[k]*eta[k] * sqrt((uh[k]*uh[k] + vh[k]*vh[k]));
     170        S /= pow(h, 7.0/3);      //Expensive
     171        //S /= h*h*(1 + h/3.0 - h*h/9.0);  //FIXME: Use a Taylor expansion
     172        //FIXME: This will save a lot of time
     173
     174        //Update momentum
     175        xmom[k] += S*uh[k];
     176        ymom[k] += S*vh[k];
     177      }
    172178    }
    173179  }
    174  
    175180}
    176181           
     
    344349 
    345350 
    346   PyArrayObject *h, *uh, *vh, *eta, *xmom, *ymom;
     351  PyArrayObject *w, *z, *uh, *vh, *eta, *xmom, *ymom;
    347352  int N;
    348353  double g, eps;
    349354   
    350   if (!PyArg_ParseTuple(args, "ddOOOOOO",
    351                         &g, &eps, &h, &uh, &vh, &eta,
     355  if (!PyArg_ParseTuple(args, "ddOOOOOOO",
     356                        &g, &eps, &w, &z, &uh, &vh, &eta,
    352357                        &xmom, &ymom)) 
    353358    return NULL; 
    354359
    355   N = h -> dimensions[0];   
     360  N = w -> dimensions[0];   
    356361  _manning_friction(g, eps, N,
    357                     (double*) h -> data,
     362                    (double*) w -> data,
     363                    (double*) z -> data,                   
    358364                    (double*) uh -> data,
    359365                    (double*) vh -> data,
Note: See TracChangeset for help on using the changeset viewer.