Constraints and convergence
How do filtering, constraints and convergence shape an optimized design?
SIMP defines the design problem: element densities, a penalized stiffness and compliance or volume as the objective. This page follows the loop that solves it, and explains what a reported “converged” run means.
One iteration, step by step
Before the first iteration the optimizer builds, once per run: the order-1 finite element model, the supported degrees of freedom, the assembled load vector , every full-material element matrix with its volume and centroid, the filter’s neighbour weights, and the optimizer state. A minimum-compliance run starts with every density equal to ; a minimum-volume run starts from full material. Each iteration then:
- Analyses the current design. It scales the cached by , assembles and solves with conjugate gradients. Nothing is re-meshed or re-integrated. On solid models the multigrid hierarchy is rebuilt only every third iteration; in between, only its finest matrix is replaced.
- Evaluates compliance, volume and their sensitivities from that one displacement field.
- Filters the compliance sensitivities over a radius .
- Updates all active densities with one step of the method of moving asymptotes (MMA).
- Reports the analysed design: compliance, volume fraction and largest density change are logged, and the density is streamed to the viewport. Then it tests the stopping rule.
Each iteration is therefore a full static linear solve of a model with a different stiffness distribution. A run of 50–100 iterations costs roughly that many static solves, each typically harder than the original because void elements create large stiffness contrasts. The returned density, the last history entry and the returned displacements always describe the same analysed design.
Why the loop runs in the solver module
KoFEM’s optimizer is Rust compiled to WebAssembly and runs in a browser worker. The run is one object inside that module, which the worker advances one iteration per call. Keeping the state there reuses the mesh, element matrices, supports, load, filter weights and optimizer state for every iteration; only the iteration report and, when asked, the density cross into JavaScript.
The tradeoff is control. The worker steps the run to its end without pausing, so cancelling a run terminates the worker and discards it. Progress is visible because each iteration is logged and its analysed density is streamed to the viewport.
Filtering, radius and mesh dependence
Unfiltered SIMP has two well-known failures. Checkerboards — alternating solid and void elements — look artificially stiff to low-order elements. And refining the mesh lets ever thinner members appear, so the answer changes with the mesh instead of converging to one design.

KoFEM’s filter introduces a physical length, the filter radius . Elements whose centroids are closer than it are neighbours, with linear “cone” weights:
This is Sigmund’s sensitivity filter in the form of Andreassen et al., used for compliance and volume runs. It smooths the information the optimizer acts on, not the densities themselves. It is a heuristic: the filtered value is not the exact derivative of any function, which works well for compliance but not for stress. Stress-constrained runs therefore filter densities instead; see maximum-stress constraints.
Members thinner than about are discouraged, so acts as a minimum length scale only if it spans several elements. In the app, Filter r_min is an absolute length in model units (default 1.5, i.e. 1.5 mm in the app’s mm units), not a multiple of element size. Compare it with your mesh size: a radius smaller than one element leaves each element as its own only neighbour and disables the filter. Values of 1.5–3 element sizes are common. The optimizer’s own fallback of 1.5 × the mean element size applies only when an API caller sends no positive radius.
Keeping fixed while refining the mesh is what can make designs mesh-independent: the resolution improves, but the admissible member size does not shrink. Changing changes the problem and therefore the design. Mesh independence is a property to check, not a guarantee; see the two-resolution benchmark.
Updating densities with MMA
The method of moving asymptotes (Svanberg 1987) is KoFEM’s only optimizer. At each iterate it replaces the objective and each constraint by a separable convex approximation built from the current values and gradients, bounded by moving asymptotes either side of each variable, and solves that subproblem exactly. The asymptotes widen while a variable keeps moving in one direction and contract when it oscillates.
Each variable stays within and may change by at most the move limit per iteration (default 0.2). Objective and constraints are normalized so they are of order one; compliance, for example, is divided by its first-iteration value. MMA was chosen over the simpler optimality-criteria update because one method then covers minimum compliance, minimum volume and stress constraints alike.
Topology optimization problems are nonconvex. MMA finds a design that stops improving locally; it does not prove a global optimum. A different starting density, penalty, filter radius, move limit or mesh can produce a different layout of similar stiffness.
Maximum-stress constraints
On all-solid models, either formulation can also require that the element-centre von Mises stress not exceed . Three standard devices make that tractable:
- Relaxation. The constrained stress is , where is the full-material stress of the element’s displacement and by default. Without it, vanishing elements create “singular” optima the optimizer cannot reach.
- Aggregation. One P-norm (default ) or Kreisselmeier–Steinhauser function (default ) replaces one constraint per element. An adaptive factor scales it towards the true maximum, with a lag of one iteration.
- Adjoint sensitivity. Stress is not self-adjoint, so each iteration adds a second linear solve.
These runs use a density filter: the analysed density is the -weighted average of the design variables, and every gradient is chained back exactly. The density lower bound is rather than 0. The constraint controls a relaxed, element-centre, aggregated measure. It does not bound the peak stress of a smoothed, re-meshed part, and it is not available for shell or coupled models.
When a run stops
A run is reported as converged when the largest density change of an MMA step is below the tolerance (default 0.01) and the analysed design meets its limits within small slack: 0.5% on a compliance limit and on a volume cap that accompanies a stress limit, and 2% on the true maximum relaxed stress. Otherwise it stops at the iteration limit (app default 50). A minimum-volume or stress-constrained run that ends above its limits returns its last design that met them. If no iteration ever met a stress limit, the run fails with an explicit error.
A minimum-compliance run without a stress limit meets its volume constraint through MMA itself, so the stopping test there is the density change alone. Convergence therefore means “this design stopped moving and meets the stated limits”. It does not mean:
- the design is a global optimum, or that small densities have become exactly 0 or 1;
- the compliance has converged with mesh refinement;
- the part is strong, stable or manufacturable: compliance concerns stiffness under the chosen loads only.
Satisfying the volume fraction says only how much material was used. Judge adequacy by re-analysing the interpreted shape; see reanalysis.
Check the MBB beam and mesh independence
The existing topology benchmarks run the shipped WebAssembly optimizer on structured hexahedral meshes. Their inputs are normalized: , and a unit total load, so compliance is in the matching normalized work unit. They compare a run with published layouts and with itself under refinement; there is no closed-form optimum.
The MBB beam is half of a simply supported beam with a central load, 6 long and 2 high and one element thick with out-of-plane motion fixed, so it behaves as a planar problem. It uses 36 × 12 elements, , and (about 1.8 element widths). The cantilever is a 2 × 1 × 1 box fixed at one end, loaded along the bottom edge of the free end, optimized at on two grids with the same .
| Case | Elements | Iterations | Compliance: start → end | Final volume fraction |
|---|---|---|---|---|
| MBB half-beam | 432 | 50, converged | 1802 → 413.1 | 0.5 |
| Cantilever, 10 × 5 × 5 | 250 | 45, converged | 616.6 → 188.5 | 0.4 |
| Cantilever, 20 × 10 × 10 | 2,000 | 69, converged | 650.7 → 190.5 | 0.4 |

The MBB run reproduces the published layout: a compression chord along the top, a tension tie along the bottom and diagonals between them. Its compliance falls to 22.9% of the uniform start, and 134 of 432 elements end above 0.9 and 134 below 0.1. The rest are gray.
For the cantilever, the fine grid’s density is averaged onto the coarse grid. The two converged compliances differ by 1.07%, the density fields correlate at 0.994, and the regions above 0.5 overlap with an intersection-over-union of 0.9278. This shows the filter holding the layout fixed across one factor-2 refinement of one problem on structured hexahedra. It does not establish mesh independence for unstructured Netgen tetrahedra, other filter radii, shells or stress-constrained runs.
KoFEM’s automated tests rerun both benchmarks with their tolerance bands and compare them with the recorded numbers. The public MBB beam example solves the full beam from a STEP model on a Netgen mesh in the app.
Implementation and references
- Sigmund (2001), A 99 line topology optimization code written in Matlab, Structural and Multidisciplinary Optimization 21, 120–127; and Andreassen et al. (2011), Efficient topology optimization in MATLAB using 88 lines of code, Structural and Multidisciplinary Optimization 43, 1–16.
- Svanberg (1987), The method of moving asymptotes — a new method for structural optimization, International Journal for Numerical Methods in Engineering 24, 359–373.
- Le, Norato, Bruns, Ha and Tortorelli (2010), Stress-based topology optimization for continua, Structural and Multidisciplinary Optimization 41, 605–620; and Bruggi (2008), On an alternative approach to stress constraints relaxation in topology optimization, Structural and Multidisciplinary Optimization 36, 125–141.
- iteration loop, stopping rule, sensitivity filter, default radius, MMA optimizer, relaxed, aggregated stress and adjoint, stress density floor and the worker’s step loop.
- app defaults and benchmark descriptions and bands.