skills/core-numerical/mesh-generation/SKILL.md
Plan and evaluate mesh generation for numerical simulations — estimate grid resolution from physics scales (interface width, boundary layers, wavelengths), check aspect ratios and skewness against quality thresholds, choose between structured, unstructured, and adaptive mesh refinement strategies, and compute grid sizing for 1D/2D/3D domains. Use when setting up a new mesh, diagnosing poor solver convergence caused by mesh quality, deciding how many points to place across a phase-field interface or boundary layer, or preparing a mesh convergence study, even if the user only asks "what resolution do I need" or "why is my solver failing."
npx skillsauth add HeshamFS/materials-simulation-skills mesh-generationInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Provide a consistent workflow for selecting mesh resolution and checking mesh quality for PDE simulations.
| Input | Description | Example |
|-------|-------------|---------|
| Domain size | Physical dimensions | 1.0 × 1.0 m |
| Feature size | Smallest feature to resolve | 0.01 m |
| Points per feature | Resolution requirement | 10 points |
| Aspect ratio limit | Maximum dx/dy ratio | 5:1 |
| Quality threshold | Skewness limit | < 0.8 |
What is the smallest feature size?
├── Interface width → dx ≤ width / 5
├── Boundary layer → dx ≤ layer_thickness / 10
├── Wave length → dx ≤ lambda / 20
└── Diffusion length → dx ≤ sqrt(D × dt) / 2
| Problem | Recommended Mesh | |---------|------------------| | Simple geometry, uniform | Structured Cartesian | | Complex geometry | Unstructured triangular/tetrahedral | | Boundary layers | Hybrid (structured near walls) | | Adaptive refinement | Quadtree/Octree or AMR |
| Script | Key Outputs |
|--------|-------------|
| scripts/grid_sizing.py | dx, nx, ny, nz, notes |
| scripts/mesh_quality.py | aspect_ratio, skewness, quality_flags |
scripts/grid_sizing.pyscripts/mesh_quality.pyUser: I need to mesh a 1mm × 1mm domain for a phase-field simulation with interface width of 10 μm.
Agent workflow:
python3 scripts/grid_sizing.py --length 0.001 --resolution 200 --json
# Compute grid sizing for 1D domain
python3 scripts/grid_sizing.py --length 1.0 --resolution 200 --json
# Check mesh quality
python3 scripts/mesh_quality.py --dx 1.0 --dy 0.5 --dz 0.5 --json
# High aspect ratio check
python3 scripts/mesh_quality.py --dx 1.0 --dy 0.1 --json
| Error | Cause | Resolution |
|-------|-------|------------|
| length must be positive | Invalid domain size | Use positive value |
| resolution must be > 1 | Insufficient points | Use at least 2 |
| dx, dy must be positive | Invalid spacing | Use positive values |
| Aspect Ratio | Quality | Impact | |--------------|---------|--------| | 1:1 | Excellent | Optimal accuracy | | 1:1 - 3:1 | Good | Acceptable | | 3:1 - 5:1 | Fair | May affect accuracy | | > 5:1 | Poor | Solver issues likely |
| Skewness | Quality | Impact | |----------|---------|--------| | 0 - 0.25 | Excellent | Optimal | | 0.25 - 0.50 | Good | Acceptable | | 0.50 - 0.80 | Fair | May affect accuracy | | > 0.80 | Poor | Likely problems |
| Application | Points per Feature | |-------------|-------------------| | Phase-field interface | 5-10 | | Boundary layer | 10-20 | | Shock | 3-5 (with capturing) | | Wave propagation | 10-20 per wavelength | | Smooth gradients | 5-10 |
length, resolution, dx, dy, dz) are validated as finite positive numbers with upper bounds to prevent resource exhaustiondims is restricted to {1, 2, 3}argparse type parameters reject non-numeric input at the CLI boundary before any processing occursallowed-tools excludes Bash to prevent the agent from executing arbitrary commands when processing user-provided inputseval(), exec(), or dynamic code generationshell=True)Read and Write to prepare inputs and capture outputs rather than constructing shell commands from user textreferences/mesh_types.md - Structured vs unstructuredreferences/quality_metrics.md - Aspect ratio/skewness thresholdsdevelopment
Plan verification and validation campaigns for simulation codes using manufactured solutions, canonical benchmark problems, grid/time refinement, uncertainty propagation, and pass/fail acceptance criteria. Use when an agent needs to prove a solver, model, or result is trustworthy rather than only plausible.
testing
Map computational materials tasks onto workflow engines such as atomate2, jobflow, AiiDA, pyiron, or a simple one-off script. Use when deciding how to structure a reproducible campaign, DAG, restart strategy, provenance record, storage layout, or migration path from ad hoc scripts to managed workflows.
development
Plan molecular dynamics post-processing for materials simulations, including RDF, MSD and diffusion, VACF/VDOS, coordination numbers, bond-angle distributions, stress-strain curves, equilibration detection, PBC unwrapping, and trajectory format choices. Use before writing MD analysis scripts or trusting trajectory-derived results.
development
Triage cross-code simulation failures and propose safe retry ladders for nonconvergence, NaN/Inf, exploding energies, unstable timesteps, pressure blow-up, missing potentials, bad pseudopotentials, corrupted output, and incomplete runs. Use when an agent sees a failed or suspicious materials simulation and needs a defensible first response.