Changeset 258 for inundation/ga/storm_surge/pyvolution/quantity_ext.c
- Timestamp:
- Sep 1, 2004, 2:31:48 AM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/pyvolution/quantity_ext.c
r255 r258 14 14 #include "math.h" 15 15 16 17 //FIXME: Should live in util_ext.c 18 double max(double x, double y) { 19 //Return maximum of two doubles 20 21 if (x > y) return x; 22 else return y; 23 } 24 25 double min(double x, double y) { 26 //Return minimum of two doubles 27 28 if (x < y) return x; 29 else return y; 30 } 31 32 33 void _limit(int N, double beta, double* qc, double* qv, 34 double* qmin, double* qmax) { 35 36 int k, i, k3; 37 double dq, dqa[3], phi, r; 38 39 for (k=0; k<N; k++) { 40 k3 = k*3; 41 42 //Find the gradient limiter (phi) across vertices 43 phi = 1.0; 44 for (i=0; i<3; i++) { 45 r = 1.0; 46 47 dq = qv[k3+i] - qc[k]; //Delta between vertex and centroid values 48 dqa[i] = dq; //Save dq for use in the next loop 49 50 if (dq > 0.0) r = (qmax[k] - qc[k])/dq; 51 if (dq < 0.0) r = (qmin[k] - qc[k])/dq; 52 53 54 phi = min( min(r*beta, 1.0), phi); 55 } 56 57 //Then update using phi limiter 58 for (i=0; i<3; i++) { 59 qv[k3+i] = qc[k] + phi*dqa[i]; 60 } 61 } 62 } 16 //Shared code snippets 17 #include "util_ext.h" 18 #include "quantity_ext.h" 63 19 64 20 /////////////////////////////////////////////////
Note: See TracChangeset
for help on using the changeset viewer.