source: anuga_work/development/2010-projects/anuga_1d/base/limiters_python.py @ 7852

Last change on this file since 7852 was 7852, checked in by steve, 14 years ago

Moving calculation of limiters to numpy calculations

File size: 1.8 KB
RevLine 
[7852]1#! /usr/bin/python
2
3# To change this template, choose Tools | Templates
4# and open the template in the editor.
5
6__author__="steve"
7__date__ ="$16/06/2010 4:29:59 PM$"
8
9
10
11def  minmod(a,b):
12    from numpy import abs, where
13
14    phi = where((abs(a) < abs(b)) & (a*b > 0.0), a, 0.0)
15    phi = where((abs(b) < abs(a)) & (a*b > 0.0), b, phi)
16
17    return phi
18
19def  minmod_kurganov(a,b,c):
20    from numpy import sign, abs, minimum, where
21
22    return where( (sign(a)*sign(b) > 0.0) & (sign(a)*sign(c)>0.0), 
23        sign(a)*minimum(abs(a),abs(b),abs(c)), 0.0 )
24
25
26def  maxmod(a,b):
27
28    from numpy import abs, where
29
30    phi =  where((abs(a) > abs(b)) & (a*b > 0.0), a, 0.0)
31    phi =  where((abs(b) > abs(a)) & (a*b > 0.0), b, phi)
32
33    return phi
34
35
36def vanleer(a,b):
37
38    from numpy import abs, where
39
40    return where((abs(a) + abs(b) >= 1.0e-12), (a*abs(b)+abs(a)*b)/(abs(a)+abs(b)), 0.0)
41
42
43def vanalbada(a,b):
44
45    from numpy import abs, where
46
47    return where((a*a + b*b >= 1.0e-16), (a*a*b+a*b*b)/(a*a+b*b), 0.0)
48
49
50
51def  minmod_old(beta_p,beta_m):
52    if (abs(beta_p) < abs(beta_m)) & (beta_p*beta_m > 0.0):
53        phi = beta_p
54    elif (abs(beta_m) < abs(beta_p)) & (beta_p*beta_m > 0.0):
55        phi = beta_m
56    else:
57        phi = 0.0
58    return phi
59
60
61def vanleer_old(a,b):
62    if abs(a)+abs(b) > 1e-12:
63        return (a*abs(b)+abs(a)*b)/(abs(a)+abs(b))
64    else:
65        return 0.0
66
67
68def vanalbada_old(a,b):
69    if a*a+b*b > 1e-12:
70        return (a*a*b+a*b*b)/(a*a+b*b)
71    else:
72        return 0.0
73
74
75def  maxmod_old(a,b):
76    if (abs(a) > abs(b)) & (a*b > 0.0):
77        phi = a
78    elif (abs(b) > abs(a)) & (a*b > 0.0):
79        phi = b
80    else:
81        phi = 0.0
82    return phi
83
84def  minmod_kurganov_old(a,b,c):
85    from numpy import sign
86    if sign(a)==sign(b)==sign(c):
87        return sign(a)*min(abs(a),abs(b),abs(c))
88    else:
89        return 0.0
Note: See TracBrowser for help on using the repository browser.