https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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"
14
15extern "C" void
16FOR_NAME(umat, UMAT)(double * stress,
17 double * /*statev*/,
18 double * ddsdde,
19 double * /*sse*/,
20 double * /*spd*/,
21 double * /*scd*/,
22 double * /*rpl*/,
23 double * /*ddsddt*/,
24 double * /*drplde*/,
25 double * /*drpldt*/,
26 double * stran,
27 double * dstran,
28 double * /*time*/,
29 double * /*dtime*/,
30 double * /*temp*/,
31 double * /*dtemp*/,
32 double * /*predef*/,
33 double * /*dpred*/,
34 char * /*cmname*/,
35 int * /*ndi*/,
36 int * /*nshr*/,
37 int * /*ntens*/,
38 int * /*nstatv*/,
39 double * props,
40 int * nprops,
41 double * /*coords*/,
42 double * /*drot*/,
43 double * /*pnewdt*/,
44 double * /*celent*/,
45 double * /*dfgrd0*/,
46 double * /*dfgrd1*/,
47 int * /*noel*/,
48 int * /*npt*/,
49 int * /*layer*/,
50 int * /*kspt*/,
51 int * /*kstep*/,
52 int * /*kinc*/,
53 short /*cmname_len*/)
54{
55 if (*nprops != 2)
56 throw std::invalid_argument("This UMAT requires exactly two properties.");
57
58 double E = props[0];
59 double nu = props[1];
60 double G = E / 2.0 / (1.0 + nu);
61 double lambda = 2.0 * G * nu / (1.0 - 2.0 * nu);
62 double eps[6];
63
64 // Build stress as in
65 // https://github.com/michael-schw/Abaqus-UMAT-Cpp-Subroutine/blob/main/umat.cpp
66 for (int i = 0; i < 6; i++)
67 eps[i] = stran[i] + dstran[i];
68
69 auto eps_trace = eps[0] + eps[1] + eps[2];
70
71 for (int i = 0; i < 3; i++)
72 {
73 stress[i] = lambda * eps_trace + 2.0 * G * eps[i];
74 stress[i + 3] = G * eps[i + 3];
75 }
76
77 Eigen::Matrix<double, 6, 6> C;
78 buildStiffnessMatrix(C, G, lambda);
79
80 for (int i = 0; i < 6; i++)
81 for (int j = 0; j < 6; j++)
82 ddsdde[6 * i + j] = 0.0;
83
84 for (int i = 0; i < 3; i++)
85 {
86 ddsdde[6 * i + 0] = C(0, i);
87 ddsdde[6 * i + 1] = C(1, i);
88 ddsdde[6 * i + 2] = C(2, i);
89 ddsdde[6 * (i + 3) + (i + 3)] = C(i + 3, i + 3);
90 }
91}
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's first par...
void FOR_NAME(umat, UMAT)
Definition umat.C:16