Chaste  Release::2017.1
PoleZeroMaterialLaw.cpp
1 /*
2 
3 Copyright (c) 2005-2017, 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 template<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 
175 template<unsigned DIM>
177 {
178  return 0.0;
179 }
180 
181 template<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
195 template class PoleZeroMaterialLaw<2>;
196 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)