Intrepid
maked.py
1 psi0 = lambda x: 0.5 * x * ( x - 1.0 )
2 psi1 = lambda x: ( 1.0 - x ) * ( 1.0 + x )
3 psi2 = lambda x: 0.5 * x * ( 1.0 + x )
4 psi = [psi0,psi1,psi2]
5 
6 dpsi0 = lambda x: x - 0.5
7 dpsi1 = lambda x: -2.0 * x
8 dpsi2 = lambda x: x + 0.5
9 dpsi = [dpsi0,dpsi1,dpsi2]
10 
11 ddpsi0 = lambda x: 1.0
12 ddpsi1 = lambda x: -2.0
13 ddpsi2 = lambda x: 1.0
14 ddpsi = [ddpsi0, ddpsi1, ddpsi2]
15 
16 xs = [ -1.0 , 0.0 , 1.0 ]
17 pts = [ (xs[i],xs[j],xs[k]) for k in range(3) for j in range(3) for i in range(3) ]
18 
19 
20 # This is D1
21 #for k in range(3):
22 # for j in range(3):
23 # for i in range(3):
24 # for pt in pts:
25 # print dpsi[i](pt[0])*psi[j](pt[1])*psi[k](pt[2])
26 # print psi[i](pt[0])*dpsi[j](pt[1])*psi[k](pt[2])
27 # print psi[i](pt[0])*psi[j](pt[1])*dpsi[k](pt[2])
28 
29 # This is for D2
30 #for k in range(3):
31 # for j in range(3):
32 # for i in range(3):
33 # for pt in pts:
34 # # (2,0,0)
35 # print ddpsi[i](pt[0])*psi[j](pt[1])*psi[k](pt[2])
36 # # (1,1,0)
37 # print dpsi[i](pt[0])*dpsi[j](pt[1])*psi[k](pt[2])
38 # # (1,0,1)
39 # print dpsi[i](pt[0])*psi[j](pt[1])*dpsi[k](pt[2])
40 # # (0,2,0)
41 # print psi[i](pt[0])*ddpsi[j](pt[1])*psi[k](pt[2])
42 # # (0,1,1)
43 # print psi[i](pt[0])*dpsi[j](pt[1])*dpsi[k](pt[2])
44 # # (0,0,2)
45 # print psi[i](pt[0])*psi[j](pt[1])*ddpsi[k](pt[2])
46 
47 # This is for D3
48 #for k in range(3):
49 # for j in range(3):
50 # for i in range(3):
51 # for pt in pts:
52 # # (3,0,0)
53 # print 0.0
54 # # (2,1,0)
55 # print ddpsi[i](pt[0])*dpsi[j](pt[1])*psi[k](pt[2])
56 # # (2,0,1)
57 # print ddpsi[i](pt[0])*psi[j](pt[1])*dpsi[k](pt[2])
58 # # (1,2,0)
59 # print dpsi[i](pt[0])*ddpsi[j](pt[1])*psi[k](pt[2])
60 # # (1,1,1)
61 # print dpsi[i](pt[0])*dpsi[j](pt[1])*dpsi[k](pt[2])
62 # # (1,0,2)
63 # print dpsi[i](pt[0])*psi[j](pt[1])*ddpsi[k](pt[2])
64 # # (0,3,0)
65 # print 0.0
66 # # (0,2,1)
67 # print psi[i](pt[0])*ddpsi[j](pt[1])*dpsi[k](pt[2])
68 # # (0,1,2)
69 # print psi[i](pt[0])*dpsi[j](pt[1])*ddpsi[k](pt[2])
70 # # (0,0,3)
71 # print 0.0
72 
73 # This is for D4
74 for k in range(3):
75  for j in range(3):
76  for i in range(3):
77  for pt in pts:
78  # (4,0,0)
79  print 0.0
80  # (3,1,0)
81  print 0.0
82  # (3,0,1)
83  print 0.0
84  # (2,2,0)
85  print ddpsi[i](pt[0])*ddpsi[j](pt[1])*psi[k](pt[2])
86  # (2,1,1)
87  print ddpsi[i](pt[0])*dpsi[j](pt[1])*dpsi[k](pt[2])
88  # (2,0,2)
89  print ddpsi[i](pt[0])*psi[j](pt[1])*ddpsi[k](pt[2])
90  # (1,3,0)
91  print 0.0
92  # (1,2,1)
93  print dpsi[i](pt[0])*ddpsi[j](pt[1])*dpsi[k](pt[2])
94  # (1,1,2)
95  print dpsi[i](pt[0])*dpsi[j](pt[1])*ddpsi[k](pt[2])
96  # (1,0,3)
97  print 0.0
98  # (0,4,0)
99  print 0.0
100  # (0,3,1)
101  print 0.0
102  # (0,2,2)
103  print psi[i](pt[0])*ddpsi[j](pt[1])*ddpsi[k](pt[2])
104  # (0,1,3)
105  print 0.0
106  # (0,0,4)
107  print 0.0
108 
109