https://mooseframework.inl.gov
umat.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #include <stdexcept>
11 
12 #include "omi_for_c.h"
13 #include "build_stiffness_matrix.h"
14 
15 extern "C" void FOR_NAME(umat, UMAT)(double * stress,
16  double * /*statev*/,
17  double * ddsdde,
18  double * /*sse*/,
19  double * /*spd*/,
20  double * /*scd*/,
21  double * /*rpl*/,
22  double * /*ddsddt*/,
23  double * /*drplde*/,
24  double * /*drpldt*/,
25  double * stran,
26  double * dstran,
27  double * /*time*/,
28  double * /*dtime*/,
29  double * /*temp*/,
30  double * /*dtemp*/,
31  double * /*predef*/,
32  double * /*dpred*/,
33  char * /*cmname*/,
34  int * /*ndi*/,
35  int * /*nshr*/,
36  int * /*ntens*/,
37  int * /*nstatv*/,
38  double * props,
39  int * nprops,
40  double * /*coords*/,
41  double * /*drot*/,
42  double * /*pnewdt*/,
43  double * /*celent*/,
44  double * /*dfgrd0*/,
45  double * /*dfgrd1*/,
46  int * /*noel*/,
47  int * /*npt*/,
48  int * /*layer*/,
49  int * /*kspt*/,
50  int * /*kstep*/,
51  int * /*kinc*/,
52  short /*cmname_len*/)
53 {
54  if (*nprops != 2)
55  throw std::invalid_argument("This UMAT requires exactly two properties.");
56 
57  double E = props[0];
58  double nu = props[1];
59  double G = E / 2.0 / (1.0 + nu);
60  double lambda = 2.0 * G * nu / (1.0 - 2.0 * nu);
61  double eps[6];
62 
63  // Build stress as in
64  // https://github.com/michael-schw/Abaqus-UMAT-Cpp-Subroutine/blob/main/umat.cpp
65  for (int i = 0; i < 6; i++)
66  eps[i] = stran[i] + dstran[i];
67 
68  auto eps_trace = eps[0] + eps[1] + eps[2];
69 
70  for (int i = 0; i < 3; i++)
71  {
72  stress[i] = lambda * eps_trace + 2.0 * G * eps[i];
73  stress[i + 3] = G * eps[i + 3];
74  }
75 
76  Eigen::Matrix<double, 6, 6> C;
77  buildStiffnessMatrix(C, G, lambda);
78 
79  for (int i = 0; i < 6; i++)
80  for (int j = 0; j < 6; j++)
81  ddsdde[6 * i + j] = 0.0;
82 
83  for (int i = 0; i < 3; i++)
84  {
85  ddsdde[6 * i + 0] = C(0, i);
86  ddsdde[6 * i + 1] = C(1, i);
87  ddsdde[6 * i + 2] = C(2, i);
88  ddsdde[6 * (i + 3) + (i + 3)] = C(i + 3, i + 3);
89  }
90 }
const Real eps
void FOR_NAME(umat, UMAT)
Definition: umat.C:15
static const std::string G
Definition: NS.h:166
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
void buildStiffnessMatrix(Eigen::Ref< Eigen::Matrix< double, 6, 6 >> C, const double &G, const double &lambda)
build a 6x6 representation of the stiffness tensor in C from the shear modulus G and Lame&#39;s first par...
static const std::string C
Definition: NS.h:168