Chaste  Release::3.4
AbstractIsotropicCompressibleMaterialLaw.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 "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  * for some reason, maybe because of optimisations.
54  */
55  #define COVERAGE_IGNORE
56  assert((DIM==2) || (DIM==3));
57  #undef COVERAGE_IGNORE
58 
59  assert(pressure==0.0);
60 
61  static c_matrix<double,DIM,DIM> identity = identity_matrix<double>(DIM);
62 
63  double I1 = Trace(rC);
64  double I2 = SecondInvariant(rC);
65  double I3 = Determinant(rC);
66 
67  static c_matrix<double,DIM,DIM> dI2dC;
68  dI2dC = I1*identity - rC; // MUST be on separate line to above!
69 
70  double w1 = Get_dW_dI1(I1,I2,I3);
71  double w2 = Get_dW_dI2(I1,I2,I3);
72  double w3 = Get_dW_dI3(I1,I2,I3);
73 
74 
75  // Compute stress: **** See FiniteElementImplementations document. ****
76  //
77  // T = dW_dE
78  // = 2 dW_dC
79  // = 2 ( w1 dI1/dC + w2 dI2/dC + w3 dI3/dC )
80  // = 2 ( w1 I + w2 (I1*I - C) + w3 I3 inv(C) )
81  //
82  // where w1 = dW/dI1, etc
83  //
84  rT = 2*w1*identity + 2*w3*I3*rInvC;
85  if (DIM==3)
86  {
87  rT += 2*w2*dI2dC;
88  }
89 
90  // Compute stress derivative if required: **** See FiniteElementImplementations document. ****
91  //
92  // The stress derivative dT_{MN}/dE_{PQ} is
93  //
94  //
95  // dT_dE = 2 dT_dC
96  // = 4 d/dC ( w1 I + w2 (I1*I - C) + w3 I3 inv(C) )
97  // so (in the following ** represents outer product):
98  // (1/4) dT_dE = w11 I**I + w12 I**(I1*I-C) + w13 I**inv(C)
99  // + w21 (I1*I-C)**I + w22 (I1*I-C)**(I1*I-C) + w23 (I1*I-C)**inv(C) + w2 (I**I - dC/dC)
100  // + w31 I3 inv(C)**I + w32 I3 inv(C)**(I1*I-C) + (w33 I3 + w3) inv(C)**inv(C) + w3 d(invC)/dC
101  //
102  // Here, I**I represents the tensor A[M][N][P][Q] = (M==N)*(P==Q) // ie delta(M,N)delta(P,Q), etc
103  //
104 
105  if (computeDTdE)
106  {
107  double w11 = Get_d2W_dI1(I1,I2,I3);
108  double w22 = Get_d2W_dI2(I1,I2,I3);
109  double w33 = Get_d2W_dI3(I1,I2,I3);
110 
111  double w23 = Get_d2W_dI2I3(I1,I2,I3);
112  double w13 = Get_d2W_dI1I3(I1,I2,I3);
113  double w12 = Get_d2W_dI1I2(I1,I2,I3);
114 
115  for (unsigned M=0; M<DIM; M++)
116  {
117  for (unsigned N=0; N<DIM; N++)
118  {
119  for (unsigned P=0; P<DIM; P++)
120  {
121  for (unsigned Q=0; Q<DIM; Q++)
122  {
123  rDTdE(M,N,P,Q) = 4 * w11 * (M==N) * (P==Q)
124  + 4 * w13 * I3 * ( (M==N) * rInvC(P,Q) + rInvC(M,N)*(P==Q) ) // the w13 and w31 terms
125  + 4 * (w33*I3 + w3) * I3 * rInvC(M,N) * rInvC(P,Q)
126  - 4 * w3 * I3 * rInvC(M,P) * rInvC(Q,N);
127 
128  if (DIM==3)
129  {
130  rDTdE(M,N,P,Q) += 4 * w22 * dI2dC(M,N) * dI2dC(P,Q)
131  + 4 * w12 * ((M==N)*dI2dC(P,Q) + (P==Q)*dI2dC(M,N)) // the w12 and w21 terms
132  + 4 * w23 * I3 * ( dI2dC(M,N)*rInvC(P,Q) + rInvC(M,N)*dI2dC(P,Q)) // the w23 and w32 terms
133  + 4 * w2 * ((M==N)*(P==Q) - (M==P)*(N==Q));
134  }
135  }
136  }
137  }
138  }
139  }
140 }
141 
143 // Explicit instantiation
145 
146 //template class AbstractIsotropicCompressibleMaterialLaw<1>;
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)