Chaste  Release::3.4
PoleZeroMaterialLaw.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 "PoleZeroMaterialLaw.hpp"
37 
38 template<unsigned DIM>
40 {
41 }
42 
43 template<unsigned DIM>
44 void 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 
84 template<unsigned DIM>
85 PoleZeroMaterialLaw<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 
92 
93 template<unsigned DIM>
95  c_matrix<double,DIM,DIM>& rInvC,
96  double pressure,
97  c_matrix<double,DIM,DIM>& rT,
99  bool computeDTdE)
100 {
101  static c_matrix<double,DIM,DIM> C_transformed;
102  static c_matrix<double,DIM,DIM> invC_transformed;
103 
104  // The material law parameters are set up assuming the fibre direction is (1,0,0)
105  // and sheet direction is (0,1,0), so we have to transform C,inv(C),and T.
106  // Let P be the change-of-basis matrix P = (\mathbf{m}_f, \mathbf{m}_s, \mathbf{m}_n).
107  // The transformed C for the fibre/sheet basis is C* = P^T C P.
108  // We then compute T* = T*(C*), and then compute T = P T* P^T.
109 
110  this->ComputeTransformedDeformationTensor(rC, rInvC, C_transformed, invC_transformed);
111 
112  // compute T*
113 
114  c_matrix<double,DIM,DIM> E = 0.5*(C_transformed - mIdentity);
115 
116  for (unsigned M=0; M<DIM; M++)
117  {
118  for (unsigned N=0; N<DIM; N++)
119  {
120  double e = E(M,N);
121  {
122  double b = mB[M][N];
123  double a = mA[M][N];
124  double k = mK[M][N];
125 
126  //if this fails one of the strain values got too large for the law
127  if (e>=a)
128  {
129  EXCEPTION("E_{MN} >= a_{MN} - strain unacceptably large for model");
130  }
131 
132  rT(M,N) = k
133  * e
134  * (2*(a-e) + b*e)
135  * pow(a-e,-b-1)
136  - pressure*invC_transformed(M,N);
137  }
138  }
139  }
140 
141  if (computeDTdE)
142  {
143  for (unsigned M=0; M<DIM; M++)
144  {
145  for (unsigned N=0; N<DIM; N++)
146  {
147  for (unsigned P=0; P<DIM; P++)
148  {
149  for (unsigned Q=0; Q<DIM; Q++)
150  {
151  rDTdE(M,N,P,Q) = 2 * pressure * invC_transformed(M,P) * invC_transformed(Q,N);
152  }
153  }
154 
155  double e = E(M,N);
156 
157  double b = mB[M][N];
158  double a = mA[M][N];
159  double k = mK[M][N];
160 
161  rDTdE(M,N,M,N) += k
162  * pow(a-e, -b-2)
163  * (
164  2*(a-e)*(a-e)
165  + 4*b*e*(a-e)
166  + b*(b+1)*e*e
167  );
168  }
169  }
170  }
171 
172  // Now do: T = P T* P^T and dTdE_{MNPQ} = P_{Mm}P_{Nn}P_{Pp}P_{Qq} dT*dE*_{mnpq}
173  this->TransformStressAndStressDerivative(rT, rDTdE, computeDTdE);
174 }
175 
176 template<unsigned DIM>
178 {
179  return 0.0;
180 }
181 
182 template<unsigned DIM>
184 {
185  assert(scaleFactor > 0.0);
186  for (unsigned i=0; i<mK.size(); i++)
187  {
188  for (unsigned j=0; j<mK[i].size(); j++)
189  {
190  mK[i][j] /= scaleFactor;
191  }
192  }
193 }
194 
196 // Explicit instantiation
198 
199 template class PoleZeroMaterialLaw<2>;
200 template class PoleZeroMaterialLaw<3>;
void SetParameters(std::vector< std::vector< double > > k, std::vector< std::vector< double > > a, std::vector< std::vector< double > > b)
void ScaleMaterialParameters(double scaleFactor)
#define EXCEPTION(message)
Definition: Exception.hpp:143
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)