-
Notifications
You must be signed in to change notification settings - Fork 297
/
HyperelasticMaterial.h
143 lines (117 loc) · 5.7 KB
/
HyperelasticMaterial.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/******************************************************************************
* SOFA, Simulation Open-Framework Architecture *
* (c) 2006 INRIA, USTL, UJF, CNRS, MGH *
* *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by *
* the Free Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*******************************************************************************
* Authors: The SOFA Team and external contributors (see Authors.txt) *
* *
* Contact information: contact@sofa-framework.org *
******************************************************************************/
#pragma once
#include <sofa/component/solidmechanics/fem/hyperelastic/config.h>
#include <sofa/core/topology/BaseMeshTopology.h>
#include <sofa/core/topology/TopologyData.h>
#include <sofa/type/Vec.h>
#include <sofa/type/Mat.h>
#include <sofa/type/MatSym.h>
#include <string>
//#include <Eigen/Core>
#include <Eigen/QR>
#include <Eigen/Eigenvalues>
namespace sofa::component::solidmechanics::fem::hyperelastic::material
{
template<typename Real>
class StrainInformation;
template<typename DataTypes>
struct MaterialParameters;
/** a Class that describe a generic hyperelastic material .
The material is described based on continuum mechanics and the description is independent
to any discretization method like the finite element method.
A material is generically described by a strain energy function and its first and second derivatives.
*/
template<class DataTypes>
class HyperelasticMaterial
{
public:
typedef typename DataTypes::Coord Coord;
typedef typename Coord::value_type Real;
typedef type::MatSym<3,Real> MatrixSym;
typedef type::Mat<3,3,Real> Matrix3;
typedef type::Mat<6,6,Real> Matrix6;
virtual ~HyperelasticMaterial(){}
/** returns the strain energy of the current configuration */
virtual Real getStrainEnergy(StrainInformation<DataTypes>*, const MaterialParameters<DataTypes>&)
{
return 0;
}
/** computes the second Piola Kirchhoff stress tensor of the current configuration */
virtual void deriveSPKTensor(StrainInformation<DataTypes>*, const MaterialParameters<DataTypes>&,
MatrixSym&)
{
}
/** computes the Elasticity Tensor of the current configuration */
virtual void applyElasticityTensor(StrainInformation<DataTypes>*,
const MaterialParameters<DataTypes>&, const MatrixSym&,
MatrixSym&)
{
}
virtual void ElasticityTensor(StrainInformation<DataTypes>*, const MaterialParameters<DataTypes>&,
Matrix6&)
{
}
};
/** structure that store the parameters required to that are necessary to compute the strain energy
The material parameters might be constant in space (homogeneous material) or not */
template<typename DataTypes>
struct MaterialParameters {
typedef typename DataTypes::Coord Coord;
typedef typename Coord::value_type Real;
/** an array of Real values that correspond to the material parameters : the size depends on the material,
e.g. 2 Lame coefficients for St-Venant Kirchhoff materials */
std::vector<Real> parameterArray;
/** the direction of anisotropy in the rest configuration : the size of the array is 0 if the material is
isotropic, 1 if it is transversely isotropic and 2 for orthotropic materials (assumed to be orthogonal to each other)*/
std::vector<Coord> anisotropyDirection;
/** for viscous part, give the real alphai and taui such as alpha(t)= alpha0+sum(1,N)alphaiexp(-t/taui)*/
std::vector<Real> parameterAlpha;
std::vector<Real> parameterTau;//starting with delta t the time step
};
template<typename DataTypes>
class StrainInformation
{
public:
typedef typename DataTypes::Coord Coord;
typedef typename Coord::value_type Real;
typedef type::MatSym<3,Real> MatrixSym;
typedef typename Eigen::SelfAdjointEigenSolver<Eigen::Matrix<Real,3,3> >::MatrixType EigenMatrix;
typedef typename Eigen::SelfAdjointEigenSolver<Eigen::Matrix<Real,3,3> >::RealVectorType CoordEigen;
/// Trace of C = I1
Real trC;
Real J;
Real lambda;
/// Trace of C^2 : I2 = (trCSquare - trC^2)/2
Real trCsquare;
/// boolean indicating whether the invariants have been computed
bool hasBeenInitialized;
/// right Cauchy-Green deformation tensor C (gradPhi^T gradPhi)
MatrixSym deformationTensor;
EigenMatrix Evect;
CoordEigen Evalue;
Real logJ;
MatrixSym E;
StrainInformation() : trC(0), J(0), lambda(0), trCsquare(0), hasBeenInitialized(false), deformationTensor(), Evect(), Evalue(), logJ(0), E() {}
virtual ~StrainInformation() {}
};
} // namespace sofa::component::solidmechanics::fem::hyperelastic::material