v0.16.3
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< ObjectiveFunctionData > pythonPtr
 
boost::shared_ptr< HookeOps::CommonData > commPtr
 
boost::shared_ptr< MatrixDouble > uPtr
 

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 742 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 743 of file gradient.cpp.

747 : OP(field_name, field_name, DomainEleOp::OPROW), pythonPtr(python_ptr),
748 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 750 of file gradient.cpp.

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

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: