Chaste  Release::2017.1
AbstractIsotropicIncompressibleMaterialLaw.cpp
1 /*
2 
3 Copyright (c) 2005-2017, University of Oxford.
4 All rights reserved.
5 
6 University of Oxford means the Chancellor, Masters and Scholars of the
7 University of Oxford, having an administrative office at Wellington
8 Square, Oxford OX1 2JD, UK.
9 
10 This file is part of Chaste.
11 
12 Redistribution and use in source and binary forms, with or without
13 modification, are permitted provided that the following conditions are met:
14  * Redistributions of source code must retain the above copyright notice,
15  this list of conditions and the following disclaimer.
16  * Redistributions in binary form must reproduce the above copyright notice,
17  this list of conditions and the following disclaimer in the documentation
18  and/or other materials provided with the distribution.
19  * Neither the name of the University of Oxford nor the names of its
20  contributors may be used to endorse or promote products derived from this
21  software without specific prior written permission.
22 
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 
34 */
35 
36 #include "AbstractIsotropicIncompressibleMaterialLaw.hpp"
37 
38 template<unsigned DIM>
40 {
41 }
42 
43 template<unsigned DIM>
45  c_matrix<double,DIM,DIM>& rC,
46  c_matrix<double,DIM,DIM>& rInvC,
47  double pressure,
48  c_matrix<double,DIM,DIM>& rT,
50  bool computeDTdE)
51 {
52  assert((DIM==2) || (DIM==3)); // LCOV_EXCL_LINE
53 
54  static c_matrix<double,DIM,DIM> identity = identity_matrix<double>(DIM);
55 
56  double I1 = Trace(rC);
57  double I2 = SecondInvariant(rC);
58 
59  double w1 = Get_dW_dI1(I1, I2);
60  double w2; // only computed if DIM==3
61 
62  // Compute stress: **** See FiniteElementImplementations document. ****
63  //
64  // T = dW_dE
65  // = 2 * w1 * dI1_dC_MN + 2 * w2 * dI1_dC_MN - p * invC
66  // = 2 * w1 * delta_MN + 2 * w2 * (I1 delta_MN - C_MN) - p * invC
67  //
68  // (where w1 = dW/dI1, etc).
69 
70  rT = 2*w1*identity - pressure*rInvC;
71  if (DIM==3)
72  {
73  w2 = Get_dW_dI2(I1, I2);
74  rT += 2*w2*(I1*identity - rC);
75  }
76 
77  // Compute stress derivative if required: **** See FiniteElementImplementations document. ****
78  //
79  // The stress derivative dT_{MN}/dE_{PQ} is
80  //
81  // dT_dE = 4 * w11 * dI1_dC_MN * dI1_dC_PQ
82  // + 4 * w1 * d2I1_dC2
83  // + 4 * w22 * dI2_dC_MN * dI2_dC_PQ
84  // + 4 * w2 * d2I2_dC2
85  // + 4 * w12 * (dI1_dC_MN*dI2_dC_PQ + dI1_dC_PQ*dI2_dC_MN)
86  // - 2 * pressure * d_invC_dC;
87  //
88  // where
89  // dI1_dC_MN = (M==N); // ie delta_{MN}
90  // dI1_dC_PQ = (P==Q);
91  // d2I1_dC2 = 0;
92  //
93  // dI2_dC_MN = I1*(M==N)-C[M][N];
94  // dI2_dC_PQ = I1*(P==Q)-C[P][Q];
95  // d2I2_dC2 = (M==N)*(P==Q)-(M==P)*(N==Q);
96  //
97  // d_invC_dC = -invC[M][P]*invC[Q][N];
98  //
99  if (computeDTdE)
100  {
101  double w11 = Get_d2W_dI1(I1,I2);
102 
103  double w12;
104  double w22;
105 
106  if (DIM==3)
107  {
108  w22 = Get_d2W_dI2(I1, I2);
109  w12 = Get_d2W_dI1I2(I1, I2);
110  }
111 
112  for (unsigned M=0; M<DIM; M++)
113  {
114  for (unsigned N=0; N<DIM; N++)
115  {
116  for (unsigned P=0; P<DIM; P++)
117  {
118  for (unsigned Q=0; Q<DIM; Q++)
119  {
120  rDTdE(M,N,P,Q) = 4 * w11 * (M==N) * (P==Q)
121  + 2 * pressure * rInvC(M,P) * rInvC(Q,N);
122 
123  if (DIM==3)
124  {
125  rDTdE(M,N,P,Q) += 4 * w22 * (I1*(M==N) - rC(M,N)) * (I1*(P==Q) - rC(P,Q))
126  + 4 * w2 * ((M==N)*(P==Q) - (M==P)*(N==Q))
127  + 4 * w12 * ((M==N)*(I1*(P==Q) - rC(P,Q)) + (P==Q)*(I1*(M==N) - rC(M,N)));
128  }
129  }
130  }
131  }
132  }
133  }
134 }
135 
136 template<>
138 {
139  return 2*Get_dW_dI1(2,0);
140 }
141 
142 template<>
144 {
145  return 2*Get_dW_dI1(3,3) + 4*Get_dW_dI2(3,3);
146 }
147 
148 // Explicit instantiation
T SecondInvariant(const c_matrix< T, 3, 3 > &rM)
T Trace(const c_matrix< T, 1, 1 > &rM)
void ComputeStressAndStressDerivative(c_matrix< double, DIM, DIM > &rC, c_matrix< double, DIM, DIM > &rInvC, double pressure, c_matrix< double, DIM, DIM > &rT, FourthOrderTensor< DIM, DIM, DIM, DIM > &rDTdE, bool computeDTdE)
virtual double Get_dW_dI1(double I1, double I2)=0
virtual double Get_dW_dI2(double I1, double I2)=0