1487 {
1493
1495 auto nb_gauss_pts = getGaussPts().size2();
1496
1497 auto objective_dstress = boost::make_shared<MatrixDouble>(symm_size, nb_gauss_pts);
1498 auto objective_dstrain = boost::make_shared<MatrixDouble>(symm_size, nb_gauss_pts);
1499 auto objective_du = boost::make_shared<MatrixDouble>(
SPACE_DIM, nb_gauss_pts);
1500
1501
1502
1503 auto evaluate_python = [&]()
1504 {
1506 auto &coords = OP::getCoordsAtGaussPts();
1509 objective_dstress);
1512 objective_dstrain);
1515 objective_du);
1516
1517 auto vol = OP::getMeasure();
1518 auto t_w = OP::getFTensor0IntegrationWeight();
1519
1520 auto t_D = getFTensor4DdgFromMat<SPACE_DIM, SPACE_DIM, 0>(*(
commPtr->matDPtr));
1523
1524 auto t_obj_dstress = getFTensor2SymmetricFromMat<SPACE_DIM>(*objective_dstress);
1525 auto t_obj_dstrain = getFTensor2SymmetricFromMat<SPACE_DIM>(*objective_dstrain);
1526 auto t_obj_du = getFTensor1FromMat<SPACE_DIM>(*objective_du);
1527
1528
1529 for(int gg = 0; gg != nb_gauss_pts; ++gg)
1530 {
1531 const double alpha = t_w * vol;
1533 t_adjoint_stress(
i,
j) = t_D(
i,
j,
k,
l) * t_obj_dstress(
k,
l) + t_obj_dstrain(
i,
j);
1534
1535 auto t_nf = OP::template getNf<SPACE_DIM>();
1536 int rr = 0;
1537 for (; rr != OP::nbRows /
SPACE_DIM; rr++)
1538 {
1539 t_nf(
j) += alpha * t_row_grad(
i) * t_adjoint_stress(
i,
j);
1540 t_nf(
j) += alpha * t_row_base * t_obj_du(
j);
1541
1542 ++t_row_grad;
1543 ++t_row_base;
1544 ++t_nf;
1545 }
1546
1547 for (; rr < OP::nbRowBaseFunctions; ++rr)
1548 {
1549 ++t_row_grad;
1550 ++t_row_base;
1551 }
1552 ++t_obj_dstrain;
1553 ++t_obj_dstress;
1554 ++t_obj_du;
1555 ++t_w;
1556
1557 }
1559
1560
1561 };
1562 CHKERR evaluate_python();
1564 }
#define FTENSOR_INDEX(DIM, I)
constexpr int SPACE_DIM
[Define dimension]
#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::Tensor1< FTensor::PackPtr< double *, Tensor_Dim >, Tensor_Dim > getFTensor1DiffN(const FieldApproximationBase base)
Get derivatives of base functions.
FTensor::Tensor0< FTensor::PackPtr< double *, 1 > > getFTensor0N(const FieldApproximationBase base)
Get base function as Tensor0.