Chaste  Release::3.4
AbstractIsotropicIncompressibleMaterialLaw.cpp
1 /*
2 
3 Copyright (c) 2005-2016, 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  /*
53  * This is covered, but gcov doesn't see this as being covered
54  * for some reason, maybe because of optimisations.
55  */
56  #define COVERAGE_IGNORE
57  assert((DIM==2) || (DIM==3));
58  #undef COVERAGE_IGNORE
59 
60  static c_matrix<double,DIM,DIM> identity = identity_matrix<double>(DIM);
61 
62  double I1 = Trace(rC);
63  double I2 = SecondInvariant(rC);
64 
65  double w1 = Get_dW_dI1(I1, I2);
66  double w2; // only computed if DIM==3
67 
68  // Compute stress: **** See FiniteElementImplementations document. ****
69  //
70  // T = dW_dE
71  // = 2 * w1 * dI1_dC_MN + 2 * w2 * dI1_dC_MN - p * invC
72  // = 2 * w1 * delta_MN + 2 * w2 * (I1 delta_MN - C_MN) - p * invC
73  //
74  // (where w1 = dW/dI1, etc).
75 
76  rT = 2*w1*identity - pressure*rInvC;
77  if (DIM==3)
78  {
79  w2 = Get_dW_dI2(I1, I2);
80  rT += 2*w2*(I1*identity - rC);
81  }
82 
83  // Compute stress derivative if required: **** See FiniteElementImplementations document. ****
84  //
85  // The stress derivative dT_{MN}/dE_{PQ} is
86  //
87  // dT_dE = 4 * w11 * dI1_dC_MN * dI1_dC_PQ
88  // + 4 * w1 * d2I1_dC2
89  // + 4 * w22 * dI2_dC_MN * dI2_dC_PQ
90  // + 4 * w2 * d2I2_dC2
91  // + 4 * w12 * (dI1_dC_MN*dI2_dC_PQ + dI1_dC_PQ*dI2_dC_MN)
92  // - 2 * pressure * d_invC_dC;
93  //
94  // where
95  // dI1_dC_MN = (M==N); // ie delta_{MN}
96  // dI1_dC_PQ = (P==Q);
97  // d2I1_dC2 = 0;
98  //
99  // dI2_dC_MN = I1*(M==N)-C[M][N];
100  // dI2_dC_PQ = I1*(P==Q)-C[P][Q];
101  // d2I2_dC2 = (M==N)*(P==Q)-(M==P)*(N==Q);
102  //
103  // d_invC_dC = -invC[M][P]*invC[Q][N];
104  //
105  if (computeDTdE)
106  {
107  double w11 = Get_d2W_dI1(I1,I2);
108 
109  double w12;
110  double w22;
111 
112  if (DIM==3)
113  {
114  w22 = Get_d2W_dI2(I1, I2);
115  w12 = Get_d2W_dI1I2(I1, I2);
116  }
117 
118  for (unsigned M=0; M<DIM; M++)
119  {
120  for (unsigned N=0; N<DIM; N++)
121  {
122  for (unsigned P=0; P<DIM; P++)
123  {
124  for (unsigned Q=0; Q<DIM; Q++)
125  {
126  rDTdE(M,N,P,Q) = 4 * w11 * (M==N) * (P==Q)
127  + 2 * pressure * rInvC(M,P) * rInvC(Q,N);
128 
129  if (DIM==3)
130  {
131  rDTdE(M,N,P,Q) += 4 * w22 * (I1*(M==N) - rC(M,N)) * (I1*(P==Q) - rC(P,Q))
132  + 4 * w2 * ((M==N)*(P==Q) - (M==P)*(N==Q))
133  + 4 * w12 * ((M==N)*(I1*(P==Q) - rC(P,Q)) + (P==Q)*(I1*(M==N) - rC(M,N)));
134  }
135  }
136  }
137  }
138  }
139  }
140 }
141 
142 template<>
144 {
145  return 2*Get_dW_dI1(2,0);
146 }
147 
148 template<>
150 {
151  return 2*Get_dW_dI1(3,3) + 4*Get_dW_dI2(3,3);
152 }
153 
155 // Explicit instantiation
157 
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