37 {
38
40
41 try {
42
43 moab::Core mb_instance;
44 moab::Interface &moab = mb_instance;
47
49
50 VectorDouble active_variables(12 + cp_ptr->nbInternalVariables);
52
54 12 + cp_ptr->nbInternalVariables);
55 cp_ptr->activeVariablesW.swap(tmp_active);
56 auto tmp_gradient =
58 cp_ptr->gradientW.swap(tmp_gradient);
59
60 auto strain = cp_ptr->getTotalStrain();
61 auto internal_variables = cp_ptr->getInternalVariables();
62 auto stress = cp_ptr->getStress();
63 auto plastic_strain = cp_ptr->getPlasticStrain();
64
65 cp_ptr->createMatAVecR();
66 cp_ptr->snesCreate();
67
68 const int idx = 3;
69 double alpha = 0.1;
71 for (
int ii = 0; ii <
N; ii++) {
72 cout << "Step " << ii << endl;
73
74 if (ii <= 14) {
75 strain[idx] += +alpha;
76 strain[0] += +alpha;
77 } else if (ii <= 100) {
78 strain[idx] += -alpha;
79 strain[0] += -alpha;
80 } else {
81 strain[idx] += +alpha;
82 }
83
84 cp_ptr->plasticStrain0 = plastic_strain;
85 cp_ptr->internalVariables0 = internal_variables;
86 CHKERR VecSetValue(cp_ptr->Chi, 6 + cp_ptr->nbInternalVariables, 0,
87 INSERT_VALUES);
88 CHKERR VecAssemblyBegin(cp_ptr->Chi);
89 CHKERR VecAssemblyEnd(cp_ptr->Chi);
91 cp_ptr.get());
92
94 bool nonlinear = false;
95 if (cp_ptr->y >
tol) {
96 nonlinear = true;
97 CHKERR cp_ptr->solveClosestProjection();
98 }
99
100 cout << "plot " << strain[idx] << " " << stress[idx] << " "
101 << internal_variables[0] << " " << plastic_strain[idx] << " "
102 << cp_ptr->deltaGamma << endl;
103
104 if (nonlinear) {
105 CHKERR cp_ptr->consistentTangent();
106 cerr << endl;
107 cerr << "Cep " << cp_ptr->Cep << endl;
110 const double eps = 1e-6;
111 for (int ii = 0; ii < 6; ii++) {
112 strain = strain0;
114 CHKERR cp_ptr->solveClosestProjection();
115 for (
int dd = 0;
dd < 6;
dd++) {
116 e(dd, ii) += stress[
dd] / (2 *
eps);
117 }
118 strain = strain0;
120 CHKERR cp_ptr->solveClosestProjection();
121 for (
int dd = 0;
dd < 6;
dd++) {
122 e(dd, ii) -= stress[
dd] / (2 *
eps);
123 }
124 }
125 strain = strain0;
126 cerr << "e " << e << endl;
127 }
128
129
130
131 }
132 }
134
136
137 return 0;
138}
#define CATCH_ERRORS
Catch errors.
#define CHKERR
Inline error check.
auto createMaterial(std::array< int, ClosestPointProjection::LAST_TAPE > tapes_tags={0, 1, 2})
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.
Deprecated interface functions.