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

Member Typedef Documentation

◆ OP

using OpObjective::OP = ForcesAndSourcesCore::UserDataOperator

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

803 : OP(NOSPACE, OP::OPSPACE), pythonPtr(python_ptr), commPtr(comm_ptr),
804 jacPtr(jac_ptr), uPtr(u_ptr), globObjectivePtr(glob_objective_ptr) {}
@ NOSPACE
Definition definitions.h:83
boost::shared_ptr< double > globObjectivePtr
Definition gradient.cpp:855
ForcesAndSourcesCore::UserDataOperator OP
Definition gradient.cpp:796
boost::shared_ptr< MatrixDouble > jacPtr
Definition gradient.cpp:853
boost::shared_ptr< MatrixDouble > uPtr
Definition gradient.cpp:854
boost::shared_ptr< HookeOps::CommonData > commPtr
Definition gradient.cpp:852
boost::shared_ptr< ObjectiveFunctionData > pythonPtr
Definition gradient.cpp:851

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

813 {
815
816 auto nb_gauss_pts =
817 getGaussPts().size2(); // number of gauss points in the element
818
819 auto objective_ptr = boost::make_shared<MatrixDouble>(
820 1, nb_gauss_pts); // objective function values at gauss points
821
822 auto evaluate_python = [&]() {
824 auto &coords = OP::getCoordsAtGaussPts();
825 CHKERR pythonPtr->evalInteriorObjectiveFunction(
826 coords, uPtr, commPtr->getMatCauchyStress(), commPtr->getMatStrain(),
827 objective_ptr);
828
829 auto t_obj = getFTensor0FromMat(*objective_ptr);
830
831 auto vol = OP::getMeasure();
832 auto t_w = getFTensor0IntegrationWeight();
833 for (auto gg = 0; gg != nb_gauss_pts; ++gg) {
834
835 auto alpha = t_w * vol;
836 (*globObjectivePtr) += alpha * t_obj;
837
838 ++t_w;
839
840 ++t_obj;
841 }
843 };
844
845 CHKERR evaluate_python();
846
848 }
#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 852 of file gradient.cpp.

◆ globObjectivePtr

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

Definition at line 855 of file gradient.cpp.

◆ jacPtr

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

Definition at line 853 of file gradient.cpp.

◆ pythonPtr

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

Definition at line 851 of file gradient.cpp.

◆ uPtr

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

Definition at line 854 of file gradient.cpp.


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