v0.16.3
Loading...
Searching...
No Matches
Functions | Variables
closest_point_projection.cpp File Reference
#include <MoFEM.hpp>
#include <boost/program_options.hpp>
#include <ADOLCPlasticity.hpp>
#include <ADOLCPlasticityMaterialModels.hpp>

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Variables

static char help []
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 37 of file closest_point_projection.cpp.

37 {
38
39 MoFEM::Core::Initialize(&argc, &argv, (char *)0, help);
40
41 try {
42
43 moab::Core mb_instance;
44 moab::Interface &moab = mb_instance;
45 MoFEM::Core core(moab);
46
47 auto cp_ptr = createMaterial<ParaboloidalPlasticity>();
48
49 VectorDouble active_variables(12 + cp_ptr->nbInternalVariables);
50 VectorDouble grad_w(12 + cp_ptr->nbInternalVariables);
51
52 auto tmp_active = getVectorAdaptor(&(active_variables[0]),
53 12 + cp_ptr->nbInternalVariables);
54 cp_ptr->activeVariablesW.swap(tmp_active);
55 auto tmp_gradient =
56 getVectorAdaptor(&(grad_w[0]), 12 + cp_ptr->nbInternalVariables);
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;
69 int N = 40;
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);
89 CHKERR ADOLCPlasticityRes(cp_ptr->sNes, cp_ptr->Chi, cp_ptr->R,
90 cp_ptr.get());
91
92 double tol = 1e-8;
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;
107 MatrixDouble e = cp_ptr->Cep;
108 VectorDouble strain0 = strain;
109 const double eps = 1e-6;
110 for (int ii = 0; ii < 6; ii++) {
111 strain = strain0;
112 strain[ii] -= eps;
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;
118 strain[ii] += eps;
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 // std::string wait;
129 // std::cin >> wait;
130 }
131 }
133
135
136 return 0;
137}
static const double eps
static char help[]
#define CATCH_ERRORS
Catch errors.
#define CHKERR
Inline error check.
double tol
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)
Definition ddTensor0.hpp:33
auto getVectorAdaptor(T1 ptr, const size_t n)
Get Vector adaptor.
Definition Templates.hpp:49
const int N
Definition speed_test.cpp:3
Core (interface) class.
Definition Core.hpp:83
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
Definition Core.cpp:68
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Definition Core.cpp:123

Variable Documentation

◆ help

char help[]
static
Initial value:
= "...\n"
"\n"

Definition at line 34 of file closest_point_projection.cpp.