MCPcopy Create free account
hub / github.com/OpenFOAM/OpenFOAM-dev / main

Function main

applications/test/tensor/Test-tensor.C:9–201  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7using namespace Foam;
8
9int main()
10{
11 tensor t1(1, 2, 3, 4, 5, 6, 7, 8, 9);
12 tensor t2(1, 2, 3, 1, 2, 3, 1, 2, 3);
13
14 tensor t3 = t1 + t2;
15
16 Info<< t3 << endl;
17
18 tensor t4(3,-2,1,-2,2,0,1, 0, 4);
19
20 Info<< inv(t4) << endl;
21 Info<< (inv(t4) & t4) << endl;
22
23 Info<< t1.x() << t1.y() << t1.z() << endl;
24
25 tensor t6(1,0,-4,0,5,4,-4,4,3);
26 //tensor t6(1,2,0,2,5,0,0,0,0);
27
28 Info<< "tensor " << t6 << endl;
29 vector e = eigenValues(t6);
30 Info<< "eigenvalues " << e << endl;
31
32 tensor ev = eigenVectors(t6);
33 Info<< "eigenvectors " << ev << endl;
34
35 Info<< "Check determinant " << e.x()*e.y()*e.z() << " " << det(t6) << endl;
36
37 Info<< "Check eigenvectors "
38 << (eigenVectors(t6, e) & t6) << " "
39 << (e.x()*eigenVectors(t6, e).x())
40 << (e.y()*eigenVectors(t6, e).y())
41 << (e.z()*eigenVectors(t6, e).z())
42 << endl;
43
44 Info<< "Check eigenvalues for symmTensor "
45 << eigenValues(symm(t6)) - eigenValues(tensor(symm(t6))) << endl;
46
47 Info<< "Check eigenvectors for symmTensor "
48 << eigenVectors(symm(t6)) - eigenVectors(tensor(symm(t6))) << endl;
49
50 tensor t7(1, 2, 3, 2, 4, 5, 3, 5, 6);
51
52 Info<< "Check transformation "
53 << (t1 & t7 & t1.T()) << " " << transform(t1, t7) << endl;
54
55 symmTensor st1(1, 2, 3, 4, 5, 6);
56 symmTensor st2(7, 8, 9, 10, 11, 12);
57
58 Info<< "Check symmetric transformation "
59 << transform(t1, st1) << endl;
60
61 Info<< "Check dot product of symmetric tensors "
62 << (st1 & st2) << endl;
63
64 Info<< "Check inner sqr of a symmetric tensor "
65 << innerSqr(st1) << " " << innerSqr(st1) - (st1 & st1) << endl;
66

Callers

nothing calls this directly

Calls 15

invFunction · 0.50
eigenValuesFunction · 0.50
eigenVectorsFunction · 0.50
detFunction · 0.50
symmFunction · 0.50
transformFunction · 0.50
innerSqrFunction · 0.50
twoSymmFunction · 0.50
skewFunction · 0.50
sqrFunction · 0.50
magSqrFunction · 0.50
magClass · 0.50

Tested by

no test coverage detected