SWMMVis  6.0.0-alpha.4
Qt6/C++ GIS-based graphical user interface for the SWMMVis engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
sizefield.h File Reference
#include "mesh/meshgenerator.h"
#include <QRectF>
#include <QVector>
Include dependency graph for sizefield.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  mesh::SizeFieldOptions
 
class  mesh::SizeField
 Distance-to-feature field sampled as a max-area function. More...
 

Namespaces

namespace  mesh
 

Detailed Description

Author
Caleb Buahin caleb.nosp@m..bua.nosp@m.hin@g.nosp@m.mail.nosp@m..com
Date
2026
License\n GPL-3.0-or-later

Graded element sizing for Triangle refinement (MESH_MINSIZE_ENFORCEMENT_V2_AND_GRADING_PLAN_2026-09-01.md Track B).

WHY THIS EXISTS. With a uniform -a<maxArea> cap the WHOLE domain is refined to the cap, however far a cell sits from anything that needs resolution — on a large domain most of the output vertices buy nothing. This field keeps the near-feature size exactly where the uniform cap put it and lets the permitted area grow with distance from the constrained features, under a Lipschitz bound that is itself the smooth-transition guarantee:

h(x) = nearSize + gradation · d(x)
A(x) = (√3/4) · h(x)²          (area of the equilateral triangle)

where d(x) is the distance to the nearest constrained feature (constraint segments, hole-ring edges, tagged Steiner points). Near a feature (d → 0) the permitted area equals the uniform cap, so feature resolution is IDENTICAL to today's mesh; away from features cells coarsen at a bounded rate. The result is strictly FEWER cells than the uniform cap, never more.

The outer domain ring is deliberately NOT a seed: it is usually a watershed clip, not a hydraulic feature, and seeding it would pin fine cells along the whole perimeter. Triangle still refines near the boundary wherever the boundary's own local feature size demands it.

Mechanics: a uniform background grid over the domain bbox holds the distance to the nearest seed at each cell centre — exact distances are stamped in a small neighbourhood around every seed, then a two-pass chamfer transform (3-4 weights scaled to the pitch) propagates them. Chamfer overestimates by at most ~8%, which errs on the fine (safe) side of the gradation. Everything is serial and order-independent, so the field — and therefore the mesh — is deterministic.