PoleZeroMaterialLaw.cpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2011
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 }
00035 
00036 template<unsigned DIM>
00037 void PoleZeroMaterialLaw<DIM>::SetParameters(std::vector<std::vector<double> > k,
00038                                              std::vector<std::vector<double> > a,
00039                                              std::vector<std::vector<double> > b)
00040 {
00041     if (DIM!=2 && DIM !=3)
00042     {
00043         EXCEPTION("Can only have a 2 or 3d incompressible pole-zero law");
00044     }
00045 
00046     assert(k.size()==DIM);
00047     assert(a.size()==DIM);
00048     assert(b.size()==DIM);
00049 
00050     for (unsigned i=0; i<DIM; i++)
00051     {
00052         assert(k[i].size()==DIM);
00053         assert(a[i].size()==DIM);
00054         assert(b[i].size()==DIM);
00055 
00056         for (unsigned j=0; j<DIM; j++)
00057         {
00058             assert( k[i][j] = k[j][i] );
00059             assert( a[i][j] = a[j][i] );
00060             assert( b[i][j] = b[j][i] );
00061         }
00062     }
00063 
00064     mK = k;
00065     mA = a;
00066     mB = b;
00067 
00068     for (unsigned M=0; M<DIM; M++)
00069     {
00070         for (unsigned N=0; N<DIM; N++)
00071         {
00072             mIdentity(M,N) = M==N ? 1.0 : 0.0;
00073         }
00074     }
00075 }
00076 
00077 template<unsigned DIM>
00078 PoleZeroMaterialLaw<DIM>::PoleZeroMaterialLaw(std::vector<std::vector<double> > k,
00079                                               std::vector<std::vector<double> > a,
00080                                               std::vector<std::vector<double> > b)
00081 {
00082     SetParameters(k,a,b);
00083 }
00084 
00085 
00086 template<unsigned DIM>
00087 void PoleZeroMaterialLaw<DIM>::ComputeStressAndStressDerivative(c_matrix<double,DIM,DIM>& rC,
00088                                                                 c_matrix<double,DIM,DIM>& rInvC,
00089                                                                 double                    pressure,
00090                                                                 c_matrix<double,DIM,DIM>& rT,
00091                                                                 FourthOrderTensor<DIM,DIM,DIM,DIM>&   rDTdE,
00092                                                                 bool                      computeDTdE)
00093 {
00094     static c_matrix<double,DIM,DIM> C_transformed;
00095     static c_matrix<double,DIM,DIM> invC_transformed;
00096 
00097     // The material law parameters are set up assuming the fibre direction is (1,0,0)
00098     // and sheet direction is (0,1,0), so we have to transform C,inv(C),and T.
00099     // Let P be the change-of-basis matrix P = (\mathbf{m}_f, \mathbf{m}_s, \mathbf{m}_n).
00100     // The transformed C for the fibre/sheet basis is C* = P^T C P.
00101     // We then compute T* = T*(C*), and then compute T = P T* P^T.
00102 
00103     ComputeTransformedDeformationTensor(rC, rInvC, C_transformed, invC_transformed);
00104 
00105     // compute T*
00106 
00107     c_matrix<double,DIM,DIM> E = 0.5*(C_transformed - mIdentity);
00108 
00109     for (unsigned M=0; M<DIM; M++)
00110     {
00111         for (unsigned N=0; N<DIM; N++)
00112         {
00113             double e = E(M,N);
00114             {
00115                 double b = mB[M][N];
00116                 double a = mA[M][N];
00117                 double k = mK[M][N];
00118 
00119                 //if this fails one of the strain values got too large for the law
00120                 if (e>=a)
00121                 {
00122                     EXCEPTION("E_{MN} >= a_{MN} - strain unacceptably large for model");
00123                 }
00124 
00125                 rT(M,N) =   k
00126                           * e
00127                           * (2*(a-e) + b*e)
00128                           * pow(a-e,-b-1)
00129                           - pressure*invC_transformed(M,N);
00130             }
00131         }
00132     }
00133 
00134     if (computeDTdE)
00135     {
00136         for (unsigned M=0; M<DIM; M++)
00137         {
00138             for (unsigned N=0; N<DIM; N++)
00139             {
00140                 for (unsigned P=0; P<DIM; P++)
00141                 {
00142                     for (unsigned Q=0; Q<DIM; Q++)
00143                     {
00144                         rDTdE(M,N,P,Q) = 2 * pressure * invC_transformed(M,P) * invC_transformed(Q,N);
00145                     }
00146                 }
00147 
00148                 double e = E(M,N);
00149 
00150                 double b = mB[M][N];
00151                 double a = mA[M][N];
00152                 double k = mK[M][N];
00153 
00154                 rDTdE(M,N,M,N) +=   k
00155                                   * pow(a-e, -b-2)
00156                                   * (
00157                                        2*(a-e)*(a-e)
00158                                      + 4*b*e*(a-e)
00159                                      + b*(b+1)*e*e
00160                                     );
00161             }
00162         }
00163     }
00164 
00165     // Now do:   T = P T* P^T   and   dTdE_{MNPQ}  =  P_{Mm}P_{Nn}P_{Pp}P_{Qq} dT*dE*_{mnpq}
00166     this->TransformStressAndStressDerivative(rT, rDTdE, computeDTdE);
00167 }
00168 
00169 template<unsigned DIM>
00170 double PoleZeroMaterialLaw<DIM>::GetZeroStrainPressure()
00171 {
00172     return 0.0;
00173 }
00174 
00175 template<unsigned DIM>
00176 void PoleZeroMaterialLaw<DIM>::ScaleMaterialParameters(double scaleFactor)
00177 {
00178     assert(scaleFactor > 0.0);
00179     for (unsigned i=0; i<mK.size(); i++)
00180     {
00181         for (unsigned j=0; j<mK[i].size(); j++)
00182         {
00183             mK[i][j] /= scaleFactor;
00184         }
00185     }
00186 }
00187 
00189 // Explicit instantiation
00191 
00192 template class PoleZeroMaterialLaw<2>;
00193 template class PoleZeroMaterialLaw<3>;
Generated on Thu Dec 22 13:00:05 2011 for Chaste by  doxygen 1.6.3