Marc & Structures
Course index

Save your progress

Enter your email and we will send a secure sign-in link. There is no password and the first link creates your account.

Meshing, quality, and convergence

ESIZE, LESIZE, MSHAPE, MSHKEY, SHPP, CHECK, VCLEAR, and convergence

On this page
  1. Objectives
  2. Prerequisites and downloads
  3. How to use this lesson
  4. Session map
  5. Prediction — How much does it cost to divide h by two?
  6. Mental model — Three different questions
  7. Anatomy of a comparable family
  8. Step 1 — From nominal size to divisions
  9. Step 2 — ESIZE vs LESIZE
  10. Step 3 — Require mapped hexahedrons
  11. Step 4 — Create the mesh audit record
  12. Step 5 — Turn quality into a test
  13. Step 6 — The inherited test case
  14. Step 7 — Clean without destroying the geometry
  15. Step 8 — Automate the family
  16. Step 9 — Measure convergence
  17. Step 10 — Make a defensible decision
  18. Why don't we use maximum stress?
  19. The CSV as a record of the study
  20. Bug hunting
  21. Verifiable challenge — When mesh_h does not divide the part exactly
  22. Self-assessment
  23. Evidence of learning
  24. Exit checklist
  25. Technical traceability

The model already contains a consistent geometry, element, and material. Now we must decide how much discretization you need. We will not choose a mesh for its appearance: we will build a comparable family, we will audit it and let a Physical magnitude determines when refining stops substantially changing the response.

Your mission

You will generate three structured hexahedral meshes, you will check their topology and quality, you will measure the tip displacement with the same test case and select the first mesh whose variation compared to the next is less than 2%.

Central rule: an attractive mesh does not demonstrate convergence; a small difference is also meaningless if the cases represent different problems.

Objectives

By completing M04 you will be able to demonstrate that:

  • You distinguish refinement, quality and convergence.
  • You build a hexahedral mesh using parametric divisions.
  • You explain the difference between a global control and one applied to specific lines.
  • You audit topology, attributes, and shape warnings before solving.
  • You keep geometry, material, load and measurement point constant.
  • You calculate the change relative to the next finer mesh.
  • You select a mesh by a stated criterion or conclude that the study is insufficient.

Prerequisites and downloads

  • Have completed M03 and recognize SOLID185, TYPE and MAT.
  • Remember from M02 that a selection is a temporary state and must be recovered with ALLSEL,ALL.
  • Having run the first simulation of M00. Your solution block is reused as an instrument, not new content.

How to use this lesson

TrackDurationScope
Quick win 35–40 min Prediction, first mesh, and mesh audit record.
Complete 70–75 min Also, 40/320/2560 family, convergence and challenge with mesh_h limit.

Recommendation: a beautiful mesh does not demonstrate convergence. You need a comparable family and a monitored magnitude with explicit tolerance.

Session map

  1. Mission: targets, downloads and refinement prediction.
  2. Mental model: quality, convergence, and a defensible decision.
  3. Demo: meshing, quality, family and convergence.
  4. Bug hunting: incomparable meshes and invented convergence.
  5. Challenge: mesh_h which does not cleanly split the part.
  6. Mastery: final test that records demonstrated mastery and recommends M05.

Prediction — How much does it cost to divide h by two?

If we refined a line, we would double its number of elements. But our beam occupies three dimensions. By dividing the size by two we double simultaneously div_x, div_y and div_z:

2 × 2 × 2 = 8
Three hexahedral meshes with 40, 320 and 2560 elements
Two refinements turn 40 elements into 2560: sixty-four times more.

The calculation time does not have to grow exactly with that proportion: it also intervenes the degrees of freedom, connectivity, memory and the solver. But the geometric growth explains why “refining just in case” is an expensive strategy.

Mental model — Three different questions

ConceptQuestionEvidence
RefinementHave we increased the resolution?Divisions, nodes and elements.
QualityAre the elements geometrically acceptable?SHPP,SUMMARY and CHECK.
ConvergenceIs a relevant physical quantity stabilized?Variation of displacement between meshes.

None of the three tests replace the others

A million distorted elements do not make a good mesh. A perfect mesh but too thick can give a stiff response. Two equal results do not prove either nothing if the length or load were changed simultaneously.

Anatomy of a comparable family

A convergence study changes only one decision: discretization. In all three cases we will keep exactly:

  • geometry 1.0 × 0.10 × 0.05 m;
  • SOLID185 with the same formulation;
  • steel with EX=210E9 Pa and PRXY=0.30;
  • fixed support, the total force of -1000 N and its direction;
  • the coordinate of the node used to measure the displacement.

We will also preserve the element family and meshing strategy. Compare tetrahedra thick linear lines with thin hexahedrons would mix two changes and make it difficult to interpret the cause.

Step 1 — From nominal size to divisions

For the base family, the dimensions are exact multiples of the three sizes:

div_x=beam_l/mesh_h
div_y=beam_h/mesh_h
div_z=beam_b/mesh_h

We don't call nx, ny and nz to these parameters: MAPDL reserves those names for intrinsic nodal coordinate functions.

mesh_hnx × ny × nzElementsNodes
0.0500m20 × 2 × 140126
0.0250m40 × 4 × 2320615
0.0125m80 × 8 × 425603645

For a structured block, the theoretical counts are:

n_elements = div_x*div_y*div_z
n_nodes    = (div_x+1)*(div_y+1)*(div_z+1)

These equations provide a strong check: if they do not match, the resulting mesh does not have the structure that the script claimed to build.

Coarse MAPDL mesh 20 by 2 divisions on the L by H face
Figure 2. Coarse mesh: 40 elements (20×2×1). Normal view of the face L×H; convergence is decided with CSV, not visual smoothness.
Medium MAPDL mesh 40 by 4 divisions on the L by H face
Figure 3. Average mesh: 320 elements (40×4×2).
Fine MAPDL mesh 80 by 8 divisions on the L by H face
Figure 4. Fine mesh: 2560 elements (80×8×4).

Step 2 — ESIZE vs LESIZE

ESIZE,mesh_size(i)

ESIZE declares the default global size. MAPDL calculates divisions from of that value, rounding them when necessary. However, a global control does not express alone how we want to distribute elements in each direction.

LSEL,S,LENGTH,,beam_l
LESIZE,ALL,,,div_x(i),,1

LSEL,S,LENGTH,,beam_h
LESIZE,ALL,,,div_y(i),,1

LSEL,S,LENGTH,,beam_b
LESIZE,ALL,,,div_z(i),,1
ALLSEL,ALL

LSEL groups lines by geometric meaning, not by ID. LESIZE,ALL applies integer divisions to selected lines. The argument KFORC=1 forces you to replace any previous division, something necessary after to clean one mesh and prepare the next.

Step 3 — Require mapped hexahedrons

MSHAPE,0,3D
MSHKEY,1
VMESH,ALL

MSHAPE,0,3D requests hexahedrons and MSHKEY,1 requires mapped meshing. We do not use MSHKEY,2, because allowing a free mesh as an alternative could hide a flaw in our preparation. The rectangular block is mappable and the edges opposites receive the same number of divisions.

A free mesh is not "bad." Here we use a regular structure to isolate the effect of the size. In an industrial geometry, the strategy must adapt to the form.

Step 4 — Create the mesh audit record

Before solving, each mesh must demonstrate four properties:

*GET,n_nodes(i),NODE,0,COUNT
*GET,n_elems(i),ELEM,0,COUNT

ESEL,S,TYPE,,1
*GET,n_type1(i),ELEM,0,COUNT
ALLSEL,ALL

ESEL,S,MAT,,1
*GET,n_mat1(i),ELEM,0,COUNT
ALLSEL,ALL

The test passes only when:

n_elems = div_x*div_y*div_z
n_nodes = (div_x+1)*(div_y+1)*(div_z+1)
n_type1 = n_elems
n_mat1  = n_elems

This is how we connect M04 with M03: a finer mesh that loses its attributes is not an improvement of the same model, but another model.

Step 5 — Turn quality into a test

SHPP,DEFAULT
SHPP,ON
...
SHPP,SUMMARY
CHECK,ESEL,WARN
*GET,n_shape_bad(i),ELEM,0,COUNT
ALLSEL,ALL

SHPP,SUMMARY lists the shape-test summary for the selected elements. Then CHECK,ESEL,WARN does something especially useful: it deselects elements with no issues and retains only those that produce warnings or errors. Therefore, n_shape_bad=0 is a condition that can be checked automatically.

CHECK modifies the selection

If you do not execute ALLSEL,ALL afterward, the test case could operate only on the problematic elements or on an empty set.

Step 6 — The inherited test case

To measure convergence we need a physical response. The next block reuses the vertical route that you already executed in M00:

NSEL,S,LOC,X,0
D,ALL,ALL,0
ALLSEL,ALL

NSEL,S,LOC,X,beam_l
*GET,n_tip,NODE,0,COUNT
force_per_node=tip_force/n_tip
F,ALL,FY,force_per_node
ALLSEL,ALL

FINISH
/SOLU
ANTYPE,STATIC,NEW
SOLVE
FINISH

/POST1
SET,LAST
*GET,uy_tip(i),NODE,probe_node,U,Y

In M04 this block works like a laboratory instrument: all its inputs remain constants and only returns one reading. M05 will explain and audit the boundary conditions; M06, the solution and balance; M07, the extraction and validation of results.

The measurement node is selected by X=beam_l, Y=0 and Z=0. That coordinate exists in all meshes. Writing an ID would mix refinement with a change accidental of the observed point.

Step 7 — Clean without destroying the geometry

/PREP7
ALLSEL,ALL
DDELE,ALL,ALL
FDELE,ALL,ALL
CMDELE,fixed_nodes
CMDELE,tip_nodes
VCLEAR,ALL

VCLEAR,ALL removes the elements and nodes associated with the volume, but retains the solid model and its attributes. Change ESIZE without cleaning and remeshing no refines an existing mesh: only changes a preference for future operations.

Step 8 — Automate the family

*DIM,mesh_size,ARRAY,3
mesh_size(1)=0.0500
mesh_size(2)=0.0250
mesh_size(3)=0.0125

*DO,i,1,3
  ! divisions, meshing, audit, measurement, and cleanup
*ENDDO

The loop does not create three separate handwritten studies. It ensures that all cases follow exactly the same sequence and reduces the chances of changing a condition inadvertently.

Step 9 — Measure convergence

change_pct(1)=ABS(uy_tip(2)-uy_tip(1))/ABS(uy_tip(2))*100
change_pct(2)=ABS(uy_tip(3)-uy_tip(2))/ABS(uy_tip(3))*100
change_pct(3)=-1

Each mesh is compared to the next finest, used as an improved estimate. The last it cannot be compared with itself; the value -1 means "without comparison", not perfect convergence.

Convergence curve and selection of the first mesh with variation less than two percent
The mesh is accepted only if it passes both the passport and the response criteria.

Step 10 — Make a defensible decision

The algorithm runs through the comparisons from the most economical mesh:

selected_case=0

! If change 1→2 < 2% and both meshes pass:
!   selected_case=1
! Otherwise, test change 2→3.
! If that also fails:
!   selected_case=0

We never automatically choose mesh 3 because it is the finest available. If the last comparison exceeds the threshold, the study is inconclusive and needs another mesh.

Why don't we use maximum stress?

Ideal fixed support introduces an abrupt transition between fully constrained nodes and free material. A point stress next to that boundary can grow or move during refinement, even when the global displacement is already stable. Choosing it as the only criterion would confuse convergence of a global magnitude with potentially singular local behavior.

In M07 we will compare stresses in justifiable regions and separate nominal stress, physical concentration and numerical singularity.

The CSV as a record of the study

04_mesh_convergence.mac generates m04_mesh_study.csv:

case,mesh_h,nx,ny,nz,n_nodes,n_elements,n_type1,n_mat1,uy_tip,change_to_next_pct,mesh_pass,selected

It must contain three rows. Only one may have selected=1; it is also valid for all are zero if no comparison satisfies. The CSV records intent, cost, audit, response and decision in the same reproducible evidence.

Validated reference result

In MAPDL Student 2025 R2, variations of approximately 1.168 % and 0.501 %. With a threshold of 2%, the algorithm selects case 1. The result is deliberately interesting: “first acceptable mesh” is not means "finest mesh available."

Bug hunting

Run 04_bug_hunt.mac and write for each defect: symptom, cause, evidence and correction. Look for five contaminations:

  1. The length declared for the second case no longer matches that of the first.
  2. It changes ESIZE unexecuted VCLEAR and mesh again.
  3. Applies -1000 N to each tip node instead of conserving total force.
  4. The measuring point is identified by a fixed ID.
  5. The mesh with the most elements is chosen without calculating any physical variation.

Verifiable challenge — When mesh_h does not divide the part exactly

Complete 04_challenge.mac with sizes 0.04, 0.02 and 0.01 m. In the first case, beam_h/mesh_h=2.5: one line cannot contain two and a half elements.

Your script should:

  1. Declare a policy to convert each quotient to an integer number of divisions.
  2. Inform the nominal size and the divisions actually used.
  3. Build the mesh without line, node or element IDs.
  4. Recheck the topological equations with the adopted integers.
  5. Generate the same CSV and select a mesh only if it meets the 2%.

The decision is part of the model

Rounding to the nearest integer approximates the nominal size. Always rounding up ensures that the actual size does not exceed it. Either choice must be explicit and applied consistently; do not silently delegate the decision to the mesher.

Self-assessment

  1. Why do approximately eight times as many elements appear when dividing the size by two?
  2. What practical difference exists between ESIZE and LESIZE?
  3. Which set remains active after CHECK,ESEL,WARN?
  4. Why can't the last mesh have a change with respect to itself?
  5. What should you conclude if selected_case=0?
> See short answers
  1. Because the divisions are duplicated in three directions: 2³=8.
  2. ESIZE is global; LESIZE controls selected lines and can impose divisions.
  3. Only items that produce warnings or check errors.
  4. Convergence needs independent finer estimation.
  5. That the study does not allow a choice: another mesh must be added or the family must be revised.

Evidence of learning

  • m04_mesh_study.csv with three cases.
  • Topological counts coincident with divisions.
  • Summary SHPP and n_shape_bad=0.
  • A graph of |uy_tip| versus the number of elements.
  • The selected mesh and a justification based on cost and variation.
  • The diagnosis of the five defects.

Exit checklist

  • ☐ My three cases only differ in the discretization.
  • ☐ The divisions are obtained from parameters and not from IDs.
  • ☐ The real topology matches the expected one.
  • ☐ TYPE, MAT and form approve before solving.
  • ☐ The total load and the measurement point remain constant.
  • ☐ Each change uses the next finer mesh as its reference.
  • ☐ I accept selected_case=0 as a valid conclusion.
  • ☐ I do not use the singular stress of the fixed support as a criterion.

Technical traceability

The lesson uses Modeling and Meshing Guide for the mapped strategy; Command Reference 2024 R1 for ESIZE, LESIZE, MSHAPE, MSHKEY, SHPP, CHECK and VCLEAR; and Element Reference for SOLID185.

Next step: M05

The test case has kept its boundary conditions constant. In M05 we will stop treating them as a preconfigured black box: we will translate the physical diagram into constraints and loads, and audit their resultant before solving.

Show that you can do it without hints

You need at least 80% and every critical check correct. You can retry without a limit; each attempt gives you a focused review path.

8 checks

Competency

Choose a mesh based on quality and convergence.

Expected evidence

Relative variation of displacement below 2%.

Save mastery across devices

Enter your email to receive a secure link. Your account stores only progress, attempts, and scores.

1.What does a single mesh with a smooth contour show? Critical
2.Enter the percentage variation threshold used to accept convergence. Critical
%
3.Which sequence represents increasing refinement?
4.SHPP reports poorly shaped elements. What do you do? Critical
5.Prediction: if mesh_h decreases while maintaining the geometry, what do you normally expect?
6.No pair of meshes meets the 2%. What should the script record? Critical
7.Mesh refinement accidentally changes one region material. Is the convergence study valid? Retrieval M03
8.Why restore ALLSEL before counting the full mesh? Retrieval M02

The assessment is scored and progress is saved in this browser.