Chaste Commit::baa90ac2819b962188b7562f2326be23c47859a7
AbstractIsotropicCompressibleMaterialLaw.cpp
1/*
2
3Copyright (c) 2005-2024, University of Oxford.
4All rights reserved.
5
6University of Oxford means the Chancellor, Masters and Scholars of the
7University of Oxford, having an administrative office at Wellington
8Square, Oxford OX1 2JD, UK.
9
10This file is part of Chaste.
11
12Redistribution and use in source and binary forms, with or without
13modification, 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
23THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
34*/
35
36#include "AbstractIsotropicCompressibleMaterialLaw.hpp"
37
38template<unsigned DIM>
42
43template<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 Determinant(const boost::numeric::ublas::c_matrix< T, 1, 1 > &rM)
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)