SG++-Doxygen-Documentation
bSplines.py

plots anisotropic full grids that form part of the combination technique

1 from argparse import ArgumentParser
5 from pysgpp.pysgpp_swig import DataVector, CombigridOperation,\
6  CombigridMultiOperation, CombigridTensorOperation
7 import pysgpp
8 import os
9
10 import matplotlib.pyplot as plt
11 import numpy as np
15 from numpy import square
16
17 # calulate scalar product of basis functions
18 #===============================================================================
19 # For basis functions (1,1) (0,0) (0,1) (2,1) (2,3) in this order (the shift between level 0 and 1 is due to the combigrid conversion
20 #
21 # 1 0.6666666666666666 0.5 0.275 0.275
22 # 0.6666666666666666 0.5333333333333333 0.25 0.2504166666666666 0.11041666666666665
23 # 0.5 0.25 0.3333333333333333 0.0675 0.2075
24 # 0.275 0.2504166666666666 0.0675 0.13857142857142857 0.016857142857142862
25 # 0.275 0.11041666666666665 0.2075 0.016857142857142862 0.13857142857142857
26 #===============================================================================
27
28 degree = 5
29 basis = pysgpp.SNakBsplineBoundaryCombigridBase(degree)
30 l1 = 1
31 i1 = 1
32 l2 = 1
33 i2 = 1
34 scalarProduct = quad(lambda x: basis.eval(l1,i1,x) * basis.eval(l2,i2,x), 0,1)
35 print(scalarProduct)
36
37 # print basis functions
38 B00=[];B01=[]
39 B11=[]
40 B21=[];B23=[]
41 B31=[];B33=[];B35=[];B37=[]
42 B41=[];B43=[];B45=[];B47=[];B49=[];B411=[];B413=[];B415=[]
43 B51=[];B53=[];B55=[];B57=[];B59=[];B511=[];B513=[];B515=[];B517=[];B519=[];B521=[];B523=[];B525=[];B527=[];B529=[];B531=[]
44 X = np.linspace(0,1,250)
45 for i in range(0,len(X)):
46  B00.append(basis.eval(0,0,X[i])); B01.append(basis.eval(0,1,X[i]));
47  B11.append(basis.eval(1,1,X[i]))
48  B21.append(basis.eval(2,1,X[i])); B23.append(basis.eval(2,3,X[i]))
49  B31.append(basis.eval(3,1,X[i])); B33.append(basis.eval(3,3,X[i])); B35.append(basis.eval(3,5,X[i])); B37.append(basis.eval(3,7,X[i]))
50  B41.append(basis.eval(4,1,X[i])); B43.append(basis.eval(4,3,X[i])); B45.append(basis.eval(4,5,X[i])); B47.append(basis.eval(4,7,X[i]));B49.append(basis.eval(4,9,X[i])); B411.append(basis.eval(4,11,X[i])); B413.append(basis.eval(4,13,X[i])); B415.append(basis.eval(4,15,X[i]))
51  B51.append(basis.eval(5,1,X[i])); B53.append(basis.eval(5,3,X[i])); B55.append(basis.eval(5,5,X[i])); B57.append(basis.eval(5,7,X[i]));B59.append(basis.eval(5,9,X[i])); B511.append(basis.eval(5,11,X[i])); B513.append(basis.eval(5,13,X[i])); B515.append(basis.eval(5,15,X[i])); B517.append(basis.eval(5,17,X[i])); B519.append(basis.eval(5,19,X[i])); B521.append(basis.eval(5,21,X[i])); B523.append(basis.eval(5,23,X[i]));B525.append(basis.eval(5,25,X[i])); B527.append(basis.eval(5,27,X[i])); B529.append(basis.eval(5,29,X[i])); B531.append(basis.eval(5,31,X[i]))
52 fig = plt.figure()
53 #plt.plot(X,B00); plt.plot(X,B01)
54 #plt.plot(X,B11)
55 #plt.plot(X,B21);plt.plot(X,B23)
56 #plt.plot(X,B31);plt.plot(X,B33);plt.plot(X,B35);plt.plot(X,B37)
57 plt.plot(X,B41);plt.plot(X,B43);plt.plot(X,B45);plt.plot(X,B47);plt.plot(X,B49);plt.plot(X,B411);plt.plot(X,B413);plt.plot(X,B415)
58 #plt.plot(X,B51);plt.plot(X,B53);plt.plot(X,B55);plt.plot(X,B57);plt.plot(X,B59);plt.plot(X,B511);plt.plot(X,B513);plt.plot(X,B515);plt.plot(X,B517);plt.plot(X,B519);plt.plot(X,B521);plt.plot(X,B523);plt.plot(X,B525);plt.plot(X,B527);plt.plot(X,B529);plt.plot(X,B531)
59 plt.xticks(np.linspace(0, 1, 2**4 + 1))
60 plt.show()