00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <iostream>
00023
00024 #include "tensors/tensors.h"
00025 #include "tensors/functions.h"
00026
00027 using namespace std;
00028
00029 int main(int argc, char **argv)
00030 {
00031
00032
00033 Tensors::Tensor2 a; a(0)=10; a(1)=20; a(2)=30; a(3)=4*sqrt(2.0); a(4)=6*sqrt(2.0); a(5)=5*sqrt(2.0);
00034 Tensors::Tensor2 b; b(0)=20; b(1)=40; b(2)=60; b(3)=8*sqrt(2.0); b(4)=12*sqrt(2.0); b(5)=10*sqrt(2.0);
00035
00036
00037 cout << "a = " << a << endl;
00038 cout << "b = " << b << endl;
00039
00040 Tensors::Tensor4 T;
00041 for (int i=0; i<6; ++i)
00042 for (int j=0; j<6; ++j)
00043 T(i,j) = 10*(i+1) + (j+1);
00044
00045 Tensors::Tensor2 ab;
00046 Tensors::Tensor2 inv_a;
00047 REAL only_ev_a[3];
00048 REAL ev_a[3];
00049 Tensors::Tensor2 ep_a[3];
00050 Tensors::Tensor2 sqrt_a;
00051
00052 Tensors::Mult(a,b,ab);
00053
00054 if (!Tensors::Inv(a,inv_a))
00055 {
00056 cout << "ERROR: Inv(a) failed\n";
00057 }
00058 if (!Tensors::Eigenvals(a,only_ev_a))
00059 {
00060 cout << "ERROR: Eigenvals(a) failed\n";
00061 }
00062 if (!Tensors::Eigenvp(a,ev_a,ep_a))
00063 {
00064 cout << "ERROR: Eigenvp(a) failed\n";
00065 }
00066 if (!Tensors::Sqrt(a,sqrt_a))
00067 {
00068 cout << "ERROR: sqrt(a) failed\n";
00069 }
00070
00071 cout << "ab = \n" << ab << endl;
00072 cout << "Norm(a) = " << Tensors::Norm(a) << endl;
00073 cout << "inv_a = \n" << inv_a << endl;
00074 cout << "only_ev_a = \n"; for (int i=0; i<3; ++i) cout << only_ev_a[i] << endl;
00075 cout << "ev_a = \n"; for (int i=0; i<3; ++i) cout << ev_a[i] << endl;
00076 cout << "ep_a = \n"; for (int i=0; i<3; ++i) cout << ep_a[i] << endl;
00077 cout << "sqrt_a = \n" << sqrt_a << endl;
00078
00079 REAL Ia[3];
00080 REAL Ev,Ed,p,q,tn,ts,P,Q;
00081
00082 Tensors::Tensor2 I; I(0)=1.0; I(1)=1.0; I(2)=1.0; I(3)=0.0; I(4)=0.0; I(5)=0.0;
00083
00084
00085 Tensors::CharInvs(a,Ia);
00086 Tensors::Strain_Ev_Ed(a,Ev,Ed);
00087 Tensors::Stress_p_q(a,p,q);
00088 Tensors::Stress_tn_ts(a,tn,ts);
00089 Tensors::Stress_P_Q(a,P,Q);
00090
00091 cout << "a = " << a << endl;
00092 cout << "Ia[0]=" << Ia[0] << ", Ia[1]=" << Ia[1] << ", Ia[2]=" << Ia[2] << endl;
00093 cout << "Ev=" << Ev << ", Ed=" << Ed << ", p=" << p << ", q=" << q << endl;
00094 cout << "tn=" << tn << ", ts=" << ts << endl;
00095 cout << "P=" << P << ", Q=" << Q << endl;
00096
00097 cout << "I=" << Tensors::I << endl;
00098 cout << "IIsym=\n" << Tensors::IIsym << endl;
00099 cout << "IdyI=\n" << Tensors::IdyI << endl;
00100
00101 REAL sin3th;
00102 Tensors::Tensor2 S;
00103 Tensors::Stress_p_q_S_sin3th(a, p,q,S,sin3th);
00104 cout << "p=" << p << ", q=" << q << ", S=" << S << ", sin3th=" << sin3th << endl;
00105
00106 Tensors::Stress_P_Q_S_sin3th(a, P,Q,S,sin3th);
00107 cout << "P=" << P << ", Q=" << Q << ", sin3th=" << sin3th << endl;
00108
00109 return 0;
00110 }