Changeset 240 for inundation/ga/storm_surge/pyvolution/util.py
- Timestamp:
- Aug 30, 2004, 4:24:12 PM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/pyvolution/util.py
r198 r240 82 82 83 83 84 def rotate_python(q, normal, direction = 1):85 """Rotate the momentum component q (q[1], q[2])86 from x,y coordinates to coordinates based on normal vector.87 88 If direction is negative the rotation is inverted.89 90 Input vector is preserved91 92 This function is specific to the shallow water wave equation93 """94 95 #FIXME: Needs to be tested96 97 from Numeric import zeros, Float98 99 assert len(q) == 3,\100 'Vector of conserved quantities must have length 3'\101 'for 2D shallow water equation'102 103 try:104 l = len(normal)105 except:106 raise 'Normal vector must be an Numeric array'107 108 #FIXME: Put this test into C-extension as well109 assert l == 2, 'Normal vector must have 2 components'110 111 112 n1 = normal[0]113 n2 = normal[1]114 115 r = zeros(len(q), Float) #Rotated quantities116 r[0] = q[0] #First quantity, height, is not rotated117 118 if direction == -1:119 n2 = -n2120 121 122 r[1] = n1*q[1] + n2*q[2]123 r[2] = -n2*q[1] + n1*q[2]124 125 return r126 127 128 84 129 85 … … 133 89 import compile 134 90 if compile.can_use_C_extension('util_ext.c'): 135 from util_ext import gradient , rotate91 from util_ext import gradient 136 92 else: 137 93 gradient = gradient_python 138 rotate = rotate_python139 140 141 94 142 95
Note: See TracChangeset
for help on using the changeset viewer.