v0.16.3
Loading...
Searching...
No Matches
PlasticIncrementalOptimization.cpp
Go to the documentation of this file.
1/**
2 * @file PlasticIncrementalOptimization.cpp
3 * @brief Incremental plasticity optimization
4 */
5
6#define SINGULARITY
7#include <MoFEM.hpp>
8using namespace MoFEM;
9
11
12#include <Lie.hpp>
13#include <MatrixFunction.hpp>
16
17namespace EshelbianPlasticity {
18
19using namespace PlasticIncrementalOptimizationInternal;
20
21namespace PlasticIncrementalOptimizationInternal {
22
25 // Snapshot H_p^n from the quadrature history in Eq. (1.54), label
26 // eq:quadrature-history-update.
27 history.clear();
28 auto save = [&](boost::shared_ptr<FieldEntity> field_entity_ptr) {
30 auto field_data = field_entity_ptr->getEntFieldData();
31 if (field_data.size() != plasticLogarithmicStretchCoordinateSize)
33 "Equilibrated-value test requires five trace-free P0 plasticH "
34 "coordinates per cell; got %zu",
35 field_data.size());
37 std::copy(field_data.begin(), field_data.end(), values.begin());
38 history.emplace(field_entity_ptr->getEnt(), values);
40 };
41 CHKERR ep.mField.getInterface<FieldBlas>()->fieldLambdaOnEntities(
42 save, ep.plasticHField, ep.plasticVolumes.get());
44}
45
47 EshelbianCore &ep, const PlasticHistory &history,
49 const double scale) {
51 // Apply the logarithmic update H_p^{n+1}=H_p^n+Delta H_p from Eq. (1.4),
52 // label eq:logarithmic-update, to the saved P0 coefficients.
53 const auto t_direction_coordinates =
55 auto set = [&](boost::shared_ptr<FieldEntity> field_entity_ptr) {
57 const auto history_it = history.find(field_entity_ptr->getEnt());
58 if (history_it == history.end())
60 "Missing saved plasticH data for entity %llu",
61 static_cast<unsigned long long>(field_entity_ptr->getEnt()));
62 auto field_data = field_entity_ptr->getEntFieldData();
63 if (field_data.size() != history_it->second.size())
65 "Changed plasticH coefficient count while restoring history");
66 std::copy(history_it->second.begin(), history_it->second.end(),
67 field_data.begin());
68 auto t_field = getFTensor1FromPtr<plasticLogarithmicStretchCoordinateSize>(
69 &field_data[0]);
71 t_field(L) += scale * t_direction_coordinates(L);
73 };
74 CHKERR ep.mField.getInterface<FieldBlas>()->fieldLambdaOnEntities(
75 set, ep.plasticHField, ep.plasticVolumes.get());
77}
78
80 PlasticKappaHistory &history) {
82 history.clear();
83 auto save = [&](boost::shared_ptr<FieldEntity> field_entity_ptr) {
85 auto field_data = field_entity_ptr->getEntFieldData();
86 if (field_data.size() != 1)
88 "Committed plastic kappa requires one P0 coefficient per "
89 "cell; got %zu",
90 field_data.size());
91 const double kappa = field_data[0];
92 if (!std::isfinite(kappa) || kappa < 0)
94 "Committed plastic kappa on entity %llu must be finite and "
95 "non-negative; got %g",
96 static_cast<unsigned long long>(field_entity_ptr->getEnt()),
97 kappa);
98 history.emplace(field_entity_ptr->getEnt(), kappa);
100 };
101 CHKERR ep.mField.getInterface<FieldBlas>()->fieldLambdaOnEntities(
102 save, ep.plasticKappaField, ep.plasticVolumes.get());
104}
105
107 const PlasticKappaHistory &history) {
109 auto set = [&](boost::shared_ptr<FieldEntity> field_entity_ptr) {
111 const auto history_it = history.find(field_entity_ptr->getEnt());
112 if (history_it == history.end())
114 "Missing saved plastic kappa for entity %llu",
115 static_cast<unsigned long long>(field_entity_ptr->getEnt()));
116 auto field_data = field_entity_ptr->getEntFieldData();
117 if (field_data.size() != 1)
119 "Changed plastic-kappa coefficient count while restoring "
120 "history");
121 field_data[0] = history_it->second;
123 };
124 CHKERR ep.mField.getInterface<FieldBlas>()->fieldLambdaOnEntities(
125 set, ep.plasticKappaField, ep.plasticVolumes.get());
127}
128
131 CHKERR ep.mField.getInterface<FieldBlas>()->fieldLambdaOnValues(
132 [](const double) { return 0.; }, ep.plasticFlowField,
133 ep.plasticVolumes.get());
135}
136
139 CHKERR VecGhostUpdateBegin(state, INSERT_VALUES, SCATTER_FORWARD);
140 CHKERR VecGhostUpdateEnd(state, INSERT_VALUES, SCATTER_FORWARD);
142 SCATTER_REVERSE, RowColData::COL);
144}
145
146} // namespace PlasticIncrementalOptimizationInternal
147
151
153 return "plasticity";
154}
155
159
160const std::string &
164
165const std::string &
169
170const std::string &
174
177 boost::ptr_deque<ForcesAndSourcesCore::UserDataOperator> &pipeline) const {
178 // Only transformed quadrature weights are needed. Keep the P0 bases
179 // unchanged while evaluating vector-owned trial coefficients.
181 pipeline, {NOSPACE}, ep.materialH1Positions);
182}
183
188 "Plastic incremental optimization requires -plastic_volume 1 "
189 "and -cohesive_interface_on 0");
192 "Plastic incremental-optimization control DM is not available");
193 if (!timeSolver)
195 "Plastic incremental optimization requires a state TS");
197}
198
200 SmartPetscObj<Vec> &committed_control,
201 SmartPetscObj<Vec> &candidate_control) {
203 committed_control =
207 "Plastic trial-control vector is not available");
208 candidate_control = ep.incrementalTrialControl;
209 // Mesh field data store committed kappa, whereas every vector with this DM
210 // layout stores fresh increments (Delta H_p, Delta kappa).
211 CHKERR VecZeroEntries(committed_control);
212 CHKERR VecZeroEntries(candidate_control);
215 CHKERR PetscOptionsGetReal(PETSC_NULLPTR, "",
216 "-incremental_optimization_yield_stress",
217 &initialYieldStress, PETSC_NULLPTR);
219 PETSC_NULLPTR, "",
220 "-incremental_optimization_isotropic_hardening_modulus",
221 &isotropicHardeningModulus, PETSC_NULLPTR);
222 CHKERR PetscOptionsGetReal(PETSC_NULLPTR, "",
223 "-incremental_optimization_dissipation_epsilon",
224 &dissipationRegularizationEpsilon, PETSC_NULLPTR);
225 if (!std::isfinite(initialYieldStress) || !(initialYieldStress > 0))
227 "Initial plastic yield stress must be finite and positive");
228 if (!std::isfinite(isotropicHardeningModulus) ||
231 "Isotropic hardening modulus must be finite and non-negative");
232 if (!std::isfinite(dissipationRegularizationEpsilon) ||
235 "Plastic dissipation epsilon must be finite and non-negative");
236 PlasticKappaHistory kappa_history;
237 CHKERR savePlasticKappaHistory(ep, kappa_history);
238 MOFEM_LOG("EP", Sev::inform)
239 << "Plastic model parameters: initial yield stress "
240 << initialYieldStress << ", isotropic hardening modulus "
242 << ", dissipation epsilon " << dissipationRegularizationEpsilon
243 << ", constraint scaling sqrt(reference cell volume)";
244
246}
247
263
266 DM constraint_dm, Vec multipliers) {
267 return initialisePlasticInequalityMultipliers(*this, constraint_dm,
268 multipliers);
269}
270
273 Vec committed_control, Vec reference_control) {
275 (void)committed_control;
276 // Both Delta H_p and Delta kappa are fresh increment variables. Committed
277 // kappa remains in mesh field storage.
278 CHKERR VecZeroEntries(reference_control);
280}
281
286
290
297
303
306 double &value) {
307 // The generic "dissipation" slot is the complete local incremental
308 // resistance: irreversible yield work plus stored hardening-energy change.
309 return evaluatePlasticIncrementalResistanceValue(*this, control, value);
310}
311
313 Vec control, Vec smooth_gradient, Vec objective_gradient) {
314 return assembleIncrementalObjectiveGradient(*this, control, smooth_gradient,
315 objective_gradient);
316}
317
320 Vec control, Vec constraints) {
321 return evaluatePlasticInequalityConstraints(*this, control, constraints);
322}
323
326 Vec control, Vec smooth_gradient, Mat jacobian) {
327 return assemblePlasticInequalityJacobian(*this, control, smooth_gradient,
328 jacobian);
329}
330
333 Mat jacobian) {
337 "Fallback plastic Jacobian scratch vector is unavailable");
339 // At the exact cone apex, zero is an admissible subgradient. Away from the
340 // apex, and on the rounded branch, the row depends only on the control.
342 *this, control, fallbackJacobianSmoothGradient, jacobian);
344}
345
346boost::shared_ptr<IncrementalOptimizationContext>
350 auto problem = boost::make_shared<PlasticIncrementalOptimizationProblem>(
351 ep, std::move(ts));
352 return createIncrementalOptimizationContext(problem, std::move(state));
353}
354
356 const boost::shared_ptr<IncrementalOptimizationContext> &context) {
357 if (!context || !context->problem)
359 "Incremental-optimization context has no problem");
360 auto plastic_problem =
361 boost::dynamic_pointer_cast<PlasticIncrementalOptimizationProblem>(
362 context->problem);
363 if (!plastic_problem)
365 "Incremental-optimization problem is not plasticity");
366 return *plastic_problem;
367}
368
371
372 if (!ep.physicalEquations ||
373 !ep.physicalEquations->providesHelmholtzFreeEnergy())
375 "Selected material does not provide the Helmholtz free energy "
376 "required by the equilibrated mechanical value");
378 .any() ||
383 "Equilibrated mechanical value requires explicit logarithmic "
384 "stretch, -grad no_h1, -rotations large, and -no_stretch 0");
385
386 // Keep this threshold identical to setElasticElementToTs(), which selects
387 // I2Function as soon as alphaRho exceeds machine epsilon.
388 if (std::abs(ep.alphaRho) > std::numeric_limits<double>::epsilon())
390 "Incremental optimization currently supports first-order "
391 "pseudo-time relaxation only; set -density_alpha_rho 0");
392
393 if (ep.externalStrainVecPtr && !ep.externalStrainVecPtr->empty())
395 "The material Helmholtz derivative with imposed external strain "
396 "is not implemented");
397 if (ep.crackingOn || (ep.contactFaces && !ep.contactFaces->empty()))
399 "Equilibrated mechanical value does not include cracking or "
400 "contact contributions");
401 if (!ep.internalStressTagName.empty())
403 "Equilibrated mechanical value does not include initial "
404 "internal stress");
405
407}
408
410 EquilibriumSolveReport &report) {
412 // Fixed-control state map S(q) from Eq. (3.5), label gen:eq:state-map; its
413 // plastic specialization is Eq. (1.56), label eq:discrete-state-solve.
414 report = {};
415 if (!ts || !state)
417 "Fixed-control equilibrium requires a TS and a state vector");
418
419 PetscReal initial_dt = 0;
420 CHKERR TSGetTimeStep(ts, &initial_dt);
421 // currentPhysicalTime is the fixed outer load coordinate. TS time is a
422 // local pseudo-time, reset for every TAO trial, and all rates in the state
423 // equations are derivatives with respect to this pseudo-time.
424 CHKERR TSSetStepNumber(ts, 0);
425 CHKERR TSSetTime(ts, 0);
426 CHKERR TSSetSolution(ts, state);
427 CHKERR TSRestartStep(ts);
428 SNES snes = nullptr;
429 PetscBool previous_force_iteration = PETSC_FALSE;
430 CHKERR TSGetSNES(ts, &snes);
431 CHKERR SNESGetForceIteration(snes, &previous_force_iteration);
432 // Re-equilibrate every distinct TAO control. Taking at least one Newton step
433 // keeps the reduced Helmholtz value and adjoint gradient consistent for
434 // line search even when the previous state's residual is below the absolute
435 // SNES tolerance.
436 CHKERR SNESSetForceIteration(snes, PETSC_TRUE);
437 const MoFEMErrorCode solve_error = TSSolve(ts, PETSC_NULLPTR);
438 const MoFEMErrorCode restore_force_error =
439 SNESSetForceIteration(snes, previous_force_iteration);
440 const MoFEMErrorCode restore_dt_error = TSSetTimeStep(ts, initial_dt);
441 CHKERR restore_force_error;
442 CHKERR restore_dt_error;
443 if (solve_error) {
445 report.errorCode = solve_error;
447 }
448
449 TSConvergedReason reason;
450 CHKERR TSGetConvergedReason(ts, &reason);
451 if (reason < 0) {
455 }
456
457 PetscReal pseudo_time = 0;
458 PetscReal final_pseudo_time = 0;
459 CHKERR TSGetTime(ts, &pseudo_time);
460 CHKERR TSGetMaxTime(ts, &final_pseudo_time);
461 const double tolerance =
462 100. * std::numeric_limits<double>::epsilon() *
463 std::max(1., std::abs(static_cast<double>(final_pseudo_time)));
464 if (pseudo_time + tolerance < final_pseudo_time) {
465 if (reason != TS_CONVERGED_ITS) {
469 }
470 PetscInt steps = 0;
471 CHKERR TSGetStepNumber(ts, &steps);
472 MOFEM_LOG("EP", Sev::warning)
473 << "Fixed-control equilibrium reached the TS step limit after " << steps
474 << " steps at pseudo-time " << pseudo_time << " (target "
475 << final_pseudo_time
476 << "); continuing with the final state and checking its rate-free "
477 "equilibrium residual";
478 }
479
481 SCATTER_FORWARD);
482 CHKERR VecGhostUpdateBegin(state, INSERT_VALUES, SCATTER_FORWARD);
483 CHKERR VecGhostUpdateEnd(state, INSERT_VALUES, SCATTER_FORWARD);
484
485 // The last SNES norm belongs to the time-discrete, rate-dependent equation.
486 // It can be small while damping still balances a nonzero mechanical
487 // residual. The reduced Helmholtz gradient
488 // is valid only at the rate-free stationary state, so assemble the same
489 // IFunction with a zero pseudo-time rate and report that residual instead.
490 auto zero_pseudo_rate = vectorDuplicate(state);
491 auto rate_free_residual = vectorDuplicate(state);
492 CHKERR VecZeroEntries(zero_pseudo_rate);
493 CHKERR TSComputeIFunction(ts, pseudo_time, state, zero_pseudo_rate,
494 rate_free_residual, PETSC_FALSE);
495 PetscReal pseudo_time_equation_norm = 0;
496 CHKERR SNESGetFunctionNorm(snes, &pseudo_time_equation_norm);
497 PetscReal rate_free_norm = 0;
498 CHKERR VecNorm(rate_free_residual, NORM_2, &rate_free_norm);
499 MOFEM_LOG("EP", Sev::verbose)
500 << "Pseudo-time equation residual " << pseudo_time_equation_norm
501 << ", rate-free equilibrium residual " << rate_free_norm
502 << " at pseudo-time " << pseudo_time;
503 report.equilibriumNorm = rate_free_norm;
506}
507
508namespace PlasticIncrementalOptimizationInternal {
509
510namespace {
511
512MoFEMErrorCode synchroniseCommitStageError(MPI_Comm comm,
513 MoFEMErrorCode local_error,
514 MoFEMErrorCode &global_error) {
516 const int local_code = static_cast<int>(local_error);
517 int global_code = 0;
518 CHKERR MPI_Allreduce(&local_code, &global_code, 1, MPI_INT, MPI_MAX, comm);
519 global_error = static_cast<MoFEMErrorCode>(global_code);
521}
522
523} // namespace
524
526 EshelbianCore &ep, Vec solution, Vec equilibrated_state,
527 Vec committed_control, Vec candidate_control, Vec reference_control) {
529 // Commit Delta H_p and Delta kappa only after the complete solution passed
530 // validation. Trial vectors never overwrite either mesh history.
531 PlasticHistory plastic_before;
532 PlasticKappaHistory kappa_before;
533 MoFEMErrorCode local_stage_error =
534 ep.plasticVolume ? savePlasticHistory(ep, plastic_before) : 0;
535 MoFEMErrorCode stage_error = 0;
536 CHKERR synchroniseCommitStageError(ep.mField.get_comm(), local_stage_error,
537 stage_error);
538 CHKERR stage_error;
539 local_stage_error =
540 ep.plasticVolume ? savePlasticKappaHistory(ep, kappa_before) : 0;
541 CHKERR synchroniseCommitStageError(ep.mField.get_comm(), local_stage_error,
542 stage_error);
543 CHKERR stage_error;
544 auto control_before = vectorDuplicate(committed_control);
545 auto candidate_before = vectorDuplicate(candidate_control);
546 auto reference_before = vectorDuplicate(reference_control);
547 auto state_before = vectorDuplicate(equilibrated_state);
548 auto mesh_control_before =
550 const auto record_first_error = [](MoFEMErrorCode &first_error,
551 MoFEMErrorCode next_error) {
552 if (!first_error)
553 first_error = next_error;
554 };
555 local_stage_error = VecCopy(committed_control, control_before);
556 record_first_error(local_stage_error,
557 VecCopy(candidate_control, candidate_before));
558 record_first_error(local_stage_error,
559 VecCopy(reference_control, reference_before));
560 record_first_error(local_stage_error,
561 VecCopy(equilibrated_state, state_before));
562 CHKERR synchroniseCommitStageError(ep.mField.get_comm(), local_stage_error,
563 stage_error);
564 CHKERR stage_error;
565 local_stage_error = DMoFEMMeshToLocalVector(
566 ep.dmIncrementalOptimization, mesh_control_before, INSERT_VALUES,
567 SCATTER_FORWARD, RowColData::ROW);
568 CHKERR synchroniseCommitStageError(ep.mField.get_comm(), local_stage_error,
569 stage_error);
570 CHKERR stage_error;
571
572 const auto commit = [&]() {
574 local_stage_error = DMoFEMMeshToLocalVector(
575 ep.dmIncrementalOptimization, solution, INSERT_VALUES,
576 SCATTER_REVERSE, RowColData::ROW);
577 CHKERR synchroniseCommitStageError(ep.mField.get_comm(), local_stage_error,
578 stage_error);
579 if (stage_error)
580 MoFEMFunctionReturnHot(stage_error);
581 std::map<EntityHandle, PackedPlasticCoordinates> plastic_increment;
582 if (ep.plasticVolume) {
583 auto save_increment = [&](boost::shared_ptr<FieldEntity> field_entity) {
585 auto data = field_entity->getEntFieldData();
587 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
588 "Plastic increment does not have five trace-free P0 "
589 "coordinates");
591 std::copy(data.begin(), data.end(), values.begin());
592 plastic_increment.emplace(field_entity->getEnt(), values);
594 };
595 local_stage_error =
596 ep.mField.getInterface<FieldBlas>()->fieldLambdaOnEntities(
597 save_increment, ep.plasticFlowField, ep.plasticVolumes.get());
598 CHKERR synchroniseCommitStageError(
599 ep.mField.get_comm(), local_stage_error, stage_error);
600 if (stage_error)
601 MoFEMFunctionReturnHot(stage_error);
602 auto add_increment = [&](boost::shared_ptr<FieldEntity> field_entity) {
604 auto data = field_entity->getEntFieldData();
605 const auto increment = plastic_increment.find(field_entity->getEnt());
606 if (increment == plastic_increment.end() ||
608 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
609 "Plastic commit entity layout is inconsistent");
610 for (int coordinate = 0;
612 ++coordinate)
613 data[coordinate] += increment->second[coordinate];
615 };
616 local_stage_error =
617 ep.mField.getInterface<FieldBlas>()->fieldLambdaOnEntities(
618 add_increment, ep.plasticHField, ep.plasticVolumes.get());
619 CHKERR synchroniseCommitStageError(
620 ep.mField.get_comm(), local_stage_error, stage_error);
621 if (stage_error)
622 MoFEMFunctionReturnHot(stage_error);
623
624 // The reverse scatter placed Delta kappa in the shared scalar field
625 // layout. Replace it by the accumulated mesh history kappa_n+1.
626 auto add_kappa_increment =
627 [&](boost::shared_ptr<FieldEntity> field_entity) {
629 auto data = field_entity->getEntFieldData();
630 const auto history = kappa_before.find(field_entity->getEnt());
631 if (history == kappa_before.end() || data.size() != 1)
632 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
633 "Plastic-kappa commit entity layout is inconsistent");
634 const double delta_kappa = data[0];
635 if (!std::isfinite(delta_kappa))
636 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA,
637 "Accepted plastic-kappa increment on entity %llu must "
638 "be finite; got %g",
639 static_cast<unsigned long long>(field_entity->getEnt()),
640 delta_kappa);
641 // Feasibility has already been checked with TAO's configured
642 // tolerance. Clamp a tolerated negative residue so that the
643 // committed history remains exactly irreversible.
644 data[0] = history->second + std::max(0., delta_kappa);
646 };
647 local_stage_error =
648 ep.mField.getInterface<FieldBlas>()->fieldLambdaOnEntities(
649 add_kappa_increment, ep.plasticKappaField,
650 ep.plasticVolumes.get());
651 CHKERR synchroniseCommitStageError(
652 ep.mField.get_comm(), local_stage_error, stage_error);
653 if (stage_error)
654 MoFEMFunctionReturnHot(stage_error);
655 }
656 // Both TAO blocks remain increment-only. Keep accepted Delta H_p on the
657 // mesh until the step monitor writes it; mesh plasticKappa already stores
658 // the accumulated value and is never cleared by the physical-step driver.
659 local_stage_error = VecZeroEntries(committed_control);
660 record_first_error(local_stage_error, VecZeroEntries(candidate_control));
661 record_first_error(local_stage_error, VecZeroEntries(reference_control));
662 CHKERR synchroniseCommitStageError(ep.mField.get_comm(), local_stage_error,
663 stage_error);
664 if (stage_error)
665 MoFEMFunctionReturnHot(stage_error);
667 };
668
669 const MoFEMErrorCode commit_error = commit();
670 if (commit_error) {
671 const FTensor::Tensor2_symmetric<double, SPACE_DIM> t_zero(0., 0., 0., 0.,
672 0., 0.);
673 const MoFEMErrorCode restore_plastic_error =
674 ep.plasticVolume ? setPlasticHistory(ep, plastic_before, t_zero, 0.)
675 : 0;
676 const MoFEMErrorCode restore_control_error =
677 VecCopy(control_before, committed_control);
678 const MoFEMErrorCode restore_candidate_error =
679 VecCopy(candidate_before, candidate_control);
680 const MoFEMErrorCode restore_reference_error =
681 VecCopy(reference_before, reference_control);
682 const MoFEMErrorCode restore_mesh_control_error = DMoFEMMeshToLocalVector(
683 ep.dmIncrementalOptimization, mesh_control_before, INSERT_VALUES,
684 SCATTER_REVERSE, RowColData::ROW);
685 const MoFEMErrorCode restore_kappa_error =
686 ep.plasticVolume ? setPlasticKappaHistory(ep, kappa_before) : 0;
687 const MoFEMErrorCode restore_state_error =
688 VecCopy(state_before, equilibrated_state);
689 // Do not return between paired ghost-update calls during rollback. Every
690 // rank completes the same communication sequence before errors are
691 // reduced and reported below.
692 const MoFEMErrorCode restore_state_ghost_begin_error =
693 VecGhostUpdateBegin(equilibrated_state, INSERT_VALUES,
694 SCATTER_FORWARD);
695 const MoFEMErrorCode restore_state_ghost_end_error =
696 VecGhostUpdateEnd(equilibrated_state, INSERT_VALUES,
697 SCATTER_FORWARD);
698 const MoFEMErrorCode restore_mesh_state_error = DMoFEMMeshToLocalVector(
699 ep.dmElastic, equilibrated_state, INSERT_VALUES, SCATTER_REVERSE,
701 MoFEMErrorCode local_restore_error = restore_plastic_error;
702 if (!local_restore_error)
703 local_restore_error = restore_control_error;
704 if (!local_restore_error)
705 local_restore_error = restore_candidate_error;
706 if (!local_restore_error)
707 local_restore_error = restore_reference_error;
708 if (!local_restore_error)
709 local_restore_error = restore_mesh_control_error;
710 if (!local_restore_error)
711 local_restore_error = restore_kappa_error;
712 if (!local_restore_error)
713 local_restore_error = restore_state_error;
714 if (!local_restore_error)
715 local_restore_error = restore_state_ghost_begin_error;
716 if (!local_restore_error)
717 local_restore_error = restore_state_ghost_end_error;
718 if (!local_restore_error)
719 local_restore_error = restore_mesh_state_error;
720 MoFEMErrorCode restore_error = 0;
721 CHKERR synchroniseCommitStageError(ep.mField.get_comm(),
722 local_restore_error, restore_error);
723 CHKERR restore_error;
724 CHKERR commit_error;
725 }
727}
728
729} // namespace PlasticIncrementalOptimizationInternal
730
732 DM constraint_dm, Vec control, Vec smooth_gradient,
733 Vec inequality_multipliers, PetscReal gradient_tolerance,
734 PetscReal constraint_tolerance, std::string &diagnostics) {
736 *this, constraint_dm, control, smooth_gradient, inequality_multipliers,
737 gradient_tolerance, constraint_tolerance, diagnostics);
738}
739
741 Vec solution, Vec equilibrated_state, Vec committed_control,
742 Vec candidate_control, Vec reference_control) {
744 ep, solution, equilibrated_state, committed_control, candidate_control,
745 reference_control);
746}
747
755
756} // namespace EshelbianPlasticity
Eshelbian plasticity interface.
boost::shared_ptr< IncrementalOptimizationContext > context
Lie algebra implementation.
Shared implementation details for plastic incremental optimization.
Plasticity implementation of incremental optimization.
#define FTENSOR_INDEX(DIM, I)
@ COL
@ ROW
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
@ NOSPACE
Definition definitions.h:83
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_OPERATION_UNSUCCESSFUL
Definition definitions.h:34
@ MOFEM_DATA_INCONSISTENCY
Definition definitions.h:31
@ MOFEM_INVALID_DATA
Definition definitions.h:36
@ MOFEM_NOT_IMPLEMENTED
Definition definitions.h:32
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
double kappa
PetscErrorCode DMMoFEMAddElement(DM dm, std::string fe_name)
add element to dm
Definition DMMoFEM.cpp:488
PetscErrorCode DMMoFEMAddSubFieldRow(DM dm, const char field_name[])
Definition DMMoFEM.cpp:238
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
Definition DMMoFEM.cpp:514
auto createDMVector(DM dm, RowColData rc=RowColData::COL)
Get smart vector from DM.
Definition DMMoFEM.hpp:1237
PetscErrorCode DMMoFEMAddSubFieldCol(DM dm, const char field_name[])
Definition DMMoFEM.cpp:280
#define MOFEM_LOG(channel, severity)
Log.
MoFEMErrorCode assemblePlasticInequalityJacobian(PlasticIncrementalOptimizationProblem &problem, Vec control, Vec smooth_gradient, Mat jacobian)
MoFEMErrorCode setPlasticHistory(EshelbianCore &ep, const PlasticHistory &history, const FTensor::Tensor2_symmetric< double, SPACE_DIM > &t_direction, const double scale)
MoFEMErrorCode assembleIncrementalObjectiveGradient(PlasticIncrementalOptimizationProblem &problem, Vec control, Vec smooth_gradient, Vec objective_gradient)
MoFEMErrorCode initialisePlasticInequalityMultipliers(const PlasticIncrementalOptimizationProblem &problem, DM constraint_dm, Vec multipliers)
MoFEMErrorCode setPlasticKappaHistory(EshelbianCore &ep, const PlasticKappaHistory &history)
MoFEMErrorCode savePlasticHistory(EshelbianCore &ep, PlasticHistory &history)
MoFEMErrorCode evaluatePlasticInequalityConstraints(const PlasticIncrementalOptimizationProblem &problem, Vec control, Vec constraints)
std::array< double, plasticLogarithmicStretchCoordinateSize > PackedPlasticCoordinates
MoFEMErrorCode savePlasticKappaHistory(EshelbianCore &ep, PlasticKappaHistory &history)
MoFEMErrorCode validatePlasticIncrementalSolution(PlasticIncrementalOptimizationProblem &problem, DM constraint_dm, Vec control, Vec smooth_gradient, Vec inequality_multipliers, PetscReal gradient_tolerance, PetscReal constraint_tolerance, std::string &diagnostics)
MoFEMErrorCode evaluatePlasticIncrementalResistanceValue(const PlasticIncrementalOptimizationProblem &problem, Vec control, double &value)
FTensor::Tensor1< double, plasticLogarithmicStretchCoordinateSize > plasticLogarithmicStretchCoordinatesFromTensor(const FTensor::Tensor2_symmetric< T, SPACE_DIM > &t_values)
MoFEMErrorCode assembleReducedHelmholtzGradient(EshelbianCore &ep, TS ts, Vec gradient)
MoFEMErrorCode commitIncrementalOptimizationLoadStep(EshelbianCore &ep, Vec solution, Vec equilibrated_state, Vec committed_control, Vec candidate_control, Vec reference_control)
boost::shared_ptr< IncrementalOptimizationContext > createIncrementalOptimizationContext(boost::shared_ptr< IncrementalOptimizationProblem > problem, SmartPetscObj< Vec > state)
MoFEMErrorCode validateEquilibratedMechanicalValueScope(EshelbianCore &ep)
boost::shared_ptr< IncrementalOptimizationContext > createPlasticIncrementalOptimizationContext(EshelbianCore &ep, SmartPetscObj< TS > ts, SmartPetscObj< Vec > state)
MoFEMErrorCode solveEquilibriumStateTS(TopologicalTAOCtxImpl *ctx_impl_ptr)
MoFEMErrorCode solveIncrementalOptimizationTAO(const boost::shared_ptr< IncrementalOptimizationContext > &context, Vec state)
MoFEMErrorCode evaluateEquilibratedMechanicalValue(EshelbianCore &ep, TS ts, double &value)
PlasticIncrementalOptimizationProblem & getPlasticIncrementalOptimizationProblem(const boost::shared_ptr< IncrementalOptimizationContext > &context)
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
implementation of Data Operators for Forces and Sources
Definition Common.hpp:10
PetscErrorCode PetscOptionsGetReal(PetscOptions *, const char pre[], const char name[], PetscReal *dval, PetscBool *set)
SmartPetscObj< Vec > vectorDuplicate(Vec vec)
Create duplicate vector of smart vector.
SmartPetscObj< Vec > incrementalTrialControl
boost::shared_ptr< ExternalStrainVec > externalStrainVecPtr
static enum StretchSelector stretchSelector
boost::shared_ptr< Range > contactFaces
MoFEM::Interface & mField
boost::shared_ptr< Range > plasticVolumes
const std::string materialH1Positions
static PetscBool crackingOn
const std::string elementVolumeName
static enum RotSelector rotSelector
static enum RotSelector gradApproximator
const std::string plasticHField
const std::string plasticFlowField
MoFEMErrorCode runIncrementalOptimizationTAO(TS ts, Vec x)
boost::shared_ptr< PhysicalEquations > physicalEquations
static std::string internalStressTagName
static PetscBool plasticVolume
static PetscBool interfaceCrack
SmartPetscObj< DM > dmElastic
Elastic problem.
const std::string plasticKappaField
SmartPetscObj< DM > dmIncrementalOptimization
Incremental-optimization control problem.
MoFEMErrorCode initialiseInequalityMultipliers(DM constraint_dm, Vec multipliers) override
MoFEMErrorCode assembleConservativeGradient(Vec smooth_gradient) override
MoFEMErrorCode initialiseReferenceControl(Vec committed_control, Vec reference_control) override
MoFEMErrorCode createControlData(SmartPetscObj< Vec > &committed_control, SmartPetscObj< Vec > &candidate_control) override
MoFEMErrorCode assembleObjectiveGradient(Vec control, Vec smooth_gradient, Vec objective_gradient) override
MoFEMErrorCode solveState(Vec state, EquilibriumSolveReport &report) override
PlasticIncrementalOptimizationProblem(EshelbianCore &ep, SmartPetscObj< TS > ts)
MoFEMErrorCode evaluateInequalityConstraints(Vec control, Vec constraints) override
MoFEMErrorCode commit(Vec solution, Vec equilibrated_state, Vec committed_control, Vec candidate_control, Vec reference_control) override
MoFEMErrorCode validateSolution(DM constraint_dm, Vec control, Vec smooth_gradient, Vec inequality_multipliers, PetscReal gradient_tolerance, PetscReal constraint_tolerance, std::string &diagnostics) override
MoFEMErrorCode evaluateDissipation(Vec control, double &value) override
MoFEMErrorCode assembleInequalityJacobian(Vec control, Vec smooth_gradient, Mat jacobian) override
MoFEMErrorCode assembleInequalityJacobianWithoutSmoothGradient(Vec control, Mat jacobian) override
MoFEMErrorCode addConstitutiveGeometryOperators(boost::ptr_deque< ForcesAndSourcesCore::UserDataOperator > &pipeline) const
Add operators pushing bases from local to physical configuration.
virtual MPI_Comm & get_comm() const =0
Basic algebra on fields.
Definition FieldBlas.hpp:21
intrusive_ptr for managing petsc objects
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
double scale
Definition plastic.cpp:123