AbstractMaterialLaw.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 "AbstractMaterialLaw.hpp"
00030 
00031 template<unsigned DIM>
00032 AbstractMaterialLaw<DIM>::AbstractMaterialLaw()
00033     : mpChangeOfBasisMatrix(NULL)
00034 {
00035 }
00036 
00037 
00038 
00039 template<unsigned DIM>
00040 void AbstractMaterialLaw<DIM>::ComputeCauchyStress(c_matrix<double,DIM,DIM>& rF,
00041                                                    double pressure,
00042                                                    c_matrix<double,DIM,DIM>& rSigma)
00043 {
00044     double detF = Determinant(rF);
00045 
00046     c_matrix<double,DIM,DIM> C = prod(trans(rF), rF);
00047     c_matrix<double,DIM,DIM> invC = Inverse(C);
00048 
00049     c_matrix<double,DIM,DIM> T;
00050 
00051     static FourthOrderTensor<DIM,DIM,DIM,DIM> dTdE; // not filled in, made static for efficiency
00052 
00053     ComputeStressAndStressDerivative(C, invC, pressure, T, dTdE, false);
00054 
00055     // looping it probably more eficient then doing rSigma = (1/detF)*rF*T*transpose(rF)
00056     // which doesn't seem to compile anyway, as rF is a Tensor<2,DIM> and T is a
00057     // SymmetricTensor<2,DIM>
00058     for (unsigned i=0; i<DIM; i++)
00059     {
00060         for (unsigned j=0; j<DIM; j++)
00061         {
00062             rSigma(i,j) = 0.0;
00063             for (unsigned M=0; M<DIM; M++)
00064             {
00065                 for (unsigned N=0; N<DIM; N++)
00066                 {
00067                     rSigma(i,j) += rF(i,M)*T(M,N)*rF(j,N);
00068                 }
00069             }
00070             rSigma(i,j) /= detF;
00071         }
00072     }
00073 }
00074 
00075 template<unsigned DIM>
00076 void AbstractMaterialLaw<DIM>::Compute1stPiolaKirchoffStress(c_matrix<double,DIM,DIM>& rF,
00077                                                              double pressure,
00078                                                              c_matrix<double,DIM,DIM>& rS)
00079 {
00080     c_matrix<double,DIM,DIM> C = prod(trans(rF), rF);
00081     c_matrix<double,DIM,DIM> invC = Inverse(C);
00082 
00083     c_matrix<double,DIM,DIM> T;
00084 
00085     static FourthOrderTensor<DIM,DIM,DIM,DIM> dTdE; // not filled in, made static for efficiency
00086 
00087     ComputeStressAndStressDerivative(C, invC, pressure, T, dTdE, false);
00088 
00089     rS = prod(T, trans(rF));
00090 }
00091 
00092 template<unsigned DIM>
00093 void AbstractMaterialLaw<DIM>::Compute2ndPiolaKirchoffStress(c_matrix<double,DIM,DIM>& rC,
00094                                                              double pressure,
00095                                                              c_matrix<double,DIM,DIM>& rT)
00096 {
00097     c_matrix<double,DIM,DIM> invC = Inverse(rC);
00098 
00099     static FourthOrderTensor<DIM,DIM,DIM,DIM> dTdE; // not filled in, made static for efficiency
00100 
00101     ComputeStressAndStressDerivative(rC, invC, pressure, rT, dTdE, false);
00102 }
00103 
00104 template<unsigned DIM>
00105 void AbstractMaterialLaw<DIM>::ScaleMaterialParameters(double scaleFactor)
00106 {
00107     #define COVERAGE_IGNORE
00108     EXCEPTION("[the material law you are using]::ScaleMaterialParameters() has not been implemented\n");
00109     #undef COVERAGE_IGNORE
00110 }
00111 
00112 
00113 template<unsigned DIM>
00114 void AbstractMaterialLaw<DIM>::SetChangeOfBasisMatrix(c_matrix<double,DIM,DIM>& rChangeOfBasisMatrix)
00115 {
00116     mpChangeOfBasisMatrix = &rChangeOfBasisMatrix;
00117 }
00118 
00119 template<unsigned DIM>
00120 void AbstractMaterialLaw<DIM>::ResetToNoChangeOfBasisMatrix()
00121 {
00122     mpChangeOfBasisMatrix = NULL;
00123 }
00124 
00125 
00126 template<unsigned DIM>
00127 void AbstractMaterialLaw<DIM>::ComputeTransformedDeformationTensor(c_matrix<double,DIM,DIM>& rC, c_matrix<double,DIM,DIM>& rInvC,
00128                                                                    c_matrix<double,DIM,DIM>& rCTransformed, c_matrix<double,DIM,DIM>& rInvCTransformed)
00129 {
00130     // Writing the local coordinate system as fibre/sheet/normal, as in cardiac problems..
00131 
00132     // Let P be the change-of-basis matrix P = (\mathbf{m}_f, \mathbf{m}_s, \mathbf{m}_n).
00133     // The transformed C for the fibre/sheet basis is C* = P^T C P.
00134 
00135     if(mpChangeOfBasisMatrix)
00136     {
00137         // C* = P^T C P, and ditto inv(C)
00138         rCTransformed = prod(trans(*mpChangeOfBasisMatrix),(c_matrix<double,DIM,DIM>)prod(rC,*mpChangeOfBasisMatrix));         // C*    = P^T C    P
00139         rInvCTransformed = prod(trans(*mpChangeOfBasisMatrix),(c_matrix<double,DIM,DIM>)prod(rInvC,*mpChangeOfBasisMatrix));   // invC* = P^T invC P
00140     }
00141     else
00142     {
00143         rCTransformed = rC;
00144         rInvCTransformed = rInvC;
00145     }
00146 }
00147 
00148 template<unsigned DIM>
00149 void AbstractMaterialLaw<DIM>::TransformStressAndStressDerivative(c_matrix<double,DIM,DIM>& rT,
00150                                                                   FourthOrderTensor<DIM,DIM,DIM,DIM>& rDTdE,
00151                                                                   bool transformDTdE)
00152 {
00153     //  T = P T* P^T   and   dTdE_{MNPQ}  =  P_{Mm}P_{Nn}P_{Pp}P_{Qq} dT*dE*_{mnpq}
00154     if(mpChangeOfBasisMatrix)
00155     {
00156         static c_matrix<double,DIM,DIM> T_transformed_times_Ptrans;
00157         T_transformed_times_Ptrans = prod(rT, trans(*mpChangeOfBasisMatrix));
00158 
00159         rT = prod(*mpChangeOfBasisMatrix, T_transformed_times_Ptrans);  // T = P T* P^T
00160 
00161         // dTdE_{MNPQ}  =  P_{Mm}P_{Nn}P_{Pp}P_{Qq} dT*dE*_{mnpq}
00162         if (transformDTdE)
00163         {
00164             static FourthOrderTensor<DIM,DIM,DIM,DIM> temp;
00165             temp.template SetAsContractionOnFirstDimension<DIM>(*mpChangeOfBasisMatrix, rDTdE);
00166             rDTdE.template SetAsContractionOnSecondDimension<DIM>(*mpChangeOfBasisMatrix, temp);
00167             temp.template SetAsContractionOnThirdDimension<DIM>(*mpChangeOfBasisMatrix, rDTdE);
00168             rDTdE.template SetAsContractionOnFourthDimension<DIM>(*mpChangeOfBasisMatrix, temp);
00169         }
00170     }
00171 }
00172 
00173 
00174 
00175 
00177 // Explicit instantiation
00179 
00180 //template class AbstractMaterialLaw<1>;
00181 template class AbstractMaterialLaw<2>;
00182 template class AbstractMaterialLaw<3>;

Generated on Tue May 31 14:31:48 2011 for Chaste by  doxygen 1.5.5