v0.14.0
Functions | Variables
cloasest_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 cloasest_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  MoFEM::Interface &m_field = core;
47 
48  auto cp_ptr = createMaterial<ParaboloidalPlasticity>();
49 
50  VectorDouble active_variables(12 + cp_ptr->nbInternalVariables);
51  VectorDouble grad_w(12 + cp_ptr->nbInternalVariables);
52 
53  auto tmp_active = getVectorAdaptor(&(active_variables[0]),
54  12 + cp_ptr->nbInternalVariables);
55  cp_ptr->activeVariablesW.swap(tmp_active);
56  auto tmp_gradient =
57  getVectorAdaptor(&(grad_w[0]), 12 + cp_ptr->nbInternalVariables);
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;
70  int N = 40;
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);
90  CHKERR ADOLCPlasticityRes(cp_ptr->sNes, cp_ptr->Chi, cp_ptr->R,
91  cp_ptr.get());
92 
93  double tol = 1e-8;
94  bool nonlinear = false;
95  if (cp_ptr->y > tol) {
96  nonlinear = true;
97  CHKERR cp_ptr->solveClosetProjection();
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;
108  MatrixDouble e = cp_ptr->Cep;
109  VectorDouble strain0 = strain;
110  const double eps = 1e-6;
111  for (int ii = 0; ii < 6; ii++) {
112  strain = strain0;
113  strain[ii] -= eps;
114  CHKERR cp_ptr->solveClosetProjection();
115  for (int dd = 0; dd < 6; dd++) {
116  e(dd, ii) += stress[dd] / (2 * eps);
117  }
118  strain = strain0;
119  strain[ii] += eps;
120  CHKERR cp_ptr->solveClosetProjection();
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  // std::string wait;
130  // std::cin >> wait;
131  }
132  }
133  CATCH_ERRORS;
134 
136 
137  return 0;
138 }

Variable Documentation

◆ help

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

Definition at line 34 of file cloasest_point_projection.cpp.

MoFEM::CoreTmp< 0 >
Core (interface) class.
Definition: Core.hpp:82
MoFEM::Types::MatrixDouble
UBlasMatrix< double > MatrixDouble
Definition: Types.hpp:77
MoFEM::CoreTmp< 0 >::Finalize
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Definition: Core.cpp:112
MoFEM::DeprecatedCoreInterface
Deprecated interface functions.
Definition: DeprecatedCoreInterface.hpp:16
MoFEM::Interface
DeprecatedCoreInterface Interface
Definition: Interface.hpp:2010
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:548
MoFEM::getVectorAdaptor
auto getVectorAdaptor(T1 ptr, const size_t n)
Get Vector adaptor.
Definition: Templates.hpp:31
ADOLCPlasticity::ADOLCPlasticityRes
MoFEMErrorCode ADOLCPlasticityRes(SNES snes, Vec chi, Vec r, void *ctx)
Internal SNES function used at integration points to calulate stress.
Definition: ClosetPointProjection.cpp:558
N
const int N
Definition: speed_test.cpp:3
MoFEM::CoreTmp< 0 >::Initialize
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
Definition: Core.cpp:72
FTensor::dd
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
CATCH_ERRORS
#define CATCH_ERRORS
Catch errors.
Definition: definitions.h:385
help
static char help[]
Definition: cloasest_point_projection.cpp:34
MoFEM::Core
CoreTmp< 0 > Core
Definition: Core.hpp:1148
eps
static const double eps
Definition: check_base_functions_derivatives_on_tet.cpp:11
MoFEM::Types::VectorDouble
UBlasVector< double > VectorDouble
Definition: Types.hpp:68
tol
double tol
Definition: mesh_smoothing.cpp:26