https://mooseframework.inl.gov
elastic_print_eigen.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 #pragma GCC diagnostic push
11 #pragma GCC diagnostic ignored "-Wunused-parameter"
12 
13 #include <stdio.h>
14 // Ignore warnings from Eigen related to deprecated declarations (C++17)
15 #include "libmesh/ignore_warnings.h"
16 #include <Eigen/Eigen>
17 #include "libmesh/restore_warnings.h"
18 
19 #include "MooseError.h"
20 
21 void
22 buildStiffnessMatrix(Eigen::Ref<Eigen::Matrix<double, 6, 6>> C,
23  const double & G,
24  const double & lambda)
25 {
26  C = Eigen::Matrix<double, 6, 6>::Zero();
27 
28  for (int i = 0; i < 3; i++)
29  {
30  C(i, i) += 2 * G;
31  C(i + 3, i + 3) += G;
32  for (int j = 0; j < 3; j++)
33  C(i, j) += lambda;
34  }
35 }
36 
37 extern "C" void
38 umat_(double * stress,
39  double * statev,
40  double * ddsdde,
41  double * sse,
42  double * spd,
43  double * scd,
44  double * rpl,
45  double * ddsddt,
46  double * drplde,
47  double * drpldt,
48  double * stran,
49  double * dstran,
50  double * time,
51  double * dtime,
52  double * temp,
53  double * dtemp,
54  double * predef,
55  double * dpred,
56  char * cmname,
57  int * ndi,
58  int * nshr,
59  int * ntens,
60  int * nstatv,
61  double * props,
62  int * nprops,
63  double * coords,
64  double * drot,
65  double * pnewdt,
66  double * celent,
67  double * dfgrd0,
68  double * dfgrd1,
69  int * noel,
70  int * npt,
71  int * layer,
72  int * kspt,
73  int * kstep,
74  int * kinc,
75  short cmname_len)
76 {
77 
78  double E = props[0];
79  double nu = props[1];
80  double G = E / 2.0 / (1.0 + nu);
81  double lambda = 2.0 * G * nu / (1.0 - 2.0 * nu);
82  double eps[6];
83  double eps_trace;
84 
85  for (int i = 0; i < 6; i++)
86  eps[i] = stran[i] + dstran[i];
87 
88  eps_trace = eps[0] + eps[1] + eps[2];
89 
90  for (int i = 0; i < 3; i++)
91  {
92  stress[i] = lambda * eps_trace + 2.0 * G * eps[i];
93  stress[i + 3] = G * eps[i + 3];
94  }
95 
96  Eigen::Matrix<double, 6, 6> C;
97  buildStiffnessMatrix(C, G, lambda);
98 
99  for (int i = 0; i < 6; i++)
100  for (int j = 0; j < 6; j++)
101  ddsdde[6 * i + j] = 0.0;
102 
103  for (int i = 0; i < 3; i++)
104  {
105  ddsdde[6 * i + 0] = C(0, i);
106  ddsdde[6 * i + 1] = C(1, i);
107  ddsdde[6 * i + 2] = C(2, i);
108  ddsdde[6 * (i + 3) + (i + 3)] = C(i + 3, i + 3);
109  }
110 
111  // Print out eigenvalue using Eigen matrix
112  auto eigenvalues = C.eigenvalues();
113 
114  if (*npt == 8 && time[0] == 0.0)
115  for (int index_i = 0; index_i < *ntens; index_i++)
116  Moose::out << "Eigenvalues " << index_i << " " << eigenvalues(index_i).real() << std::endl;
117 }
118 
119 #pragma GCC diagnostic pop
void umat_(double *stress, double *statev, double *ddsdde, double *sse, double *spd, double *scd, double *rpl, double *ddsddt, double *drplde, double *drpldt, double *stran, double *dstran, double *time, double *dtime, double *temp, double *dtemp, double *predef, double *dpred, char *cmname, int *ndi, int *nshr, int *ntens, int *nstatv, double *props, int *nprops, double *coords, double *drot, double *pnewdt, double *celent, double *dfgrd0, double *dfgrd1, int *noel, int *npt, int *layer, int *kspt, int *kstep, int *kinc, short cmname_len)
const Real eps
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