Chaste  Release::2018.1
AbstractIsotropicCompressibleMaterialLaw.cpp
1 /*
2 
3 Copyright (c) 2005-2018, 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 "AbstractIsotropicCompressibleMaterialLaw.hpp"
37 
38 template<unsigned DIM>
40 {
41 }
42 
43 template<unsigned DIM>
45  c_matrix<double,DIM,DIM>& rInvC,
46  double pressure,
47  c_matrix<double,DIM,DIM>& rT,
49  bool computeDTdE)
50 {
51  /*
52  * This is covered, but gcov doesn't see this as being covered
53  * because it runs at compile time checking templates I think.
54  */
55  assert((DIM==2) || (DIM==3)); // LCOV_EXCL_LINE
56  assert(pressure==0.0);
57 
58  static c_matrix<double,DIM,DIM> identity = identity_matrix<double>(DIM);
59 
60  double I1 = Trace(rC);
61  double I2 = SecondInvariant(rC);
62  double I3 = Determinant(rC);
63 
64  static c_matrix<double,DIM,DIM> dI2dC;
65  dI2dC = I1*identity - rC; // MUST be on separate line to above!
66 
67  double w1 = Get_dW_dI1(I1,I2,I3);
68  double w2 = Get_dW_dI2(I1,I2,I3);
69  double w3 = Get_dW_dI3(I1,I2,I3);
70 
71 
72  // Compute stress: **** See FiniteElementImplementations document. ****
73  //
74  // T = dW_dE
75  // = 2 dW_dC
76  // = 2 ( w1 dI1/dC + w2 dI2/dC + w3 dI3/dC )
77  // = 2 ( w1 I + w2 (I1*I - C) + w3 I3 inv(C) )
78  //
79  // where w1 = dW/dI1, etc
80  //
81  rT = 2*w1*identity + 2*w3*I3*rInvC;
82  if (DIM==3)
83  {
84  rT += 2*w2*dI2dC;
85  }
86 
87  // Compute stress derivative if required: **** See FiniteElementImplementations document. ****
88  //
89  // The stress derivative dT_{MN}/dE_{PQ} is
90  //
91  //
92  // dT_dE = 2 dT_dC
93  // = 4 d/dC ( w1 I + w2 (I1*I - C) + w3 I3 inv(C) )
94  // so (in the following ** represents outer product):
95  // (1/4) dT_dE = w11 I**I + w12 I**(I1*I-C) + w13 I**inv(C)
96  // + w21 (I1*I-C)**I + w22 (I1*I-C)**(I1*I-C) + w23 (I1*I-C)**inv(C) + w2 (I**I - dC/dC)
97  // + w31 I3 inv(C)**I + w32 I3 inv(C)**(I1*I-C) + (w33 I3 + w3) inv(C)**inv(C) + w3 d(invC)/dC
98  //
99  // Here, I**I represents the tensor A[M][N][P][Q] = (M==N)*(P==Q) // ie delta(M,N)delta(P,Q), etc
100  //
101 
102  if (computeDTdE)
103  {
104  double w11 = Get_d2W_dI1(I1,I2,I3);
105  double w22 = Get_d2W_dI2(I1,I2,I3);
106  double w33 = Get_d2W_dI3(I1,I2,I3);
107 
108  double w23 = Get_d2W_dI2I3(I1,I2,I3);
109  double w13 = Get_d2W_dI1I3(I1,I2,I3);
110  double w12 = Get_d2W_dI1I2(I1,I2,I3);
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  + 4 * w13 * I3 * ( (M==N) * rInvC(P,Q) + rInvC(M,N)*(P==Q) ) // the w13 and w31 terms
122  + 4 * (w33*I3 + w3) * I3 * rInvC(M,N) * rInvC(P,Q)
123  - 4 * w3 * I3 * rInvC(M,P) * rInvC(Q,N);
124 
125  if (DIM==3)
126  {
127  rDTdE(M,N,P,Q) += 4 * w22 * dI2dC(M,N) * dI2dC(P,Q)
128  + 4 * w12 * ((M==N)*dI2dC(P,Q) + (P==Q)*dI2dC(M,N)) // the w12 and w21 terms
129  + 4 * w23 * I3 * ( dI2dC(M,N)*rInvC(P,Q) + rInvC(M,N)*dI2dC(P,Q)) // the w23 and w32 terms
130  + 4 * w2 * ((M==N)*(P==Q) - (M==P)*(N==Q));
131  }
132  }
133  }
134  }
135  }
136  }
137 }
138 
139 // Explicit instantiation
T SecondInvariant(const c_matrix< T, 3, 3 > &rM)
T Trace(const c_matrix< T, 1, 1 > &rM)
T Determinant(const boost::numeric::ublas::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)