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 1497 of file adjoint.cpp.

Member Typedef Documentation

◆ OP [1/2]

Definition at line 1498 of file adjoint.cpp.

◆ OP [2/2]

Definition at line 743 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 1499 of file adjoint.cpp.

1503 : OP(field_name, field_name, DomainEleOp::OPROW), pythonPtr(python_ptr),
1504 commPtr(comm_ptr), uPtr(u_ptr) {}
constexpr auto field_name
boost::shared_ptr< HookeOps::CommonData > commPtr
Definition adjoint.cpp:1584
DomainBaseOp OP
Definition adjoint.cpp:1498
boost::shared_ptr< MatrixDouble > uPtr
Definition adjoint.cpp:1585
boost::shared_ptr< ObjectiveFunctionData > pythonPtr
Definition adjoint.cpp:1583

◆ 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 744 of file gradient.cpp.

748 : OP(field_name, field_name, DomainEleOp::OPROW), pythonPtr(python_ptr),
749 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 1506 of file adjoint.cpp.

1506 {
1512
1513 constexpr auto symm_size = (SPACE_DIM * (SPACE_DIM + 1)) / 2;
1514 auto nb_gauss_pts = getGaussPts().size2();
1515
1516 auto objective_dstress =
1517 boost::make_shared<MatrixDouble>(nb_gauss_pts, symm_size);
1518 auto objective_dstrain =
1519 boost::make_shared<MatrixDouble>(nb_gauss_pts, symm_size);
1520 auto objective_du =
1521 boost::make_shared<MatrixDouble>(nb_gauss_pts, SPACE_DIM);
1522
1523 auto evaluate_python = [&]() {
1525 auto &coords = OP::getCoordsAtGaussPts();
1526 CHKERR pythonPtr->evalInteriorObjectiveGradientStress(
1527 coords, uPtr, commPtr->getMatCauchyStress(), commPtr->getMatStrain(),
1528 objective_dstress);
1529 CHKERR pythonPtr->evalInteriorObjectiveGradientStrain(
1530 coords, uPtr, commPtr->getMatCauchyStress(), commPtr->getMatStrain(),
1531 objective_dstrain);
1532 CHKERR pythonPtr->evalInteriorObjectiveGradientU(
1533 coords, uPtr, commPtr->getMatCauchyStress(), commPtr->getMatStrain(),
1534 objective_du);
1535
1536 auto vol = OP::getMeasure();
1537 auto t_w = OP::getFTensor0IntegrationWeight();
1538
1539 auto t_D =
1540 getFTensor4DdgFromMat<SPACE_DIM, SPACE_DIM, 0>(*(commPtr->matDPtr));
1541 auto t_row_grad = data.getFTensor1DiffN<SPACE_DIM>();
1542 auto t_row_base = data.getFTensor0N();
1543
1544 auto t_obj_dstress =
1545 getFTensor2SymmetricFromMat<SPACE_DIM>(*objective_dstress);
1546 auto t_obj_dstrain =
1547 getFTensor2SymmetricFromMat<SPACE_DIM>(*objective_dstrain);
1548 auto t_obj_du = getFTensor1FromMat<SPACE_DIM>(*objective_du);
1549
1550 for (int gg = 0; gg != nb_gauss_pts; ++gg) {
1551 const double alpha = t_w * vol;
1553 t_adjoint_stress(i, j) =
1554 t_D(i, j, k, l) * t_obj_dstress(k, l) + t_obj_dstrain(i, j);
1555
1556 auto t_nf = OP::template getNf<SPACE_DIM>();
1557 int rr = 0;
1558 for (; rr != OP::nbRows / SPACE_DIM; rr++) {
1559 t_nf(j) += alpha * t_row_grad(i) * t_adjoint_stress(i, j);
1560 t_nf(j) += alpha * t_row_base * t_obj_du(j);
1561
1562 ++t_row_grad;
1563 ++t_row_base;
1564 ++t_nf;
1565 }
1566
1567 for (; rr < OP::nbRowBaseFunctions; ++rr) {
1568 ++t_row_grad;
1569 ++t_row_base;
1570 }
1571 ++t_obj_dstrain;
1572 ++t_obj_dstress;
1573 ++t_obj_du;
1574 ++t_w;
1575 }
1577 };
1578 CHKERR evaluate_python();
1580 }
#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 751 of file gradient.cpp.

751 {
757
758 constexpr auto symm_size = (SPACE_DIM * (SPACE_DIM + 1)) / 2;
759 auto nb_gauss_pts = getGaussPts().size2();
760
761 auto objective_dstress =
762 boost::make_shared<MatrixDouble>(nb_gauss_pts, symm_size);
763 auto objective_dstrain =
764 boost::make_shared<MatrixDouble>(nb_gauss_pts, symm_size);
765 auto objective_du =
766 boost::make_shared<MatrixDouble>(nb_gauss_pts, SPACE_DIM);
767
768 auto evaluate_python = [&]() {
770 auto &coords = OP::getCoordsAtGaussPts();
771 CHKERR pythonPtr->evalInteriorObjectiveGradientStress(
772 coords, uPtr, commPtr->getMatCauchyStress(), commPtr->getMatStrain(),
773 objective_dstress);
774 CHKERR pythonPtr->evalInteriorObjectiveGradientStrain(
775 coords, uPtr, commPtr->getMatCauchyStress(), commPtr->getMatStrain(),
776 objective_dstrain);
777 CHKERR pythonPtr->evalInteriorObjectiveGradientU(
778 coords, uPtr, commPtr->getMatCauchyStress(), commPtr->getMatStrain(),
779 objective_du);
780
781 auto vol = OP::getMeasure();
782 auto t_w = OP::getFTensor0IntegrationWeight();
783
784 auto t_D =
785 getFTensor4DdgFromMat<SPACE_DIM, SPACE_DIM, 0>(*(commPtr->matDPtr));
786 auto t_row_grad = data.getFTensor1DiffN<SPACE_DIM>();
787 auto t_row_base = data.getFTensor0N();
788
789 auto t_obj_dstress =
790 getFTensor2SymmetricFromMat<SPACE_DIM>(*objective_dstress);
791 auto t_obj_dstrain =
792 getFTensor2SymmetricFromMat<SPACE_DIM>(*objective_dstrain);
793 auto t_obj_du = getFTensor1FromMat<SPACE_DIM>(*objective_du);
794
795 for (int gg = 0; gg != nb_gauss_pts; ++gg) {
796 const double alpha = t_w * vol;
798 t_adjoint_stress(i, j) =
799 t_D(i, j, k, l) * t_obj_dstress(k, l) + t_obj_dstrain(i, j);
800
801 auto t_nf = OP::template getNf<SPACE_DIM>();
802 int rr = 0;
803 for (; rr != OP::nbRows / SPACE_DIM; rr++) {
804 t_nf(j) += alpha * t_row_grad(i) * t_adjoint_stress(i, j);
805 t_nf(j) += alpha * t_row_base * t_obj_du(j);
806
807 ++t_row_grad;
808 ++t_row_base;
809 ++t_nf;
810 }
811
812 for (; rr < OP::nbRowBaseFunctions; ++rr) {
813 ++t_row_grad;
814 ++t_row_base;
815 }
816 ++t_obj_dstrain;
817 ++t_obj_dstress;
818 ++t_obj_du;
819 ++t_w;
820 }
822 };
823 CHKERR evaluate_python();
825 }

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: