initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / applications / test / tensor / tensorTest.C
blobefc7824dd6577151973afda3a65e028ae323fb3e
1 #include "tensor.H"
2 #include "symmTensor.H"
3 #include "transform.H"
4 #include "stringList.H"
5 #include "IOstreams.H"
7 using namespace Foam;
9 int main()
11     tensor t1(1, 2, 3, 4, 5, 6, 7, 8, 9);
12     tensor t2(1, 2, 3, 1, 2, 3, 1, 2, 3);
14     tensor t3 = t1 + t2;
16     Info<< t3 << endl;
18     tensor t4(3,-2,1,-2,2,0,1, 0, 4);
20     Info<< inv(t4) << endl;
21     Info<< (inv(t4) & t4) << endl;
23     Info<< t1.x() << t1.y() << t1.z() << endl;
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     Info<< "tensor " << t6 << endl;
28     vector e = eigenValues(t6);
29     Info<< "eigenvalues " << e << endl;
30     tensor ev = eigenVectors(t6);
31     Info<< "eigenvectors " << ev << endl;
33     Info<< "Check determinant " << e.x()*e.y()*e.z() << " " << det(t6) << endl;
35     Info<< "Check eigenvectors "
36         << (eigenVector(t6, e[0]) & t6) << e[0]*eigenVector(t6, e[0]) << " "
37         << (eigenVector(t6, e[1]) & t6) << e[1]*eigenVector(t6, e[1]) << " "
38         << (eigenVector(t6, e[2]) & t6) << e[2]*eigenVector(t6, e[2])
39         << endl;
41     Info<< "Check eigenvalues for symmTensor "
42         << eigenValues(symm(t6)) - eigenValues(tensor(symm(t6))) << endl;
44     Info<< "Check eigenvectors for symmTensor "
45         << eigenVectors(symm(t6)) - eigenVectors(tensor(symm(t6))) << endl;
47     tensor t7(1, 2, 3, 2, 4, 5, 3, 5, 6);
49     Info<< "Check transformation "
50         << (t1 & t7 & t1.T()) << " " << transform(t1, t7) << endl;
52     symmTensor st1(1, 2, 3, 4, 5, 6);
54     Info<< "Check symmetric transformation "
55         << transform(t1, st1) << endl;
57     vector v1(1, 2, 3);
59     Info<< sqr(v1) << endl;
60     Info<< symm(t7) << endl;
61     Info<< twoSymm(t7) << endl;
62     Info<< magSqr(st1) << endl;
63     Info<< mag(st1) << endl;
65     Info<< (symm(t7) && t7) - (0.5*(t7 + t7.T()) && t7) << endl;
66     Info<< (t7 && symm(t7)) - (t7 && 0.5*(t7 + t7.T())) << endl;
68     return 0;