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