13 #ifndef __ADOLCPLASTICITY_HPP_
14 #define __ADOLCPLASTICITY_HPP_
17 #error "MoFEM need to be compiled with ADOL-C"
30 return FTensor::Dg<double, 3, 6>{1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
31 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0,
32 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
33 0.0, 0.0, 0.5, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0};
40 return FTensor::Dg<double, 3, 6>{1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
41 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0,
42 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
43 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0};
50 return FTensor::Dg<double, 3, 6>{1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
51 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0,
52 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
53 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0};
59 struct CommonData : boost::enable_shared_from_this<CommonData> {
104 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &
gradAtGaussPts);
111 PetscBool b_bar =
bBar ? PETSC_TRUE : PETSC_FALSE;
119 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &
stressMatrix);
122 return boost::shared_ptr<MatrixDouble>(shared_from_this(),
182 ublas::symmetric_matrix<double, ublas::lower>
C,
D;
262 boost::ptr_deque<ForcesAndSourcesCore::UserDataOperator> &pip,
263 std::string block_name,
Sev sev) {
275 bool &recalculate_elastic_tangent) {
317 SmartPetscObj<Mat>
A;
318 SmartPetscObj<Vec>
R;
321 ublas::matrix<double, ublas::column_major>
dataA;
350 boost::shared_ptr<ClosestPointProjection> cp_ptr,
bool calc_lhs);
355 boost::shared_ptr<ClosestPointProjection> cp_ptr,
bool calc_lhs);
360 boost::shared_ptr<ClosestPointProjection> cp_ptr,
bool calc_lhs);
370 template <
int DIM, IntegrationType I,
typename AssemblyDomainEleOp>
381 template <
int DIM, IntegrationType I,
typename AssemblyDomainEleOp>
391 template <
int DIM, IntegrationType I>
394 template <
int DIM, IntegrationType I>
399 using Pip = boost::ptr_deque<ForcesAndSourcesCore::UserDataOperator>;
417 template <
int DIM, AssemblyType A, IntegrationType I,
typename DomainEleOp>
420 std::string block_name, boost::shared_ptr<CommonData> common_data_ptr,
421 boost::shared_ptr<ClosestPointProjection> cp_ptr,
Sev sev = Sev::inform) {
424 CHKERR cp_ptr->addMatBlockOps(m_field, pip, block_name, sev);
426 getRawPtrOpCalculateStress<DIM>(m_field, common_data_ptr, cp_ptr,
false));
427 pip.push_back(
new typename P::template Assembly<A>::template
OpRhs<DIM, I>(
447 template <
int DIM, AssemblyType A, IntegrationType I,
typename DomainEleOp>
450 std::string block_name,
451 boost::shared_ptr<CommonData> common_data_ptr,
452 boost::shared_ptr<ClosestPointProjection> cp_ptr) {
455 CHKERR cp_ptr->addMatBlockOps(m_field, pip, block_name, Sev::noisy);
457 getRawPtrOpCalculateStress<DIM>(m_field, common_data_ptr, cp_ptr,
true));
458 pip.push_back(
new typename P::template Assembly<A>::template
OpLhs<DIM, I>(
478 std::string block_name,
479 boost::shared_ptr<CommonData> common_data_ptr,
480 boost::shared_ptr<ClosestPointProjection> cp_ptr);
488 std::string block_name,
489 boost::shared_ptr<CommonData> common_data_ptr,
490 boost::shared_ptr<ClosestPointProjection> cp_ptr);
498 std::string block_name,
499 boost::shared_ptr<CommonData> common_data_ptr,
500 boost::shared_ptr<ClosestPointProjection> cp_ptr);
512 boost::shared_ptr<FEMethod> fe_ptr);
522 const int nb_integration_pts,
double *w_ptr,
528 const int nb_integration_pts,
double *w_ptr,
533 template <
int DIM,
typename AssemblyDomainEleOp>
536 boost::shared_ptr<CommonData> common_data_ptr);
544 template <
int DIM,
typename AssemblyDomainEleOp>
547 boost::shared_ptr<CommonData> common_data_ptr);
557 template <
int DIM,
typename AssemblyDomainEleOp>
559 string field_name, boost::shared_ptr<CommonData> common_data_ptr)
561 commonDataPtr(common_data_ptr) {}
564 template <
int DIM,
typename AssemblyDomainEleOp>
571 double *w_ptr = &(OP::getGaussPts()(DIM, 0));
574 data, baseStorage, commonDataPtr->bBar, OP::getGaussPts().size2(), w_ptr,
576 auto t_stress = getFTensor2SymmetricFromMat<3>(commonDataPtr->stressMatrix);
577 const auto vol = OP::getMeasure();
578 auto t_w = OP::getFTensor0IntegrationWeight();
579 for (
int gg = 0; gg != OP::nbIntegrationPts; gg++) {
580 double alpha = vol * t_w;
581 for (
int bb = 0; bb != OP::nbRows; ++bb) {
582 OP::locF[bb] += alpha * (t_stress(
i,
j) * t_diff(
i,
j));
592 template <
int DIM,
typename AssemblyDomainEleOp>
594 string field_name, boost::shared_ptr<CommonData> common_data_ptr)
597 commonDataPtr(common_data_ptr) {
601 template <
int DIM,
typename AssemblyDomainEleOp>
608 double *w_ptr = &(OP::getGaussPts()(DIM, 0));
610 row_data, baseRowStorage, commonDataPtr->bBar, OP::getGaussPts().size2(),
613 col_data, baseColStorage, commonDataPtr->bBar, OP::getGaussPts().size2(),
616 auto get_ftensor2_symmetric = [&](
auto &storage,
const auto gg,
619 &storage(gg, 6 * rr + 0), &storage(gg, 6 * rr + 1),
620 &storage(gg, 6 * rr + 2), &storage(gg, 6 * rr + 3),
621 &storage(gg, 6 * rr + 4), &storage(gg, 6 * rr + 5)};
630 getFTensor4DdgFromMat<3, 3, 1>(commonDataPtr->materialTangentOperator);
631 const auto vol = OP::getMeasure();
632 auto t_w = OP::getFTensor0IntegrationWeight();
633 for (
int gg = 0; gg != OP::nbIntegrationPts; ++gg) {
634 const double alpha = vol * t_w;
637 for (
auto rr = 0; rr != OP::nbRows; ++rr) {
639 t_rowCep(
k,
l) = t_Cep(
i,
j,
k,
l) * t_diff_row(
i,
j);
640 auto t_diff_col = get_ftensor2_symmetric(baseColStorage, gg, 0);
641 for (
auto cc = 0; cc != OP::nbCols; ++cc) {
642 OP::locMat(rr, cc) += alpha * (t_rowCep(
k,
l) * t_diff_col(
k,
l));
655 #endif //__ADOLCPLASTICITY_HPP_