v0.16.3
Loading...
Searching...
No Matches
Public Member Functions | List of all members
ADOLCPlasticity::OpCalculateStress< DIM, LARGE_STRAIN > Struct Template Reference
Inheritance diagram for ADOLCPlasticity::OpCalculateStress< DIM, LARGE_STRAIN >:
[legend]
Collaboration diagram for ADOLCPlasticity::OpCalculateStress< DIM, LARGE_STRAIN >:
[legend]

Public Member Functions

MoFEMErrorCode doWork (int side, EntityType type, DataForcesAndSourcesCore::EntData &data) override
 
- Public Member Functions inherited from ADOLCPlasticity::OpCalculateStressImpl< DIM, LARGE_STRAIN >
 OpCalculateStressImpl (MoFEM::Interface &m_field, boost::shared_ptr< CommonData > common_data_ptr, boost::shared_ptr< ClosestPointProjection > cp_ptr, bool calc_lhs)
 

Additional Inherited Members

- Protected Member Functions inherited from ADOLCPlasticity::OpCalculateStressImpl< DIM, LARGE_STRAIN >
MoFEMErrorCode getTags ()
 
MoFEMErrorCode setTagsData (const EntityHandle tet, const int nb_gauss_pts, const int nb_internal_variables)
 
- Protected Attributes inherited from ADOLCPlasticity::OpCalculateStressImpl< DIM, LARGE_STRAIN >
MoFEM::Interface & mField
 
boost::shared_ptr< CommonData > commonDataPtr
 
boost::shared_ptr< ClosestPointProjection > cpPtr
 
bool calcLhs
 
Tag thPlasticStrain
 
Tag thInternalVariables
 

Detailed Description

template<int DIM>
struct ADOLCPlasticity::OpCalculateStress< DIM, LARGE_STRAIN >

Definition at line 286 of file ADOLCPlasticity.cpp.

Member Function Documentation

◆ doWork()

template<int DIM>
MoFEMErrorCode ADOLCPlasticity::OpCalculateStress< DIM, LARGE_STRAIN >::doWork ( int  side,
EntityType  type,
DataForcesAndSourcesCore::EntData &  data 
)
override

Definition at line 380 of file ADOLCPlasticity.cpp.

381 {
383
384 auto do_work_impl = [this](auto commonDataPtr, auto cpPtr) {
386
387 int nb_gauss_pts = this->getGaussPts().size2();
388
389 int nb_internal_variables = cpPtr->nbInternalVariables;
390 auto tet = this->getNumeredEntFiniteElementPtr()->getEnt();
391 CHKERR this->setTagsData(tet, nb_gauss_pts, nb_internal_variables);
392
393 commonDataPtr->activeVariablesW.resize(
394 nb_gauss_pts, 12 + cpPtr->nbInternalVariables, false);
395 commonDataPtr->gradientW.resize(nb_gauss_pts,
396 12 + cpPtr->nbInternalVariables, false);
397 commonDataPtr->deltaGamma.resize(nb_gauss_pts);
398
399 FTENSOR_INDEX(3, i);
400 FTENSOR_INDEX(3, j);
401 FTENSOR_INDEX(3, k);
402 FTENSOR_INDEX(3, l);
403 FTENSOR_INDEX(6, Z);
404 FTENSOR_INDEX(6, Y);
405
407 auto get_Cep =
409 commonDataPtr->materialTangentOperator, nb_gauss_pts);
410
411 // Code uses trial stress, until first solve of linear system of equations
412 int iter = 1;
413 if (this->getFEMethod()->snes_ctx != SnesMethod::CTX_SNESNONE) {
414 CHKERR SNESGetLinearSolveIterations(this->getFEMethod()->snes, &iter);
415 }
416
417 double ave_tr_strain = 0;
418 auto t_voight_stress_op = voight_to_stress_op();
419 auto t_grad =
420 getFTensor2SymmetricFromMat<DIM>(commonDataPtr->gradAtGaussPts);
421 auto t_Cep = get_Cep();
422
423 for (auto gg = 0; gg != nb_gauss_pts; ++gg) {
424
425 auto tmp_active =
426 getVectorAdaptor(&(commonDataPtr->activeVariablesW(gg, 0)),
427 12 + cpPtr->nbInternalVariables);
428 cpPtr->activeVariablesW.swap(tmp_active);
429 auto tmp_gradient = getVectorAdaptor(&(commonDataPtr->gradientW(gg, 0)),
430 12 + cpPtr->nbInternalVariables);
431 this->cpPtr->gradientW.swap(tmp_gradient);
432
433 auto t_voigt_strain =
434 calcStrain(commonDataPtr->bBar, ave_tr_strain, t_grad,
435 getFTensor1FromPtr<6>(&(cpPtr->activeVariablesW[6])));
436 ++t_grad;
437
438 // Copy plastic strains and internal variables from tags
439 auto copy_plastic_strain_and_internal_variables = [&]() {
441
442 // Get data stored on Tags
443 VectorAdaptor plastic_strain_tags =
444 VectorAdaptor(6, ublas::shallow_array_adaptor<double>(
445 6, &commonDataPtr->plasticStrainPtr[gg * 6]));
446 VectorAdaptor internal_variables_tags = VectorAdaptor(
447 nb_internal_variables,
448 ublas::shallow_array_adaptor<double>(
449 nb_internal_variables,
451 ->internalVariablesPtr[gg * nb_internal_variables]));
452
453 // Set values to closest point projection
454 cpPtr->plasticStrain0.resize(6, false);
455 noalias(cpPtr->plasticStrain0) = plastic_strain_tags;
456 cpPtr->internalVariables0.resize(nb_internal_variables, false);
457 noalias(cpPtr->internalVariables0) = internal_variables_tags;
458
459 auto cp_plastic_strain = cpPtr->getPlasticStrain();
460 auto cp_internal_variables = cpPtr->getInternalVariables();
461 noalias(cp_plastic_strain) = plastic_strain_tags;
462 noalias(cp_internal_variables) = internal_variables_tags;
464 };
465
466 CHKERR copy_plastic_strain_and_internal_variables();
467
468 auto closest_point_projection = [&](auto &recalculate_elastic_tangent) {
472 CHKERR cpPtr->setParams(t, recalculate_elastic_tangent);
473 }
474 CHKERR cpPtr->playW_NoHessian();
475 CHKERR cpPtr->playY_NoGradient();
476 double y = cpPtr->y;
477 cpPtr->deltaGamma = 0; // zero lagrange multiplier
478 if (iter > 0 && y > std::numeric_limits<double>::epsilon()) {
479 CHKERR cpPtr->solveClosestProjection();
480 }
481 commonDataPtr->deltaGamma[gg] = cpPtr->deltaGamma;
483 };
484
485 auto evaluate_consistent_tangent_matrix =
486 [&](auto &recalculate_elastic_tangent) {
488 if (recalculate_elastic_tangent)
489 CHKERR cpPtr->playW();
490
491 if (iter > 0 &&
492 cpPtr->deltaGamma > std::numeric_limits<double>::epsilon()) {
493
494 CHKERR cpPtr->consistentTangent();
495
496 auto &m = cpPtr->Cep;
497 // for generic case of non-associated plasticity consistent
498 // tangent matrix is non-symmetric
499 auto t_voight_cep =
501 &m(0, 0), &m(0, 1), &m(0, 2), &m(0, 3), &m(0, 4),
502 &m(0, 5),
503
504 &m(1, 0), &m(1, 1), &m(1, 2), &m(1, 3), &m(1, 4),
505 &m(1, 5),
506
507 &m(2, 0), &m(2, 1), &m(2, 2), &m(2, 3), &m(2, 4),
508 &m(2, 5),
509
510 &m(3, 0), &m(3, 1), &m(3, 2), &m(3, 3), &m(3, 4),
511 &m(3, 5),
512
513 &m(4, 0), &m(4, 1), &m(4, 2), &m(4, 3), &m(4, 4),
514 &m(4, 5),
515
516 &m(5, 0), &m(5, 1), &m(5, 2), &m(5, 3), &m(5, 4), &m(5, 5)
517
518 );
519
520 FTENSOR_INDEX(DIM, i);
521 FTENSOR_INDEX(DIM, j);
522 FTENSOR_INDEX(DIM, k);
523 FTENSOR_INDEX(DIM, l);
524
525 t_Cep(i, j, k, l) =
526 t_voight_stress_op(i, j, Z) *
527 (t_voight_cep(Z, Y) * t_voight_stress_op(k, l, Y));
528
529 } else {
530
531 auto &m = cpPtr->C;
532 auto t_voight_cep =
534 &m(0, 0), &m(0, 1), &m(0, 2), &m(0, 3), &m(0, 4),
535 &m(0, 5),
536
537 &m(1, 1), &m(1, 2), &m(1, 3), &m(1, 4), &m(1, 5),
538
539 &m(2, 2), &m(2, 3), &m(2, 4), &m(2, 5),
540
541 &m(3, 3), &m(3, 4), &m(3, 5),
542
543 &m(4, 4), &m(4, 5),
544
545 &m(5, 5));
546
547 FTENSOR_INDEX(DIM, i);
548 FTENSOR_INDEX(DIM, j);
549 FTENSOR_INDEX(DIM, k);
550 FTENSOR_INDEX(DIM, l);
551
552 t_Cep(i, j, k, l) =
553 t_voight_stress_op(i, j, Z) *
554 (t_voight_cep(Z, Y) * t_voight_stress_op(k, l, Y));
555 }
556
557 ++t_Cep;
559 };
560
561 // Always recalculate elastic tangent if first element
562 bool recalculate_elastic_tangent =
563 (this->getNinTheLoop() == 0) ? true : false;
564 CHKERR closest_point_projection(recalculate_elastic_tangent);
565 // always calculate consistent tangent matrix for large strain
566 CHKERR evaluate_consistent_tangent_matrix(recalculate_elastic_tangent);
567 }
568
569 auto calcs_stress_matrix = [&]() {
571 auto t_voight_stress_op = voight_to_stress_op();
572
573 auto get_stress =
575 DL>::size(commonDataPtr->stressMatrix, nb_gauss_pts);
576 auto t_stess = get_stress();
577 auto t_voight_stress = commonDataPtr->getFTensor1StressAtGaussPts();
578 for (auto gg = 0; gg != commonDataPtr->gradientW.size1(); ++gg) {
579 FTENSOR_INDEX(DIM, i);
580 FTENSOR_INDEX(DIM, j);
581 FTENSOR_INDEX(DIM, k);
582 FTENSOR_INDEX(DIM, l);
583
584 t_stess(i, j) = t_voight_stress_op(i, j, Z) * t_voight_stress(Z);
585 ++t_voight_stress;
586 ++t_stess;
587 }
589 };
590
591 auto calcs_plastic_strain_matrix = [&]() {
593 auto t_voight_strain_op = voight_to_stress_op();
594 commonDataPtr->plasticStrainMatrix.resize(
595 commonDataPtr->activeVariablesW.size1(), 6, false);
596 auto t_plastic_strain =
597 getFTensor2SymmetricFromMat<3>(commonDataPtr->plasticStrainMatrix);
598 auto t_voight_plastic_strain =
599 commonDataPtr->getFTensor1PlasticStrainAtGaussPts();
600 for (auto gg = 0; gg != commonDataPtr->activeVariablesW.size1(); ++gg) {
601 t_plastic_strain(i, j) =
602 t_voight_strain_op(i, j, Z) * t_voight_plastic_strain(Z);
603 ++t_voight_plastic_strain;
604 ++t_plastic_strain;
605 }
607 };
608
609 CHKERR calcs_stress_matrix();
610 CHKERR calcs_plastic_strain_matrix();
612 };
613
614 CHKERR do_work_impl(this->commonDataPtr, this->cpPtr);
615
617}
std::vector< int > size
Vec t
Removal: the ring edge.
#define FTENSOR_INDEX(DIM, I)
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#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
FTensor::Dg< double, 3, 6 > voight_to_stress_op()
Op convert Vight stress vector to stress tensor.
FTensor::Tensor1< T2, DIM3 > calcStrain(bool b_bar, double ave_tr_strain, FTensor::Tensor2< T1, DIM1, DIM2 > &t_grad, FTensor::Tensor1< T2, DIM3 > &&t_voight_strain)
DataLayoutTraits< DataLayout::GaussByCoeffs > DL
VectorShallowArrayAdaptor< double > VectorAdaptor
Definition Types.hpp:115
auto getVectorAdaptor(T1 ptr, const size_t n)
Get Vector adaptor.
Definition Templates.hpp:49
decltype(GetFTensor2SymmetricFromMatImpl< Tensor_Dim, S, DL, M >::get(std::declval< M & >(), 0, 0)) GetFTensor2SymmetricFromMatType
decltype(GetFTensor4DdgFromMatImpl< Tensor_Dim01, Tensor_Dim23, S, DL, M >::get(std::declval< M & >(), 0, 0)) GetFTensor4DdgFromMatType
FTensor::Index< 'm', 3 > m
MoFEMErrorCode setTagsData(const EntityHandle tet, const int nb_gauss_pts, const int nb_internal_variables)
boost::shared_ptr< ClosestPointProjection > cpPtr
@ CTX_SNESNONE
No specific SNES context.

The documentation for this struct was generated from the following file: