https://mooseframework.inl.gov
Loading...
Searching...
No Matches
small_strain_tri_uel.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/***************************************************************************************
11 ** UEL, FOR ABAQUS/STANDARD INCORPORATING ISOTROPIC ELASTICITY **
12 ***************************************************************************************/
13
14#include "MooseTypes.h"
15#include "MooseError.h"
16
17#include <libmesh/int_range.h>
18
19#include <Eigen/Core>
20#include <Eigen/Dense>
21
22extern "C" void
23uel_(double RHS[],
24 double AMATRX[],
25 double /*SVARS*/[],
26 double /*ENERGY*/[],
27 int * /*NDOFEL*/,
28 int * /*NRHS*/,
29 int * /*NSVARS*/,
30 double PROPS[],
31 int * NPROPS,
32 double COORDS[],
33 int * /*MCRD*/,
34 int * /*NNODE*/,
35 double U_[],
36 double DU_[],
37 double /*V_*/[],
38 double /*A_*/[],
39 int * /*JTYPE*/,
40 double /*TIME*/[],
41 double * /*DTIME*/,
42 int * /*KSTEP*/,
43 int * /*KINC*/,
44 int * JELEM,
45 double /*PRAMS*/[],
46 int * /*NDLOAD*/,
47 int /*JDLTYP*/[],
48 double /*ADLMAG*/[],
49 double /*PREDEF*/[],
50 int * /*NPREDF*/,
51 int /*LFLAGS*/[],
52 int * /*MLVARX*/,
53 double /*DDLMAG*/[],
54 int * /*MDLOAD*/,
55 double * /*PNEWDT*/,
56 int /*JPROPS*/[],
57 int * /*NJPROP*/,
58 double * /*PERIOD*/)
59{
60 if (*NPROPS != 2)
61 mooseError("Wrong number of properties passed in.");
62
63 // solution at the beginning of the increment
64 Eigen::Matrix<Real, 6, 1> u;
65 u << U_[0], U_[1], U_[2], U_[3], U_[4], U_[5];
66
67 // current solution increment
68 Eigen::Matrix<Real, 6, 1> du;
69 du << DU_[0], DU_[1], DU_[2], DU_[3], DU_[4], DU_[5];
70
71 // current solution
72 u += du;
73
74 const auto & x1 = COORDS[0];
75 const auto & y1 = COORDS[1];
76 const auto & x2 = COORDS[2];
77 const auto & y2 = COORDS[3];
78 const auto & x3 = COORDS[4];
79 const auto & y3 = COORDS[5];
80
81 const auto x13 = x1 - x3;
82 const auto x21 = x2 - x1;
83 const auto y12 = y1 - y2;
84 const auto y21 = y2 - y1;
85 const auto x31 = x3 - x1;
86 const auto y31 = y3 - y1;
87 const auto x32 = x3 - x2;
88 const auto y23 = y2 - y3;
89
90 // Element Jacobian
91 Eigen::Matrix<Real, 2, 2> J;
92 J << x21, y21, //
93 x31, y31; //
94
95 const auto Jdet = J.determinant();
96 if (Jdet <= 0)
97 mooseError("Negative Jacobian in element ", *JELEM);
98
99 // const auto Jinv = J.inverse();
100
101 // Area
102 const auto A = Jdet / 2.0;
103
104 Eigen::Matrix<Real, 3, 6> B;
105 B << y23, 0.0, y31, 0.0, y12, 0.0, //
106 0.0, x32, 0.0, x13, 0.0, x21, //
107 x32, y23, x13, y31, x21, y12;
108 B *= 1.0 / Jdet;
109
110 const auto Bt = B.transpose();
111
112 // element thickness
113 const Real t = 1.0;
114
115 // Young's Modulus
116 const auto Y = PROPS[0];
117
118 // Poisson's ratio
119 const auto nu = PROPS[1];
120
121 Eigen::Matrix<Real, 3, 3> E;
122
123 // plane stress
124 // E << 1.0, nu, 0.0, //
125 // nu, 1.0, 0.0, //
126 // 0.0, 0.0, (1.0 - nu) / 2.0;
127 // E *= Y / (1.0 - nu * nu);
128
129 // plane strain
130 E << 1.0 - nu, nu, 0.0, //
131 nu, 1.0 - nu, 0.0, //
132 0.0, 0.0, (1.0 - 2.0 * nu) / 2.0;
133 E *= Y / (1.0 + nu) / (1.0 - 2.0 * nu);
134
135 // integrating the CST to obtain the Element characteristic matrix (6,6)
136 const auto ke = Bt * E * B * t * A;
137
138 // nodal forces
139 const auto re = ke * u;
140
141 // copy residual (nodal forces) and Jacobian (Element characteristic matrix)
142 for (const auto i : make_range(6))
143 {
144 RHS[i] = -re(i);
145 for (const auto j : make_range(6))
146 AMATRX[i * 6 + j] = -ke(i, j);
147 }
148}
void mooseError(Args &&... args)
void uel_(double RHS[], double AMATRX[], double[], double[], int *, int *, int *, double PROPS[], int *NPROPS, double COORDS[], int *, int *, double U_[], double DU_[], double[], double[], int *, double[], double *, int *, int *, int *JELEM, double[], int *, int[], double[], double[], int *, int[], int *, double[], int *, double *, int[], int *, double *)