MFEM  v4.5.1
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
linear_elastic.hpp
Go to the documentation of this file.
1 // Copyright (c) 2010-2022, Lawrence Livermore National Security, LLC. Produced
2 // at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3 // LICENSE and NOTICE for details. LLNL-CODE-806117.
4 //
5 // This file is part of the MFEM library. For more information and source code
6 // availability visit https://mfem.org.
7 //
8 // MFEM is free software; you can redistribute it and/or modify it under the
9 // terms of the BSD-3 license. We welcome feedback and contributions, see file
10 // CONTRIBUTING.md for details.
11 
12 #ifndef MFEM_ELASTICITY_MAT_LIN_ELAST_HPP
13 #define MFEM_ELASTICITY_MAT_LIN_ELAST_HPP
14 
15 #include "linalg/tensor.hpp"
16 #include "mfem.hpp"
17 
18 using mfem::internal::tensor;
19 
20 /** @brief Linear elastic material.
21  *
22  * Defines a linear elastic material response. It satisfies the material_type
23  * interface for ElasticityOperator::SetMaterial.
24  */
25 template <int dim> struct LinearElasticMaterial
26 {
27  /**
28  * @brief Compute the stress response.
29  *
30  * @param[in] dudx derivative of the displacement
31  * @return tensor<double, dim, dim>
32  */
33  tensor<double, dim, dim>
34  MFEM_HOST_DEVICE stress(const tensor<double, dim, dim> &dudx) const
35  {
36  constexpr auto I = mfem::internal::IsotropicIdentity<dim>();
37  auto epsilon = sym(dudx);
38  return lambda * tr(epsilon) * I + 2.0 * mu * epsilon;
39  }
40 
41  /**
42  * @brief Apply the gradient of the stress.
43  *
44  */
45  tensor<double, dim, dim> MFEM_HOST_DEVICE
46  action_of_gradient(const tensor<double, dim, dim> & /* dudx */,
47  const tensor<double, dim, dim> &ddudx) const
48  {
49  return stress(ddudx);
50  }
51 
52  /**
53  * @brief Compute the gradient.
54  *
55  * This method is used in the ElasticityDiagonalPreconditioner type to
56  * compute the gradient matrix entries of the current quadrature point,
57  * instead of the action.
58  *
59  * @return tensor<double, dim, dim, dim, dim>
60  */
61  tensor<double, dim, dim, dim, dim>
62  MFEM_HOST_DEVICE gradient(tensor<double, dim, dim> /* dudx */) const
63  {
64  return mfem::internal::make_tensor<dim, dim, dim, dim>([&](int i, int j, int k,
65  int l)
66  {
67  return lambda * (i == j) * (k == l) +
68  mu * ((i == l) * (j == k) + (i == k) * (j == l));
69  });
70  }
71 
72  /// First Lame parameter
73  double lambda = 100;
74  /// Second Lame parameter
75  double mu = 50;
76 };
77 
78 #endif
double epsilon
Definition: ex25.cpp:140
double mu
Second Lame parameter.
tensor< double, dim, dim > MFEM_HOST_DEVICE action_of_gradient(const tensor< double, dim, dim > &, const tensor< double, dim, dim > &ddudx) const
Apply the gradient of the stress.
tensor< double, dim, dim > MFEM_HOST_DEVICE stress(const tensor< double, dim, dim > &dudx) const
Compute the stress response.
double lambda
First Lame parameter.
Linear elastic material.
Implementation of the tensor class.
tensor< double, dim, dim, dim, dim > MFEM_HOST_DEVICE gradient(tensor< double, dim, dim >) const
Compute the gradient.