1470 {
1476
1478 auto nb_gauss_pts = getGaussPts().size2();
1479
1480 auto objective_dstress =
1481 boost::make_shared<MatrixDouble>(nb_gauss_pts, symm_size);
1482 auto objective_dstrain =
1483 boost::make_shared<MatrixDouble>(nb_gauss_pts, symm_size);
1484 auto objective_du =
1485 boost::make_shared<MatrixDouble>(nb_gauss_pts,
SPACE_DIM);
1486
1487 auto evaluate_python = [&]() {
1489 auto &coords = OP::getCoordsAtGaussPts();
1492 objective_dstress);
1495 objective_dstrain);
1498 objective_du);
1499
1500 auto vol = OP::getMeasure();
1501 auto t_w = OP::getFTensor0IntegrationWeight();
1502
1503 auto t_D =
1504 getFTensor4DdgFromMat<SPACE_DIM, SPACE_DIM, 0>(*(
commPtr->matDPtr));
1507
1508 auto t_obj_dstress =
1509 getFTensor2SymmetricFromMat<SPACE_DIM>(*objective_dstress);
1510 auto t_obj_dstrain =
1511 getFTensor2SymmetricFromMat<SPACE_DIM>(*objective_dstrain);
1512 auto t_obj_du = getFTensor1FromMat<SPACE_DIM>(*objective_du);
1513
1514 for (int gg = 0; gg != nb_gauss_pts; ++gg) {
1515 const double alpha = t_w * vol;
1517 t_adjoint_stress(
i,
j) =
1518 t_D(
i,
j,
k,
l) * t_obj_dstress(
k,
l) + t_obj_dstrain(
i,
j);
1519
1520 auto t_nf = OP::template getNf<SPACE_DIM>();
1521 int rr = 0;
1522 for (; rr != OP::nbRows /
SPACE_DIM; rr++) {
1523 t_nf(
j) += alpha * t_row_grad(
i) * t_adjoint_stress(
i,
j);
1524 t_nf(
j) += alpha * t_row_base * t_obj_du(
j);
1525
1526 ++t_row_grad;
1527 ++t_row_base;
1528 ++t_nf;
1529 }
1530
1531 for (; rr < OP::nbRowBaseFunctions; ++rr) {
1532 ++t_row_grad;
1533 ++t_row_base;
1534 }
1535 ++t_obj_dstrain;
1536 ++t_obj_dstress;
1537 ++t_obj_du;
1538 ++t_w;
1539 }
1541 };
1542 CHKERR evaluate_python();
1544 }
#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.
constexpr int SPACE_DIM
[Define dimension]
FTensor::Index< 'i', SPACE_DIM > i
FTensor::Index< 'l', 3 > l
FTensor::Index< 'j', 3 > j
FTensor::Index< 'k', 3 > k
FTensor::Tensor0< FTensor::PackPtr< double *, 1 > > getFTensor0N(const FieldApproximationBase base)
Get base function as Tensor0.
auto getFTensor1DiffN(const FieldApproximationBase base)
Get derivatives of base functions.