# EXPORT CONTROLLED — ITAR USML Category XX  (Ocean Guard M04)
# Code_Aster STAT_NON_LINE nonlinear collapse — 1.5x MAWP elastoplastic large-displacement.
# Auto-generated by gate_codeaster_nonlinear.py. Do not hand-edit.
DEBUT(LANG='EN')

MESH = LIRE_MAILLAGE(FORMAT='MED', UNITE=20)

MODEL = AFFE_MODELE(
    MAILLAGE=MESH,
    AFFE=_F(TOUT='OUI', PHENOMENE='MECANIQUE', MODELISATION='3D'),
)

# Al-5083-H321: elastoplastic (linear kinematic hardening ECRO_LINE).
MAT = DEFI_MATERIAU(
    ELAS=_F(E=7.100000e+10, NU=0.3300),
    ECRO_LINE=_F(D_SIGM_EPSI=7.100000e+08, SY=2.150000e+08),
)

FIELDMAT = AFFE_MATERIAU(MAILLAGE=MESH, AFFE=_F(TOUT='OUI', MATER=MAT))

# ── Rigid-body-mode elimination (2026-07-10 fix, SIMPLIFIED 2026-07-10
# post-box-run — see generate_comm_file() docstring for full rationale).
# Whole-face isostatic restraint (FWD_FACE, DX=DY=DZ=0) is the PRIMARY and
# ONLY path: Aster 17.4.0 (spack-built) has removed the legacy MAIL_PY
# runtime mesh-introspection helper package the previous
# runtime-node-introspection (PT_FIX/PT_ROT) path depended on (box-confirmed
# ModuleNotFoundError), so that path was unreachable dead code and this
# restraint is now applied unconditionally instead of behind a try/except
# with no live primary branch.
_ISOSTATIC_BC = (
    _F(GROUP_MA='FWD_FACE', DX=0.0, DY=0.0, DZ=0.0),
)
print("OG_RIGID_BODY_FIX=FULL_FACE_PRIMARY")

# External pressure on the outer hull surface group (group_ma='OUTER').
LOAD = AFFE_CHAR_MECA(
    MODELE=MODEL,
    PRES_REP=_F(GROUP_MA='OUTER', PRES=1.125000e+07),
    DDL_IMPO=_ISOSTATIC_BC,
)

# Ramp 0 -> 1.0 (multiplies test pressure). Load factor lambda = ramp value.
RAMP = DEFI_FONCTION(
    NOM_PARA='INST',
    VALE=(0.0, 0.0, 1.0, 1.0),
    PROL_DROITE='CONSTANT', PROL_GAUCHE='CONSTANT',
)

LINST = DEFI_LIST_REEL(DEBUT=0.0, INTERVALLE=_F(JUSQU_A=1.0, NOMBRE=50))

# Automatic sub-stepping so a limit point is captured as non-convergence,
# not a spurious hard stop — the last converged INST = lambda_collapse.
DLIST = DEFI_LIST_INST(
    METHODE='AUTO',
    DEFI_LIST=_F(LIST_INST=LINST),
    ECHEC=_F(ACTION='DECOUPE', SUBD_METHODE='MANUEL', SUBD_PAS=4, SUBD_NIVEAU=5),
)

# STAT_NON_LINE — large displacement + plasticity (VMIS_ISOT_LINE).
# NOTE (2026-07-03 fix, COMPOR5_22): GROT_GDEP is unusable on MECA_TETRA4
# (linear tets — the current mesh, confirmed via MED element-type scan).
# GROT_GDEP requires either quadratic (MECA_TETRA10) elements or a
# different formulation on linear elements. Aster's own exception text
# recommends GREEN_LAGRANGE as the linear-tet-compatible alternative; used
# here so the gate is unblocked without depending on the mesh-order-2
# pipeline bug (generate_aster_med_mesh.py requests `-order 2` but the
# on-disk M02 .med still contains TE4-only cells — separate open defect,
# tracked for a follow-up mesh-pipeline fix so GROT_GDEP can be restored).
RESU = STAT_NON_LINE(
    MODELE=MODEL,
    CHAM_MATER=FIELDMAT,
    EXCIT=_F(CHARGE=LOAD, FONC_MULT=RAMP),
    COMPORTEMENT=_F(RELATION='VMIS_ISOT_LINE', DEFORMATION='GREEN_LAGRANGE', TOUT='OUI'),
    INCREMENT=_F(LIST_INST=DLIST),
    NEWTON=_F(MATRICE='TANGENTE', REAC_ITER=1),
    CONVERGENCE=_F(RESI_GLOB_RELA=1.0e-6, ITER_GLOB_MAXI=25),
)

# CALC_CHAMP FIX (2026-07-10, box-confirmed <SUPERVIS_4> syntax error): in
# Aster 17.4, SIEQ_* fields (equivalent stress: Von Mises, Tresca, principal
# stresses) are NOT valid under the CONTRAINTE= keyword — CONTRAINTE=
# accepts only genuine stress-tensor fields (EFGE_*/SIEF_*/SIGM_*/SIPM_*/
# SIPO_*/SIRO_ELEM/EGRU_ELNO). SIEQ_* fields belong under the separate
# CRITERES= keyword. Moved accordingly.
RESU = CALC_CHAMP(reuse=RESU, RESULTAT=RESU,
                  CRITERES=('SIEQ_ELGA',), DEFORMATION=('EPSP_ELGA',))

# Print the achieved instants (max converged INST = lambda_collapse) to the .mess.
IMPR_RESU(FORMAT='RESULTAT', RESU=_F(RESULTAT=RESU, NOM_CHAM='DEPL'))

FIN()
