Theory contents

Constraints and convergence

On this page

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 f, every full-material element matrix Ke0 with its volume and centroid, the filter’s neighbour weights, and the optimizer state. A minimum-compliance run starts with every density equal to vf; a minimum-volume run starts from full material. Each iteration then:

  1. Analyses the current design. It scales the cached Ke0 by s(ρe), assembles K(ρ) and solves Kd=​f 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.
  2. Evaluates compliance, volume and their sensitivities from that one displacement field.
  3. Filters the compliance sensitivities over a radius rmin.
  4. Updates all active densities with one step of the method of moving asymptotes (MMA).
  5. 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.

A grid of elements with a circle of radius r min around element e. Elements inside the circle are shaded blue, darkest at the centre, showing filter weights that fall linearly with distance to zero at the radius.
Filter weights around element e: they fall linearly with distance and vanish at the radius rmin. Features thinner than about the radius cannot form.

KoFEM’s filter introduces a physical length, the filter radius rmin. Elements whose centroids xe,xi are closer than it are neighbours, with linear “cone” weights:

Hei=max(0,rmin−|xe−xi|),gef=1max(ρe,10−3)∑iHei∑iHeiρigi,gi=∂c∂ρi.

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 2rmin are discouraged, so rmin 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 rmin fixed while refining the mesh is what can make designs mesh-independent: the resolution improves, but the admissible member size does not shrink. Changing rmin 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 [ρmin,1] 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 σallow. Three standard devices make that tractable:

These runs use a density filter: the analysed density is the H-weighted average of the design variables, and every gradient is chained back exactly. The density lower bound is ρmin=​10−3 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:

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: E0=​1, ν=​0.3 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, vf=​0.5, p=​3 and rmin=​0.3 (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 vf=​0.4 on two grids with the same rmin=​0.4.

Executed topology-optimization benchmarks
CaseElementsIterationsCompliance: start → endFinal volume fraction
MBB half-beam43250, converged1802 → 413.10.5
Cantilever, 10 × 5 × 525045, converged616.6 → 188.50.4
Cantilever, 20 × 10 × 102,00069, converged650.7 → 190.50.4
The optimized density of the MBB half-beam on a 36 by 12 element grid. Dark elements form a top chord, a bottom tie and diagonal members; the symmetry plane is on the left, the load on the top left and a roller at the bottom right.
The recorded MBB half-beam densities, one square per element: black above 0.5, grey 0.25–0.5, white below 0.25. The symmetry plane is on the left, the load at its top and the roller at bottom right.

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

  1. 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.
  2. Svanberg (1987), The method of moving asymptotes — a new method for structural optimization, International Journal for Numerical Methods in Engineering 24, 359–373.
  3. 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.
  4. iteration loop, stopping rule, sensitivity filter, default radius, MMA optimizer, relaxed, aggregated stress and adjoint, stress density floor and the worker’s step loop.
  5. app defaults and benchmark descriptions and bands.