PoleZeroMaterialLaw.cpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2010
00004 
00005 University of Oxford means the Chancellor, Masters and Scholars of the
00006 University of Oxford, having an administrative office at Wellington
00007 Square, Oxford OX1 2JD, UK.
00008 
00009 This file is part of Chaste.
00010 
00011 Chaste is free software: you can redistribute it and/or modify it
00012 under the terms of the GNU Lesser General Public License as published
00013 by the Free Software Foundation, either version 2.1 of the License, or
00014 (at your option) any later version.
00015 
00016 Chaste is distributed in the hope that it will be useful, but WITHOUT
00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00019 License for more details. The offer of Chaste under the terms of the
00020 License is subject to the License being interpreted in accordance with
00021 English Law and subject to any action against the University of Oxford
00022 being under the jurisdiction of the English Courts.
00023 
00024 You should have received a copy of the GNU Lesser General Public License
00025 along with Chaste. If not, see <http://www.gnu.org/licenses/>.
00026 
00027 */
00028 
00029 #include "PoleZeroMaterialLaw.hpp"
00030 
00031 template<unsigned DIM>
00032 PoleZeroMaterialLaw<DIM>::PoleZeroMaterialLaw()
00033 {
00034     mpChangeOfBasisMatrix = NULL;
00035 }
00036 
00037 template<unsigned DIM>
00038 void PoleZeroMaterialLaw<DIM>::SetParameters(std::vector<std::vector<double> > k,
00039                                              std::vector<std::vector<double> > a,
00040                                              std::vector<std::vector<double> > b)
00041 {
00042     if (DIM!=2 && DIM !=3)
00043     {
00044         EXCEPTION("Can only have a 2 or 3d incompressible pole-zero law");
00045     }
00046 
00047     assert(k.size()==DIM);
00048     assert(a.size()==DIM);
00049     assert(b.size()==DIM);
00050 
00051     for (unsigned i=0; i<DIM; i++)
00052     {
00053         assert(k[i].size()==DIM);
00054         assert(a[i].size()==DIM);
00055         assert(b[i].size()==DIM);
00056 
00057         for (unsigned j=0; j<DIM; j++)
00058         {
00059             assert( k[i][j] = k[j][i] );
00060             assert( a[i][j] = a[j][i] );
00061             assert( b[i][j] = b[j][i] );
00062         }
00063     }
00064 
00065     mK = k;
00066     mA = a;
00067     mB = b;
00068 
00069     for (unsigned M=0; M<DIM; M++)
00070     {
00071         for (unsigned N=0; N<DIM; N++)
00072         {
00073             mIdentity(M,N) = M==N ? 1.0 : 0.0;
00074         }
00075     }
00076 }
00077 
00078 template<unsigned DIM>
00079 PoleZeroMaterialLaw<DIM>::PoleZeroMaterialLaw(std::vector<std::vector<double> > k,
00080                                               std::vector<std::vector<double> > a,
00081                                               std::vector<std::vector<double> > b)
00082 {
00083     SetParameters(k,a,b);
00084     mpChangeOfBasisMatrix = NULL;
00085 }
00086 
00087 
00088 template<unsigned DIM>
00089 void PoleZeroMaterialLaw<DIM>::ComputeStressAndStressDerivative(c_matrix<double,DIM,DIM>& rC,
00090                                                                 c_matrix<double,DIM,DIM>& rInvC,
00091                                                                 double                    pressure,
00092                                                                 c_matrix<double,DIM,DIM>& rT,
00093                                                                 FourthOrderTensor<DIM>&   rDTdE,
00094                                                                 bool                      computeDTdE)
00095 {
00096     // EMTODO: can factor out change of basis code? as repeated in SchmidCosta.
00097     static c_matrix<double,DIM,DIM> C_transformed;
00098     static c_matrix<double,DIM,DIM> invC_transformed;
00099 
00100     // The material law parameters are set up assuming the fibre direction is (1,0,0)
00101     // and sheet direction is (0,1,0), so we have to transform C,inv(C),and T.
00102     // Let P be the change-of-basis matrix P = (\mathbf{m}_f, \mathbf{m}_s, \mathbf{m}_n).
00103     // The transformed C for the fibre/sheet basis is C* = P^T C P.
00104     // We then compute T* = T*(C*), and then compute T = P T* P^T.
00105 
00106     if(mpChangeOfBasisMatrix)
00107     {
00108         // C* = P^T C P, and ditto inv(C)
00109         C_transformed = prod(trans(*mpChangeOfBasisMatrix),(c_matrix<double,DIM,DIM>)prod(rC,*mpChangeOfBasisMatrix));          // C*    = P^T C    P
00110         invC_transformed = prod(trans(*mpChangeOfBasisMatrix),(c_matrix<double,DIM,DIM>)prod(rInvC,*mpChangeOfBasisMatrix));   // invC* = P^T invC P
00111     }
00112     else
00113     {
00114         C_transformed = rC;
00115         invC_transformed = rInvC;
00116     }
00117 
00118     // compute T*
00119 
00120     c_matrix<double,DIM,DIM> E = 0.5*(C_transformed - mIdentity);
00121 
00122     for (unsigned M=0; M<DIM; M++)
00123     {
00124         for (unsigned N=0; N<DIM; N++)
00125         {
00126             double e = E(M,N);
00127           //  if (e > 0)  // EMTODO4: check this
00128             {
00129                 double b = mB[M][N];
00130                 double a = mA[M][N];
00131                 double k = mK[M][N];
00132 
00133                 //if this fails one of the strain values got too large for the law
00134                 if(e>=a)
00135                 {
00136                     EXCEPTION("E_{MN} >= a_{MN} - strain unacceptably large for model");
00137                 }
00138 
00139                 rT(M,N) =   k
00140                           * e
00141                           * (2*(a-e) + b*e)
00142                           * pow(a-e,-b-1)
00143                           - pressure*invC_transformed(M,N);
00144             }
00145 //                else
00146 //                {
00147 //                    T(M,N) = 0.0;
00148 //                }
00149         }
00150     }
00151 
00152     if (computeDTdE)
00153     {
00154         for (unsigned M=0; M<DIM; M++)
00155         {
00156             for (unsigned N=0; N<DIM; N++)
00157             {
00158                 for (unsigned P=0; P<DIM; P++)
00159                 {
00160                     for (unsigned Q=0; Q<DIM; Q++)
00161                     {
00162                         rDTdE(M,N,P,Q) = 2 * pressure * invC_transformed(M,P) * invC_transformed(Q,N);
00163                     }
00164                 }
00165 
00166                 double e = E(M,N);
00167              //   if (e > 0)
00168                 {
00169                     double b = mB[M][N];
00170                     double a = mA[M][N];
00171                     double k = mK[M][N];
00172 
00173                     rDTdE(M,N,M,N) +=   k
00174                                       * pow(a-e, -b-2)
00175                                       * (
00176                                            2*(a-e)*(a-e)
00177                                          + 4*b*e*(a-e)
00178                                          + b*(b+1)*e*e
00179                                         );
00180                 }
00181             }
00182         }
00183     }
00184 
00185 
00186     // now do:   T = P T* P^T   and   dTdE_{MNPQ}  =  P_{Mm}P_{Nn}P_{Pp}P_{Qq} dT*dE*_{mnpq}
00187     if(mpChangeOfBasisMatrix)
00188     {
00189         static c_matrix<double,DIM,DIM> T_transformed_times_Ptrans;
00190         T_transformed_times_Ptrans = prod(rT, trans(*mpChangeOfBasisMatrix));
00191 
00192         rT = prod(*mpChangeOfBasisMatrix, T_transformed_times_Ptrans);  // T = P T* P^T
00193 
00194         // dTdE_{MNPQ}  =  P_{Mm}P_{Nn}P_{Pp}P_{Qq} dT*dE*_{mnpq}
00195         if (computeDTdE)
00196         {
00197             static FourthOrderTensor<DIM> temp;
00198             temp.SetAsProduct(rDTdE, *mpChangeOfBasisMatrix, 0);
00199             rDTdE.SetAsProduct(temp, *mpChangeOfBasisMatrix, 1);
00200             temp.SetAsProduct(rDTdE, *mpChangeOfBasisMatrix, 2);
00201             rDTdE.SetAsProduct(temp, *mpChangeOfBasisMatrix, 3);
00202         }
00203     }
00204 
00205 }
00206 
00207 template<unsigned DIM>
00208 double PoleZeroMaterialLaw<DIM>::GetZeroStrainPressure()
00209 {
00210     return 0.0;
00211 }
00212 
00213 template<unsigned DIM>
00214 void PoleZeroMaterialLaw<DIM>::ScaleMaterialParameters(double scaleFactor)
00215 {
00216     assert(scaleFactor > 0.0);
00217     for (unsigned i=0; i<mK.size(); i++)
00218     {
00219         for (unsigned j=0; j<mK[i].size(); j++)
00220         {
00221             mK[i][j] /= scaleFactor;
00222         }
00223     }
00224 }
00225 
00226 
00228 // Explicit instantiation
00230 
00231 template class PoleZeroMaterialLaw<2>;
00232 template class PoleZeroMaterialLaw<3>;

Generated by  doxygen 1.6.2