v0.15.5
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
EshelbianPlasticity::TopologicalTAOCtxImpl Struct Reference
Inheritance diagram for EshelbianPlasticity::TopologicalTAOCtxImpl:
[legend]
Collaboration diagram for EshelbianPlasticity::TopologicalTAOCtxImpl:
[legend]

Public Member Functions

 TopologicalTAOCtxImpl (EshelbianCore *ep, ForcesAndSourcesCore::GaussHookFun set_integration_at_interior, ForcesAndSourcesCore::GaussHookFun set_integration_at_face, SmartPetscObj< TS > time_solver)
 
- Public Member Functions inherited from EshelbianPlasticity::TopologicalTAOCtx
 TopologicalTAOCtx ()=default
 
virtual ~TopologicalTAOCtx ()=default
 

Private Member Functions

auto getMaterialH1PositionsStructureRawPtr ()
 
auto getVertexMaterialH1PositionsTag ()
 
Tag getTag (moab::Interface &moab, std::string tag_name, int size)
 
Tag getJdXTag ()
 

Private Attributes

EshelbianCoreep_ptr
 
ForcesAndSourcesCore::GaussHookFun integrationAtInterior
 
ForcesAndSourcesCore::GaussHookFun integrationAtFace
 
SmartPetscObj< TS > timeSolver
 
CommInterface::EntitiesPetscVector geometryVec
 
CommInterface::EntitiesPetscVector gradJVec
 

Friends

MoFEMErrorCode cohesiveEvaluateObjectiveAndGradient (Tao tao, Vec x, PetscReal *f, Vec g, void *ctx)
 
MoFEMErrorCode testTopologicalDerivative (TopologicalTAOCtx *ctx_ptr, const double alpha, const double rho, const double alpha_omega)
 

Detailed Description

Definition at line 31 of file EshelbianTopologicalDerivative.cpp.

Constructor & Destructor Documentation

◆ TopologicalTAOCtxImpl()

EshelbianPlasticity::TopologicalTAOCtxImpl::TopologicalTAOCtxImpl ( EshelbianCore ep,
ForcesAndSourcesCore::GaussHookFun  set_integration_at_interior,
ForcesAndSourcesCore::GaussHookFun  set_integration_at_face,
SmartPetscObj< TS >  time_solver 
)
inline

Definition at line 32 of file EshelbianTopologicalDerivative.cpp.

37 : ep_ptr(ep), integrationAtInterior(set_integration_at_interior),
38 integrationAtFace(set_integration_at_face), timeSolver(time_solver),
39
41 ep->mField.get_comm(), ep->mField.get_moab(), 0, 3, Sev::noisy)),
43 ep->mField.get_comm(), ep->mField.get_moab(), 0, 3, Sev::noisy)) {}
MoFEM::Interface & mField
static EntitiesPetscVector createEntitiesPetscVector(MPI_Comm comm, moab::Interface &moab, std::function< Range(Range)> get_entities_fun, const int nb_coeffs, Sev sev=Sev::verbose, int root_rank=0, bool get_vertices=true)
Create a ghost vector for exchanging data.
virtual moab::Interface & get_moab()=0
virtual MPI_Comm & get_comm() const =0

Member Function Documentation

◆ getJdXTag()

Tag EshelbianPlasticity::TopologicalTAOCtxImpl::getJdXTag ( )
inlineprivate

Definition at line 73 of file EshelbianTopologicalDerivative.cpp.

73{ return getTag(ep_ptr->mField.get_moab(), "DJ_DX", 3); }
Tag getTag(moab::Interface &moab, std::string tag_name, int size)

◆ getMaterialH1PositionsStructureRawPtr()

auto EshelbianPlasticity::TopologicalTAOCtxImpl::getMaterialH1PositionsStructureRawPtr ( )
inlineprivate

Definition at line 54 of file EshelbianTopologicalDerivative.cpp.

54 {
56 }
virtual const Field * get_field_structure(const std::string &name, enum MoFEMTypes bh=MF_EXIST) const =0
get field structure
const std::string materialH1Positions

◆ getTag()

Tag EshelbianPlasticity::TopologicalTAOCtxImpl::getTag ( moab::Interface &  moab,
std::string  tag_name,
int  size 
)
inlineprivate

Definition at line 63 of file EshelbianTopologicalDerivative.cpp.

63 {
64 Tag tag;
65 rval = moab.tag_get_handle(tag_name.c_str(), size, MB_TYPE_DOUBLE, tag,
66 MB_TAG_CREAT | MB_TAG_DENSE, NULL);
67 if (rval == MB_ALREADY_ALLOCATED)
68 rval = MB_SUCCESS;
69 CHK_MOAB_THROW(rval, "Failed to get tag " + tag_name);
70 return tag;
71 };
#define CHK_MOAB_THROW(err, msg)
Check error code of MoAB function and throw MoFEM exception.
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval

◆ getVertexMaterialH1PositionsTag()

auto EshelbianPlasticity::TopologicalTAOCtxImpl::getVertexMaterialH1PositionsTag ( )
inlineprivate

Definition at line 58 of file EshelbianTopologicalDerivative.cpp.

58 {
60 return field_ptr->th_FieldDataVerts;
61 }

Friends And Related Symbol Documentation

◆ cohesiveEvaluateObjectiveAndGradient

MoFEMErrorCode cohesiveEvaluateObjectiveAndGradient ( Tao  tao,
Vec  x,
PetscReal *  f,
Vec  g,
void *  ctx 
)
friend

Definition at line 1332 of file EshelbianCohesive.cpp.

1334 {
1335
1337 auto cohesive_ctx = static_cast<CohesiveTAOCtxImpl *>(ctx);
1338 auto &ep = *(cohesive_ctx->ep_ptr);
1339
1340#ifndef NDEBUG
1341 CHKERR VecView(delta_kappa, PETSC_VIEWER_STDOUT_WORLD);
1342#endif
1343 // Set delta_kappa values to the tag
1344 CHKERR VecCopy(delta_kappa, cohesive_ctx->kappaVec.second);
1345 CHKERR VecGhostUpdateBegin(cohesive_ctx->kappaVec.second, INSERT_VALUES,
1346 SCATTER_FORWARD);
1347 CHKERR VecGhostUpdateEnd(cohesive_ctx->kappaVec.second, INSERT_VALUES,
1348 SCATTER_FORWARD);
1350 ep.mField.get_moab(), cohesive_ctx->kappaVec,
1351 get_delta_kappa_tag(ep.mField.get_moab()));
1352
1353 // solve primal problem
1354 CHKERR evaluatePrimalProblemCohesiveImpl(ep, cohesive_ctx->timeSolver,
1355 cohesive_ctx->kspSolVec);
1356 // solve adjoint problem to get lambda
1357 auto ksp = snesGetKSP(tsGetSNES(cohesive_ctx->timeSolver));
1358 CHKERR evaluateCohesiveLambdaImpl(ep, cohesive_ctx->setIntegrationAtFrontFace,
1359 ksp, cohesive_ctx->lambdaVec);
1360 // evaluate dissipation and its gradient
1362 ep, cohesive_ctx->setIntegrationAtFrontFace, cohesive_ctx->lambdaVec,
1363 cohesive_ctx->dissipationVec, cohesive_ctx->gradDissipationVec);
1364
1365 CHKERR VecSum(cohesive_ctx->dissipationVec.second, f);
1366 CHKERR VecCopy(cohesive_ctx->gradDissipationVec.second, g);
1367
1368 MOFEM_LOG("EP", Sev::inform)
1369 << "Cohesive objective function (negative total dissipation): " << *f;
1370
1372}
#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.
#define MOFEM_LOG(channel, severity)
Log.
Tag get_delta_kappa_tag(moab::Interface &moab)
static MoFEMErrorCode evaluateDissipationAndGradImpl(EshelbianCore &ep, ForcesAndSourcesCore::GaussHookFun set_integration_at_front_face, SmartPetscObj< Vec > lambda_vec, CommInterface::EntitiesPetscVector &dissipation_vec, CommInterface::EntitiesPetscVector &grad_dissipation_vec)
static MoFEMErrorCode evaluatePrimalProblemCohesiveImpl(EshelbianCore &ep, SmartPetscObj< TS > ts, SmartPetscObj< Vec > x)
static MoFEMErrorCode evaluateCohesiveLambdaImpl(EshelbianCore &ep, ForcesAndSourcesCore::GaussHookFun set_integration_at_front_face, SmartPetscObj< KSP > ksp, SmartPetscObj< Vec > lambda_vec)
auto snesGetKSP(SNES snes)
auto tsGetSNES(TS ts)
constexpr double g
static MoFEMErrorCode setTagFromVector(moab::Interface &moab, EntitiesPetscVector &vec, Tag tag)

◆ testTopologicalDerivative

MoFEMErrorCode testTopologicalDerivative ( TopologicalTAOCtx ctx_ptr,
const double  alpha,
const double  rho,
const double  alpha_omega 
)
friend

Definition at line 100 of file EshelbianTopologicalDerivative.cpp.

102 {
103
105 auto *ctx_impl_ptr = dynamic_cast<TopologicalTAOCtxImpl *>(ctx_ptr);
106 if (!ctx_impl_ptr)
107 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
108 "Invalid context pointer type");
109 auto &ep = *ctx_impl_ptr->ep_ptr;
110 auto &m_field = ep.mField;
111 auto interior_integration_hook = ctx_impl_ptr->integrationAtInterior;
112 auto boundary_integration_hook = ctx_impl_ptr->integrationAtFace;
113 auto th_top_tag = ctx_impl_ptr->getVertexMaterialH1PositionsTag();
114 auto th_grad_tag = ctx_impl_ptr->getJdXTag(m_field.get_moab());
115
116 boost::shared_ptr<double> J_ptr = boost::make_shared<double>(0.);
117 auto dJ_dX_vec = ctx_impl_ptr->gradJVec.second;
118
119 auto fe_spatial =
120 boost::make_shared<VolumeElementForcesAndSourcesCore>(m_field);
121 auto dJ_dx_vec = pushTopologicalSpatialOps(
122 ep, fe_spatial, interior_integration_hook, boundary_integration_hook);
123 auto fe_material =
124 boost::make_shared<VolumeElementForcesAndSourcesCore>(m_field);
125 CHKERR pushTopologicalMaterialOps(ep, fe_material, interior_integration_hook,
126 boundary_integration_hook, J_ptr,
127 th_grad_tag);
128
129 auto lambda_vec = createDMVector(ep.dmElastic);
130 auto ksp = snesGetKSP(tsGetSNES(ctx_impl_ptr->timeSolver));
131 CHKERR KSPSolveTranspose(ksp, dJ_dx_vec, lambda_vec);
132
133 auto fe_adjoint =
134 boost::make_shared<VolumeElementForcesAndSourcesCore>(m_field);
135 auto dJ_adjoint_vec = pushTopologicalOps_dJ_adjont_gradient(
136 ep, fe_adjoint, interior_integration_hook, boundary_integration_hook,
137 lambda_vec, dJ_dX_vec, alpha, rho, alpha_omega);
138
140}
@ MOFEM_DATA_INCONSISTENCY
Definition definitions.h:31
auto createDMVector(DM dm)
Get smart vector from DM.
Definition DMMoFEM.hpp:1234
MoFEMErrorCode pushTopologicalOps_dJ_adjont_gradient(EshelbianCore &ep, boost::shared_ptr< VolumeElementForcesAndSourcesCore > fe, ForcesAndSourcesCore::GaussHookFun interior_integration_hook, ForcesAndSourcesCore::GaussHookFun boundary_integration_hook, SmartPetscObj< Vec > lambda_vec, Tag th_grad_tag, const double alpha, const double rho, const double alpha_omega)
SmartPetscObj< Vec > pushTopologicalSpatialOps(EshelbianCore &ep, boost::shared_ptr< VolumeElementForcesAndSourcesCore > fe, ForcesAndSourcesCore::GaussHookFun interior_integration_hook, ForcesAndSourcesCore::GaussHookFun boundary_integration_hook)
MoFEMErrorCode pushTopologicalMaterialOps(EshelbianCore &ep, boost::shared_ptr< VolumeElementForcesAndSourcesCore > fe, ForcesAndSourcesCore::GaussHookFun interior_integration_hook, ForcesAndSourcesCore::GaussHookFun boundary_integration_hook, boost::shared_ptr< double > J_ptr, Tag th_grad_tag)
double rho
Definition plastic.cpp:144

Member Data Documentation

◆ ep_ptr

EshelbianCore* EshelbianPlasticity::TopologicalTAOCtxImpl::ep_ptr
private

Definition at line 46 of file EshelbianTopologicalDerivative.cpp.

◆ geometryVec

CommInterface::EntitiesPetscVector EshelbianPlasticity::TopologicalTAOCtxImpl::geometryVec
private

Definition at line 51 of file EshelbianTopologicalDerivative.cpp.

◆ gradJVec

CommInterface::EntitiesPetscVector EshelbianPlasticity::TopologicalTAOCtxImpl::gradJVec
private

Definition at line 52 of file EshelbianTopologicalDerivative.cpp.

◆ integrationAtFace

ForcesAndSourcesCore::GaussHookFun EshelbianPlasticity::TopologicalTAOCtxImpl::integrationAtFace
private

Definition at line 48 of file EshelbianTopologicalDerivative.cpp.

◆ integrationAtInterior

ForcesAndSourcesCore::GaussHookFun EshelbianPlasticity::TopologicalTAOCtxImpl::integrationAtInterior
private

Definition at line 47 of file EshelbianTopologicalDerivative.cpp.

◆ timeSolver

SmartPetscObj<TS> EshelbianPlasticity::TopologicalTAOCtxImpl::timeSolver
private

Definition at line 49 of file EshelbianTopologicalDerivative.cpp.


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