v0.14.0
Functions
test_T3_004.cpp File Reference
#include "../../../src/FTensor.hpp"
#include "../test_for_zero.hpp"
#include <iostream>

Go to the source code of this file.

Functions

void test_T3_004 (const Tensor3< double, 3, 3, 3 > &t3_1)
 

Function Documentation

◆ test_T3_004()

void test_T3_004 ( const Tensor3< double, 3, 3, 3 > &  t3_1)

Definition at line 7 of file test_T3_004.cpp.

7  {
8 
12 
13  {
14  // Symmetrize of first two indices yields dg
15  Dg<double, 3, 3> t_dg;
16  t_dg(i, j, k) = t3_1(i, j, k) || t3_1(j, i, k);
18  t_sym_3(i, j, k) = t3_1(i, j, k) + t3_1(j, i, k);
19 
20  for (int ii = 0; ii != 3; ++ii)
21  for (int jj = 0; jj != 3; ++jj)
22  for (int kk = 0; kk != 3; ++kk) {
23  test_for_zero(t_dg(ii, jj, kk) - t_sym_3(ii, jj, kk),
24  "T3(i,j,k)||T3(j,i,k)(" + to_string(ii) + "," +
25  to_string(jj) + "," + to_string(kk) + ")");
26  }
27 
28  }
29 
30  // Tensor 3 times symmetric tensor 2 yields tensor 3
31  {
37  for (int ii = 0; ii != 1; ++ii)
38  for (int jj = 0; jj != 3; ++jj) {
39  for (int kk = 0; kk != 2; ++kk) {
40  t_3_1(ii, jj, kk) = 1 + ii + 10. * jj + 100. * kk;
41  }
42  }
43  for (int jj = 0; jj != 3; ++jj)
44  for (int ll = 0; ll != 3; ++ll) {
45  t_2_1(jj, ll) = 1 + jj + 10. * ll;
46  }
51  t_2s_1(j, l) = t_2_1(j, l) || t_2_1(l, j);
52  t_2_2(j, l) = t_2_1(j, l) + t_2_1(l, j);
53  t_3_2(i, l, k) =
54  t_3_1(i, j, k) * t_2s_1(j, l) - t_2s_1(j, l)*t_3_1(i, j, k);
55  for (int ii = 0; ii != 1; ++ii)
56  for (int ll = 0; ll != 3; ++ll)
57  for (int kk = 0; kk != 2; ++kk) {
58  test_for_zero(t_3_2(ii, ll, kk),
59  "T3(i,j,k)||T2s(j,l)(" + to_string(ii) + "," +
60  to_string(ll) + "," + to_string(kk) + ")");
61  }
62  t_3_2(i, l, k) =
63  t_3_1(i, j, k) * t_2s_1(j, l) - t_2_2(j, l) * t_3_1(i, j, k);
64  for (int ii = 0; ii != 1; ++ii)
65  for (int ll = 0; ll != 3; ++ll)
66  for (int kk = 0; kk != 2; ++kk) {
67  test_for_zero(t_3_2(ii, ll, kk),
68  "T3(i,j,k)||T2s(j,l)(" + to_string(ii) + "," +
69  to_string(ll) + "," + to_string(kk) + ")");
70  }
71  }
72 
73  // Tensor 3 times symmetric tensor 2 yields tensor 3
74  {
80  for (int ii = 0; ii != 3; ++ii)
81  for (int jj = 0; jj != 3; ++jj) {
82  for (int kk = 0; kk != 3; ++kk) {
83  t_3_1(ii, jj, kk) = 1 + ii + 10. * jj + 100. * kk;
84  }
85  }
86  for (int jj = 0; jj != 3; ++jj)
87  for (int ll = 0; ll != 3; ++ll) {
88  t_2_1(jj, ll) = 1 + jj + 10. * ll;
89  }
94  t_2s_1(i, j) = t_2_1(i, j) || t_2_1(j, i);
95  t_2_2(i, j) = t_2_1(i, j) + t_2_1(j, i);
96  t_3_2(l, j, k) =
97  t_3_1(i, j, k) * t_2s_1(i, l) - t_2s_1(i, l) * t_3_1(i, j, k);
98  for (int ll = 0; ll != 3; ++ll)
99  for (int jj = 0; jj != 3; ++jj)
100  for (int kk = 0; kk != 3; ++kk) {
101  test_for_zero(t_3_2(ll, jj, kk),
102  "T3(i,j,k)||T2s(i,l)(" + to_string(ll) + "," +
103  to_string(jj) + "," + to_string(kk) + ")");
104  }
105  t_3_2(l, j, k) =
106  t_3_1(i, j, k) * t_2s_1(i, l) - t_3_1(i, j, k) * t_2_2(i, l);
107 
108  for (int ll = 0; ll != 3; ++ll)
109  for (int jj = 0; jj != 3; ++jj)
110  for (int kk = 0; kk != 3; ++kk) {
111  test_for_zero(t_3_2(ll, jj, kk),
112  "T3(i,j,k)||T2s(i,l)(" + to_string(ll) + "," +
113  to_string(jj) + "," + to_string(kk) + ")");
114  }
115  }
116 
117  // Tensor 3 times tensor 3 yield tensor 2 A(i,j,k)*B(j,i,l)
118  {
119  Tensor1<double, 3> t_1;
121  for (int ii = 0; ii != 3; ++ii) {
122  t_1(ii) = 1 + ii;
123  for (int jj = 0; jj != 3; ++jj) {
124  t_2(ii, jj) = 1 + ii + 10. * jj;
125  }
126  }
132  t_3_1(i, j, k) = t_2(i, j) * t_1(k);
133  Tensor2<double, 3, 3> t_2_1;
134  t_2_1(k, l) = t_3_1(i, j, k) * t_3_1(j, i, l);
135  Tensor2<double, 3, 3> t_2_2;
136  t_2_2(k, l) = (t_2(i, j) * t_2(j, i)) * (t_1(k) * t_1(l));
137  for (int ii = 0; ii != 3; ++ii)
138  for (int jj = 0; jj != 3; ++jj) {
139  test_for_zero(t_2_1(ii, jj) - t_2_2(ii, jj), "T3(i,j,k)*T3(j,i,l)(" +
140  to_string(ii) + "," +
141  to_string(jj) + ")");
142  }
143  }
144 
145  // Tensor 3 times tensor 3 yield tensor 2 A(j,l,k)*B(i,k,l)
146  {
147  Tensor1<double, 3> t_1;
149  for (int ii = 0; ii != 3; ++ii) {
150  t_1(ii) = 1 + ii;
151  for (int jj = 0; jj != 3; ++jj) {
152  t_2(ii, jj) = 1 + ii + 10. * jj;
153  }
154  }
160  t_3_1(i, j, k) = t_1(i) * t_2(j, k);
161  Tensor2<double, 3, 3> t_2_1;
162  t_2_1(i, j) = t_3_1(j, k, l) * t_3_1(i, l, k);
163  Tensor2<double, 3, 3> t_2_2;
164  t_2_2(i, j) = (t_2(k, l) * t_2(l, k)) * (t_1(i) * t_1(j));
165  for (int ii = 0; ii != 3; ++ii)
166  for (int jj = 0; jj != 3; ++jj) {
167  test_for_zero(t_2_1(ii, jj) - t_2_2(ii, jj), "T3(j,k,l)*T3(i,l,k)(" +
168  to_string(ii) + "," +
169  to_string(jj) + ")");
170  }
171  }
172 
173  // Tensor 3 times tensor 3 yield tensor 2 A(k,i,j)*B(l,i,j)
174  {
175  Tensor1<double, 3> t_1;
177  for (int ii = 0; ii != 3; ++ii) {
178  t_1(ii) = 1 + ii;
179  for (int jj = 0; jj != 3; ++jj) {
180  t_2(ii, jj) = 1 + ii + 10. * jj;
181  }
182  }
188  t_3_1(i, j, k) = t_1(i) * t_2(j, k);
189  Tensor2<double, 3, 3> t_2_1;
190  t_2_1(k, l) = t_3_1(k, i, j) * t_3_1(l, i, j);
191  Tensor2<double, 3, 3> t_2_2;
192  t_2_2(k, l) = (t_2(i, j) * t_2(i, j)) * (t_1(k) * t_1(l));
193  for (int kk = 0; kk != 3; ++kk)
194  for (int ll = 0; ll != 3; ++ll) {
195  test_for_zero(t_2_1(kk, ll) - t_2_2(kk, ll), "T3(k,i,j)*T3(l,i,j)(" +
196  to_string(kk) + "," +
197  to_string(ll) + ")");
198  }
199  }
200 
201  // Tensor 3 times tensor 3 yield tensor 2 A(i,j,k)*B(i,j,k)
202  {
203  Tensor1<double, 3> t_1;
205  for (int ii = 0; ii != 3; ++ii) {
206  t_1(ii) = 1 + ii;
207  for (int jj = 0; jj != 3; ++jj) {
208  t_2(ii, jj) = 1 + ii + 10. * jj;
209  }
210  }
216  t_3_1(i, j, k) = t_2(i, j) * t_1(k);
217  Tensor2<double, 3, 3> t_2_1;
218  t_2_1(k, l) = t_3_1(i, j, k) * t_3_1(i, j, l);
219  Tensor2<double, 3, 3> t_2_2;
220  t_2_2(k, l) = (t_2(i, j) * t_2(i, j)) * (t_1(k) * t_1(l));
221  for (int kk = 0; kk != 3; ++kk)
222  for (int ll = 0; ll != 3; ++ll) {
223  test_for_zero(t_2_1(kk, ll) - t_2_2(kk, ll), "T3(i,j,k)*T3(i,j,l)(" +
224  to_string(kk) + "," +
225  to_string(ll) + ")");
226  }
227  }
228 
229 
230 }
FTensor::Tensor1< double, 3 >
FTensor::Tensor2_symmetric
Definition: Tensor2_symmetric_value.hpp:13
FTensor::Tensor2< double, 3, 3 >
FTensor::Tensor3
Definition: Tensor3_value.hpp:12
test_for_zero
void test_for_zero(const T &t, const std::string &s)
Definition: test_for_zero.hpp:7
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
FTensor::Index< 'i', 3 >
FTensor::Dg
Definition: Dg_value.hpp:9
j
FTensor::Index< 'j', 3 > j
Definition: matrix_function.cpp:19
k
FTensor::Index< 'k', 3 > k
Definition: matrix_function.cpp:20
l
FTensor::Index< 'l', 3 > l
Definition: matrix_function.cpp:21