1
2
3
4
5
6
7
8
9
10
11
12
13 public class CylindricalPointTensorTest extends TestCase
14 {
15 boolean debug = false;
16 public void testCylindricalPointTensor()
17 {
18 int np = 10;
19 int nt = 5;
20
21 double p[][] =
22 {
23 {
24 0., 0., 0.
25 },
26 {
27 1., 0., 0.
28 },
29 {
30 0., 1., 0.
31 },
32 {
33 0., 0., 1.
34 },
35 {
36 1., 1., 0.
37 },
38 {
39 0., 1., 1.
40 },
41 {
42 1., 0., 1.
43 },
44 {
45 1., 2., 3.
46 },
47 {
48 -2., -3., 1.
49 },
50 {
51 4., -5., 3.
52 }
53 };
54
55 double t[][][] =
56 {
57 {
58 {
59 0., 0., 0.
60 },
61 {
62 0., 0., 0.
63 },
64 {
65 0., 0., 0.
66 }
67 },
68 {
69 {
70 1., 0., 0.
71 },
72 {
73 0., 1., 0.
74 },
75 {
76 0., 0., 1.
77 }
78 },
79 {
80 {
81 1., 1., 1.
82 },
83 {
84 1., 1., 1.
85 },
86 {
87 1., 1., 1.
88 }
89 },
90 {
91 {
92 3., -2., 4.
93 },
94 {
95 -3., 6., -5.
96 },
97 {
98 -1., 2., 1.
99 }
100 },
101 {
102 {
103 -2., 2., -1.
104 },
105 {
106 3., -4., 5.
107 },
108 {
109 1., -5., 3.
110 }
111 }
112 };
113
114
115 for (int ip = 0; ip < np; ++ip)
116 {
117
118 for (int it = 0; it < nt; ++it)
119 {
120
121
122 CylindricalPointTensor tensor1 = new CylindricalPointTensor (p[ip][0], p[ip][1], p[ip][2],
123 t[it][0][0], t[it][0][1], t[it][0][2],
124 t[it][1][0], t[it][1][1], t[it][1][2],
125 t[it][2][0], t[it][2][1], t[it][2][2]);
126 if(debug) System.out.println("Cylindrical coordinates.");
127 if(debug) System.out.println(tensor1);
128 CylindricalPoint point1 = new CylindricalPoint(p[ip][0], p[ip][1], p[ip][2]);
129 CylindricalPointTensor tensor1a = new CylindricalPointTensor (point1,
130 t[it][0][0], t[it][0][1], t[it][0][2],
131 t[it][1][0], t[it][1][1], t[it][1][2],
132 t[it][2][0], t[it][2][1], t[it][2][2]);
133 Assert.assertTrue(tensor1.equals(tensor1a));
134 SpacePointTensor tensor1b = new SpacePointTensor(tensor1);
135 Assert.assertTrue(tensor1.equals(tensor1b));
136 SpacePointTensor tensor0b = tensor1;
137 Assert.assertTrue(tensor1.equals(tensor0b));
138
139
140
141 Assert.assertTrue(myequal(tensor1.t_rxy_rxy(), t[it][0][0]));
142 Assert.assertTrue(myequal(tensor1.t_rxy_phi(), t[it][0][1]));
143 Assert.assertTrue(myequal(tensor1.t_rxy_z(), t[it][0][2]));
144 Assert.assertTrue(myequal(tensor1.t_phi_rxy(), t[it][1][0]));
145 Assert.assertTrue(myequal(tensor1.t_phi_phi(), t[it][1][1]));
146 Assert.assertTrue(myequal(tensor1.t_phi_z(), t[it][1][2]));
147 Assert.assertTrue(myequal(tensor1.t_z_rxy(), t[it][2][0]));
148 Assert.assertTrue(myequal(tensor1.t_z_phi(), t[it][2][1]));
149 Assert.assertTrue(myequal(tensor1.t_z_z(), t[it][2][2]));
150
151 }
152 }
153 }
154 static boolean myequal(double x1, double x2)
155 {
156 return abs(x2 - x1) < 1.e-10;
157 }
158 }