Changeset 8129
- Timestamp:
- Mar 8, 2011, 9:47:19 PM (14 years ago)
- Location:
- trunk/anuga_core
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/compile_all.py
r7934 r8129 21 21 os.chdir('..') 22 22 os.chdir('advection') 23 execfile('..' + os.sep + 'utilities' + os.sep + 'compile.py') 24 25 os.chdir('..') 26 os.chdir('operators') 27 execfile('..' + os.sep + 'utilities' + os.sep + 'compile.py') 28 29 os.chdir('..') 30 os.chdir('structures') 23 31 execfile('..' + os.sep + 'utilities' + os.sep + 'compile.py') 24 32 -
trunk/anuga_core/source/anuga/__init__.py
r8124 r8129 320 320 #psyco.background() # attempt to profile code - only compile most used 321 321 322 322 323 #--------------------------- 324 # Operators 325 #--------------------------- 326 from anuga.operators.operator import Operator 327 323 328 #--------------------------- 324 329 # Structures -
trunk/anuga_core/source/anuga/compile_all.py
r7865 r8129 12 12 os.chdir('..') 13 13 os.chdir('advection') 14 execfile('..' + os.sep + 'utilities' + os.sep + 'compile.py') 15 16 os.chdir('..') 17 os.chdir('operators') 18 execfile('..' + os.sep + 'utilities' + os.sep + 'compile.py') 19 20 os.chdir('..') 21 os.chdir('structures') 14 22 execfile('..' + os.sep + 'utilities' + os.sep + 'compile.py') 15 23 -
trunk/anuga_core/source/anuga/shallow_water/shallow_water_ext.c
r8047 r8129 71 71 if (dq1>=dq2){ 72 72 if (dq1>=0.0) 73 73 *qmax=dq0+dq1; 74 74 else 75 75 *qmax=dq0; 76 76 77 77 *qmin=dq0+dq2; … … 80 80 else{// dq1<dq2 81 81 if (dq2>0) 82 82 *qmax=dq0+dq2; 83 83 else 84 84 *qmax=dq0; 85 85 86 86 *qmin=dq0+dq1; … … 91 91 if (dq1<=dq2){ 92 92 if (dq1<0.0) 93 93 *qmin=dq0+dq1; 94 94 else 95 95 *qmin=dq0; 96 96 97 97 *qmax=dq0+dq2; … … 100 100 else{// dq1>dq2 101 101 if (dq2<0.0) 102 102 *qmin=dq0+dq2; 103 103 else 104 104 *qmin=dq0; 105 105 106 106 *qmax=dq0+dq1; … … 175 175 //static inline double _compute_speed(double *uh, 176 176 double _compute_speed(double *uh, 177 double *h, 178 double epsilon, 179 180 177 double *h, 178 double epsilon, 179 double h0, 180 double limiting_threshold) { 181 181 182 182 double u; … … 263 263 double n1, double n2, 264 264 double epsilon, 265 266 double limiting_threshold, 267 265 double h0, 266 double limiting_threshold, 267 double g, 268 268 double *edgeflux, double *max_speed) 269 269 { … … 304 304 z = 0.5*(z_left + z_right); // Average elevation values. 305 305 // Even though this will nominally allow 306 // for discontinuities in the elevation data, 307 308 // this so results may be strange near 309 306 // for discontinuities in the elevation data, 307 // there is currently no numerical support for 308 // this so results may be strange near 309 // jumps in the bed. 310 310 311 311 // Compute speeds in x-direction … … 314 314 uh_left = q_left_rotated[1]; 315 315 u_left = _compute_speed(&uh_left, &h_left, 316 316 epsilon, h0, limiting_threshold); 317 317 318 318 w_right = q_right_rotated[0]; … … 320 320 uh_right = q_right_rotated[1]; 321 321 u_right = _compute_speed(&uh_right, &h_right, 322 322 epsilon, h0, limiting_threshold); 323 323 324 324 // Momentum in y-direction … … 330 330 // All validation tests pass, so do we really need it anymore? 331 331 _compute_speed(&vh_left, &h_left, 332 332 epsilon, h0, limiting_threshold); 333 333 _compute_speed(&vh_right, &h_right, 334 334 epsilon, h0, limiting_threshold); 335 335 336 336 // Maximal and minimal wave speeds … … 459 459 uh_left = q_left_rotated[1]; 460 460 u_left =_compute_speed(&uh_left, &h_left, 461 461 epsilon, h0, limiting_threshold); 462 462 463 463 w_right = q_right_rotated[0]; … … 465 465 uh_right = q_right_rotated[1]; 466 466 u_right =_compute_speed(&uh_right, &h_right, 467 467 epsilon, h0, limiting_threshold); 468 468 469 469 … … 553 553 554 554 void _manning_friction_sloped(double g, double eps, int N, 555 556 557 555 double* x, double* w, double* zv, 556 double* uh, double* vh, 557 double* eta, double* xmom_update, double* ymom_update) { 558 558 559 559 int k, k3, k6; … … 602 602 603 603 void _chezy_friction(double g, double eps, int N, 604 605 606 604 double* x, double* w, double* zv, 605 double* uh, double* vh, 606 double* chezy, double* xmom_update, double* ymom_update) { 607 607 608 608 int k, k3, k6; … … 785 785 // FIXME: Try with this one precomputed 786 786 for (i=0; i<3; i++) { 787 787 dz = max(dz, fabs(zv[k3+i]-zc[k])); 788 788 } 789 789 } … … 813 813 814 814 if (dz > 0.0) { 815 alpha = max( min( alpha_balance*hmin/dz, 1.0), 0.0 ); 815 alpha = max( min( alpha_balance*hmin/dz, 1.0), 0.0 ); 816 816 } else { 817 817 alpha = 1.0; // Flat bed 818 818 } 819 819 //printf("Using old style limiter\n"); … … 828 828 829 829 if (hmin < H0) { 830 alpha = 1.0; 831 for (i=0; i<3; i++) { 832 833 h_diff = hc_k - hv[i]; 834 if (h_diff <= 0) { 835 // Deep water triangle is further away from bed than 836 // shallow water (hbar < h). Any alpha will do 837 838 } else { 839 // Denominator is positive which means that we need some of the 840 // h-limited stage. 841 842 alpha = min(alpha, (hc_k - H0)/h_diff); 843 } 844 } 845 846 // Ensure alpha in [0,1] 847 if (alpha>1.0) alpha=1.0; 848 if (alpha<0.0) alpha=0.0; 849 830 alpha = 1.0; 831 for (i=0; i<3; i++) { 832 833 h_diff = hc_k - hv[i]; 834 if (h_diff <= 0) { 835 // Deep water triangle is further away from bed than 836 // shallow water (hbar < h). Any alpha will do 837 850 838 } else { 851 // Use w-limited stage exclusively in deeper water. 852 alpha = 1.0; 839 // Denominator is positive which means that we need some of the 840 // h-limited stage. 841 842 alpha = min(alpha, (hc_k - H0)/h_diff); 843 } 844 } 845 846 // Ensure alpha in [0,1] 847 if (alpha>1.0) alpha=1.0; 848 if (alpha<0.0) alpha=0.0; 849 850 } else { 851 // Use w-limited stage exclusively in deeper water. 852 alpha = 1.0; 853 853 } 854 854 } … … 875 875 if (alpha < 1) { 876 876 for (i=0; i<3; i++) { 877 878 wv[k3+i] = zv[k3+i] + (1-alpha)*hc_k + alpha*hv[i]; 879 880 881 882 883 884 877 878 wv[k3+i] = zv[k3+i] + (1-alpha)*hc_k + alpha*hv[i]; 879 880 // Update momentum at vertices 881 if (use_centroid_velocities == 1) { 882 // This is a simple, efficient and robust option 883 // It uses first order approximation of velocities, but retains 884 // the order used by stage. 885 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 // computed above using centroid_velocities instead of xmomc 910 911 912 913 914 915 916 886 // Speeds at centroids 887 if (hc_k > epsilon) { 888 uc = xmomc[k]/hc_k; 889 vc = ymomc[k]/hc_k; 890 } else { 891 uc = 0.0; 892 vc = 0.0; 893 } 894 895 // Vertex momenta guaranteed to be consistent with depth guaranteeing 896 // controlled speed 897 hv[i] = wv[k3+i] - zv[k3+i]; // Recompute (balanced) vertex depth 898 xmomv[k3+i] = uc*hv[i]; 899 ymomv[k3+i] = vc*hv[i]; 900 901 } else { 902 // Update momentum as a linear combination of 903 // xmomc and ymomc (shallow) and momentum 904 // from extrapolator xmomv and ymomv (deep). 905 // This assumes that values from xmomv and ymomv have 906 // been established e.g. by the gradient limiter. 907 908 // FIXME (Ole): I think this should be used with vertex momenta 909 // computed above using centroid_velocities instead of xmomc 910 // and ymomc as they'll be more representative first order 911 // values. 912 913 xmomv[k3+i] = (1-alpha)*xmomc[k] + alpha*xmomv[k3+i]; 914 ymomv[k3+i] = (1-alpha)*ymomc[k] + alpha*ymomv[k3+i]; 915 916 } 917 917 } 918 918 } … … 945 945 if (hc < minimum_allowed_height) { 946 946 947 948 949 950 947 // Set momentum to zero and ensure h is non negative 948 xmomc[k] = 0.0; 949 ymomc[k] = 0.0; 950 if (hc <= 0.0) wc[k] = zc[k]; 951 951 } 952 952 } … … 968 968 } else { 969 969 //Reduce excessive speeds derived from division by small hc 970 //FIXME (Ole): This may be unnecessary with new slope limiters 971 970 //FIXME (Ole): This may be unnecessary with new slope limiters 971 //in effect. 972 972 973 973 u = xmomc[k]/hc; 974 975 976 977 978 979 980 974 if (fabs(u) > maximum_allowed_speed) { 975 reduced_speed = maximum_allowed_speed * u/fabs(u); 976 //printf("Speed (u) has been reduced from %.3f to %.3f\n", 977 // u, reduced_speed); 978 xmomc[k] = reduced_speed * hc; 979 } 980 981 981 v = ymomc[k]/hc; 982 983 984 985 986 987 982 if (fabs(v) > maximum_allowed_speed) { 983 reduced_speed = maximum_allowed_speed * v/fabs(v); 984 //printf("Speed (v) has been reduced from %.3f to %.3f\n", 985 // v, reduced_speed); 986 ymomc[k] = reduced_speed * hc; 987 } 988 988 } 989 989 } … … 1056 1056 // But evidence suggests that h0 can be as little as 1057 1057 // epsilon! 1058 1058 1059 1059 limiting_threshold = 10*H0; // Avoid applying limiter below this 1060 1060 // threshold for performance reasons. … … 1062 1062 1063 1063 _flux_function_central((double*) ql -> data, 1064 (double*) qr -> data, 1065 zl, 1066 zr, 1067 1068 ((double*) normal -> data)[1], 1069 1070 1071 (double*) edgeflux -> data, 1072 1064 (double*) qr -> data, 1065 zl, 1066 zr, 1067 ((double*) normal -> data)[0], 1068 ((double*) normal -> data)[1], 1069 epsilon, h0, limiting_threshold, 1070 g, 1071 (double*) edgeflux -> data, 1072 &max_speed); 1073 1073 1074 1074 return Py_BuildValue("d", max_speed); … … 1156 1156 1157 1157 if (!PyArg_ParseTuple(args, "ddOOOOOOOO", 1158 1158 &g, &eps, &x, &w, &uh, &vh, &z, &eta, &xmom, &ymom)) { 1159 1159 report_python_error(AT, "could not parse input arguments"); 1160 1160 return NULL; … … 1174 1174 1175 1175 _manning_friction_sloped(g, eps, N, 1176 1177 1178 1179 1180 1181 1182 1183 1176 (double*) x -> data, 1177 (double*) w -> data, 1178 (double*) z -> data, 1179 (double*) uh -> data, 1180 (double*) vh -> data, 1181 (double*) eta -> data, 1182 (double*) xmom -> data, 1183 (double*) ymom -> data); 1184 1184 1185 1185 return Py_BuildValue(""); … … 1198 1198 1199 1199 if (!PyArg_ParseTuple(args, "ddOOOOOOOO", 1200 1200 &g, &eps, &x, &w, &uh, &vh, &z, &chezy, &xmom, &ymom)) { 1201 1201 report_python_error(AT, "could not parse input arguments"); 1202 1202 return NULL; … … 1216 1216 1217 1217 _chezy_friction(g, eps, N, 1218 1219 1220 1221 1222 1223 1224 1225 1218 (double*) x -> data, 1219 (double*) w -> data, 1220 (double*) z -> data, 1221 (double*) uh -> data, 1222 (double*) vh -> data, 1223 (double*) chezy -> data, 1224 (double*) xmom -> data, 1225 (double*) ymom -> data); 1226 1226 1227 1227 return Py_BuildValue(""); … … 1240 1240 1241 1241 if (!PyArg_ParseTuple(args, "ddOOOOOOO", 1242 1242 &g, &eps, &w, &uh, &vh, &z, &eta, &xmom, &ymom)) { 1243 1243 report_python_error(AT, "could not parse input arguments"); 1244 1244 return NULL; … … 1257 1257 1258 1258 _manning_friction_flat(g, eps, N, 1259 1260 1261 1262 1263 1264 1265 1259 (double*) w -> data, 1260 (double*) z -> data, 1261 (double*) uh -> data, 1262 (double*) vh -> data, 1263 (double*) eta -> data, 1264 (double*) xmom -> data, 1265 (double*) ymom -> data); 1266 1266 1267 1267 return Py_BuildValue(""); … … 1484 1484 dq2 = stage_centroid_values[k2] - stage_centroid_values[k0]; 1485 1485 1486 1486 inv_area2 = 1.0/area2; 1487 1487 // Calculate the gradient of stage on the auxiliary triangle 1488 1488 a = dy2*dq1 - dy1*dq2; … … 1517 1517 //for (i=0;i<3;i++) 1518 1518 stage_vertex_values[k3+0] = stage_centroid_values[k] + dqv[0]; 1519 1520 1519 stage_vertex_values[k3+1] = stage_centroid_values[k] + dqv[1]; 1520 stage_vertex_values[k3+2] = stage_centroid_values[k] + dqv[2]; 1521 1521 1522 1522 -
trunk/anuga_core/source/anuga/structures/structure_operator.py
r8095 r8129 6 6 from anuga.utilities.system_tools import log_to_file 7 7 from anuga.utilities.numerical_tools import ensure_numeric 8 9 10 11 class Structure_operator: 8 from anuga.operators.operator import Operator 9 10 11 12 class Structure_operator(anuga.Operator): 12 13 """Structure Operator - transfer water from one rectangular box to another. 13 14 Sets up the geometry of problem … … 37 38 logging, 38 39 verbose): 39 40 self.domain = domain41 self.domain.set_fractional_step_operator(self)40 41 anuga.Operator.__init__(self,domain) 42 42 43 self.end_points = ensure_numeric(end_points) 43 44 self.exchange_lines = ensure_numeric(exchange_lines) 44 45 self.enquiry_points = ensure_numeric(enquiry_points) 45 46 47 if domain.numproc > 1:48 msg = 'Not implemented to run in parallel'49 assert self.__parallel_safe(), msg50 46 51 47 … … 259 255 self.enquiry_points.append(centre_point1 + gap) 260 256 261 262 def __parallel_safe(self):263 264 return False265 257 266 258 def discharge_routine(self): -
trunk/anuga_core/source/anuga/structures/test_boyd_box_operator.py
r8073 r8129 3 3 4 4 import unittest 5 import os.path 6 import sys 7 8 from anuga.utilities.system_tools import get_pathname_from_package 5 6 9 7 from anuga.structures.boyd_box_operator import Boyd_box_operator 10 8 from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross 11 9 from anuga.shallow_water.shallow_water_domain import Domain 12 from anuga.shallow_water.forcing import Rainfall, Inflow13 10 import numpy 14 11 -
trunk/anuga_core/source/anuga/structures/test_inlet_operator.py
r8094 r8129 155 155 finaltime = 3.0 156 156 line1 = [[95.0, 10.0], [105.0, 10.0]] 157 Q1 = file_function('inlet_operator_test1.tms', quantities=['hydrograph']) 157 158 159 import os 160 baseDir = os.getcwd() 161 162 try: 163 os.chdir('structures') 164 except: 165 pass 166 167 Q1 = file_function(filename='inlet_operator_test1.tms', quantities=['hydrograph']) 158 168 159 169 line2 = [[10.0, 90.0], [20.0, 90.0]] 160 Q2 = file_function('inlet_operator_test2.tms', quantities=['hydrograph']) 170 Q2 = file_function(filename='inlet_operator_test2.tms', quantities=['hydrograph']) 171 172 os.chdir(baseDir) 161 173 162 174 Inlet_operator(domain, line1, Q1) -
trunk/anuga_core/source/anuga/test_all.py
r8099 r8129 23 23 24 24 # Directories that should not be searched for test files. 25 exclude_dirs = [' pypar_dist', 'shallow_water_balanced', 'structures', # Special requirements25 exclude_dirs = ['shallow_water_balanced', 'operators' , # Special requirements 26 26 '.svn', # subversion 27 27 'props', 'wcprops', 'prop-base', 'text-base', 'tmp']
Note: See TracChangeset
for help on using the changeset viewer.