Ignore:
Timestamp:
Sep 8, 2010, 5:12:10 PM (15 years ago)
Author:
steve
Message:

Slight conflict with init.py due to addition of hole_tags

File:
1 edited

Legend:

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

    r7952 r8009  
    587587        //S /= h*h*(1 + h/3.0 - h*h/9.0); //FIXME: Could use a Taylor expansion
    588588
     589
     590        //Update momentum
     591        xmom_update[k] += S*uh[k];
     592        ymom_update[k] += S*vh[k];
     593      }
     594    }
     595  }
     596}
     597
     598
     599
     600void _chezy_friction(double g, double eps, int N,
     601                           double* x, double* w, double* zv,
     602                           double* uh, double* vh,
     603                           double* chezy, double* xmom_update, double* ymom_update) {
     604
     605  int k, k3, k6;
     606  double S, h, z, z0, z1, z2, zs, zx, zy;
     607  double x0,y0,x1,y1,x2,y2;
     608
     609  for (k=0; k<N; k++) {
     610    if (chezy[k] > eps) {
     611      k3 = 3*k;
     612      // Get bathymetry
     613      z0 = zv[k3 + 0];
     614      z1 = zv[k3 + 1];
     615      z2 = zv[k3 + 2];
     616
     617      // Compute bed slope
     618      k6 = 6*k;  // base index
     619
     620      x0 = x[k6 + 0];
     621      y0 = x[k6 + 1];
     622      x1 = x[k6 + 2];
     623      y1 = x[k6 + 3];
     624      x2 = x[k6 + 4];
     625      y2 = x[k6 + 5];
     626
     627      _gradient(x0, y0, x1, y1, x2, y2, z0, z1, z2, &zx, &zy);
     628
     629      zs = sqrt(1.0 + zx*zx + zy*zy);
     630      z = (z0+z1+z2)/3.0;
     631      h = w[k]-z;
     632      if (h >= eps) {
     633        S = -g * chezy[k] * zs * sqrt((uh[k]*uh[k] + vh[k]*vh[k]));
     634        S /= pow(h, 2.0);
    589635
    590636        //Update momentum
     
    11311177                        (double*) vh -> data,
    11321178                        (double*) eta -> data,
     1179                        (double*) xmom -> data,
     1180                        (double*) ymom -> data);
     1181
     1182  return Py_BuildValue("");
     1183}
     1184
     1185
     1186PyObject *chezy_friction(PyObject *self, PyObject *args) {
     1187  //
     1188  // chezy_friction(g, eps, x, h, uh, vh, z, chezy, xmom_update, ymom_update)
     1189  //
     1190
     1191
     1192  PyArrayObject *x, *w, *z, *uh, *vh, *chezy, *xmom, *ymom;
     1193  int N;
     1194  double g, eps;
     1195
     1196  if (!PyArg_ParseTuple(args, "ddOOOOOOOO",
     1197                        &g, &eps, &x, &w, &uh, &vh, &z,  &chezy, &xmom, &ymom)) {
     1198    PyErr_SetString(PyExc_RuntimeError, "shallow_water_ext.c: chezy_friction could not parse input arguments");
     1199    return NULL;
     1200  }
     1201
     1202  // check that numpy array objects arrays are C contiguous memory
     1203  CHECK_C_CONTIG(x);
     1204  CHECK_C_CONTIG(w);
     1205  CHECK_C_CONTIG(z);
     1206  CHECK_C_CONTIG(uh);
     1207  CHECK_C_CONTIG(vh);
     1208  CHECK_C_CONTIG(chezy);
     1209  CHECK_C_CONTIG(xmom);
     1210  CHECK_C_CONTIG(ymom);
     1211
     1212  N = w -> dimensions[0];
     1213
     1214  _chezy_friction(g, eps, N,
     1215                        (double*) x -> data,
     1216                        (double*) w -> data,
     1217                        (double*) z -> data,
     1218                        (double*) uh -> data,
     1219                        (double*) vh -> data,
     1220                        (double*) chezy -> data,
    11331221                        (double*) xmom -> data,
    11341222                        (double*) ymom -> data);
     
    28182906  {"manning_friction_old", manning_friction_old, METH_VARARGS, "Print out"},
    28192907  {"manning_friction_new", manning_friction_new, METH_VARARGS, "Print out"},
     2908  {"chezy_friction", chezy_friction, METH_VARARGS, "Print out"},
    28202909  {"flux_function_central", flux_function_central, METH_VARARGS, "Print out"}, 
    28212910  {"balance_deep_and_shallow", balance_deep_and_shallow,
Note: See TracChangeset for help on using the changeset viewer.