v0.16.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Attributes | List of all members
OpStateSensitivity Struct Reference
Inheritance diagram for OpStateSensitivity:
[legend]
Collaboration diagram for OpStateSensitivity:
[legend]

Public Types

using OP = DomainBaseOp
 
using OP = DomainBaseOp
 

Public Member Functions

 OpStateSensitivity (const std::string field_name, boost::shared_ptr< ObjectiveFunctionData > python_ptr, boost::shared_ptr< HookeOps::CommonData > comm_ptr, boost::shared_ptr< MatrixDouble > u_ptr)
 
MoFEMErrorCode iNtegrate (EntitiesFieldData::EntData &data)
 
 OpStateSensitivity (const std::string field_name, boost::shared_ptr< ObjectiveFunctionData > python_ptr, boost::shared_ptr< HookeOps::CommonData > comm_ptr, boost::shared_ptr< MatrixDouble > u_ptr)
 
MoFEMErrorCode iNtegrate (EntitiesFieldData::EntData &data)
 

Private Attributes

boost::shared_ptr< ObjectiveFunctionDatapythonPtr
 
boost::shared_ptr< HookeOps::CommonDatacommPtr
 
boost::shared_ptr< MatrixDoubleuPtr
 

Detailed Description

Examples
mofem/tutorials/vec-7_shape_optimisation/adjoint.cpp.

Definition at line 1461 of file adjoint.cpp.

Member Typedef Documentation

◆ OP [1/2]

Definition at line 1462 of file adjoint.cpp.

◆ OP [2/2]

Definition at line 706 of file gradient.cpp.

Constructor & Destructor Documentation

◆ OpStateSensitivity() [1/2]

OpStateSensitivity::OpStateSensitivity ( const std::string  field_name,
boost::shared_ptr< ObjectiveFunctionData python_ptr,
boost::shared_ptr< HookeOps::CommonData comm_ptr,
boost::shared_ptr< MatrixDouble u_ptr 
)
inline

Definition at line 1463 of file adjoint.cpp.

1467 : OP(field_name, field_name, DomainEleOp::OPROW), pythonPtr(python_ptr),
1468 commPtr(comm_ptr), uPtr(u_ptr) {}
constexpr auto field_name
boost::shared_ptr< HookeOps::CommonData > commPtr
Definition adjoint.cpp:1548
DomainBaseOp OP
Definition adjoint.cpp:1462
boost::shared_ptr< MatrixDouble > uPtr
Definition adjoint.cpp:1549
boost::shared_ptr< ObjectiveFunctionData > pythonPtr
Definition adjoint.cpp:1547

◆ OpStateSensitivity() [2/2]

OpStateSensitivity::OpStateSensitivity ( const std::string  field_name,
boost::shared_ptr< ObjectiveFunctionData python_ptr,
boost::shared_ptr< HookeOps::CommonData comm_ptr,
boost::shared_ptr< MatrixDouble u_ptr 
)
inline

Definition at line 707 of file gradient.cpp.

711 : OP(field_name, field_name, DomainEleOp::OPROW), pythonPtr(python_ptr),
712 commPtr(comm_ptr), uPtr(u_ptr) {}

Member Function Documentation

◆ iNtegrate() [1/2]

MoFEMErrorCode OpStateSensitivity::iNtegrate ( EntitiesFieldData::EntData data)
inline
Examples
mofem/tutorials/vec-7_shape_optimisation/adjoint.cpp.

Definition at line 1470 of file adjoint.cpp.

1470 {
1476
1477 constexpr auto symm_size = (SPACE_DIM * (SPACE_DIM + 1)) / 2;
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();
1490 CHKERR pythonPtr->evalInteriorObjectiveGradientStress(
1491 coords, uPtr, commPtr->getMatCauchyStress(), commPtr->getMatStrain(),
1492 objective_dstress);
1493 CHKERR pythonPtr->evalInteriorObjectiveGradientStrain(
1494 coords, uPtr, commPtr->getMatCauchyStress(), commPtr->getMatStrain(),
1495 objective_dstrain);
1496 CHKERR pythonPtr->evalInteriorObjectiveGradientU(
1497 coords, uPtr, commPtr->getMatCauchyStress(), commPtr->getMatStrain(),
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));
1505 auto t_row_grad = data.getFTensor1DiffN<SPACE_DIM>();
1506 auto t_row_base = data.getFTensor0N();
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]
Definition gradient.cpp:19
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.

◆ iNtegrate() [2/2]

MoFEMErrorCode OpStateSensitivity::iNtegrate ( EntitiesFieldData::EntData data)
inline

Definition at line 714 of file gradient.cpp.

714 {
720
721 constexpr auto symm_size = (SPACE_DIM * (SPACE_DIM + 1)) / 2;
722 auto nb_gauss_pts = getGaussPts().size2();
723
724 auto objective_dstress =
725 boost::make_shared<MatrixDouble>(nb_gauss_pts, symm_size);
726 auto objective_dstrain =
727 boost::make_shared<MatrixDouble>(nb_gauss_pts, symm_size);
728 auto objective_du =
729 boost::make_shared<MatrixDouble>(nb_gauss_pts, SPACE_DIM);
730
731 auto evaluate_python = [&]() {
733 auto &coords = OP::getCoordsAtGaussPts();
734 CHKERR pythonPtr->evalInteriorObjectiveGradientStress(
735 coords, uPtr, commPtr->getMatCauchyStress(), commPtr->getMatStrain(),
736 objective_dstress);
737 CHKERR pythonPtr->evalInteriorObjectiveGradientStrain(
738 coords, uPtr, commPtr->getMatCauchyStress(), commPtr->getMatStrain(),
739 objective_dstrain);
740 CHKERR pythonPtr->evalInteriorObjectiveGradientU(
741 coords, uPtr, commPtr->getMatCauchyStress(), commPtr->getMatStrain(),
742 objective_du);
743
744 auto vol = OP::getMeasure();
745 auto t_w = OP::getFTensor0IntegrationWeight();
746
747 auto t_D =
748 getFTensor4DdgFromMat<SPACE_DIM, SPACE_DIM, 0>(*(commPtr->matDPtr));
749 auto t_row_grad = data.getFTensor1DiffN<SPACE_DIM>();
750 auto t_row_base = data.getFTensor0N();
751
752 auto t_obj_dstress =
753 getFTensor2SymmetricFromMat<SPACE_DIM>(*objective_dstress);
754 auto t_obj_dstrain =
755 getFTensor2SymmetricFromMat<SPACE_DIM>(*objective_dstrain);
756 auto t_obj_du = getFTensor1FromMat<SPACE_DIM>(*objective_du);
757
758 for (int gg = 0; gg != nb_gauss_pts; ++gg) {
759 const double alpha = t_w * vol;
761 t_adjoint_stress(i, j) =
762 t_D(i, j, k, l) * t_obj_dstress(k, l) + t_obj_dstrain(i, j);
763
764 auto t_nf = OP::template getNf<SPACE_DIM>();
765 int rr = 0;
766 for (; rr != OP::nbRows / SPACE_DIM; rr++) {
767 t_nf(j) += alpha * t_row_grad(i) * t_adjoint_stress(i, j);
768 t_nf(j) += alpha * t_row_base * t_obj_du(j);
769
770 ++t_row_grad;
771 ++t_row_base;
772 ++t_nf;
773 }
774
775 for (; rr < OP::nbRowBaseFunctions; ++rr) {
776 ++t_row_grad;
777 ++t_row_base;
778 }
779 ++t_obj_dstrain;
780 ++t_obj_dstress;
781 ++t_obj_du;
782 ++t_w;
783 }
785 };
786 CHKERR evaluate_python();
788 }

Member Data Documentation

◆ commPtr

boost::shared_ptr< HookeOps::CommonData > OpStateSensitivity::commPtr
private

◆ pythonPtr

boost::shared_ptr< ObjectiveFunctionData > OpStateSensitivity::pythonPtr
private

◆ uPtr

boost::shared_ptr< MatrixDouble > OpStateSensitivity::uPtr
private

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