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

Detailed Description

Definition at line 831 of file gradient.cpp.

Member Typedef Documentation

◆ OP

using OpObjective::OP = ForcesAndSourcesCore::UserDataOperator

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

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

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

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

◆ globObjectivePtr

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

Definition at line 891 of file gradient.cpp.

◆ jacPtr

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

Definition at line 889 of file gradient.cpp.

◆ pythonPtr

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

Definition at line 887 of file gradient.cpp.

◆ uPtr

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

Definition at line 890 of file gradient.cpp.


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