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

Public Types

using OP = ForcesAndSourcesCore::UserDataOperator
 

Public Member Functions

 OpObjective (boost::shared_ptr< ObjectiveFunctionData > python_ptr, boost::shared_ptr< HookeOps::CommonData > comm_ptr, boost::shared_ptr< MatrixDouble > jac_ptr, boost::shared_ptr< MatrixDouble > u_ptr, boost::shared_ptr< double > glob_objective_ptr)
 
MoFEMErrorCode doWork (int side, EntityType type, EntitiesFieldData::EntData &data)
 Compute objective function contributions at element level.
 

Private Attributes

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

Detailed Description

Definition at line 791 of file gradient.cpp.

Member Typedef Documentation

◆ OP

using OpObjective::OP = ForcesAndSourcesCore::UserDataOperator

Definition at line 792 of file gradient.cpp.

Constructor & Destructor Documentation

◆ OpObjective()

OpObjective::OpObjective ( boost::shared_ptr< ObjectiveFunctionData >  python_ptr,
boost::shared_ptr< HookeOps::CommonData >  comm_ptr,
boost::shared_ptr< MatrixDouble >  jac_ptr,
boost::shared_ptr< MatrixDouble >  u_ptr,
boost::shared_ptr< double >  glob_objective_ptr 
)
inline

Definition at line 794 of file gradient.cpp.

799 : OP(NOSPACE, OP::OPSPACE), pythonPtr(python_ptr), commPtr(comm_ptr),
800 jacPtr(jac_ptr), uPtr(u_ptr), globObjectivePtr(glob_objective_ptr) {}
@ NOSPACE
Definition definitions.h:83
boost::shared_ptr< double > globObjectivePtr
Definition gradient.cpp:851
ForcesAndSourcesCore::UserDataOperator OP
Definition gradient.cpp:792
boost::shared_ptr< MatrixDouble > jacPtr
Definition gradient.cpp:849
boost::shared_ptr< MatrixDouble > uPtr
Definition gradient.cpp:850
boost::shared_ptr< HookeOps::CommonData > commPtr
Definition gradient.cpp:848
boost::shared_ptr< ObjectiveFunctionData > pythonPtr
Definition gradient.cpp:847

Member Function Documentation

◆ doWork()

MoFEMErrorCode OpObjective::doWork ( int  side,
EntityType  type,
EntitiesFieldData::EntData &  data 
)
inline

Compute objective function contributions at element level.

Evaluates Python objective function with current displacement and stress state, and accumulates global objective value and gradients.

Definition at line 808 of file gradient.cpp.

809 {
811
812 auto nb_gauss_pts =
813 getGaussPts().size2(); // number of gauss points in the element
814
815 auto objective_ptr = boost::make_shared<MatrixDouble>(
816 1, nb_gauss_pts); // objective function values at gauss points
817
818 auto evaluate_python = [&]() {
820 auto &coords = OP::getCoordsAtGaussPts();
821 CHKERR pythonPtr->evalInteriorObjectiveFunction(
822 coords, uPtr, commPtr->getMatCauchyStress(), commPtr->getMatStrain(),
823 objective_ptr);
824
825 auto t_obj = getFTensor0FromMat(*objective_ptr);
826
827 auto vol = OP::getMeasure();
828 auto t_w = getFTensor0IntegrationWeight();
829 for (auto gg = 0; gg != nb_gauss_pts; ++gg) {
830
831 auto alpha = t_w * vol;
832 (*globObjectivePtr) += alpha * t_obj;
833
834 ++t_w;
835
836 ++t_obj;
837 }
839 };
840
841 CHKERR evaluate_python();
842
844 }
#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.
auto getFTensor0FromMat(M &data)
Get tensor rank 0 (scalar) form data vector.

Member Data Documentation

◆ commPtr

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

Definition at line 848 of file gradient.cpp.

◆ globObjectivePtr

boost::shared_ptr<double> OpObjective::globObjectivePtr
private

Definition at line 851 of file gradient.cpp.

◆ jacPtr

boost::shared_ptr<MatrixDouble> OpObjective::jacPtr
private

Definition at line 849 of file gradient.cpp.

◆ pythonPtr

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

Definition at line 847 of file gradient.cpp.

◆ uPtr

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

Definition at line 850 of file gradient.cpp.


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