! ============================================================
! M03 - Bug hunt
! ============================================================
/CLEAR,START                        ! does not represent what it claims to represent.
/FILNAME,m03_bug_hunt,1
/UNITS,SI
/PREP7

beam_l=1.0
beam_h=0.10
beam_b=0.05
mesh_h=0.025

ET,1,SOLID185                       ! ET,1,SOLID185 declares the element type that will be used when meshing.
KEYOPT,1,2,0                        ! KEYOPT,1,2,0 sets the solid bending formulation (no special treatment).

MP,EX,1,210000                      ! MP,EX assigns Young's modulus to material 1 in the property table.
MP,PRXY,1,0.30
MP,EX,2,70E9
MP,PRXY,2,0.33

TYPE,1                              ! TYPE,1 activates the type pointer for elements that will be created next.
MAT,2                               ! MAT,2 activates the material pointer (the error here: it should be MAT,1).

SECNUM,1                            ! SECNUM activates a section number; in solids it does not replace the volume geometry.

BLOCK,0,beam_l,0,beam_h,0,beam_b
ESIZE,mesh_h
VMESH,ALL

ESEL,S,CENT,X,0.4*beam_l,0.6*beam_l
CM,mid_elems,ELEM

! ERROR 4: ALLSEL destroys the selection before it is modified.
ALLSEL,ALL
EMODIF,ALL,MAT,2                    ! EMODIF,ALL,MAT,2 reassigns the material stored on the selected elements.

! ERROR 5: MAT,1 changes the active pointer, not elements already created.
MAT,1

*GET,n_elements,ELEM,0,COUNT
ESEL,S,MAT,,1
*GET,n_mat1,ELEM,0,COUNT
ALLSEL,ALL
ESEL,S,MAT,,2
*GET,n_mat2,ELEM,0,COUNT
ALLSEL,ALL

/COM,DIAGNOSE: units, active attributes, sections, selection scope, assignment
FINISH



