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 Types inherited from MoFEM::OpBaseImpl< A, EleOp >
using OpType = typename EleOp::OpType
 
using EntData = EntitiesFieldData::EntData
 
using MatSetValuesHook = boost::function< MoFEMErrorCode(ForcesAndSourcesCore::UserDataOperator *op_ptr, const EntitiesFieldData::EntData &row_data, const EntitiesFieldData::EntData &col_data, MatrixDouble &m)>
 

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)
 Class dedicated to integrate operator.
 
 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)
 Class dedicated to integrate operator.
 
- Public Member Functions inherited from MoFEM::OpBaseImpl< A, EleOp >
 OpBaseImpl (const std::string row_field_name, const std::string col_field_name, const OpType type, boost::shared_ptr< Range > ents_ptr=nullptr)
 Constructor for base operator implementation.
 
MoFEMErrorCode doWork (int row_side, int col_side, EntityType row_type, EntityType col_type, EntData &row_data, EntData &col_data)
 Do calculations for the left hand side.
 
MoFEMErrorCode doWork (int row_side, EntityType row_type, EntData &row_data)
 Do calculations for the right hand side.
 

Private Attributes

boost::shared_ptr< ObjectiveFunctionData > pythonPtr
 
boost::shared_ptr< HookeOps::CommonData > commPtr
 
boost::shared_ptr< MatrixDouble > uPtr
 

Additional Inherited Members

- Public Attributes inherited from MoFEM::OpBaseImpl< A, EleOp >
TimeFun timeScalingFun
 assumes that time variable is set
 
FEFun feScalingFun
 set by fe entity handle
 
boost::shared_ptr< Range > entsPtr
 Entities on which element is run.
 
- Static Public Attributes inherited from MoFEM::OpBaseImpl< A, EleOp >
static MatSetValuesHook matSetValuesHook
 
- Protected Member Functions inherited from MoFEM::OpBaseImpl< A, EleOp >
template<int DIM>
auto getNf ()
 Get local vector tensor for assembly.
 
template<int ROW_DIM, int COL_DIM = ROW_DIM>
FTensor::Tensor2< FTensor::PackPtr< double *, COL_DIM >, ROW_DIM, COL_DIM > getLocMat (const int rr)
 Get local matrix tensor for assembly.
 
virtual MoFEMErrorCode iNtegrate (EntData &, EntData &)
 Integrate grad-grad operator.
 
virtual MoFEMErrorCode aSsemble (EntData &row_data, EntData &col_data, const bool trans)
 Assemble local matrix into global matrix.
 
virtual MoFEMErrorCode aSsemble (EntData &data)
 Assemble local vector into global vector.
 
virtual size_t getNbOfBaseFunctions (EntitiesFieldData::EntData &data)
 Get number of base functions.
 
- Protected Attributes inherited from MoFEM::OpBaseImpl< A, EleOp >
int nbRows
 number of dofs on rows
 
int nbCols
 number if dof on column
 
int nbIntegrationPts
 number of integration points
 
int nbRowBaseFunctions
 number or row base functions
 
int rowSide
 row side number
 
int colSide
 column side number
 
EntityType rowType
 row type
 
EntityType colType
 column type
 
bool assembleTranspose
 
bool onlyTranspose
 
MatrixDouble locMat
 local entity block matrix
 
MatrixDouble locMatTranspose
 local entity block matrix
 
VectorDouble locF
 local entity vector
 

Detailed Description

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

Definition at line 1503 of file adjoint.cpp.

Member Typedef Documentation

◆ OP [1/2]

Definition at line 1504 of file adjoint.cpp.

◆ OP [2/2]

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

1509 : OP(field_name, field_name, DomainEleOp::OPROW), pythonPtr(python_ptr),
1510 commPtr(comm_ptr), uPtr(u_ptr) {}
constexpr auto field_name
boost::shared_ptr< HookeOps::CommonData > commPtr
Definition adjoint.cpp:1590
DomainBaseOp OP
Definition adjoint.cpp:1504
boost::shared_ptr< MatrixDouble > uPtr
Definition adjoint.cpp:1591
boost::shared_ptr< ObjectiveFunctionData > pythonPtr
Definition adjoint.cpp:1589

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

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

Member Function Documentation

◆ iNtegrate() [1/2]

MoFEMErrorCode OpStateSensitivity::iNtegrate ( EntitiesFieldData::EntData &  )
inlinevirtual

Class dedicated to integrate operator.

Parameters
dataentity data on element row
Returns
error code

Reimplemented from MoFEM::OpBaseImpl< A, EleOp >.

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

Definition at line 1512 of file adjoint.cpp.

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

◆ iNtegrate() [2/2]

MoFEMErrorCode OpStateSensitivity::iNtegrate ( EntitiesFieldData::EntData &  )
inlinevirtual

Class dedicated to integrate operator.

Parameters
dataentity data on element row
Returns
error code

Reimplemented from MoFEM::OpBaseImpl< A, EleOp >.

Definition at line 710 of file gradient.cpp.

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

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: