Chaste  Release::3.4
MooneyRivlinMaterialLaw.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 "MooneyRivlinMaterialLaw.hpp"
37 
38 template<unsigned DIM>
39 double MooneyRivlinMaterialLaw<DIM>::Get_dW_dI1(double I1, double I2)
40 {
41  return mC1;
42 }
43 
44 template<unsigned DIM>
45 double MooneyRivlinMaterialLaw<DIM>::Get_dW_dI2(double I1, double I2)
46 {
47  /*
48  * This is covered, but gcov doesn't see this as being covered
49  * for some reason, maybe because of optimisations.
50  */
51  #define COVERAGE_IGNORE
52  assert(DIM == 3);
53  #undef COVERAGE_IGNORE
54  return mC2;
55 }
56 
57 template<unsigned DIM>
58 double MooneyRivlinMaterialLaw<DIM>::Get_d2W_dI1(double I1, double I2)
59 {
60  return 0.0;
61 }
62 
63 template<unsigned DIM>
64 double MooneyRivlinMaterialLaw<DIM>::Get_d2W_dI2(double I1, double I2)
65 {
66  /*
67  * This is covered, but gcov doesn't see this as being covered
68  * for some reason, maybe because of optimisations.
69  */
70  #define COVERAGE_IGNORE
71  assert(DIM == 3);
72  #undef COVERAGE_IGNORE
73  return 0.0;
74 }
75 
76 template<unsigned DIM>
77 double MooneyRivlinMaterialLaw<DIM>::Get_d2W_dI1I2(double I1, double I2)
78 {
79  /*
80  * This is covered, but gcov doesn't see this as being covered
81  * for some reason, maybe because of optimisations.
82  */
83  #define COVERAGE_IGNORE
84  assert(DIM == 3);
85  #undef COVERAGE_IGNORE
86  return 0.0;
87 }
88 
89 template<unsigned DIM>
91 {
92  return mC1;
93 }
94 
95 template<unsigned DIM>
97 {
98  assert(DIM==3);
99  return mC2;
100 }
101 
102 template<unsigned DIM>
104  : mC1(c1),
105  mC2(c2)
106 {
107  assert(DIM==2 || DIM ==3);
108 
109  // If dim==3, check that c2 was passed in, ie c2 isn't the default value
110  if ((DIM==3) && (c2<MINUS_LARGE+1))
111  {
112  EXCEPTION("Two parameters needed for 3d Mooney-Rivlin");
113  }
114 
115  if (c1 < 0.0)
116  {
117  EXCEPTION("c1 must be positive in mooney-rivlin"); // is this correct?
118  }
119 }
120 
121 template<unsigned DIM>
123 {
124  assert(scaleFactor > 0.0);
125  mC1 /= scaleFactor;
126  mC2 /= scaleFactor;
127 }
128 
130 // Explicit instantiation
132 
133 template class MooneyRivlinMaterialLaw<2>;
134 template class MooneyRivlinMaterialLaw<3>;
void ScaleMaterialParameters(double scaleFactor)
#define EXCEPTION(message)
Definition: Exception.hpp:143
double Get_dW_dI2(double I1, double I2)
MooneyRivlinMaterialLaw(double c1, double c2=MINUS_LARGE)
double Get_d2W_dI2(double I1, double I2)
double Get_dW_dI1(double I1, double I2)
double Get_d2W_dI1(double I1, double I2)
double Get_d2W_dI1I2(double I1, double I2)