Ignore:
Timestamp:
Oct 30, 2007, 5:13:17 PM (16 years ago)
Author:
ole
Message:

Retired all Python code which is superseded by C implementations.
This has made the code base much smaller and there is less confusion when people try to understand the algorithms.

File:
1 edited

Legend:

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

    r4733 r4769  
    194194
    195195// Innermost flux function (using stage w=z+h)
    196 int flux_function_central(double *q_left, double *q_right,
    197                           double z_left, double z_right,
    198                           double n1, double n2,
    199                           double epsilon, double H0, double g,
    200                           double *edgeflux, double *max_speed) {
     196int _flux_function_central(double *q_left, double *q_right,
     197                           double z_left, double z_right,
     198                           double n1, double n2,
     199                           double epsilon, double H0, double g,
     200                           double *edgeflux, double *max_speed) {
    201201
    202202  /*Compute fluxes between volumes for the shallow water wave equation
     
    737737///////////////////////////////////////////////////////////////////
    738738// Gateways to Python
     739
     740
     741
     742PyObject *flux_function_central(PyObject *self, PyObject *args) {
     743  //
     744  // Gateway to innermost flux function.
     745  // This is only used by the unit tests as the c implementation is
     746  // normally called by compute_fluxes in this module.
     747
     748
     749  PyArrayObject *normal, *ql, *qr,  *edgeflux;
     750  double g, epsilon, max_speed, H0, zl, zr;
     751
     752  if (!PyArg_ParseTuple(args, "OOOddOddd",
     753                        &normal, &ql, &qr, &zl, &zr, &edgeflux,
     754                        &epsilon, &g, &H0)) {
     755    PyErr_SetString(PyExc_RuntimeError, "shallow_water_ext.c: flux_function_central could not parse input arguments");
     756    return NULL;
     757  }
     758
     759 
     760  _flux_function_central((double*) ql -> data,
     761                         (double*) qr -> data,
     762                         zl,
     763                         zr,                                             
     764                         ((double*) normal -> data)[0],                                                                         
     765                         ((double*) normal -> data)[1],                 
     766                         epsilon, H0, g,
     767                         (double*) edgeflux -> data,
     768                         &max_speed);
     769 
     770  return Py_BuildValue("d", max_speed); 
     771}
     772
     773
    739774
    740775PyObject *gravity(PyObject *self, PyObject *args) {
     
    14941529  } 
    14951530
    1496   //Input checks (convert sequences into numeric arrays)
     1531  // Input checks (convert sequences into numeric arrays)
    14971532  q = (PyArrayObject *)
    14981533    PyArray_ContiguousFromObject(Q, PyArray_DOUBLE, 0, 0);
     
    15061541  }
    15071542
    1508   //Allocate space for return vector r (don't DECREF)
     1543  // Allocate space for return vector r (don't DECREF)
    15091544  dimensions[0] = 3;
    15101545  r = (PyArrayObject *) PyArray_FromDims(1, dimensions, PyArray_DOUBLE);
    15111546
    1512   //Copy
     1547  // Copy
    15131548  for (i=0; i<3; i++) {
    15141549    ((double *) (r -> data))[i] = ((double *) (q -> data))[i];
    15151550  }
    15161551
    1517   //Get normal and direction
     1552  // Get normal and direction
    15181553  n1 = ((double *) normal -> data)[0];
    15191554  n2 = ((double *) normal -> data)[1];
    15201555  if (direction == -1) n2 = -n2;
    15211556
    1522   //Rotate
     1557  // Rotate
    15231558  _rotate((double *) r -> data, n1, n2);
    15241559
    1525   //Release numeric arrays
     1560  // Release numeric arrays
    15261561  Py_DECREF(q);
    15271562  Py_DECREF(normal);
    15281563
    1529   //return result using PyArray to avoid memory leak
     1564  // Return result using PyArray to avoid memory leak
    15301565  return PyArray_Return(r);
    15311566}
     
    16421677
    16431678      // Edge flux computation (triangle k, edge i)
    1644       flux_function_central(ql, qr, zl, zr,
    1645                             normals[ki2], normals[ki2+1],
    1646                             epsilon, H0, g,
    1647                             edgeflux, &max_speed);
     1679      _flux_function_central(ql, qr, zl, zr,
     1680                             normals[ki2], normals[ki2+1],
     1681                             epsilon, H0, g,
     1682                             edgeflux, &max_speed);
    16481683     
    16491684     
     
    18981933    *xmom_explicit_update,
    18991934    *ymom_explicit_update,
    1900     *already_computed_flux;//tracks whether the flux across an edge has already been computed
    1901 
    1902 
    1903   //Local variables
     1935    *already_computed_flux; // Tracks whether the flux across an edge has already been computed
     1936
     1937
     1938  // Local variables
    19041939  double timestep, max_speed, epsilon, g, H0;
    19051940  double normal[2], ql[3], qr[3], zl, zr;
     
    20602095
    20612096PyObject *balance_deep_and_shallow(PyObject *self, PyObject *args) {
     2097  // Compute linear combination between stage as computed by
     2098  // gradient-limiters limiting using w, and stage computed by
     2099  // gradient-limiters limiting using h (h-limiter).
     2100  // The former takes precedence when heights are large compared to the
     2101  // bed slope while the latter takes precedence when heights are
     2102  // relatively small.  Anything in between is computed as a balanced
     2103  // linear combination in order to avoid numerical disturbances which
     2104  // would otherwise appear as a result of hard switching between
     2105  // modes.
    20622106  //
    20632107  //    balance_deep_and_shallow(beta_h, wc, zc, wv, zv,
     
    21602204  int k, i, n, N, k3;
    21612205  int dimensions[2];
    2162   double beta_h; //Safety factor (see config.py)
     2206  double beta_h; // Safety factor (see config.py)
    21632207  double *hmin, *hmax, hn;
    21642208
     
    22012245      n = ((long*) neighbours -> data)[k3+i];
    22022246
    2203       //Initialise hvbar with values from hv
     2247      // Initialise hvbar with values from hv
    22042248      ((double*) hvbar -> data)[k3+i] = ((double*) hv -> data)[k3+i];
    22052249
    22062250      if (n >= 0) {
    2207         hn = ((double*) hc -> data)[n]; //Neighbour's centroid value
     2251        hn = ((double*) hc -> data)[n]; // Neighbour's centroid value
    22082252
    22092253        hmin[k] = min(hmin[k], hn);
     
    22162260  _limit(N, beta_h, (double*) hc -> data, (double*) hvbar -> data, hmin, hmax);
    22172261
    2218   // // //Py_DECREF(domain); //FIXME: NEcessary?
     2262  // // //Py_DECREF(domain); //FIXME: Necessary?
    22192263  free(hmin);
    22202264  free(hmax);
    22212265
    2222   //return result using PyArray to avoid memory leak
     2266  // Return result using PyArray to avoid memory leak
    22232267  return PyArray_Return(hvbar);
    2224   //return Py_BuildValue("");
    22252268}
    22262269
     
    23372380
    23382381
    2339 //////////////////////////////////////////
     2382//-------------------------------
    23402383// Method table for python module
     2384//-------------------------------
    23412385static struct PyMethodDef MethodTable[] = {
    23422386  /* The cast of the function is necessary since PyCFunction values
     
    23512395  {"gravity", gravity, METH_VARARGS, "Print out"},
    23522396  {"manning_friction", manning_friction, METH_VARARGS, "Print out"},
     2397  {"flux_function_central", flux_function_central, METH_VARARGS, "Print out"}, 
    23532398  {"balance_deep_and_shallow", balance_deep_and_shallow,
    23542399   METH_VARARGS, "Print out"},
     
    23602405  {"assign_windfield_values", assign_windfield_values,
    23612406   METH_VARARGS | METH_KEYWORDS, "Print out"},
    2362   //{"distribute_to_vertices_and_edges",
    2363   // distribute_to_vertices_and_edges, METH_VARARGS},
    2364   //{"update_conserved_quantities",
    2365   // update_conserved_quantities, METH_VARARGS},
    2366   //{"set_initialcondition",
    2367   // set_initialcondition, METH_VARARGS},
    23682407  {NULL, NULL}
    23692408};
Note: See TracChangeset for help on using the changeset viewer.