v0.16.0
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< ObjectiveFunctionDatapythonPtr
 
boost::shared_ptr< HookeOps::CommonDatacommPtr
 
boost::shared_ptr< MatrixDoublejacPtr
 
boost::shared_ptr< MatrixDoubleuPtr
 
boost::shared_ptr< doubleglobObjectivePtr
 

Detailed Description

Definition at line 832 of file gradient.cpp.

Member Typedef Documentation

◆ OP

using OpObjective::OP = ForcesAndSourcesCore::UserDataOperator

Definition at line 833 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 835 of file gradient.cpp.

840 : OP(NOSPACE, OP::OPSPACE), pythonPtr(python_ptr), commPtr(comm_ptr),
841 jacPtr(jac_ptr), uPtr(u_ptr), globObjectivePtr(glob_objective_ptr) {}
@ NOSPACE
Definition definitions.h:83
boost::shared_ptr< double > globObjectivePtr
Definition gradient.cpp:892
ForcesAndSourcesCore::UserDataOperator OP
Definition gradient.cpp:833
boost::shared_ptr< MatrixDouble > jacPtr
Definition gradient.cpp:890
boost::shared_ptr< MatrixDouble > uPtr
Definition gradient.cpp:891
boost::shared_ptr< HookeOps::CommonData > commPtr
Definition gradient.cpp:889
boost::shared_ptr< ObjectiveFunctionData > pythonPtr
Definition gradient.cpp:888

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

850 {
852
853 auto nb_gauss_pts =
854 getGaussPts().size2(); // number of gauss points in the element
855
856 auto objective_ptr = boost::make_shared<MatrixDouble>(
857 1, nb_gauss_pts); // objective function values at gauss points
858
859 auto evaluate_python = [&]() {
861 auto &coords = OP::getCoordsAtGaussPts();
862 CHKERR pythonPtr->evalInteriorObjectiveFunction(
863 coords, uPtr, commPtr->getMatCauchyStress(), commPtr->getMatStrain(),
864 objective_ptr);
865
866 auto t_obj = getFTensor0FromMat(*objective_ptr);
867
868 auto vol = OP::getMeasure();
869 auto t_w = getFTensor0IntegrationWeight();
870 for (auto gg = 0; gg != nb_gauss_pts; ++gg) {
871
872 auto alpha = t_w * vol;
873 (*globObjectivePtr) += alpha * t_obj;
874
875 ++t_w;
876
877 ++t_obj;
878 }
880 };
881
882 CHKERR evaluate_python();
883
885 }
#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 889 of file gradient.cpp.

◆ globObjectivePtr

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

Definition at line 892 of file gradient.cpp.

◆ jacPtr

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

Definition at line 890 of file gradient.cpp.

◆ pythonPtr

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

Definition at line 888 of file gradient.cpp.

◆ uPtr

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

Definition at line 891 of file gradient.cpp.


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