PolynomialMaterialLaw3d.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "PolynomialMaterialLaw3d.hpp"
00030
00031 double PolynomialMaterialLaw3d::Get_dW_dI1(double I1, double I2)
00032 {
00033 double ret = 0.0;
00034
00035
00036
00037 for (int p=1; p<=(int)mN; p++)
00038 {
00039 for (int q=0; q<=(int)mN-p; q++)
00040 {
00041 ret += mAlpha[p][q] * p * pow(I1-3,p-1) * pow(I2-3,q);
00042 }
00043 }
00044
00045 return ret;
00046 }
00047
00048 double PolynomialMaterialLaw3d::Get_dW_dI2(double I1, double I2)
00049 {
00050 double ret = 0.0;
00051
00052
00053
00054 for (int p=0; p<=(int)mN; p++)
00055 {
00056 for (int q=1; q<=(int)mN-p; q++)
00057 {
00058 ret += mAlpha[p][q] * q * pow(I1-3,p) * pow(I2-3,q-1);
00059 }
00060 }
00061 return ret;
00062 }
00063
00064 double PolynomialMaterialLaw3d::Get_d2W_dI1(double I1, double I2)
00065 {
00066 double ret = 0.0;
00067
00068
00069
00070
00071 for (int p=2; p<=(int)mN; p++)
00072 {
00073 for (int q=0; q<=(int)mN-p; q++)
00074 {
00075 ret += mAlpha[p][q] * p * (p-1) * pow(I1-3,(p-1)*(p-2)) * pow(I2-3,q);
00076 }
00077 }
00078 return ret;
00079 }
00080
00081 double PolynomialMaterialLaw3d::Get_d2W_dI2(double I1, double I2)
00082 {
00083 double ret = 0.0;
00084
00085
00086
00087
00088 for (int p=0; p<=(int)mN; p++)
00089 {
00090 for (int q=2; q<=(int)mN-p; q++)
00091 {
00092 ret += mAlpha[p][q] * q * (q-1) * pow(I1-3,p) * pow(I2-3,(q-1)*(q-2));
00093 }
00094 }
00095 return ret;
00096 }
00097
00098 double PolynomialMaterialLaw3d::Get_d2W_dI1I2(double I1, double I2)
00099 {
00100 double ret = 0.0;
00101
00102
00103
00104
00105 for (int p=1; p<=(int)mN; p++)
00106 {
00107 for (int q=1; q<=(int)mN-p; q++)
00108 {
00109 ret += mAlpha[p][q] * p * q * pow(I1-3,p-1) * pow(I2-3,q-1);
00110 }
00111 }
00112 return ret;
00113 }
00114
00115 double PolynomialMaterialLaw3d::GetAlpha(unsigned i, unsigned j)
00116 {
00117 assert(i+j > 0);
00118 assert(i+j <= mN);
00119
00120 return mAlpha[i][j];
00121 }
00122
00123 PolynomialMaterialLaw3d::PolynomialMaterialLaw3d(unsigned n, std::vector<std::vector<double> > alpha)
00124 {
00125 if (n==0)
00126 {
00127 EXCEPTION("n must be positive");
00128 }
00129
00130 mN = n;
00131
00132
00133 for (unsigned p=0; p<=mN; p++)
00134 {
00135 if (alpha[p].size() < mN+1-p)
00136 {
00137 EXCEPTION("alpha not big enough");
00138 }
00139
00140 for (unsigned q=0; q<alpha[p].size(); q++)
00141 {
00142 if ((p+q>mN) && (fabs(alpha[p][q]) > 1e-12))
00143 {
00144 std::stringstream err_mess;
00145 err_mess << "alpha[" << p << "][" << q << "] should be zero, as p+q > " << n;
00146 EXCEPTION(err_mess.str());
00147 }
00148 }
00149 }
00150
00151 mAlpha = alpha;
00152 }
00153
00154 std::vector<std::vector<double> > PolynomialMaterialLaw3d::GetZeroedAlpha(unsigned n)
00155 {
00156 std::vector<std::vector<double> > alpha(n+1);
00157
00158 for (unsigned i=0; i<n+1; i++)
00159 {
00160 alpha[i].resize(n+1);
00161 for (unsigned j=0; j<n+1; j++)
00162 {
00163 alpha[i][j] = 0.0;
00164 }
00165 }
00166
00167 return alpha;
00168 }
00169