18using namespace PlasticIncrementalOptimizationInternal;
22 :
ep(
ep), timeSolver(
std::move(ts)) {}
28 "Incremental-optimisation control storage is unavailable");
47 field.c_str(), &raw_is);
49 Vec first_block =
nullptr, second_block =
nullptr;
50 CHKERR VecGetSubVector(first, field_is, &first_block);
51 CHKERR VecGetSubVector(second, field_is, &second_block);
52 PetscBool block_equal = PETSC_FALSE;
53 CHKERR VecEqual(first_block, second_block, &block_equal);
54 CHKERR VecRestoreSubVector(second, field_is, &second_block);
55 CHKERR VecRestoreSubVector(first, field_is, &first_block);
69 field.c_str(), &raw_is);
72 CHKERR VecGetSubVector(control, field_is, &block);
73 CHKERR VecZeroEntries(block);
74 CHKERR VecRestoreSubVector(control, field_is, &block);
76 CHKERR VecGhostUpdateBegin(control, INSERT_VALUES, SCATTER_FORWARD);
77 CHKERR VecGhostUpdateEnd(control, INSERT_VALUES, SCATTER_FORWARD);
87 auto &field_snapshot = snapshot[f];
88 auto save = [&](boost::shared_ptr<FieldEntity> field_entity) {
90 auto data = field_entity->getEntFieldData();
91 field_snapshot.emplace(field_entity->getEnt(),
92 std::vector<double>(
data.begin(),
data.end()));
105 std::vector<FieldSnapshot> history;
107 PetscBool same_control = PETSC_FALSE;
111 int local_changed = !
cacheValid || !same_control ||
115 CHKERR MPI_Allreduce(&local_changed, &changed, 1, MPI_INT, MPI_MAX,
150 std::vector<FieldSnapshot> history;
155 CHKERR MPI_Allreduce(&local_changed, &changed, 1, MPI_INT, MPI_MAX,
191 "Zero-increment baseline did not equilibrate (residual %g)",
206 "The conservative gradient needs an equilibrated state");
249 "The selected material does not provide the curvature of the "
250 "reduced mechanical energy");
264 "Mechanical Hessian action requested before prepareHessian()");
274 "Mechanical metric block requested before prepareHessian()");
Eshelbian plasticity interface.
Mechanical equilibrium shared by the incremental-optimisation physics.
SmartPetscObj< Mat > metric
boost::shared_ptr< DataAtIntegrationPts > data
boost::shared_ptr< MatrixDouble > direction
Shared implementation details for plastic incremental optimization.
Plasticity implementation of incremental optimization.
SmartPetscObj< Vec > gradient
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_OPERATION_UNSUCCESSFUL
@ MOFEM_DATA_INCONSISTENCY
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
PetscErrorCode DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode, ScatterMode scatter_mode, RowColData rc=RowColData::COL)
set local (or ghosted) vector values on mesh for partition only
PetscErrorCode DMMoFEMGetFieldIS(DM dm, RowColData rc, const char field_name[], IS *is)
get field is in the problem
auto createDMVector(DM dm, RowColData rc=RowColData::COL)
Get smart vector from DM.
MoFEMErrorCode assemblePlasticAdjointContribution(EshelbianCore &ep, DM flow_output_dm, Vec adjoint, Vec gradient)
MoFEMErrorCode assembleReducedBulkMaterialEnergyGradient(EshelbianCore &ep, TS ts, Vec gradient)
MoFEMErrorCode setStateOnMesh(EshelbianCore &ep, Vec state)
MoFEMErrorCode freezeReducedBulkMaterialEnergyHessian(const ReducedBulkMaterialEnergyHessianWorkspace &source, Vec control, ReducedBulkMaterialEnergyHessianWorkspace &target)
MoFEMErrorCode prepareReducedBulkMaterialEnergyHessian(EshelbianCore &ep, TS ts, Vec control, Vec equilibrated_state, ReducedBulkMaterialEnergyHessianWorkspace &workspace)
PetscInt getReducedBulkMaterialEnergyDirectionalSolveCount(const ReducedBulkMaterialEnergyHessianWorkspace &workspace)
Vec getReducedBulkMaterialEnergyBaseAdjoint(const ReducedBulkMaterialEnergyHessianWorkspace &workspace)
MoFEMErrorCode assembleReducedBulkMaterialEnergyHessianAction(EshelbianCore &ep, TS ts, ReducedBulkMaterialEnergyHessianWorkspace &workspace, Vec direction, Vec action)
boost::shared_ptr< ReducedBulkMaterialEnergyHessianWorkspace > createReducedBulkMaterialEnergyHessianWorkspace()
MoFEMErrorCode assembleReducedBulkMaterialEnergyFlowPreconditioner(EshelbianCore &ep, ReducedBulkMaterialEnergyHessianWorkspace &workspace, Mat preconditioner, bool retain_base_adjoint=true)
MoFEMErrorCode solveEquilibriumStateTS(TopologicalTAOCtxImpl *ctx_impl_ptr)
MoFEMErrorCode evaluateEquilibratedMechanicalValue(EshelbianCore &ep, TS ts, double &value)
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
implementation of Data Operators for Forces and Sources
SmartPetscObj< Vec > vectorDuplicate(Vec vec)
Create duplicate vector of smart vector.
SmartPetscObj< Vec > incrementalTrialControl
MoFEM::Interface & mField
static double currentPhysicalTime
boost::shared_ptr< PhysicalEquations > physicalEquations
SmartPetscObj< DM > dmIncrementalOptimization
PetscInt mechanicalSolveCount
EquilibriumSolveStatus status
std::vector< std::string > stateControlFields
MoFEMErrorCode assembleConservativeGradient(DM control_dm, Vec gradient)
SmartPetscObj< TS > timeSolver
MoFEMErrorCode refreshConservativeGradient(DM control_dm)
MoFEMErrorCode snapshotHistory(std::vector< FieldSnapshot > &snapshot)
MoFEMErrorCode assembleHessianPreconditioner(Mat metric)
SmartPetscObj< Vec > cachedControl
MoFEMErrorCode publishTrialControl()
MoFEMErrorCode restoreState(Vec state)
MoFEMErrorCode solveState(Vec state, EquilibriumSolveReport &report)
double cachedPhysicalTime
MoFEMErrorCode prepareHessian(DM control_dm, Vec control)
MoFEMErrorCode evaluateBaseline(Vec state, double &value)
SmartPetscObj< Vec > cachedState
boost::shared_ptr< PlasticIncrementalOptimizationInternal::ReducedBulkMaterialEnergyHessianWorkspace > gradientWorkspace
boost::shared_ptr< PlasticIncrementalOptimizationInternal::ReducedBulkMaterialEnergyHessianWorkspace > hessianWorkspace
std::vector< std::string > historyFields
std::vector< FieldSnapshot > cachedHistory
MoFEMErrorCode applyHessian(Vec direction, Vec action)
IncrementalMechanics(EshelbianCore &ep, SmartPetscObj< TS > ts)
PetscInt mechanicalSolves
PetscInt getDirectionalSolveCount() const
MoFEMErrorCode evaluateConservativeValue(double &value)
EquilibriumSolveReport cachedReport
SmartPetscObj< Vec > cachedGradient
MoFEMErrorCode stateControlBlocksEqual(Vec first, Vec second, PetscBool &equal)
bool supportsHessianAction() const
MoFEMErrorCode fixedDataAreCurrent(bool ¤t)
MoFEMErrorCode zeroStateControlBlocks(Vec control)
virtual MPI_Comm & get_comm() const =0
intrusive_ptr for managing petsc objects
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.