v0.16.0
Loading...
Searching...
No Matches
HMHNeohookean.cpp
Go to the documentation of this file.
1/**
2 * @file HMHNeohookean.cpp
3 * @brief Implementation of NeoHookean material
4 * @date 2024-08-31
5 *
6 * @copyright Copyright (c) 2024
7 *
8 */
9
10namespace EshelbianPlasticity {
11
12// #define NEOHOOKEAN_SCALING
14
15 /**
16 * @brief Definition of Neo-hookean function
17 *
18 * P(i, I) = 2. * c10_default * (tF(i, I) - tInvF(i, I)) +
19 * K_default * log(detF) * tInvF(i, I)
20 * tCof(i, I) = detF * tInvF(I, i)
21 * Psi = c10* (trace(tCof) + 2ln(det(F)) - 3) + (K/2.) * (log(detF))^2
22 *
23 * @param c10
24 * @param v
25 * @return double
26 */
27 static inline double fun_neohookean(double c10, double v) {
28 return (2.0 * c10) * (-1. + EshelbianCore::f(2 * v));
29 }
30
31 /**
32 * @brief Definition of derivative of Neo-hookean function
33 *
34 * @param c10
35 * @param v
36 * @return * double
37 */
38 static inline double fun_d_neohookean(double c10, double v) {
39 return
40
41 (4.0 * c10) * EshelbianCore::d_f(2 * v);
42 }
43
44 /**
45 * @brief Definition of axiator of Neo-hookean function
46 *
47 * Psi = (K/2.) * (log(J))^2 = (K/2.) * (log(exp tr H))^2 = (K/2.) * (tr H)^2
48 *
49 * @param c10
50 * @param v
51 * @return double
52 */
53 static inline double fun_neohookean_bulk(double K, double tr) {
54 return K * tr;
55 }
56
57 /**
58 * @brief Definition of derivative of axiator of Neo-hookean function
59 *
60 * @param K
61 * @param tr
62 * @return double
63 */
64 static inline double fun_diff_neohookean_bulk(double K, double tr) {
65 return K;//K * exp(tr) * (1. + tr); // K*2*ln(J)/J
66 }
67
68 HMHNeohookean(MoFEM::Interface &m_field, const double c10, const double K)
69 : PhysicalEquations(), mField(m_field), c10_default(c10),
70 K_default(K) {
71
72 CHK_THROW_MESSAGE(getOptions(), "get options failed");
74 "extract block data failed");
75
76#ifdef NEOHOOKEAN_SCALING
77 if (blockData.size()) {
78 double ave_K = 0;
79 for (auto b : blockData) {
80 ave_K += b.K;
81 }
82 eqScaling = ave_K / blockData.size();
83 }
84#endif
85
86 MOFEM_LOG("EP", Sev::inform) << "Neo-Hookean scaling = " << eqScaling;
87
90 "Stretch selector is not equal to LOG");
91 } else {
92 if (EshelbianCore::exponentBase != exp(1)) {
94 "Exponent base is not equal to exp(1)");
95 }
96 }
97 }
98
100 for (auto &b : blockData) {
101 if (b.blockEnts.find(ent) != b.blockEnts.end()) {
102 return std::make_pair(b.c10, b.K);
103 }
104 }
105 if (blockData.size() != 0)
107 "Block not found for entity handle. If you mat set "
108 "block, set it to all elements");
109 return std::make_pair(c10_default, K_default);
110 }
111
112 struct OpJacobian : public EshelbianPlasticity::OpJacobian {
113 using EshelbianPlasticity::OpJacobian::OpJacobian;
114 MoFEMErrorCode evaluateRhs(EntData &data) { return 0; }
115 MoFEMErrorCode evaluateLhs(EntData &data) { return 0; }
116 };
117
119 returnOpJacobian(const bool eval_rhs, const bool eval_lhs,
120 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
121 boost::shared_ptr<PhysicalEquations> physics_ptr) {
122 return (new OpJacobian(eval_rhs, eval_lhs, data_ptr, physics_ptr));
123 }
124
125 MoFEMErrorCode getOptions() {
127 PetscOptionsBegin(PETSC_COMM_WORLD, "neo_hookean_", "", "none");
128
129 c10_default = 1;
130 CHKERR PetscOptionsScalar("-c10", "C10", "", c10_default, &c10_default,
131 PETSC_NULLPTR);
132 K_default = 1;
133 CHKERR PetscOptionsScalar("-K", "Bulk modulus K", "", K_default, &K_default,
134 PETSC_NULLPTR);
135
136 alphaGradU = 0;
137 CHKERR PetscOptionsScalar("-viscosity_alpha_grad_u", "viscosity", "",
138 alphaGradU, &alphaGradU, PETSC_NULLPTR);
139
140 PetscOptionsEnd();
141
142 MOFEM_LOG_CHANNEL("WORLD");
143 MOFEM_TAG_AND_LOG("WORLD", Sev::inform, "MatBlock Neo-Hookean (default)")
144 << "c10 = " << c10_default << " K = " << K_default
145 << " grad alpha u = " << alphaGradU;
147 }
148
149 MoFEMErrorCode extractBlockData(Sev sev) {
150 return extractBlockData(
151
152 mField.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(std::regex(
153
154 (boost::format("%s(.*)") % "MAT_NEOHOOKEAN").str()
155
156 )),
157
158 sev);
159 }
160
161 MoFEMErrorCode
162 extractBlockData(std::vector<const CubitMeshSets *> meshset_vec_ptr,
163 Sev sev) {
165
166 for (auto m : meshset_vec_ptr) {
167 MOFEM_LOG("EP", sev) << *m;
168 std::vector<double> block_data;
169 CHKERR m->getAttributes(block_data);
170 if (block_data.size() < 2) {
171 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
172 "Expected that block has atleast two attributes");
173 }
174 auto get_block_ents = [&]() {
175 Range ents;
176 CHKERR mField.get_moab().get_entities_by_handle(m->meshset, ents, true);
177 return ents;
178 };
179
180 double c10 = block_data[0];
181 double K = block_data[1];
182
183 blockData.push_back({c10, K, get_block_ents()});
184
185 MOFEM_LOG("EP", sev) << "MatBlock Neo-Hookean c10 = "
186 << blockData.back().c10
187 << " K = " << blockData.back().K << " nb ents. = "
188 << blockData.back().blockEnts.size();
189 }
191 }
192
194
195 OpSpatialPhysical(const std::string &field_name,
196 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
197 const double alpha_u);
198
199 MoFEMErrorCode integrate(EntData &data);
200
201 private:
202 const double alphaU;
203 };
204
205 virtual VolUserDataOperator *
207 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
208 const double alpha_u) {
209 return new OpSpatialPhysical(field_name, data_ptr, alpha_u);
210 }
211
213
215 const std::string &field_name,
216 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
217 boost::shared_ptr<ExternalStrainVec> external_strain_vec_ptr,
218 std::map<std::string, boost::shared_ptr<ScalingMethod>> smv);
219
220 MoFEMErrorCode integrate(EntData &data);
221
222 private:
223 boost::shared_ptr<ExternalStrainVec> externalStrainVecPtr;
224 std::map<std::string, boost::shared_ptr<ScalingMethod>> scalingMethodsMap;
225 };
226
228 const std::string &field_name,
229 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
230 boost::shared_ptr<ExternalStrainVec> external_strain_vec_ptr,
231 std::map<std::string, boost::shared_ptr<ScalingMethod>> smv) {
232 return new OpSpatialPhysicalExternalStrain(field_name, data_ptr,
233 external_strain_vec_ptr, smv);
234 }
235
237 OpSpatialPhysical_du_du(std::string row_field, std::string col_field,
238 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
239 const double alpha);
240 MoFEMErrorCode getOptions();
241 MoFEMErrorCode integrate(EntData &row_data, EntData &col_data);
242
243 private:
244 const double alphaU;
245 double minimEigenValue = 0;
246 };
247
249 std::string row_field, std::string col_field,
250 boost::shared_ptr<DataAtIntegrationPts> data_ptr, const double alpha) {
251 return new OpSpatialPhysical_du_du(row_field, col_field, data_ptr, alpha);
252 }
253
254private:
256
258 double K_default;
260 struct BlockData {
261 double c10;
262 double K;
264 };
265 std::vector<BlockData> blockData;
266
267 double eqScaling = 1.;
268};
269
271 const std::string &field_name,
272 boost::shared_ptr<DataAtIntegrationPts> data_ptr, const double alpha_u)
273 : OpAssembleVolume(field_name, data_ptr, OPROW), alphaU(alpha_u) {}
274
275extern "C" {
276void tetcircumcenter_tp(double a[3], double b[3], double c[3], double d[3],
277 double circumcenter[3], double *xi, double *eta,
278 double *zeta);
279}
280
283
284 auto neohookean_ptr =
285 boost::dynamic_pointer_cast<HMHNeohookean>(dataAtPts->physicsPtr);
286 if (!neohookean_ptr) {
287 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
288 "Pointer to HMHNeohookean is null");
289 }
290 auto [def_c10, def_K] =
291 neohookean_ptr->getMaterialParameters(getFEEntityHandle());
292
293 double c10 = def_c10 / neohookean_ptr->eqScaling;
294 double alpha_u = alphaU / neohookean_ptr->eqScaling;
295 double K = def_K / neohookean_ptr->eqScaling;
296
297 double alpha_grad_u =
298 neohookean_ptr->alphaGradU / neohookean_ptr->eqScaling;
299
301 auto t_L = symm_L_tensor();
302
303 constexpr auto t_kd_sym = FTensor::Kronecker_Delta_symmetric<int>();
304 constexpr auto t_kd = FTensor::Kronecker_Delta<int>();
305
306 int nb_dofs = data.getIndices().size();
307 int nb_integration_pts = data.getN().size1();
308 auto v = getVolume();
309 auto t_w = getFTensor0IntegrationWeight();
310 auto t_approx_P_adjoint_log_du =
311 dataAtPts->getFTensorAdjointPdU(nb_integration_pts);
312 auto t_u = dataAtPts->getFTensorStretch(nb_integration_pts);
313 auto t_dot_log_u = dataAtPts->getFTensorLogStretchDot(nb_integration_pts);
314 auto t_diff_u = dataAtPts->getFTensorDiffStretch(nb_integration_pts);
315 auto t_log_u = dataAtPts->getFTensorLogStretch(nb_integration_pts);
316 auto t_grad_log_u =
317 dataAtPts->getFTensorGradLogStretchDot(nb_integration_pts);
318 auto t_log_u2_h1 = dataAtPts->getFTensorLogStretch2H1(nb_integration_pts);
319
320 auto t_eigen_vals = dataAtPts->getFTensorEigenVals(nb_integration_pts);
321 auto t_eigen_vecs = dataAtPts->getFTensorEigenVecs(nb_integration_pts);
322 auto &nbUniq = dataAtPts->nbUniq;
323 auto t_nb_uniq =
324 FTensor::Tensor0<FTensor::PackPtr<int *, 1>>(nbUniq.data().data());
325
326 auto t_diff = diff_tensor();
327
334
335 auto get_ftensor2 = [](auto &v) {
337 &v[0], &v[1], &v[2], &v[3], &v[4], &v[5]);
338 };
339
340 int nb_base_functions = data.getN().size2();
341 auto t_row_base_fun = data.getFTensor0N();
342 auto t_grad_base_fun = data.getFTensor1DiffN<3>();
343
344 auto no_h1 = [&]() {
346
347 for (int gg = 0; gg != nb_integration_pts; ++gg) {
348 double a = v * t_w;
349 ++t_w;
350
351 auto neohookean = [c10](auto v) { return fun_neohookean(c10, v); };
352 auto t_neohookean_hencky =
353 EigenMatrix::getMat(t_eigen_vals, t_eigen_vecs, neohookean);
354 ++t_eigen_vals;
355 ++t_eigen_vecs;
356 ++t_nb_uniq;
357
358 const double tr = t_log_u(i, i);
360 t_P(L) = t_L(i, j, L) * (t_neohookean_hencky(i, j) +
361 t_kd(i, j) * fun_neohookean_bulk(K, tr));
363 t_viscous_P(L) = alpha_u * (t_L(i, j, L) * t_dot_log_u(i, j));
364
366 t_residual(L) = t_approx_P_adjoint_log_du(L) - t_P(L) - t_viscous_P(L);
367 t_residual(L) *= a;
368
370 t_grad_residual(L, i) = alpha_grad_u * t_grad_log_u(L, i);
371 t_grad_residual(L, i) *= a;
372
373 ++t_approx_P_adjoint_log_du;
374 ++t_log_u;
375 ++t_dot_log_u;
376 ++t_grad_log_u;
377
378 auto t_nf = getFTensor1FromPtr<size_symm>(&*nF.data().begin());
379 int bb = 0;
380 for (; bb != nb_dofs / size_symm; ++bb) {
381 t_nf(L) -= t_row_base_fun * t_residual(L);
382 t_nf(L) += t_grad_base_fun(i) * t_grad_residual(L, i);
383 ++t_nf;
384 ++t_row_base_fun;
385 ++t_grad_base_fun;
386 }
387 for (; bb != nb_base_functions; ++bb) {
388 ++t_row_base_fun;
389 ++t_grad_base_fun;
390 }
391 }
392
394 };
395
396 auto large = [&]() {
398 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
399 "Not implemented for Neo-Hookean (used ADOL-C)");
401 };
402
405 CHKERR no_h1();
406 break;
407 case LARGE_ROT:
408 case MODERATE_ROT:
409 CHKERR large();
410 break;
411 default:
412 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
413 "gradApproximator not handled");
414 };
415
417}
418
420 const std::string &field_name,
421 boost::shared_ptr<DataAtIntegrationPts> data_ptr,
422 boost::shared_ptr<ExternalStrainVec> external_strain_vec_ptr,
423 std::map<std::string, boost::shared_ptr<ScalingMethod>> smv)
424 : OpAssembleVolume(field_name, data_ptr, OPROW),
425 externalStrainVecPtr(external_strain_vec_ptr), scalingMethodsMap{smv} {}
426
427MoFEMErrorCode
430
431 auto neohookean_ptr =
432 boost::dynamic_pointer_cast<HMHNeohookean>(dataAtPts->physicsPtr);
433 if (!neohookean_ptr) {
434 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
435 "Pointer to HMHNeohookean is null");
436 }
437
438 double time = OpAssembleVolume::getFEMethod()->ts_t;
441 }
442 // get entity of tet
444 // iterate over all block data
445
446 for (auto &ext_strain_block : (*externalStrainVecPtr)) {
447 auto block_name = "(.*)ANALYTICAL_EXTERNALSTRAIN(.*)";
448 std::regex reg_name(block_name);
449 if (std::regex_match(ext_strain_block.blockName, reg_name)) {
450 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
451 "Analytical external strain not implemented for Neo-Hookean "
452 "material.");
453 }
454 // check if finite element entity is part of the EXTERNALSTRAIN block
455 if (ext_strain_block.ents.find(fe_ent) != ext_strain_block.ents.end()) {
456 double scale = 1;
457 if (scalingMethodsMap.find(ext_strain_block.blockName) !=
458 scalingMethodsMap.end()) {
459 scale *=
460 scalingMethodsMap.at(ext_strain_block.blockName)->getScale(time);
461 } else {
462 MOFEM_LOG("SELF", Sev::warning)
463 << "No scaling method found for " << ext_strain_block.blockName;
464 }
465
466 // get ExternalStrain block data
467 double external_strain_val = scale * ext_strain_block.val;
468 double K = ext_strain_block.bulkModulusK;
469
471 auto t_L = symm_L_tensor();
472 constexpr auto t_kd = FTensor::Kronecker_Delta<int>();
473
474 int nb_dofs = data.getIndices().size();
475 int nb_integration_pts = data.getN().size1();
476 auto v = getVolume();
477 auto t_w = getFTensor0IntegrationWeight();
478
485
486 int nb_base_functions = data.getN().size2();
487 auto t_row_base_fun = data.getFTensor0N();
488
489 const double tr = 3.0 * external_strain_val;
490 const double sigma_J = K * tr;
491
492 for (int gg = 0; gg != nb_integration_pts; ++gg) {
493 double a = v * t_w;
494 ++t_w;
495
497 t_residual(L) = 0.0;
498 t_residual(L) += (t_L(i, j, L) * t_kd(i, j)) * sigma_J;
499 t_residual(L) *= a;
500
501 auto t_nf = getFTensor1FromPtr<size_symm>(&*nF.data().begin());
502 int bb = 0;
503 for (; bb != nb_dofs / size_symm; ++bb) {
504 t_nf(L) -= t_row_base_fun * t_residual(L);
505 ++t_nf;
506 ++t_row_base_fun;
507 }
508 for (; bb != nb_base_functions; ++bb) {
509 ++t_row_base_fun;
510 }
511 }
512 }
513 }
515}
516
518 std::string row_field, std::string col_field,
519 boost::shared_ptr<DataAtIntegrationPts> data_ptr, const double alpha)
520 : OpAssembleVolumePositiveDefine(row_field, col_field, data_ptr, OPROWCOL,
521 false),
522 alphaU(alpha) {
523
524 CHK_THROW_MESSAGE(getOptions(), "get options failed");
525
526 MOFEM_LOG("EP", Sev::inform)
527 << "Neo-Hookean min_eigen_value = " << minimEigenValue;
528
529 sYmm = false;
530}
531
534 PetscOptionsBegin(PETSC_COMM_WORLD, "neo_hookean_", "", "none");
535 CHKERR PetscOptionsScalar("-min_eigen_value", "Minimum eigenvalue", "",
536 minimEigenValue, &minimEigenValue, PETSC_NULLPTR);
537 PetscOptionsEnd();
539}
540
541MoFEMErrorCode
543 EntData &col_data) {
545
546 auto neohookean_ptr =
547 boost::dynamic_pointer_cast<HMHNeohookean>(dataAtPts->physicsPtr);
548 if (!neohookean_ptr) {
549 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
550 "Pointer to HMHNeohookean is null");
551 }
552 auto [def_c10, def_K] =
553 neohookean_ptr->getMaterialParameters(getFEEntityHandle());
554
555 double c10 = def_c10 / neohookean_ptr->eqScaling;
556 double alpha_u = alphaU / neohookean_ptr->eqScaling;
557 double lambda = def_K / neohookean_ptr->eqScaling;
558
559 double alpha_grad_u =
560 neohookean_ptr->alphaGradU / neohookean_ptr->eqScaling;
561
564
565 constexpr auto t_kd_sym = FTensor::Kronecker_Delta_symmetric<int>();
566 constexpr auto t_kd = FTensor::Kronecker_Delta<int>();
567
568 auto t_L = symm_L_tensor();
569 auto t_diff = diff_tensor();
570
571 int nb_integration_pts = row_data.getN().size1();
572 int row_nb_dofs = row_data.getIndices().size();
573 int col_nb_dofs = col_data.getIndices().size();
574
575 auto get_ftensor2 = [](MatrixDouble &m, const int r, const int c) {
577 size_symm>(
578
579 &m(r + 0, c + 0), &m(r + 0, c + 1), &m(r + 0, c + 2), &m(r + 0, c + 3),
580 &m(r + 0, c + 4), &m(r + 0, c + 5),
581
582 &m(r + 1, c + 0), &m(r + 1, c + 1), &m(r + 1, c + 2), &m(r + 1, c + 3),
583 &m(r + 1, c + 4), &m(r + 1, c + 5),
584
585 &m(r + 2, c + 0), &m(r + 2, c + 1), &m(r + 2, c + 2), &m(r + 2, c + 3),
586 &m(r + 2, c + 4), &m(r + 2, c + 5),
587
588 &m(r + 3, c + 0), &m(r + 3, c + 1), &m(r + 3, c + 2), &m(r + 3, c + 3),
589 &m(r + 3, c + 4), &m(r + 3, c + 5),
590
591 &m(r + 4, c + 0), &m(r + 4, c + 1), &m(r + 4, c + 2), &m(r + 4, c + 3),
592 &m(r + 4, c + 4), &m(r + 4, c + 5),
593
594 &m(r + 5, c + 0), &m(r + 5, c + 1), &m(r + 5, c + 2), &m(r + 5, c + 3),
595 &m(r + 5, c + 4), &m(r + 5, c + 5)
596
597 );
598 };
599
606
607 auto v = getVolume();
608 auto ts_a = getTSa();
609 auto t_w = getFTensor0IntegrationWeight();
610
611 int row_nb_base_functions = row_data.getN().size2();
612 auto t_row_base_fun = row_data.getFTensor0N();
613 auto t_row_grad_fun = row_data.getFTensor1DiffN<3>();
614
615 auto t_diff_u =
616 dataAtPts->getFTensorDiffStretch(nb_integration_pts);
617 auto t_log_u =
618 dataAtPts->getFTensorLogStretch(nb_integration_pts);
619 auto t_log_u2_h1 =
620 dataAtPts->getFTensorLogStretch2H1(nb_integration_pts);
621 auto t_u = dataAtPts->getFTensorStretch(nb_integration_pts);
622 auto t_approx_P_adjoint__dstretch =
623 dataAtPts->getFTensorAdjointPdstretch(nb_integration_pts);
624 auto t_eigen_vals = dataAtPts->getFTensorEigenVals(nb_integration_pts);
625 auto t_eigen_vecs = dataAtPts->getFTensorEigenVecs(nb_integration_pts);
626 auto &nbUniq = dataAtPts->nbUniq;
627 auto t_nb_uniq =
628 FTensor::Tensor0<FTensor::PackPtr<int *, 1>>(nbUniq.data().data());
629
630 auto no_h1 = [&]() {
632
633 for (int gg = 0; gg != nb_integration_pts; ++gg) {
634 double a = v * t_w;
635 ++t_w;
636
637 auto neohookean = [c10](auto v) { return fun_neohookean(c10, v); };
638 auto d_neohookean = [c10, lambda](auto v) {
639 return fun_d_neohookean(c10, v);
640 };
641
642 auto t_diff_neohookean = EigenMatrix::getDiffMat(
643 t_eigen_vals, t_eigen_vecs, neohookean, d_neohookean, t_nb_uniq);
644
645 const auto tr = t_log_u(i, i);
647 t_dP(L, J) = t_L(i, j, L) * ((t_diff_neohookean(i, j, k, l) +
649 t_kd_sym(i, j) * t_kd_sym(k, l)) *
650 t_L(k, l, J));
651 t_dP(L, J) += (alpha_u * ts_a) *
652 (t_L(i, j, L) * (t_diff(i, j, k, l) * t_L(k, l, J)));
653
654
655
656
657 if constexpr (1) {
659 t_deltaP(i, j) = (t_approx_P_adjoint__dstretch(i, j) ||
660 t_approx_P_adjoint__dstretch(j, i)) /
661 2.;
662 auto t_diff2_uP = EigenMatrix::getDiffDiffMat(
663 t_eigen_vals, t_eigen_vecs, EshelbianCore::f, EshelbianCore::d_f,
664 EshelbianCore::dd_f, t_deltaP, t_nb_uniq);
665 t_dP(L, J) -= t_L(i, j, L) * (t_diff2_uP(i, j, k, l) * t_L(k, l, J));
666 }
667 ++t_approx_P_adjoint__dstretch;
668 ++t_log_u;
669 ++t_eigen_vals;
670 ++t_eigen_vecs;
671 ++t_nb_uniq;
672
673 // Symmetrize tangesnt stiffness matrix, and add calulate eigen values,
674 // tham add minimum eigen value to the tangent stiffness matrix
676 t_hessian_eig_vecs(L, J) = (t_dP(L, J) + t_dP(J, L)) / 2.;
677 FTensor::Tensor1<double, size_symm> t_hessian_eig_vals;
678 CHKERR computeEigenValuesSymmetric(t_hessian_eig_vecs,
679 t_hessian_eig_vals);
680 auto min_eig_val = [this](double v) {
681 return (v - minimEigenValue + std::abs(v - minimEigenValue)) / 2.;
682 };
683 auto t_dP_min_eig = EigenMatrix::getMat(t_hessian_eig_vals,
684 t_hessian_eig_vecs, min_eig_val);
685 t_dP(L, J) = t_dP_min_eig(L, J);
686
687 int rr = 0;
688 for (; rr != row_nb_dofs / size_symm; ++rr) {
689 auto t_col_base_fun = col_data.getFTensor0N(gg, 0);
690 auto t_col_grad_fun = col_data.getFTensor1DiffN<3>(gg, 0);
691
692 auto t_m = get_ftensor2(K, 6 * rr, 0);
693 for (int cc = 0; cc != col_nb_dofs / size_symm; ++cc) {
694 double b = a * t_row_base_fun * t_col_base_fun;
695 double c = (a * alpha_grad_u * ts_a) *
696 (t_row_grad_fun(i) * t_col_grad_fun(i));
697 t_m(L, J) += b * t_dP(L, J);
698 t_m(L, J) += c * t_kd_sym(L, J);
699
700 ++t_m;
701 ++t_col_base_fun;
702 ++t_col_grad_fun;
703 }
704 ++t_row_base_fun;
705 ++t_row_grad_fun;
706 }
707
708 for (; rr != row_nb_base_functions; ++rr) {
709 ++t_row_base_fun;
710 ++t_row_grad_fun;
711 }
712
713 }
715 };
716
717 auto large = [&]() {
719 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
720 "Not implemented for Neo-Hookean (used ADOL-C)");
722 };
723
726 CHKERR no_h1();
727 break;
728 case LARGE_ROT:
729 case MODERATE_ROT:
730 CHKERR large();
731 break;
732 default:
733 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
734 "gradApproximator not handled");
735 };
736
738}
739
740} // namespace EshelbianPlasticity
#define MOFEM_TAG_AND_LOG(channel, severity, tag)
Tag and log in channel.
#define FTENSOR_INDEX(DIM, I)
constexpr double a
constexpr int SPACE_DIM
Kronecker Delta class symmetric.
Kronecker Delta class.
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_DATA_INCONSISTENCY
Definition definitions.h:31
@ MOFEM_NOT_IMPLEMENTED
Definition definitions.h:32
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
constexpr auto t_kd
double eta
#define MOFEM_LOG(channel, severity)
Log.
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
FTensor::Index< 'i', SPACE_DIM > i
static double lambda
const double c
speed of light (cm/ns)
const double v
phase velocity of light in medium (cm/ns)
const double n
refractive index of diffusive medium
FTensor::Index< 'J', DIM1 > J
Definition level_set.cpp:30
FTensor::Index< 'l', 3 > l
FTensor::Index< 'j', 3 > j
FTensor::Index< 'k', 3 > k
auto getMat(A &&t_val, B &&t_vec, Fun< double > f)
Get the Mat object.
auto getDiffMat(A &&t_val, B &&t_vec, Fun< double > f, Fun< double > d_f, const int nb)
Get the Diff Mat object.
auto getDiffDiffMat(A &&t_val, B &&t_vec, Fun< double > f, Fun< double > d_f, Fun< double > dd_f, C &&t_S, const int nb)
Get the Diff Diff Mat object.
void tetcircumcenter_tp(double a[3], double b[3], double c[3], double d[3], double circumcenter[3], double *xi, double *eta, double *zeta)
EntitiesFieldData::EntData EntData
ForcesAndSourcesCore::UserDataOperator UserDataOperator
static constexpr auto size_symm
constexpr auto field_name
FTensor::Index< 'm', 3 > m
static enum StretchSelector stretchSelector
static enum RotSelector gradApproximator
static PetscBool physicalTimeFlg
static double exponentBase
static double currentPhysicalTime
static boost::function< double(const double)> f
static boost::function< double(const double)> dd_f
static boost::function< double(const double)> d_f
std::map< std::string, boost::shared_ptr< ScalingMethod > > scalingMethodsMap
OpSpatialPhysicalExternalStrain(const std::string &field_name, boost::shared_ptr< DataAtIntegrationPts > data_ptr, boost::shared_ptr< ExternalStrainVec > external_strain_vec_ptr, std::map< std::string, boost::shared_ptr< ScalingMethod > > smv)
OpSpatialPhysical_du_du(std::string row_field, std::string col_field, boost::shared_ptr< DataAtIntegrationPts > data_ptr, const double alpha)
MoFEMErrorCode integrate(EntData &row_data, EntData &col_data)
OpSpatialPhysical(const std::string &field_name, boost::shared_ptr< DataAtIntegrationPts > data_ptr, const double alpha_u)
static double fun_diff_neohookean_bulk(double K, double tr)
Definition of derivative of axiator of Neo-hookean function.
static double fun_d_neohookean(double c10, double v)
Definition of derivative of Neo-hookean function.
UserDataOperator * returnOpJacobian(const bool eval_rhs, const bool eval_lhs, boost::shared_ptr< DataAtIntegrationPts > data_ptr, boost::shared_ptr< PhysicalEquations > physics_ptr)
static double fun_neohookean_bulk(double K, double tr)
Definition of axiator of Neo-hookean function.
virtual VolUserDataOperator * returnOpSpatialPhysical(const std::string &field_name, boost::shared_ptr< DataAtIntegrationPts > data_ptr, const double alpha_u)
std::vector< BlockData > blockData
MoFEMErrorCode extractBlockData(std::vector< const CubitMeshSets * > meshset_vec_ptr, Sev sev)
MoFEMErrorCode extractBlockData(Sev sev)
static double fun_neohookean(double c10, double v)
Definition of Neo-hookean function.
auto getMaterialParameters(EntityHandle ent)
virtual VolUserDataOperator * returnOpSpatialPhysicalExternalStrain(const std::string &field_name, boost::shared_ptr< DataAtIntegrationPts > data_ptr, boost::shared_ptr< ExternalStrainVec > external_strain_vec_ptr, std::map< std::string, boost::shared_ptr< ScalingMethod > > smv)
HMHNeohookean(MoFEM::Interface &m_field, const double c10, const double K)
VolUserDataOperator * returnOpSpatialPhysical_du_du(std::string row_field, std::string col_field, boost::shared_ptr< DataAtIntegrationPts > data_ptr, const double alpha)
virtual moab::Interface & get_moab()=0
bool sYmm
If true assume that matrix is symmetric structure.
Deprecated interface functions.
Data on single entity (This is passed as argument to DataOperator::doWork)
EntityHandle getFEEntityHandle() const
Return finite element entity handle.
const FEMethod * getFEMethod() const
Return raw pointer to Finite Element Method object.
PetscReal ts_t
Current time value.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
double scale
Definition plastic.cpp:124
double zeta
Viscous hardening.
Definition plastic.cpp:131