364 {
366
367#ifndef NDEBUG
370 "DataAtIntegrationPts pointer is null");
373 "Topological data pointer is null");
374#endif
375
376 const int nb_gauss_pts = getGaussPts().size2();
377 if (!nb_gauss_pts)
379
380 auto stress_full_ptr = boost::make_shared<MatrixDouble>();
381 auto get_stress_full =
383 DL>::size(*stress_full_ptr, nb_gauss_pts);
384 stress_full_ptr->clear();
385 auto strain_full_ptr = boost::make_shared<MatrixDouble>();
386 auto get_strain_full =
388 DL>::size(*strain_full_ptr, nb_gauss_pts);
389 strain_full_ptr->clear();
390
391 auto t_stress = get_stress_full();
392 auto t_strain = get_strain_full();
393
394 auto t_biot =
dataAtPts->getFTensorAdjointPdstretch(nb_gauss_pts);
395 auto t_u =
dataAtPts->getFTensorStretch(nb_gauss_pts);
396
397 auto next = [&]() {
398 ++t_stress;
399 ++t_strain;
400 ++t_biot;
401 ++t_u;
402 };
403
405
406 for (auto gg = 0; gg != nb_gauss_pts; ++gg) {
407
408
409 t_stress(
i,
j) = t_biot(
i,
j);
410 t_strain(
i,
j) = t_u(
i,
j);
411 next();
412 }
413
414 auto evaluate_python_objective = [&]() {
418 "ObjectiveFunctionData pointer is null");
419
420 auto &coords = OP::getCoordsAtGaussPts();
422 coords,
dataAtPts->getSmallWL2AtPts(), stress_full_ptr, strain_full_ptr,
425 coords,
dataAtPts->getSmallWL2AtPts(), stress_full_ptr, strain_full_ptr,
426 topoData->getObjDStrainAtPts(),
false);
428 coords,
dataAtPts->getSmallWL2AtPts(), stress_full_ptr, strain_full_ptr,
429 topoData->getObjDDisplacementAtPts(),
false);
431 coords,
dataAtPts->getSmallWL2AtPts(), stress_full_ptr, strain_full_ptr,
432 topoData->getObjDStressAtPts(),
false);
434 };
435
436 auto evaluate_energy_of_hencky_model = [&]() {
438
440 *
topoData->getObjDDisplacementAtPts(), nb_gauss_pts);
441 topoData->getObjDDisplacementAtPts()->clear();
443 DL>::size(*
topoData->getObjDStressAtPts(), nb_gauss_pts);
444 topoData->getObjDStressAtPts()->clear();
446 *
topoData->getObjDRotationAtPts(), nb_gauss_pts);
447
448 auto eval_evergy = [&](auto &&t_D) {
449 auto get_obj =
451 *
topoData->getObjAtPts(), nb_gauss_pts);
452 auto get_dstrain_obj =
455 nb_gauss_pts);
456 auto t_obj = get_obj();
457 auto t_dstrain_obj = get_dstrain_obj();
458 auto t_log_u =
dataAtPts->getFTensorLogStretchTotal(nb_gauss_pts);
459 for (int gg = 0; gg != nb_gauss_pts; ++gg) {
460 t_obj(0) = 0.5 * (t_log_u(
i,
j) * t_D(
i,
j,
k,
l) * t_log_u(
k,
l));
461 t_dstrain_obj(
i,
j) = t_D(
i,
j,
k,
l) * t_log_u(
k,
l);
462 ++t_log_u;
463 ++t_obj;
464 ++t_dstrain_obj;
465 ++t_D;
466 }
467 };
468
470 eval_evergy(
471 getFTensor4DdgFromMat<SPACE_DIM, SPACE_DIM, 0>(
dataAtPts->matD));
472 } else {
473 eval_evergy(getFTensor4DdgFromMat<SPACE_DIM, SPACE_DIM>(
dataAtPts->matD));
474 }
475
476 topoData->getObjDRotationAtPts()->clear();
478 };
479
480 auto evaluate_energy_of_hencky_model_nostreach = [&]() {
482
484 *
topoData->getObjDDisplacementAtPts(), nb_gauss_pts);
485 topoData->getObjDDisplacementAtPts()->clear();
487 DL>::size(*
topoData->getObjDStrainAtPts(), nb_gauss_pts);
488 topoData->getObjDStrainAtPts()->clear();
490 *
topoData->getObjDRotationAtPts(), nb_gauss_pts);
491 topoData->getObjDRotationAtPts()->clear();
492
493 auto eval_evergy = [&](auto &&t_inv_D) {
494 auto get_obj =
496 *
topoData->getObjAtPts(), nb_gauss_pts);
497 auto get_dstress_obj =
500 nb_gauss_pts);
501 auto t_obj = get_obj();
502 auto t_dstress_obj = get_dstress_obj();
503 auto t_stress =
dataAtPts->getFTensorAdjointPdstretch(nb_gauss_pts);
504 for (int gg = 0; gg != nb_gauss_pts; ++gg) {
505 t_obj(0) =
506 0.5 * (t_stress(
i,
j) * t_inv_D(
i,
j,
k,
l) * t_stress(
k,
l));
507 t_dstress_obj(
i,
j) = t_inv_D(
i,
j,
k,
l) * t_stress(
k,
l);
508 ++t_stress;
509 ++t_obj;
510 ++t_dstress_obj;
511 ++t_inv_D;
512 }
513 };
514
516 eval_evergy(
517 getFTensor4DdgFromMat<SPACE_DIM, SPACE_DIM, 0>(
dataAtPts->matInvD));
518 } else {
519 eval_evergy(
520 getFTensor4DdgFromMat<SPACE_DIM, SPACE_DIM>(
dataAtPts->matInvD));
521 }
523 };
524
525 auto conversion_of_biot_stress = [&]() {
527
528
530 *
topoData->getObjDRotationAtPts(), nb_gauss_pts);
531 topoData->getObjDRotationAtPts()->clear();
532
533 auto t_obj_dbiot =
topoData->getFTensorObjDStress(nb_gauss_pts);
534 auto t_obj_domega =
topoData->getFTensorObjDRotation(nb_gauss_pts);
535 auto t_R =
dataAtPts->getFTensorRotMat(nb_gauss_pts);
536 auto t_P =
dataAtPts->getFTensorApproxP(nb_gauss_pts);
537 auto t_grad_h1 =
dataAtPts->getFTensorSmallWGradH1(nb_gauss_pts);
538 auto t_omega =
dataAtPts->getFTensorRotAxis(nb_gauss_pts);
539
546
547 for (auto gg = 0; gg != nb_gauss_pts; ++gg) {
549 t_dJ_dbiot(
l, o) = t_obj_dbiot(
l, o);
550
553
554
555 t_obj_dbiot(
i,
k) = t_dJ_dbiot(
i,
k);
557 break;
564 break;
565 default:
567 "rotationSelector not handled");
568 }
569
570
571 t_obj_dbiot(
i,
k) = t_R(
i,
l) * t_dJ_dbiot(
l,
k);
572 t_obj_domega(
m) = t_dJ_dbiot(
l,
k) * t_diff_R(
i,
l,
m) * t_P(
i,
k);
573 } break;
577 t_h1(o,
k) =
t_kd(o,
k) + t_grad_h1(o,
k);
578
583 break;
587 break;
588 default:
590 "rotationSelector not handled");
591 }
592
593
594 t_obj_dbiot(
i,
k) = t_R(
i,
l) * (t_dJ_dbiot(
l, o) * t_h1(o,
k));
596 t_dJ_dbiot(
l, o) * (t_diff_R(
i,
l,
m) * t_P(
i,
k)) * t_h1(o,
k);
597 } break;
598 default:
600 "gradApproximator not handled");
601 }
602
603 ++t_obj_dbiot;
604 ++t_obj_domega;
605 ++t_R;
606 ++t_P;
607 ++t_grad_h1;
608 ++t_omega;
609 }
610
612 };
613
614 auto conversion_of_stretch = [&]() {
616
617
618 auto t_obj_dstretch =
topoData->getFTensorObjDStrain(nb_gauss_pts);
619 auto t_diff_stretch =
dataAtPts->getFTensorDiffStretch(nb_gauss_pts);
620
625
626 for (auto gg = 0; gg != nb_gauss_pts; ++gg) {
628 t_dJ_dstretch(
i,
j) = t_obj_dstretch(
i,
j);
629
630 t_obj_dstretch(
k,
l) = t_dJ_dstretch(
i,
j) * t_diff_stretch(
i,
j,
k,
l);
631
632 ++t_obj_dstretch;
633 ++t_diff_stretch;
634 }
635
637 };
638
639 auto conversion_of_stretch_to_stress_for_no_stretch = [&](auto t_inv_D) {
641
642
643 auto t_obj_dstress =
topoData->getFTensorObjDStress(nb_gauss_pts);
644 auto t_obj_dstretch =
topoData->getFTensorObjDStrain(nb_gauss_pts);
645
650
651 for (auto gg = 0; gg != nb_gauss_pts; ++gg) {
653 t_dstretch_dstress(
i,
j) =
654 ((t_obj_dstretch(
k,
l) || t_obj_dstretch(
l,
k)) / 2.) *
656
657 t_obj_dstress(
i,
j) += t_dstretch_dstress(
i,
j);
658
659 ++t_obj_dstress;
660 ++t_obj_dstretch;
661 ++t_inv_D;
662 }
663
665 };
666
669 CHKERR evaluate_python_objective();
670 CHKERR conversion_of_biot_stress();
673 CHKERR conversion_of_stretch_to_stress_for_no_stretch(
674 getFTensor4DdgFromMat<SPACE_DIM, SPACE_DIM, 0>(
dataAtPts->matInvD));
675 } else {
676 CHKERR conversion_of_stretch_to_stress_for_no_stretch(
677 getFTensor4DdgFromMat<SPACE_DIM, SPACE_DIM>(
dataAtPts->matInvD));
678 }
679 } else {
680 CHKERR conversion_of_stretch();
681 }
682 break;
685 CHKERR evaluate_energy_of_hencky_model_nostreach();
686 CHKERR conversion_of_biot_stress();
687 } else {
688 CHKERR evaluate_energy_of_hencky_model();
689 }
690 break;
691 default:
693 "Objective model type not handled");
694 }
695
697}
#define FTENSOR_INDEXES(DIM,...)
#define FTENSOR_INDEX(DIM, I)
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_DATA_INCONSISTENCY
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
FTensor::Index< 'i', SPACE_DIM > i
FTensor::Index< 'l', 3 > l
FTensor::Index< 'j', 3 > j
FTensor::Index< 'k', 3 > k
constexpr std::enable_if<(Dim0<=2 &&Dim1<=2), Tensor2_Expr< Levi_Civita< T >, T, Dim0, Dim1, i, j > >::type levi_civita(const Index< i, Dim0 > &, const Index< j, Dim1 > &)
levi_civita functions to make for easy adhoc use
decltype(GetFTensor1FromMatImpl< Tensor_Dim, S, DL, M >::get(std::declval< M & >(), 0, 0)) GetFTensor1FromMatType
decltype(GetFTensor2FromMatImpl< Tensor_Dim0, Tensor_Dim1, S, DL, M >::get(std::declval< M & >(), 0, 0)) GetFTensor2FromMatType
FTensor::Index< 'm', 3 > m
static enum StretchHandling stretchHandling
static enum RotSelector rotSelector
static enum RotSelector gradApproximator
static bool hasNonHomogeneousMaterialBlock
static auto diffExp(A &&t_w_vee, B &&theta)