ls_python/spatialDerivative.py
def upwindFirstWENO5(data, dim, grid):
    '''
    Fifth order accurate weighted ENO derivatives
    
    data: 2d or 3d Numpy array
    dim: dimension on which gradients are to be calculated
        I assume dim 0 is x -> so axis 1 in a numpy array
                 dim 1 is y -> axis 0 in numpy array
                 dim 3 is z (same)
        
    grid: grid object - here is used mainly for storing grid spacing, dx
    
    returns: upwind derivative phi_{dim}_plus, downwind derivative phi_{dim}_minus
    '''
    if dim == 0:
        axis = 1
    elif dim == 1:
        axis = 0
    else:
        axis = dim
        
    D1_minus_half = np.diff(data, prepend=1,axis=axis)/grid.dx #phi(i,j) - phi(i-1,j)
    D1_minus_3_2 = np.roll(D1_minus_half, 1, axis=axis) #phi(i-1,j) - phi(i-2,j)
    D1_minus_5_2 = np.roll(D1_minus_half, 2, axis=axis)#phi(i-2,j) - phi(i-3,j)
    
    D1_plus_half = np.roll(D1_minus_half, -1, axis=axis) #phi(i+1,j) - phi(i,j)
    D1_plus_3_2 = np.roll(D1_minus_half, -2, axis=axis) #phi(i+2,j) - phi(i+1,j)
    D1_plus_5_2 = np.roll(D1_minus_half, -3, axis=axis) #phi(i+3,j) - phi(i+2,j)
    
     
    # phi_minus
    v1 = D1_minus_5_2
    v2 = D1_minus_3_2
    v3 = D1_minus_half
    v4 = D1_plus_half
    v5 = D1_plus_3_2
    
    phi_dim_minus = getWENOApprox(v1, v2, v3, v4, v5)
    
    # phi_plus
    v1 = D1_plus_5_2
    v2 = D1_plus_3_2
    v3 = D1_plus_half
    v4 = D1_minus_half
    v5 = D1_minus_3_2
    
    phi_dim_plus = getWENOApprox(v1, v2, v3, v4, v5)
    
    return phi_dim_minus, phi_dim_plus

    Fifth order accurate weighted ENO derivatives
    
    data: 2d or 3d Numpy array
    dim: dimension on which gradients are to be calculated
        I assume dim 0 is x -> so axis 1 in a numpy array
                 dim 1 is y -> axis 0 in numpy array
                 dim 3 is z (same)
        
    grid: grid object - here is used mainly for storing grid spacing, dx
    
    returns: upwind derivative phi_{dim}_plus, downwind derivative phi_{dim}_minus
    
Fifth order accurate weighted ENO derivatives
data: 2d or 3d Numpy array
dim: dimension on which gradients are to be calculated
I assume dim 0 is x -> so axis 1 in a numpy array
dim 1 is y -> axis 0 in numpy array
dim 3 is z (same)

grid object - here is used mainly for storing grid spacing, dx

upwind derivative phi_{dim}_plus, downwind derivative phi_{dim}_minus
Fifth order accurate weighted ENO derivatives data : 2d or 3d Numpy array dim : dimension on which gradients are to be calculated I assume dim 0 is x - > so axis 1 in a numpy array dim 1 is y - > axis 0 in numpy array dim 3 is z ( same ) grid object - here is used mainly for storing grid spacing dx upwind derivative phi_ { dim } _plus downwind derivative phi_ { dim } _minus
def upwindFirstWENO5(data, dim, grid):
    if dim == 0:
        axis = 1
    elif dim == 1:
        axis = 0
    else:
        axis = dim
    D1_minus_half = np.diff(data, prepend=1,axis=axis)/grid.dx 
    D1_minus_3_2 = np.roll(D1_minus_half, 1, axis=axis) 
    D1_minus_5_2 = np.roll(D1_minus_half, 2, axis=axis)
    D1_plus_half = np.roll(D1_minus_half, -1, axis=axis) 
    D1_plus_3_2 = np.roll(D1_minus_half, -2, axis=axis) 
    D1_plus_5_2 = np.roll(D1_minus_half, -3, axis=axis) 
    v1 = D1_minus_5_2
    v2 = D1_minus_3_2
    v3 = D1_minus_half
    v4 = D1_plus_half
    v5 = D1_plus_3_2
    phi_dim_minus = getWENOApprox(v1, v2, v3, v4, v5)
    v1 = D1_plus_5_2
    v2 = D1_plus_3_2
    v3 = D1_plus_half
    v4 = D1_minus_half
    v5 = D1_minus_3_2
    phi_dim_plus = getWENOApprox(v1, v2, v3, v4, v5)
    return phi_dim_minus, phi_dim_plus
def upwindFirstWENO5 ( data , dim , grid ) : if dim == 0 : axis = 1 elif dim == 1 : axis = 0 else : axis = dim D1_minus_half = np . diff ( data , prepend = 1 , axis = axis ) / grid . dx D1_minus_3_2 = np . roll ( D1_minus_half , 1 , axis = axis ) D1_minus_5_2 = np . roll ( D1_minus_half , 2 , axis = axis ) D1_plus_half = np . roll ( D1_minus_half , - 1 , axis = axis ) D1_plus_3_2 = np . roll ( D1_minus_half , - 2 , axis = axis ) D1_plus_5_2 = np . roll ( D1_minus_half , - 3 , axis = axis ) v1 = D1_minus_5_2 v2 = D1_minus_3_2 v3 = D1_minus_half v4 = D1_plus_half v5 = D1_plus_3_2 phi_dim_minus = getWENOApprox ( v1 , v2 , v3 , v4 , v5 ) v1 = D1_plus_5_2 v2 = D1_plus_3_2 v3 = D1_plus_half v4 = D1_minus_half v5 = D1_minus_3_2 phi_dim_plus = getWENOApprox ( v1 , v2 , v3 , v4 , v5 ) return phi_dim_minus , phi_dim_plus
Fifth order accurate weighted ENO derivatives
data: 2d or 3d Numpy array
dim: dimension on which gradients are to be calculated
I assume dim 0 is x -> so axis 1 in a numpy array
dim 1 is y -> axis 0 in numpy array
dim 3 is z (same)
Fifth order accurate weighted ENO derivatives data : 2d or 3d Numpy array dim : dimension on which gradients are to be calculated I assume dim 0 is x - > so axis 1 in a numpy array dim 1 is y - > axis 0 in numpy array dim 3 is z ( same )
'''
    Fifth order accurate weighted ENO derivatives
    
    data: 2d or 3d Numpy array
    dim: dimension on which gradients are to be calculated
        I assume dim 0 is x -> so axis 1 in a numpy array
                 dim 1 is y -> axis 0 in numpy array
                 dim 3 is z (same)
        
    grid: grid object - here is used mainly for storing grid spacing, dx
    
    returns: upwind derivative phi_{dim}_plus, downwind derivative phi_{dim}_minus
    ''' #phi(i,j) - phi(i-1,j) #phi(i-1,j) - phi(i-2,j) #phi(i-2,j) - phi(i-3,j) #phi(i+1,j) - phi(i,j) #phi(i+2,j) - phi(i+1,j) #phi(i+3,j) - phi(i+2,j) # phi_minus # phi_plus
data
dim
grid