Chaste Commit::ca8ccdedf819b6e02855bc0e8e6f50bdecbc5208
AbstractMaterialLaw.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 "AbstractMaterialLaw.hpp"
37
38template<unsigned DIM>
40 : mpChangeOfBasisMatrix(nullptr)
41{
42}
43
44template<unsigned DIM>
45void AbstractMaterialLaw<DIM>::ComputeCauchyStress(c_matrix<double,DIM,DIM>& rF,
46 double pressure,
47 c_matrix<double,DIM,DIM>& rSigma)
48{
49 double detF = Determinant(rF);
50
51 c_matrix<double,DIM,DIM> C = prod(trans(rF), rF);
52 c_matrix<double,DIM,DIM> invC = Inverse(C);
53
54 c_matrix<double,DIM,DIM> T;
55
56 static FourthOrderTensor<DIM,DIM,DIM,DIM> dTdE; // not filled in, made static for efficiency
57
58 ComputeStressAndStressDerivative(C, invC, pressure, T, dTdE, false);
59
60 /*
61 * Looping is probably more eficient then doing rSigma = (1/detF)*rF*T*transpose(rF),
62 * which doesn't seem to compile anyway, as rF is a Tensor<2,DIM> and T is a
63 * SymmetricTensor<2,DIM>.
64 */
65 for (unsigned i=0; i<DIM; i++)
66 {
67 for (unsigned j=0; j<DIM; j++)
68 {
69 rSigma(i,j) = 0.0;
70 for (unsigned M=0; M<DIM; M++)
71 {
72 for (unsigned N=0; N<DIM; N++)
73 {
74 rSigma(i,j) += rF(i,M)*T(M,N)*rF(j,N);
75 }
76 }
77 rSigma(i,j) /= detF;
78 }
79 }
80}
81
82template<unsigned DIM>
84 double pressure,
85 c_matrix<double,DIM,DIM>& rS)
86{
87 c_matrix<double,DIM,DIM> C = prod(trans(rF), rF);
88 c_matrix<double,DIM,DIM> invC = Inverse(C);
89
90 c_matrix<double,DIM,DIM> T;
91
92 static FourthOrderTensor<DIM,DIM,DIM,DIM> dTdE; // not filled in, made static for efficiency
93
94 ComputeStressAndStressDerivative(C, invC, pressure, T, dTdE, false);
95
96 rS = prod(T, trans(rF));
97}
98
99template<unsigned DIM>
101 double pressure,
102 c_matrix<double,DIM,DIM>& rT)
103{
104 c_matrix<double,DIM,DIM> invC = Inverse(rC);
105
106 static FourthOrderTensor<DIM,DIM,DIM,DIM> dTdE; // not filled in, made static for efficiency
107
108 ComputeStressAndStressDerivative(rC, invC, pressure, rT, dTdE, false);
109}
110
111// LCOV_EXCL_START
112template<unsigned DIM>
114{
115 EXCEPTION("[the material law you are using]::ScaleMaterialParameters() has not been implemented\n");
116}
117// LCOV_EXCL_STOP
118
119template<unsigned DIM>
120void AbstractMaterialLaw<DIM>::SetChangeOfBasisMatrix(c_matrix<double,DIM,DIM>& rChangeOfBasisMatrix)
121{
122 mpChangeOfBasisMatrix = &rChangeOfBasisMatrix;
123}
124
125template<unsigned DIM>
127{
128 mpChangeOfBasisMatrix = nullptr;
129}
130
131template<unsigned DIM>
132void AbstractMaterialLaw<DIM>::ComputeTransformedDeformationTensor(c_matrix<double,DIM,DIM>& rC, c_matrix<double,DIM,DIM>& rInvC,
133 c_matrix<double,DIM,DIM>& rCTransformed, c_matrix<double,DIM,DIM>& rInvCTransformed)
134{
135 // Writing the local coordinate system as fibre/sheet/normal, as in cardiac problems..
136
137 // Let P be the change-of-basis matrix P = (\mathbf{m}_f, \mathbf{m}_s, \mathbf{m}_n).
138 // The transformed C for the fibre/sheet basis is C* = P^T C P.
139 if (mpChangeOfBasisMatrix)
140 {
141 // C* = P^T C P, and ditto inv(C)
142 rCTransformed = prod(trans(*mpChangeOfBasisMatrix),(c_matrix<double,DIM,DIM>)prod(rC,*mpChangeOfBasisMatrix)); // C* = P^T C P
143 rInvCTransformed = prod(trans(*mpChangeOfBasisMatrix),(c_matrix<double,DIM,DIM>)prod(rInvC,*mpChangeOfBasisMatrix)); // invC* = P^T invC P
144 }
145 else
146 {
147 rCTransformed = rC;
148 rInvCTransformed = rInvC;
149 }
150}
151
152template<unsigned DIM>
155 bool transformDTdE)
156{
157 // T = P T* P^T and dTdE_{MNPQ} = P_{Mm}P_{Nn}P_{Pp}P_{Qq} dT*dE*_{mnpq}
158 if (mpChangeOfBasisMatrix)
159 {
160 static c_matrix<double,DIM,DIM> T_transformed_times_Ptrans;
161 T_transformed_times_Ptrans = prod(rT, trans(*mpChangeOfBasisMatrix));
162
163 rT = prod(*mpChangeOfBasisMatrix, T_transformed_times_Ptrans); // T = P T* P^T
164
165 // dTdE_{MNPQ} = P_{Mm}P_{Nn}P_{Pp}P_{Qq} dT*dE*_{mnpq}
166 if (transformDTdE)
167 {
169 temp.template SetAsContractionOnFirstDimension<DIM>(*mpChangeOfBasisMatrix, rDTdE);
170 rDTdE.template SetAsContractionOnSecondDimension<DIM>(*mpChangeOfBasisMatrix, temp);
171 temp.template SetAsContractionOnThirdDimension<DIM>(*mpChangeOfBasisMatrix, rDTdE);
172 rDTdE.template SetAsContractionOnFourthDimension<DIM>(*mpChangeOfBasisMatrix, temp);
173 }
174 }
175}
176
177// Explicit instantiation
178template class AbstractMaterialLaw<2>;
179template class AbstractMaterialLaw<3>;
#define EXCEPTION(message)
T Determinant(const boost::numeric::ublas::c_matrix< T, 1, 1 > &rM)
boost::numeric::ublas::c_matrix< T, 1, 1 > Inverse(const boost::numeric::ublas::c_matrix< T, 1, 1 > &rM)
void Compute1stPiolaKirchoffStress(c_matrix< double, DIM, DIM > &rF, double pressure, c_matrix< double, DIM, DIM > &rS)
void ComputeCauchyStress(c_matrix< double, DIM, DIM > &rF, double pressure, c_matrix< double, DIM, DIM > &rSigma)
void ComputeTransformedDeformationTensor(c_matrix< double, DIM, DIM > &rC, c_matrix< double, DIM, DIM > &rInvC, c_matrix< double, DIM, DIM > &rCTransformed, c_matrix< double, DIM, DIM > &rInvCTransformed)
void TransformStressAndStressDerivative(c_matrix< double, DIM, DIM > &rT, FourthOrderTensor< DIM, DIM, DIM, DIM > &rDTdE, bool transformDTdE)
void Compute2ndPiolaKirchoffStress(c_matrix< double, DIM, DIM > &rC, double pressure, c_matrix< double, DIM, DIM > &rT)
virtual void ScaleMaterialParameters(double scaleFactor)
void SetChangeOfBasisMatrix(c_matrix< double, DIM, DIM > &rChangeOfBasisMatrix)