37 {
38
40
41 try {
42
43 moab::Core mb_instance;
44 moab::Interface &moab = mb_instance;
46
47 auto cp_ptr = createMaterial<ParaboloidalPlasticity>();
48
49 VectorDouble active_variables(12 + cp_ptr->nbInternalVariables);
51
53 12 + cp_ptr->nbInternalVariables);
54 cp_ptr->activeVariablesW.swap(tmp_active);
55 auto tmp_gradient =
57 cp_ptr->gradientW.swap(tmp_gradient);
58
59 auto strain = cp_ptr->getTotalStrain();
60 auto internal_variables = cp_ptr->getInternalVariables();
61 auto stress = cp_ptr->getStress();
62 auto plastic_strain = cp_ptr->getPlasticStrain();
63
64 cp_ptr->createMatAVecR();
65 cp_ptr->snesCreate();
66
67 const int idx = 3;
68 double alpha = 0.1;
70 for (
int ii = 0; ii <
N; ii++) {
71 cout << "Step " << ii << endl;
72
73 if (ii <= 14) {
74 strain[idx] += +alpha;
75 strain[0] += +alpha;
76 } else if (ii <= 100) {
77 strain[idx] += -alpha;
78 strain[0] += -alpha;
79 } else {
80 strain[idx] += +alpha;
81 }
82
83 cp_ptr->plasticStrain0 = plastic_strain;
84 cp_ptr->internalVariables0 = internal_variables;
85 CHKERR VecSetValue(cp_ptr->Chi, 6 + cp_ptr->nbInternalVariables, 0,
86 INSERT_VALUES);
87 CHKERR VecAssemblyBegin(cp_ptr->Chi);
88 CHKERR VecAssemblyEnd(cp_ptr->Chi);
90 cp_ptr.get());
91
93 bool nonlinear = false;
94 if (cp_ptr->y >
tol) {
95 nonlinear = true;
96 CHKERR cp_ptr->solveClosestProjection();
97 }
98
99 cout << "plot " << strain[idx] << " " << stress[idx] << " "
100 << internal_variables[0] << " " << plastic_strain[idx] << " "
101 << cp_ptr->deltaGamma << endl;
102
103 if (nonlinear) {
104 CHKERR cp_ptr->consistentTangent();
105 cerr << endl;
106 cerr << "Cep " << cp_ptr->Cep << endl;
109 const double eps = 1e-6;
110 for (int ii = 0; ii < 6; ii++) {
111 strain = strain0;
113 CHKERR cp_ptr->solveClosestProjection();
114 for (
int dd = 0;
dd < 6;
dd++) {
115 e(dd, ii) += stress[
dd] / (2 *
eps);
116 }
117 strain = strain0;
119 CHKERR cp_ptr->solveClosestProjection();
120 for (
int dd = 0;
dd < 6;
dd++) {
121 e(dd, ii) -= stress[
dd] / (2 *
eps);
122 }
123 }
124 strain = strain0;
125 cerr << "e " << e << endl;
126 }
127
128
129
130 }
131 }
133
135
136 return 0;
137}
#define CATCH_ERRORS
Catch errors.
#define CHKERR
Inline error check.
MoFEMErrorCode ADOLCPlasticityRes(SNES snes, Vec chi, Vec r, void *ctx)
Internal SNES function used at integration points to calulate stress.
const Tensor2_symmetric_Expr< const ddTensor0< T, Dim, i, j >, typename promote< T, double >::V, Dim, i, j > dd(const Tensor0< T * > &a, const Index< i, Dim > index1, const Index< j, Dim > index2, const Tensor1< int, Dim > &d_ijk, const Tensor1< double, Dim > &d_xyz)
auto getVectorAdaptor(T1 ptr, const size_t n)
Get Vector adaptor.
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.