$npx -y skills add matlab/matlab-agentic-toolkit --skill matlab-solve-pdeEnd-to-end finite element analysis in MATLAB PDE Toolbox — geometry creation, model setup, solve, and post-processing in one skill. Use when building geometry from primitives or file import, setting up femodel with BCs/loads/materials, solving thermal/structural/EM problems, and
| 1 | # PDE Toolbox — Full FEA Workflow |
| 2 | |
| 3 | End-to-end finite element analysis: geometry → model setup → solve → post-process. Uses the modern `femodel` workflow (R2025a+). |
| 4 | |
| 5 | ## When to Use |
| 6 | |
| 7 | - Building geometry from primitives (`multicuboid`, `multicylinder`, `multisphere`), STL/STEP import, or 2-D `decsg` |
| 8 | - Setting up `femodel` with boundary conditions, loads, materials, and initial conditions |
| 9 | - Solving thermal, structural, or electromagnetic problems (steady, transient, modal, frequency, conduction) |
| 10 | - Post-processing FE results: interpolation, derived quantities, visualization |
| 11 | |
| 12 | ## When Not to Use |
| 13 | |
| 14 | - General-equation PDE (`createpde(N)`) — that legacy workflow is not covered here |
| 15 | - System-level simulation (Simulink/Simscape) — use product-specific skills |
| 16 | - Mesh-only tasks with no PDE solve (e.g., surface meshing for visualization) |
| 17 | |
| 18 | ## Workflow Overview |
| 19 | |
| 20 | 1. **Geometry** — Create with primitives, `decsg`, file import, or boolean ops → wrap in `fegeometry` |
| 21 | 2. **Model** — `femodel(AnalysisType=..., Geometry=gm)` → material, BCs, loads, ICs |
| 22 | 3. **Mesh** — `generateMesh(model)` (default first, refine if needed) |
| 23 | 4. **Solve** — `result = solve(model)` or `solve(model, tlist)` |
| 24 | 5. **Post-process** — Extract fields, interpolate, compute derived quantities, visualize |
| 25 | |
| 26 | ## Phase 1: Geometry |
| 27 | |
| 28 | ### fegeometry — The Hub |
| 29 | |
| 30 | ```matlab |
| 31 | gm = fegeometry(multicuboid(1, 1, 1)); % From primitives |
| 32 | gm = fegeometry("model.stl"); % From STL/STEP file |
| 33 | gm = fegeometry(decsg(gd, sf, ns)); % From 2-D CSG |
| 34 | gm = fegeometry(nodes, elements); % From mesh data |
| 35 | ``` |
| 36 | |
| 37 | **`fegeometry` is for the `femodel` workflow only.** Do NOT use `fegeometry` with `createpde(N)` — that legacy workflow uses `geometryFromEdges` (2-D) or `importGeometry` (3-D) instead. This skill covers `femodel` exclusively. |
| 38 | |
| 39 | Key properties: `NumCells`, `NumFaces`, `NumEdges`, `Vertices` |
| 40 | |
| 41 | ### 3-D Primitives |
| 42 | |
| 43 | | Function | Origin | Arguments | |
| 44 | |----------|--------|-----------| |
| 45 | | `multicuboid(W, D, H)` | x-y centered, **base at z=0** | Width, Depth, Height | |
| 46 | | `multicylinder(R, H)` | x-y centered, **base at z=0** | Radius, Height | |
| 47 | | `multisphere(R)` | **Centered at origin** | Radius | |
| 48 | |
| 49 | Nested cells (vectors), stacked layers (`ZOffset`), hollow (`Void=[true,false]`): |
| 50 | |
| 51 | ```matlab |
| 52 | gm = fegeometry(multicylinder([0.3, 0.5], 1, Void=[true, false])); % hollow pipe |
| 53 | gm = fegeometry(multicuboid([1, 1], [1, 1], [0.3, 0.7], ZOffset=[0, 0.3])); % stacked |
| 54 | ``` |
| 55 | |
| 56 | See `references/primitives-and-import.md` for full options and file import details. |
| 57 | |
| 58 | ### Boolean Operations |
| 59 | |
| 60 | ```matlab |
| 61 | gmCombined = union(gm1, gm2); % Merge into 1 cell |
| 62 | gmCombined = union(gm1, gm2, KeepBoundaries=true); % Preserve cells (multi-material) |
| 63 | gmCombined = union(gm1, gm2, KeepBoundaries=[true, false]); % Selective per shape |
| 64 | gmResult = subtract(gm1, gm2); % Cut gm2 from gm1 |
| 65 | gmResult = intersect(gm1, gm2); % Keep only overlapping region |
| 66 | ``` |
| 67 | |
| 68 | **`KeepBoundaries`**: Use `true` when shapes get different materials (preserves internal faces as cell boundaries). Omit or use `false` to merge into a single cell. |
| 69 | |
| 70 | **Cell modification** after boolean ops: |
| 71 | |
| 72 | ```matlab |
| 73 | gm = mergeCells(gm); % Merge ALL cells into one |
| 74 | gm = mergeCells(gm, [2, 3]); % Merge specific cells (must be connected) |
| 75 | gm = deleteCell(gm, cellIDs); % Remove unwanted cells |
| 76 | ``` |
| 77 | |
| 78 | **Rules:** Union first, subtract last. The function is `subtract` — NOT `subtractgeom`. Never assemble pre-hollowed pieces. Call `mergeCells` only ONCE at the end. |
| 79 | |
| 80 | See `references/boolean-and-cell-ops.md` for full strategy (Sculpt+Carve, Void flags, addCell, addVoid, face imprinting). |
| 81 | |
| 82 | ### 2-D Geometry with decsg |
| 83 | |
| 84 | Each shape is a column vector in the geometry matrix. First entry identifies the type: |
| 85 | |
| 86 | | Type code | Shape | Column format | |
| 87 | |-----------|-------|---------------| |