Step 4 — Prepare the center band
ALLSEL,ALL
ESEL,S,CENT,X,0.4*beam_l,0.6*beam_l
CM,mid_elems,ELEM
*GET,n_mid_elems,ELEM,0,COUNT
ALLSEL,ALLWe reused the robust pattern of M02. The component does not depend on IDs and will be the exact scope of the challenge modification.
Step 5 — Audit elements, not pointers
*GET,n_elements,ELEM,0,COUNT
ESEL,S,TYPE,,1
*GET,n_type1,ELEM,0,COUNT
ALLSEL,ALL
ESEL,S,MAT,,1
*GET,n_mat1,ELEM,0,COUNT
ALLSEL,ALL
ESEL,S,MAT,,2
*GET,n_mat2,ELEM,0,COUNT
ALLSEL,ALL
ESEL,S,MAT,,2 asks which elements store material 2. It does not ask which
material is active. The base case passes only if:
n_type1 = n_elements
n_mat1 = n_elements
n_mat2 = 0
0 < n_mid_elems < n_elements
ETLIST,1 and MPLIST,ALL complement the audit: they show the
definitions, while counts demonstrate assignments.
Step 6 — Correct an Existing Assignment
In the challenge, the correct sequence preserves the selected scope:
CMSEL,S,mid_elems
EMODIF,ALL,MAT,2
ALLSEL,ALL
Here ALL means all selected elements. Therefore,
ALLSEL,ALL must come afterward. If you run it first, you will change the entire beam.
MAT=2) after EMODIF is applied to mid_elems.
CSV contract
03_elements_materials.mac generates m03_attribute_audit.csv:
case,n_elements,n_type1,n_mat1,n_mat2,n_mid_elems,young_steel,young_aluminum,young_ratio,passes
We do not set an exact number of elements because it may vary with the mesher or version.
Relationships do express the intent of the model. In the base case,
passes=1 demands that everything be steel; in the challenge, the band must be aluminum and the
modulus ratio must equal 3.
Reusable pattern
! 1. Define
ET,type_id,element_name
MP,EX,material_id,young
! 2. Activate
TYPE,type_id
MAT,material_id
! 3. Create
VMESH,ALL
! 4. Audit
ESEL,S,MAT,,material_id
*GET,n_assigned,ELEM,0,COUNT
ALLSEL,ALL