Chaste Release::3.1
AbstractIsotropicCompressibleMaterialLaw.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 "AbstractIsotropicCompressibleMaterialLaw.hpp"
00037 
00038 template<unsigned DIM>
00039 AbstractIsotropicCompressibleMaterialLaw<DIM>::~AbstractIsotropicCompressibleMaterialLaw()
00040 {
00041 }
00042 
00043 template<unsigned DIM>
00044 void AbstractIsotropicCompressibleMaterialLaw<DIM>::ComputeStressAndStressDerivative(c_matrix<double,DIM,DIM>& rC,
00045                                                                                      c_matrix<double,DIM,DIM>& rInvC,
00046                                                                                      double                    pressure,
00047                                                                                      c_matrix<double,DIM,DIM>& rT,
00048                                                                                      FourthOrderTensor<DIM,DIM,DIM,DIM>&   rDTdE,
00049                                                                                      bool                      computeDTdE)
00050 {
00051     /*
00052      * This is covered, but gcov doesn't see this as being covered
00053      * for some reason, maybe because of optimisations.
00054      */
00055     #define COVERAGE_IGNORE
00056     assert((DIM==2) || (DIM==3));
00057     #undef COVERAGE_IGNORE
00058 
00059     assert(pressure==0.0);
00060 
00061     static c_matrix<double,DIM,DIM> identity = identity_matrix<double>(DIM);
00062 
00063     double I1 = Trace(rC);
00064     double I2 = SecondInvariant(rC);
00065     double I3 = Determinant(rC);
00066 
00067     static c_matrix<double,DIM,DIM> dI2dC;
00068     dI2dC = I1*identity - rC;              // MUST be on separate line to above!
00069 
00070     double w1 = Get_dW_dI1(I1,I2,I3);
00071     double w2 = Get_dW_dI2(I1,I2,I3);
00072     double w3 = Get_dW_dI3(I1,I2,I3);
00073 
00074 
00075     // Compute stress:  **** See FiniteElementImplementations document. ****
00076     //
00077     //  T = dW_dE
00078     //    = 2 dW_dC
00079     //    = 2 (  w1 dI1/dC   +  w2 dI2/dC      +   w3 dI3/dC )
00080     //    = 2 (  w1 I        +  w2 (I1*I - C)  +   w3 I3 inv(C) )
00081     //
00082     //  where w1 = dW/dI1, etc
00083     //
00084     rT = 2*w1*identity + 2*w3*I3*rInvC;
00085     if (DIM==3)
00086     {
00087         rT += 2*w2*dI2dC;
00088     }
00089 
00090     // Compute stress derivative if required:  **** See FiniteElementImplementations document. ****
00091     //
00092     // The stress derivative dT_{MN}/dE_{PQ} is
00093     //
00094     //
00095     //  dT_dE = 2 dT_dC
00096     //        = 4  d/dC ( w1 I  +  w2 (I1*I - C)  +   w3 I3 inv(C) )
00097     //  so (in the following ** represents outer product):
00098     //  (1/4) dT_dE =        w11 I**I          +    w12 I**(I1*I-C)           +     w13 I**inv(C)
00099     //                  +    w21 (I1*I-C)**I   +    w22 (I1*I-C)**(I1*I-C)    +     w23 (I1*I-C)**inv(C)           +   w2 (I**I - dC/dC)
00100     //                  +    w31 I3 inv(C)**I  +    w32 I3 inv(C)**(I1*I-C)   +  (w33 I3 + w3) inv(C)**inv(C)      +   w3 d(invC)/dC
00101     //
00102     //  Here, I**I represents the tensor A[M][N][P][Q] = (M==N)*(P==Q) // ie delta(M,N)delta(P,Q),   etc
00103     //
00104 
00105     if (computeDTdE)
00106     {
00107         double  w11    = Get_d2W_dI1(I1,I2,I3);
00108         double  w22    = Get_d2W_dI2(I1,I2,I3);
00109         double  w33    = Get_d2W_dI3(I1,I2,I3);
00110 
00111         double  w23  = Get_d2W_dI2I3(I1,I2,I3);
00112         double  w13  = Get_d2W_dI1I3(I1,I2,I3);
00113         double  w12  = Get_d2W_dI1I2(I1,I2,I3);
00114 
00115         for (unsigned M=0; M<DIM; M++)
00116         {
00117             for (unsigned N=0; N<DIM; N++)
00118             {
00119                 for (unsigned P=0; P<DIM; P++)
00120                 {
00121                     for (unsigned Q=0; Q<DIM; Q++)
00122                     {
00123                         rDTdE(M,N,P,Q) =   4 * w11  * (M==N) * (P==Q)
00124                                          + 4 * w13  * I3 * ( (M==N) * rInvC(P,Q)  +  rInvC(M,N)*(P==Q) )  // the w13 and w31 terms
00125                                          + 4 * (w33*I3 + w3) * I3 * rInvC(M,N) * rInvC(P,Q)
00126                                          - 4 * w3 * I3 * rInvC(M,P) * rInvC(Q,N);
00127 
00128                         if (DIM==3)
00129                         {
00130                             rDTdE(M,N,P,Q) +=   4 * w22  * dI2dC(M,N) * dI2dC(P,Q)
00131                                               + 4 * w12  * ((M==N)*dI2dC(P,Q) + (P==Q)*dI2dC(M,N))          // the w12 and w21 terms
00132                                               + 4 * w23 * I3 * ( dI2dC(M,N)*rInvC(P,Q) + rInvC(M,N)*dI2dC(P,Q)) // the w23 and w32 terms
00133                                               + 4 * w2   * ((M==N)*(P==Q) - (M==P)*(N==Q));
00134                         }
00135                     }
00136                 }
00137             }
00138         }
00139     }
00140 }
00141 
00143 // Explicit instantiation
00145 
00146 //template class AbstractIsotropicCompressibleMaterialLaw<1>;
00147 template class AbstractIsotropicCompressibleMaterialLaw<2>;
00148 template class AbstractIsotropicCompressibleMaterialLaw<3>;