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

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

Moving 2010 project

File size: 1.8 KB
Line 
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(minimum(abs(a),abs(b)),abs(c)), 0.0 )
24
25
26
27def  maxmod(a,b):
28
29    from numpy import abs, where
30
31    phi =  where((abs(a) > abs(b)) & (a*b > 0.0), a, 0.0)
32    phi =  where((abs(b) > abs(a)) & (a*b > 0.0), b, phi)
33
34    return phi
35
36
37def vanleer(a,b):
38
39    from numpy import fabs, where
40
41    return where((fabs(a) + fabs(b) >= 1.0e-12), (a*fabs(b)+fabs(a)*b)/(fabs(a)+fabs(b)), 0.0)
42
43
44def vanalbada(a,b):
45
46    from numpy import abs, where
47
48    return where((a*a + b*b >= 1.0e-16), (a*a*b+a*b*b)/(a*a+b*b), 0.0)
49
50
51
52def  minmod_old(beta_p,beta_m):
53    if (abs(beta_p) < abs(beta_m)) & (beta_p*beta_m > 0.0):
54        phi = beta_p
55    elif (abs(beta_m) < abs(beta_p)) & (beta_p*beta_m > 0.0):
56        phi = beta_m
57    else:
58        phi = 0.0
59    return phi
60
61
62def vanleer_old(a,b):
63    if abs(a)+abs(b) > 1e-12:
64        return (a*abs(b)+abs(a)*b)/(abs(a)+abs(b))
65    else:
66        return 0.0
67
68
69def vanalbada_old(a,b):
70    if a*a+b*b > 1e-12:
71        return (a*a*b+a*b*b)/(a*a+b*b)
72    else:
73        return 0.0
74
75
76def  maxmod_old(a,b):
77    if (abs(a) > abs(b)) & (a*b > 0.0):
78        phi = a
79    elif (abs(b) > abs(a)) & (a*b > 0.0):
80        phi = b
81    else:
82        phi = 0.0
83    return phi
84
85def  minmod_kurganov_old(a,b,c):
86    from numpy import sign
87    if sign(a)==sign(b)==sign(c):
88        return sign(a)*min(abs(a),abs(b),abs(c))
89    else:
90        return 0.0
Note: See TracBrowser for help on using the repository browser.