[cig-commits] [commit] master: py: Simplify definition of GLL points. (71171d3)
cig_noreply at geodynamics.org
cig_noreply at geodynamics.org
Wed Jan 7 07:56:26 PST 2015
Repository : https://github.com/geodynamics/specfem1d
On branch : master
Link : https://github.com/geodynamics/specfem1d/compare/5ac1833074897dbc9cc286395ddae214ea0452e3...c63d455e0ff0075e43cb487147ab0bc101d4019c
>---------------------------------------------------------------
commit 71171d394d31b635c014ba14fb4100944847123e
Author: Elliott Sales de Andrade <esalesde at physics.utoronto.ca>
Date: Tue Jan 6 03:48:14 2015 -0500
py: Simplify definition of GLL points.
>---------------------------------------------------------------
71171d394d31b635c014ba14fb4100944847123e
Python_version/defines.py | 97 +++++++++++++++++++++++++++--------------------
1 file changed, 55 insertions(+), 42 deletions(-)
diff --git a/Python_version/defines.py b/Python_version/defines.py
index 395d7d4..e9d25ff 100644
--- a/Python_version/defines.py
+++ b/Python_version/defines.py
@@ -53,51 +53,64 @@ from pylab import * # Matplotlib's pylab interface
import functions # Contains fundamental functions
# Gauss Lobatto Legendre points and integration weights
-ksiGLL4=np.array([-1,-0.6546536707,0,0.6546536707,1])
-wGLL4=np.array([0.1,0.5444444444,0.7111111111,0.5444444444,0.1])
-ksiGLL5=np.array([-1,-0.7650553239,-0.2852315164,0.2852315164,0.7650553239,1])
-wGLL5=np.array([0.0666666666,0.3784749562,0.5548583770,0.5548583770,0.3784749562,0.0666666666])
-ksiGLL6=np.array([-1,-0.8302238962,-0.4688487934,0,0.4688487934,0.8302238962,1])
-wGLL6=np.array([0.0476190476,0.2768260473,0.4317453812,0.4876190476,0.4317453812,0.2768260473,0.0476190476])
-ksiGLL7=np.array([-1,-0.8717401485,-0.5917001814,-0.2092992179,0.2092992179,0.5917001814,0.8717401485,1])
-wGLL7=np.array([0.0357142857,0.2107042271,0.3411226924,0.4124587946,0.4124587946,0.3411226924,0.2107042271,0.0357142857])
-
-if N == 4:
- ksiGLL=ksiGLL4
- wGLL=wGLL4
-elif N == 5:
- ksiGLL=ksiGLL5
- wGLL=wGLL5
-elif N == 6:
- ksiGLL=ksiGLL6
- wGLL=wGLL6
-else:
- ksiGLL=ksiGLL7
- wGLL=wGLL7
+ksiGLL = {
+ 4: np.array([-1, -0.6546536707, 0, 0.6546536707, 1]),
+ 5: np.array([-1, -0.7650553239, -0.2852315164, 0.2852315164, 0.7650553239,
+ 1]),
+ 6: np.array([-1, -0.8302238962, -0.4688487934, 0, 0.4688487934,
+ 0.8302238962, 1]),
+ 7: np.array([-1, -0.8717401485, -0.5917001814, -0.2092992179, 0.2092992179,
+ 0.5917001814, 0.8717401485, 1]),
+}
+
+wGLL = {
+ 4: np.array([0.1, 0.5444444444, 0.7111111111, 0.5444444444, 0.1]),
+ 5: np.array([0.0666666666, 0.3784749562, 0.5548583770, 0.5548583770,
+ 0.3784749562, 0.0666666666]),
+ 6: np.array([0.0476190476, 0.2768260473, 0.4317453812, 0.4876190476,
+ 0.4317453812, 0.2768260473, 0.0476190476]),
+ 7: np.array([0.0357142857, 0.2107042271, 0.3411226924, 0.4124587946,
+ 0.4124587946, 0.3411226924, 0.2107042271, 0.0357142857]),
+}
# Gauss Lobatto Jacobi points and integration weights
-ksiGLJ4=np.array([-1.0,-0.5077876295,0.1323008207,0.7088201421,1.0])
-wGLJ4=np.array([0.01333333333,0.2896566946,0.7360043695,0.794338936,0.1666666667])
-ksiGLJ5=np.array([-1.0,-0.6507788566,-0.1563704318,0.3734893787,0.7972962733,1.0])
-wGLJ5=np.array([0.006349206349,0.1503293754,0.452292685,0.6858215721,0.5909214468,0.1142857143])
-ksiGLJ6=np.array([-1.0,-0.7401236486,-0.3538526341,0.09890279315,0.5288423045,0.8508465697,1.0])
-wGLJ6=np.array([0.003401360544,0.08473655296,0.2803032119,0.5016469619,0.5945754451,0.4520031342,0.08333333333])
-ksiGLJ7=np.array([-1.0,-0.7993818545,-0.4919057913,-0.1117339354,0.2835397724,0.6337933270,0.8856884817,1.0])
-wGLJ7=np.array([0.001984126984,0.0510689152,0.1792187805,0.3533996177,0.4909749105,0.5047839706,0.3550776151,0.06349206349])
-
-if NGLJ == 4:
- ksiGLJ=ksiGLJ4
- wGLJ=wGLJ4
-elif NGLJ == 5:
- ksiGLJ=ksiGLJ5
- wGLJ=wGLJ5
-elif NGLJ == 6:
- ksiGLJ=ksiGLJ6
- wGLJ=wGLJ6
-else:
- ksiGLJ=ksiGLJ7
- wGLJ=wGLJ7
+ksiGLJ = {
+ 4: np.array([-1.0, -0.5077876295, 0.1323008207, 0.7088201421, 1.0]),
+ 5: np.array([-1.0, -0.6507788566, -0.1563704318, 0.3734893787,
+ 0.7972962733, 1.0]),
+ 6: np.array([-1.0, -0.7401236486, -0.3538526341, 0.09890279315,
+ 0.5288423045, 0.8508465697, 1.0]),
+ 7: np.array([-1.0, -0.7993818545, -0.4919057913, -0.1117339354,
+ 0.2835397724, 0.6337933270, 0.8856884817, 1.0]),
+}
+
+wGLJ = {
+ 4: np.array([0.01333333333, 0.2896566946, 0.7360043695, 0.794338936,
+ 0.1666666667]),
+ 5: np.array([0.006349206349, 0.1503293754, 0.452292685, 0.6858215721,
+ 0.5909214468, 0.1142857143]),
+ 6: np.array([0.003401360544, 0.08473655296, 0.2803032119, 0.5016469619,
+ 0.5945754451, 0.4520031342, 0.08333333333]),
+ 7: np.array([0.001984126984, 0.0510689152, 0.1792187805, 0.3533996177,
+ 0.4909749105, 0.5047839706, 0.3550776151, 0.06349206349]),
+}
+
+
+try:
+ ksiGLL = ksiGLL[N]
+ wGLL = wGLL[N]
+except KeyError:
+ print >> sys.stderr, 'ERROR: N = %d is invalid!' % (N, )
+ sys.exit()
+
+try:
+ ksiGLJ = ksiGLJ[NGLJ]
+ wGLJ = wGLJ[NGLJ]
+except KeyError:
+ print >> sys.stderr, 'ERROR: NGLJ = %d is invalid!' % (NGLJ, )
+ sys.exit()
+
class Parameter:
"""Contains all the constants and parameters necessary for 1D spectral
More information about the CIG-COMMITS
mailing list