Ignore:
Timestamp:
Aug 30, 2004, 4:24:12 PM (21 years ago)
Author:
ole
Message:

Added C implementation of compute_fluxes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/ga/storm_surge/pyvolution/util.py

    r198 r240  
    8282
    8383
    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 preserved
    91 
    92     This function is specific to the shallow water wave equation
    93     """
    94 
    95     #FIXME: Needs to be tested
    96 
    97     from Numeric import zeros, Float
    98    
    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 well
    109     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 quantities
    116     r[0] = q[0]              #First quantity, height, is not rotated
    117 
    118     if direction == -1:
    119         n2 = -n2
    120 
    121 
    122     r[1] =  n1*q[1] + n2*q[2]
    123     r[2] = -n2*q[1] + n1*q[2]
    124    
    125     return r
    126 
    127 
    12884
    12985
     
    13389import compile
    13490if compile.can_use_C_extension('util_ext.c'):
    135     from util_ext import gradient, rotate
     91    from util_ext import gradient
    13692else:
    13793    gradient = gradient_python
    138     rotate = rotate_python
    139 
    140 
    14194
    14295
Note: See TracChangeset for help on using the changeset viewer.