Chaste Commit::ca8ccdedf819b6e02855bc0e8e6f50bdecbc5208
PoleZeroMaterialLaw.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 "PoleZeroMaterialLaw.hpp"
37
38template<unsigned DIM>
42
43template<unsigned DIM>
44void PoleZeroMaterialLaw<DIM>::SetParameters(std::vector<std::vector<double> > k,
45 std::vector<std::vector<double> > a,
46 std::vector<std::vector<double> > b)
47{
48 if (DIM!=2 && DIM !=3)
49 {
50 EXCEPTION("Can only have a 2 or 3d incompressible pole-zero law");
51 }
52
53 assert(k.size() == DIM);
54 assert(a.size() == DIM);
55 assert(b.size() == DIM);
56
57 for (unsigned i = 0; i < DIM; i++)
58 {
59 assert(k[i].size() == DIM);
60 assert(a[i].size() == DIM);
61 assert(b[i].size() == DIM);
62
63 for (unsigned j = 0; j < DIM; j++)
64 {
65 assert(k[i][j] == k[j][i]);
66 assert(a[i][j] == a[j][i]);
67 assert(b[i][j] == b[j][i]);
68 }
69 }
70
71 mK = k;
72 mA = a;
73 mB = b;
74
75 for (unsigned M=0; M<DIM; M++)
76 {
77 for (unsigned N=0; N<DIM; N++)
78 {
79 mIdentity(M,N) = M==N ? 1.0 : 0.0;
80 }
81 }
82}
83
84template<unsigned DIM>
85PoleZeroMaterialLaw<DIM>::PoleZeroMaterialLaw(std::vector<std::vector<double> > k,
86 std::vector<std::vector<double> > a,
87 std::vector<std::vector<double> > b)
88{
89 SetParameters(k,a,b);
90}
91
92template<unsigned DIM>
94 c_matrix<double,DIM,DIM>& rInvC,
95 double pressure,
96 c_matrix<double,DIM,DIM>& rT,
98 bool computeDTdE)
99{
100 static c_matrix<double,DIM,DIM> C_transformed;
101 static c_matrix<double,DIM,DIM> invC_transformed;
102
103 // The material law parameters are set up assuming the fibre direction is (1,0,0)
104 // and sheet direction is (0,1,0), so we have to transform C,inv(C),and T.
105 // Let P be the change-of-basis matrix P = (\mathbf{m}_f, \mathbf{m}_s, \mathbf{m}_n).
106 // The transformed C for the fibre/sheet basis is C* = P^T C P.
107 // We then compute T* = T*(C*), and then compute T = P T* P^T.
108
109 this->ComputeTransformedDeformationTensor(rC, rInvC, C_transformed, invC_transformed);
110
111 // compute T*
112
113 c_matrix<double,DIM,DIM> E = 0.5*(C_transformed - mIdentity);
114
115 for (unsigned M=0; M<DIM; M++)
116 {
117 for (unsigned N=0; N<DIM; N++)
118 {
119 double e = E(M,N);
120 {
121 double b = mB[M][N];
122 double a = mA[M][N];
123 double k = mK[M][N];
124
125 //if this fails one of the strain values got too large for the law
126 if (e>=a)
127 {
128 EXCEPTION("E_{MN} >= a_{MN} - strain unacceptably large for model");
129 }
130
131 rT(M,N) = k
132 * e
133 * (2*(a-e) + b*e)
134 * pow(a-e,-b-1)
135 - pressure*invC_transformed(M,N);
136 }
137 }
138 }
139
140 if (computeDTdE)
141 {
142 for (unsigned M=0; M<DIM; M++)
143 {
144 for (unsigned N=0; N<DIM; N++)
145 {
146 for (unsigned P=0; P<DIM; P++)
147 {
148 for (unsigned Q=0; Q<DIM; Q++)
149 {
150 rDTdE(M,N,P,Q) = 2 * pressure * invC_transformed(M,P) * invC_transformed(Q,N);
151 }
152 }
153
154 double e = E(M,N);
155
156 double b = mB[M][N];
157 double a = mA[M][N];
158 double k = mK[M][N];
159
160 rDTdE(M,N,M,N) += k
161 * pow(a-e, -b-2)
162 * (
163 2*(a-e)*(a-e)
164 + 4*b*e*(a-e)
165 + b*(b+1)*e*e
166 );
167 }
168 }
169 }
170
171 // Now do: T = P T* P^T and dTdE_{MNPQ} = P_{Mm}P_{Nn}P_{Pp}P_{Qq} dT*dE*_{mnpq}
172 this->TransformStressAndStressDerivative(rT, rDTdE, computeDTdE);
173}
174
175template<unsigned DIM>
177{
178 return 0.0;
179}
180
181template<unsigned DIM>
183{
184 assert(scaleFactor > 0.0);
185 for (unsigned i=0; i<mK.size(); i++)
186 {
187 for (unsigned j=0; j<mK[i].size(); j++)
188 {
189 mK[i][j] /= scaleFactor;
190 }
191 }
192}
193
194// Explicit instantiation
195template class PoleZeroMaterialLaw<2>;
196template class PoleZeroMaterialLaw<3>;
#define EXCEPTION(message)
void ScaleMaterialParameters(double scaleFactor)
void SetParameters(std::vector< std::vector< double > > k, std::vector< std::vector< double > > a, std::vector< std::vector< double > > b)
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)