MFEM  v3.3
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
nonlininteg.hpp
Go to the documentation of this file.
1 // Copyright (c) 2010, Lawrence Livermore National Security, LLC. Produced at
2 // the Lawrence Livermore National Laboratory. LLNL-CODE-443211. All Rights
3 // reserved. See file COPYRIGHT for details.
4 //
5 // This file is part of the MFEM library. For more information and source code
6 // availability see http://mfem.org.
7 //
8 // MFEM is free software; you can redistribute it and/or modify it under the
9 // terms of the GNU Lesser General Public License (as published by the Free
10 // Software Foundation) version 2.1 dated February 1999.
11 
12 #ifndef MFEM_NONLININTEG
13 #define MFEM_NONLININTEG
14 
15 #include "../config/config.hpp"
16 #include "fe.hpp"
17 #include "coefficient.hpp"
18 
19 namespace mfem
20 {
21 
22 /** The abstract base class NonlinearFormIntegrator is used to express the
23  local action of a general nonlinear finite element operator. In addition
24  it may provide the capability to assemble the local gradient operator
25  and to compute the local energy. */
27 {
28 public:
29  /// Perform the local action of the NonlinearFormIntegrator
30  virtual void AssembleElementVector(const FiniteElement &el,
32  const Vector &elfun, Vector &elvect) = 0;
33 
34  /// Assemble the local gradient matrix
35  virtual void AssembleElementGrad(const FiniteElement &el,
37  const Vector &elfun, DenseMatrix &elmat);
38 
39  /// Compute the local energy
40  virtual double GetElementEnergy(const FiniteElement &el,
42  const Vector &elfun);
43 
45 };
46 
47 
48 /// Abstract class for hyperelastic models
50 {
51 protected:
53 
54 public:
55  HyperelasticModel() { T = NULL; }
56 
57  /// An element transformation that can be used to evaluate coefficients.
59 
60  /// Evaluate the strain energy density function, W=W(J).
61  virtual double EvalW(const DenseMatrix &J) const = 0;
62 
63  /// Evaluate the 1st Piola-Kirchhoff stress tensor, P=P(J).
64  virtual void EvalP(const DenseMatrix &J, DenseMatrix &P) const = 0;
65 
66  /** Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor
67  and assemble its contribution to the local gradient matrix 'A'.
68  'DS' is the gradient of the basis matrix (dof x dim), and 'weight'
69  is the quadrature weight. */
70  virtual void AssembleH(const DenseMatrix &J, const DenseMatrix &DS,
71  const double weight, DenseMatrix &A) const = 0;
72 
73  virtual ~HyperelasticModel() { }
74 };
75 
76 
77 /** Inverse-harmonic hyperelastic model with a strain energy density function
78  given by the formula: W(J) = (1/2) det(J) Tr((J J^t)^{-1}) where J is the
79  deformation gradient. */
81 {
82 protected:
83  mutable DenseMatrix Z, S; // dim x dim
84  mutable DenseMatrix G, C; // dof x dim
85 
86 public:
87  virtual double EvalW(const DenseMatrix &J) const;
88 
89  virtual void EvalP(const DenseMatrix &J, DenseMatrix &P) const;
90 
91  virtual void AssembleH(const DenseMatrix &J, const DenseMatrix &DS,
92  const double weight, DenseMatrix &A) const;
93 };
94 
95 
96 /** Neo-Hookean hyperelastic model with a strain energy density function given
97  by the formula: \f$(\mu/2)(\bar{I}_1 - dim) + (K/2)(det(J)/g - 1)^2\f$ where
98  J is the deformation gradient and \f$\bar{I}_1 = (det(J))^{-2/dim} Tr(J
99  J^t)\f$. The parameters \f$\mu\f$ and K are the shear and bulk moduli,
100  respectively, and g is a reference volumetric scaling. */
102 {
103 protected:
104  mutable double mu, K, g;
107 
108  mutable DenseMatrix Z; // dim x dim
109  mutable DenseMatrix G, C; // dof x dim
110 
111  inline void EvalCoeffs() const;
112 
113 public:
114  NeoHookeanModel(double _mu, double _K, double _g = 1.0)
115  : mu(_mu), K(_K), g(_g), have_coeffs(false) { c_mu = c_K = c_g = NULL; }
116 
118  : mu(0.0), K(0.0), g(1.0), c_mu(&_mu), c_K(&_K), c_g(_g),
119  have_coeffs(true) { }
120 
121  virtual double EvalW(const DenseMatrix &J) const;
122 
123  virtual void EvalP(const DenseMatrix &J, DenseMatrix &P) const;
124 
125  virtual void AssembleH(const DenseMatrix &J, const DenseMatrix &DS,
126  const double weight, DenseMatrix &A) const;
127 };
128 
129 
130 /// Hyperelastic integrator for any given HyperelasticModel
132 {
133 private:
134  HyperelasticModel *model;
135 
136  DenseMatrix DSh, DS, J0i, J1, J, P, PMatI, PMatO;
137 
138 public:
140 
141  virtual double GetElementEnergy(const FiniteElement &el,
143  const Vector &elfun);
144 
145  virtual void AssembleElementVector(const FiniteElement &el,
147  const Vector &elfun, Vector &elvect);
148 
149  virtual void AssembleElementGrad(const FiniteElement &el,
151  const Vector &elfun, DenseMatrix &elmat);
152 
153  virtual ~HyperelasticNLFIntegrator();
154 };
155 
156 }
157 
158 #endif
Abstract class for Finite Elements.
Definition: fe.hpp:46
virtual double GetElementEnergy(const FiniteElement &el, ElementTransformation &Tr, const Vector &elfun)
Compute the local energy.
virtual void EvalP(const DenseMatrix &J, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P=P(J).
virtual double EvalW(const DenseMatrix &J) const
Evaluate the strain energy density function, W=W(J).
NeoHookeanModel(Coefficient &_mu, Coefficient &_K, Coefficient *_g=NULL)
virtual void AssembleH(const DenseMatrix &J, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Definition: nonlininteg.cpp:60
Data type dense matrix using column-major storage.
Definition: densemat.hpp:22
virtual void EvalP(const DenseMatrix &J, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P=P(J).
Definition: nonlininteg.cpp:41
Hyperelastic integrator for any given HyperelasticModel.
void EvalCoeffs() const
void SetTransformation(ElementTransformation &_T)
An element transformation that can be used to evaluate coefficients.
Definition: nonlininteg.hpp:58
virtual void AssembleElementGrad(const FiniteElement &el, ElementTransformation &Tr, const Vector &elfun, DenseMatrix &elmat)
Assemble the local gradient matrix.
Definition: nonlininteg.cpp:17
virtual void AssembleElementVector(const FiniteElement &el, ElementTransformation &Tr, const Vector &elfun, Vector &elvect)
Perform the local action of the NonlinearFormIntegrator.
NeoHookeanModel(double _mu, double _K, double _g=1.0)
Base class Coefficient that may optionally depend on time.
Definition: coefficient.hpp:31
virtual void AssembleElementVector(const FiniteElement &el, ElementTransformation &Tr, const Vector &elfun, Vector &elvect)=0
Perform the local action of the NonlinearFormIntegrator.
virtual void AssembleH(const DenseMatrix &J, const DenseMatrix &DS, const double weight, DenseMatrix &A) const =0
virtual void AssembleH(const DenseMatrix &J, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
HyperelasticNLFIntegrator(HyperelasticModel *m)
virtual double EvalW(const DenseMatrix &J) const
Evaluate the strain energy density function, W=W(J).
Definition: nonlininteg.cpp:34
virtual void EvalP(const DenseMatrix &J, DenseMatrix &P) const =0
Evaluate the 1st Piola-Kirchhoff stress tensor, P=P(J).
Abstract class for hyperelastic models.
Definition: nonlininteg.hpp:49
Vector data type.
Definition: vector.hpp:36
virtual void AssembleElementGrad(const FiniteElement &el, ElementTransformation &Tr, const Vector &elfun, DenseMatrix &elmat)
Assemble the local gradient matrix.
virtual double GetElementEnergy(const FiniteElement &el, ElementTransformation &Tr, const Vector &elfun)
Compute the local energy.
Definition: nonlininteg.cpp:25
virtual double EvalW(const DenseMatrix &J) const =0
Evaluate the strain energy density function, W=W(J).
ElementTransformation * T
Definition: nonlininteg.hpp:52