v0.15.5
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
 

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)
 

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

Member Typedef Documentation

◆ OP

Definition at line 1478 of file adjoint.cpp.

Constructor & Destructor Documentation

◆ OpStateSensitivity()

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

1483 : OP(field_name, field_name, DomainEleOp::OPROW), pythonPtr(python_ptr), commPtr(comm_ptr),
1484 uPtr(u_ptr){}
constexpr auto field_name
boost::shared_ptr< ObjectiveFunctionData > pythonPtr
Definition adjoint.cpp:1568
DomainBaseOp OP
Definition adjoint.cpp:1478
boost::shared_ptr< MatrixDouble > uPtr
Definition adjoint.cpp:1570
boost::shared_ptr< HookeOps::CommonData > commPtr
Definition adjoint.cpp:1569

Member Function Documentation

◆ iNtegrate()

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

Definition at line 1486 of file adjoint.cpp.

1487 {
1493
1494 constexpr auto symm_size = (SPACE_DIM * (SPACE_DIM + 1)) / 2;
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();
1507 CHKERR pythonPtr->evalInteriorObjectiveGradientStress(
1508 coords, uPtr, commPtr->getMatCauchyStress(), commPtr->getMatStrain(),
1509 objective_dstress);
1510 CHKERR pythonPtr->evalInteriorObjectiveGradientStrain(
1511 coords, uPtr, commPtr->getMatCauchyStress(), commPtr->getMatStrain(),
1512 objective_dstrain);
1513 CHKERR pythonPtr->evalInteriorObjectiveGradientU(
1514 coords, uPtr, commPtr->getMatCauchyStress(), commPtr->getMatStrain(),
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));
1521 auto t_row_grad = data.getFTensor1DiffN<SPACE_DIM>();
1522 auto t_row_base = data.getFTensor0N();
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]
Definition adjoint.cpp:28
#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.

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 file: