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 template<unsigned DIM>
00038 void AbstractMaterialLaw<DIM>::ComputeCauchyStress(c_matrix<double,DIM,DIM>& rF,
00039                                                    double pressure,
00040                                                    c_matrix<double,DIM,DIM>& rSigma)
00041 {
00042     double detF = Determinant(rF);
00043 
00044     c_matrix<double,DIM,DIM> C = prod(trans(rF), rF);
00045     c_matrix<double,DIM,DIM> invC = Inverse(C);
00046 
00047     c_matrix<double,DIM,DIM> T;
00048 
00049     static FourthOrderTensor<DIM,DIM,DIM,DIM> dTdE; // not filled in, made static for efficiency
00050 
00051     ComputeStressAndStressDerivative(C, invC, pressure, T, dTdE, false);
00052 
00053     /*
00054      * Looping is probably more eficient then doing rSigma = (1/detF)*rF*T*transpose(rF),
00055      * which doesn't seem to compile anyway, as rF is a Tensor<2,DIM> and T is a
00056      * SymmetricTensor<2,DIM>.
00057      */
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 template<unsigned DIM>
00113 void AbstractMaterialLaw<DIM>::SetChangeOfBasisMatrix(c_matrix<double,DIM,DIM>& rChangeOfBasisMatrix)
00114 {
00115     mpChangeOfBasisMatrix = &rChangeOfBasisMatrix;
00116 }
00117 
00118 template<unsigned DIM>
00119 void AbstractMaterialLaw<DIM>::ResetToNoChangeOfBasisMatrix()
00120 {
00121     mpChangeOfBasisMatrix = NULL;
00122 }
00123 
00124 template<unsigned DIM>
00125 void AbstractMaterialLaw<DIM>::ComputeTransformedDeformationTensor(c_matrix<double,DIM,DIM>& rC, c_matrix<double,DIM,DIM>& rInvC,
00126                                                                    c_matrix<double,DIM,DIM>& rCTransformed, c_matrix<double,DIM,DIM>& rInvCTransformed)
00127 {
00128     // Writing the local coordinate system as fibre/sheet/normal, as in cardiac problems..
00129 
00130     // Let P be the change-of-basis matrix P = (\mathbf{m}_f, \mathbf{m}_s, \mathbf{m}_n).
00131     // The transformed C for the fibre/sheet basis is C* = P^T C P.
00132     if (mpChangeOfBasisMatrix)
00133     {
00134         // C* = P^T C P, and ditto inv(C)
00135         rCTransformed = prod(trans(*mpChangeOfBasisMatrix),(c_matrix<double,DIM,DIM>)prod(rC,*mpChangeOfBasisMatrix));         // C*    = P^T C    P
00136         rInvCTransformed = prod(trans(*mpChangeOfBasisMatrix),(c_matrix<double,DIM,DIM>)prod(rInvC,*mpChangeOfBasisMatrix));   // invC* = P^T invC P
00137     }
00138     else
00139     {
00140         rCTransformed = rC;
00141         rInvCTransformed = rInvC;
00142     }
00143 }
00144 
00145 template<unsigned DIM>
00146 void AbstractMaterialLaw<DIM>::TransformStressAndStressDerivative(c_matrix<double,DIM,DIM>& rT,
00147                                                                   FourthOrderTensor<DIM,DIM,DIM,DIM>& rDTdE,
00148                                                                   bool transformDTdE)
00149 {
00150     //  T = P T* P^T   and   dTdE_{MNPQ}  =  P_{Mm}P_{Nn}P_{Pp}P_{Qq} dT*dE*_{mnpq}
00151     if (mpChangeOfBasisMatrix)
00152     {
00153         static c_matrix<double,DIM,DIM> T_transformed_times_Ptrans;
00154         T_transformed_times_Ptrans = prod(rT, trans(*mpChangeOfBasisMatrix));
00155 
00156         rT = prod(*mpChangeOfBasisMatrix, T_transformed_times_Ptrans);  // T = P T* P^T
00157 
00158         // dTdE_{MNPQ}  =  P_{Mm}P_{Nn}P_{Pp}P_{Qq} dT*dE*_{mnpq}
00159         if (transformDTdE)
00160         {
00161             static FourthOrderTensor<DIM,DIM,DIM,DIM> temp;
00162             temp.template SetAsContractionOnFirstDimension<DIM>(*mpChangeOfBasisMatrix, rDTdE);
00163             rDTdE.template SetAsContractionOnSecondDimension<DIM>(*mpChangeOfBasisMatrix, temp);
00164             temp.template SetAsContractionOnThirdDimension<DIM>(*mpChangeOfBasisMatrix, rDTdE);
00165             rDTdE.template SetAsContractionOnFourthDimension<DIM>(*mpChangeOfBasisMatrix, temp);
00166         }
00167     }
00168 }
00169 
00171 // Explicit instantiation
00173 
00174 //template class AbstractMaterialLaw<1>;
00175 template class AbstractMaterialLaw<2>;
00176 template class AbstractMaterialLaw<3>;
Generated on Thu Dec 22 13:00:05 2011 for Chaste by  doxygen 1.6.3