Chaste Release::3.1
PoleZeroMaterialLaw.cpp
00001 /*
00002 
00003 Copyright (c) 2005-2012, University of Oxford.
00004 All rights reserved.
00005 
00006 University of Oxford means the Chancellor, Masters and Scholars of the
00007 University of Oxford, having an administrative office at Wellington
00008 Square, Oxford OX1 2JD, UK.
00009 
00010 This file is part of Chaste.
00011 
00012 Redistribution and use in source and binary forms, with or without
00013 modification, are permitted provided that the following conditions are met:
00014  * Redistributions of source code must retain the above copyright notice,
00015    this list of conditions and the following disclaimer.
00016  * Redistributions in binary form must reproduce the above copyright notice,
00017    this list of conditions and the following disclaimer in the documentation
00018    and/or other materials provided with the distribution.
00019  * Neither the name of the University of Oxford nor the names of its
00020    contributors may be used to endorse or promote products derived from this
00021    software without specific prior written permission.
00022 
00023 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00024 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00025 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00026 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
00027 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00028 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
00029 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00030 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00031 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
00032 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00033 
00034 */
00035 
00036 #include "PoleZeroMaterialLaw.hpp"
00037 
00038 template<unsigned DIM>
00039 PoleZeroMaterialLaw<DIM>::PoleZeroMaterialLaw()
00040 {
00041 }
00042 
00043 template<unsigned DIM>
00044 void PoleZeroMaterialLaw<DIM>::SetParameters(std::vector<std::vector<double> > k,
00045                                              std::vector<std::vector<double> > a,
00046                                              std::vector<std::vector<double> > b)
00047 {
00048     if (DIM!=2 && DIM !=3)
00049     {
00050         EXCEPTION("Can only have a 2 or 3d incompressible pole-zero law");
00051     }
00052 
00053     assert(k.size()==DIM);
00054     assert(a.size()==DIM);
00055     assert(b.size()==DIM);
00056 
00057     for (unsigned i=0; i<DIM; i++)
00058     {
00059         assert(k[i].size()==DIM);
00060         assert(a[i].size()==DIM);
00061         assert(b[i].size()==DIM);
00062 
00063         for (unsigned j=0; j<DIM; j++)
00064         {
00065             assert( k[i][j] = k[j][i] );
00066             assert( a[i][j] = a[j][i] );
00067             assert( b[i][j] = b[j][i] );
00068         }
00069     }
00070 
00071     mK = k;
00072     mA = a;
00073     mB = b;
00074 
00075     for (unsigned M=0; M<DIM; M++)
00076     {
00077         for (unsigned N=0; N<DIM; N++)
00078         {
00079             mIdentity(M,N) = M==N ? 1.0 : 0.0;
00080         }
00081     }
00082 }
00083 
00084 template<unsigned DIM>
00085 PoleZeroMaterialLaw<DIM>::PoleZeroMaterialLaw(std::vector<std::vector<double> > k,
00086                                               std::vector<std::vector<double> > a,
00087                                               std::vector<std::vector<double> > b)
00088 {
00089     SetParameters(k,a,b);
00090 }
00091 
00092 
00093 template<unsigned DIM>
00094 void PoleZeroMaterialLaw<DIM>::ComputeStressAndStressDerivative(c_matrix<double,DIM,DIM>& rC,
00095                                                                 c_matrix<double,DIM,DIM>& rInvC,
00096                                                                 double                    pressure,
00097                                                                 c_matrix<double,DIM,DIM>& rT,
00098                                                                 FourthOrderTensor<DIM,DIM,DIM,DIM>&   rDTdE,
00099                                                                 bool                      computeDTdE)
00100 {
00101     static c_matrix<double,DIM,DIM> C_transformed;
00102     static c_matrix<double,DIM,DIM> invC_transformed;
00103 
00104     // The material law parameters are set up assuming the fibre direction is (1,0,0)
00105     // and sheet direction is (0,1,0), so we have to transform C,inv(C),and T.
00106     // Let P be the change-of-basis matrix P = (\mathbf{m}_f, \mathbf{m}_s, \mathbf{m}_n).
00107     // The transformed C for the fibre/sheet basis is C* = P^T C P.
00108     // We then compute T* = T*(C*), and then compute T = P T* P^T.
00109 
00110     ComputeTransformedDeformationTensor(rC, rInvC, C_transformed, invC_transformed);
00111 
00112     // compute T*
00113 
00114     c_matrix<double,DIM,DIM> E = 0.5*(C_transformed - mIdentity);
00115 
00116     for (unsigned M=0; M<DIM; M++)
00117     {
00118         for (unsigned N=0; N<DIM; N++)
00119         {
00120             double e = E(M,N);
00121             {
00122                 double b = mB[M][N];
00123                 double a = mA[M][N];
00124                 double k = mK[M][N];
00125 
00126                 //if this fails one of the strain values got too large for the law
00127                 if (e>=a)
00128                 {
00129                     EXCEPTION("E_{MN} >= a_{MN} - strain unacceptably large for model");
00130                 }
00131 
00132                 rT(M,N) =   k
00133                           * e
00134                           * (2*(a-e) + b*e)
00135                           * pow(a-e,-b-1)
00136                           - pressure*invC_transformed(M,N);
00137             }
00138         }
00139     }
00140 
00141     if (computeDTdE)
00142     {
00143         for (unsigned M=0; M<DIM; M++)
00144         {
00145             for (unsigned N=0; N<DIM; N++)
00146             {
00147                 for (unsigned P=0; P<DIM; P++)
00148                 {
00149                     for (unsigned Q=0; Q<DIM; Q++)
00150                     {
00151                         rDTdE(M,N,P,Q) = 2 * pressure * invC_transformed(M,P) * invC_transformed(Q,N);
00152                     }
00153                 }
00154 
00155                 double e = E(M,N);
00156 
00157                 double b = mB[M][N];
00158                 double a = mA[M][N];
00159                 double k = mK[M][N];
00160 
00161                 rDTdE(M,N,M,N) +=   k
00162                                   * pow(a-e, -b-2)
00163                                   * (
00164                                        2*(a-e)*(a-e)
00165                                      + 4*b*e*(a-e)
00166                                      + b*(b+1)*e*e
00167                                     );
00168             }
00169         }
00170     }
00171 
00172     // Now do:   T = P T* P^T   and   dTdE_{MNPQ}  =  P_{Mm}P_{Nn}P_{Pp}P_{Qq} dT*dE*_{mnpq}
00173     this->TransformStressAndStressDerivative(rT, rDTdE, computeDTdE);
00174 }
00175 
00176 template<unsigned DIM>
00177 double PoleZeroMaterialLaw<DIM>::GetZeroStrainPressure()
00178 {
00179     return 0.0;
00180 }
00181 
00182 template<unsigned DIM>
00183 void PoleZeroMaterialLaw<DIM>::ScaleMaterialParameters(double scaleFactor)
00184 {
00185     assert(scaleFactor > 0.0);
00186     for (unsigned i=0; i<mK.size(); i++)
00187     {
00188         for (unsigned j=0; j<mK[i].size(); j++)
00189         {
00190             mK[i][j] /= scaleFactor;
00191         }
00192     }
00193 }
00194 
00196 // Explicit instantiation
00198 
00199 template class PoleZeroMaterialLaw<2>;
00200 template class PoleZeroMaterialLaw<3>;