! ============================================================
! M02 - Caza de errores
! Este archivo se ejecuta, pero contiene cinco defectos logicos.
! No lo uses como plantilla de produccion.
! ============================================================

/CLEAR,START
/FILNAME,m02_bug_hunt,1
/TITLE,M02 - Caza de errores
/UNITS,SI

beam_l=1.0
beam_h=0.10
beam_b=0.05
young=210E9
nu=0.30
mesh_h=0.025

/PREP7
ET,1,SOLID185
MP,EX,1,young
MP,PRXY,1,nu
TYPE,1
MAT,1
BLOCK,0,beam_l,0,beam_h,0,beam_b
ESIZE,mesh_h
VMESH,ALL

ALLSEL,ALL
*GET,n_nodes,NODE,0,COUNT
*GET,n_elements,ELEM,0,COUNT

! DEFECTO 1: una region fisica se identifica mediante IDs.
NSEL,S,NODE,,1,15
CM,fixed_nodes,NODE
ALLSEL,ALL

! DEFECTO 2: ALLSEL se ejecuta antes de guardar la punta.
NSEL,S,LOC,X,beam_l
ALLSEL,ALL
CM,tip_nodes,NODE

! DEFECTO 3: el sistema local no se restaura.
LOCAL,11,CART,beam_l,0,0
CSYS,11
NSEL,S,LOC,X,0
CM,tip_local_nodes,NODE
ALLSEL,ALL

! DEFECTO 4: la tolerancia tiene el orden de la malla.
SELTOL,mesh_h
NSEL,S,LOC,Y,beam_h
CM,top_nodes,NODE
ALLSEL,ALL

! DEFECTO 5: la seleccion parcial de elementos se propaga.
ESEL,S,CENT,X,0.4*beam_l,0.6*beam_l
CM,mid_elems,ELEM
*GET,n_elements_after,ELEM,0,COUNT

*CFOPEN,m02_bug_hunt_audit,csv
*VWRITE
('n_nodes,n_elements,n_elements_after')
*VWRITE,n_nodes,n_elements,n_elements_after
(F10.0,',',F10.0,',',F10.0)
*CFCLOS

/COM,BUG HUNT FINISHED - diagnose five logical defects
FINISH

