Mesh controls: Python, Control Room, and realized FEM mesh¶
Last changes: Documentation changelog
Three states must never be confused
Fullmag distinguishes authored policy, backend-effective policy, and realized mesh. Applying a policy does not rebuild the mesh. A geometry or policy change makes the current FEM mesh stale. Only a successful mesh-build command publishes a new mesh asset and realization report.
Control hierarchy¶
FEM meshing is controlled at several nested scopes:
Scope |
Python owner |
Control Room owner |
Numerical role |
|---|---|---|---|
study default |
|
resolved session/backend policy |
default order, hmax, imported mesh, demag linear policy |
universe/airbox |
|
|
exterior geometry, air hmin/hmax, growth, grading |
magnetic object |
|
|
object target, topology, layers, local fields, operations |
authored object region |
region mesh policy |
|
regional hmin/hmax, transition distance, order |
shared assembly compatibility record |
|
not exposed as an effective UI policy |
preserved API data; the current shared-domain builder does not consume its fields |
realized asset |
|
Mesh Build monitor/report/quality |
exact nodes, elements, markers, quality, fallbacks, digest |
A lower scope overrides only the keys it owns. Empty/None values inherit; they do not write zero.
The final shared-domain builder must satisfy all active scopes simultaneously.
Numerical interpretation¶
A size field defines a requested metric-like target, schematically
followed by growth, conformity, geometry, and mesher constraints. Therefore:
the smallest overlapping field wins locally;
requested
hmaxis not a guaranteed measured maximum;transition and grading controls can propagate refinement beyond the selected feature;
a local object or region request can increase the airbox element count through conformity;
the realized size distribution must be inspected in the build report and quality histogram.
Symbols and SI units¶
Symbol/control |
Meaning |
SI unit |
|---|---|---|
hmin, hmax, padding, size, center, interface/edge/corner distances |
authored geometric length controls |
\(\mathrm{m}\) |
boundary-layer thickness and region transition distance |
authored layer and transition lengths |
\(\mathrm{m}\) |
growth, curvature, stretching, size factor, element ratio |
dimensionless grading controls |
\(1\) |
element order, layers, algorithms, iterations, smoothing |
discrete controls and identifiers |
\(1\) |
quality statistics |
metric named by the realized report |
metric-specific, named by the report |
\(h_{\mathrm{target}}(\mathbf x)\) |
resolved local target element size before mesher/conformity constraints |
\(\mathrm{m}\) |
\(\mathcal S(\mathbf x)\) |
active size fields at the spatial point |
\(1\) |
All Control Room length inputs are canonical SI metres. The interface does not silently convert a
number entered as 5 into five nanometres.
Calibration families¶
The public calibration vocabulary is:
general_physics;micromagnetics_static;micromagnetics_relaxation;micromagnetics_frequency_domain;magnetostatics_dominated;imported_surface_cleanup.
A calibration name is normalized and preserved as provenance, but it does not currently select or
change numerical defaults. size_preset and explicit numeric controls determine those defaults.
Calibration provenance is not evidence that the resulting mesh is converged for a particular
observable.
Size presets¶
When the corresponding numeric control is absent, the reviewed preset resolver supplies these fallbacks:
Preset |
Maximum growth |
Curvature factor |
Narrow-region resolution |
|---|---|---|---|
|
1.2 |
0.20 |
1.00 |
|
1.3 |
0.25 |
0.85 |
|
1.4 |
0.40 |
0.70 |
|
1.5 |
0.50 |
0.60 |
|
1.6 |
0.60 |
0.50 |
|
1.8 |
0.80 |
0.30 |
|
2.0 |
1.00 |
0.20 |
|
2.2 |
1.20 |
0.15 |
|
2.4 |
1.50 |
0.10 |
Explicit numeric values override preset fallbacks. size_factor then scales preset-derived targets
where the active mesh workflow applies that factor.
MeshSizeControls¶
Python field |
Type |
Default |
SI unit |
Validation / meaning |
ProblemIR |
|---|---|---|---|---|---|
|
|
|
\(1\) |
standalone compatibility payload; constructor does not validate it |
none; no authoring facade attaches it |
|
|
|
\(1\) |
standalone compatibility payload; constructor does not validate it |
none; no authoring facade attaches it |
|
|
|
\(\mathrm{m}\) |
standalone compatibility payload; constructor does not validate it |
none; no authoring facade attaches it |
|
|
|
\(\mathrm{m}\) |
standalone compatibility payload; constructor does not validate it |
none; no authoring facade attaches it |
|
|
|
\(1\) |
standalone compatibility payload; constructor does not validate it |
none; no authoring facade attaches it |
|
|
|
\(1\) |
standalone compatibility payload; constructor does not validate it |
none; no authoring facade attaches it |
|
|
|
\(1\) |
standalone compatibility payload; constructor does not validate it |
none; no authoring facade attaches it |
Stage-first commands¶
Python command |
Scope |
Effect |
|---|---|---|
|
study |
selects FEM semantics; unresolved/FDM UI lanes withhold FEM writes |
|
universe |
authors exterior-domain mode and geometry |
|
universe |
authors airbox hmin/hmax, growth, grading, calibration and preset |
|
object |
authors ordinary object size, order, algorithms, quality and refinements |
|
object |
authors thickness layers and tetrahedral/prismatic thin-film topology |
region mesh policy |
region |
authors regional size/order/transition override |
|
shared domain |
explicitly requests mesh materialization |
|
algebraic solver |
configures Poisson/demag solve; it does not change mesh geometry |
Complete stage-first example¶
# %% Global, airbox, object, and exact thin-film mesh controls
import fullmag as fm
nm = 1.0e-9
study = fm.study("fem_mesh_controls")
study.engine("fem")
study.device("cpu", precision="double")
study.mode("strict")
study.universe(mode="manual", size=(1.0e-6, 500 * nm, 400 * nm))
study.universe.mesh(
minimum_element_size=8 * nm,
maximum_element_size=90 * nm,
maximum_element_growth_rate=1.3,
grading="geometric",
)
film = study.geometry(
fm.Box(size=(400 * nm, 120 * nm, 4 * nm), name="film"),
name="film",
)
film.mesh.thin_film(
minimum_element_size=2 * nm,
maximum_element_size=4 * nm,
layers=2,
topology="prismatic",
exact_layers=True,
transition="pyramid_to_tetrahedra",
order=1,
)
film.Ms = 800.0e3
film.Aex = 13.0e-12
film.alpha = 0.02
film.m = fm.texture.uniform(1.0, 0.0, 0.0)
study.exchange()
study.demag(model="airbox", variant="robin")
study.build_domain_mesh()
study.stages.add_relax(
stage_id="equilibrium",
algorithm="nonlinear_cg",
tolT=1.0e-6,
max_steps=50_000,
)
Ten dokładny blok przeszedł podczas przeglądu test wykonania kontraktu authoringu z zastąpioną
wyłącznie kosztowną materializacją siatki; konstrukcja domeny, polityk i etapu zakończyła się bez
wyjątku. Integracyjnym wzorcem repozytoryjnym jest
tests/standard_problems/mumag/sp4/fem/scenarios/relax_projected_gradient_bb.py; przykład skraca
kwalifikację SP4, ale zachowuje jej stage-first budowę domeny, filmu i etapu relaksacji.
Control Room crosswalk¶
Airbox Mesh Parameters¶
UI label |
Canonical JSON key |
Meaning |
|---|---|---|
Maximum element size |
|
far-field/air upper target |
Minimum element size |
|
near/interface lower target |
Maximum element growth rate |
|
requested grading growth |
Curvature factor |
|
curved-boundary refinement |
Resolution of narrow regions |
|
small-gap/thin-feature resolution |
Element grading |
|
|
Domain mode |
|
inherited, |
Padding X/Y/Z |
|
exterior clearance vector in metres |
Size X/Y/Z |
|
explicit exterior size vector in metres |
Center X/Y/Z |
|
explicit exterior centre in metres |
The panel shows backend-effective values separately. Unknown effective keys are counted rather than silently presented as structured fields.
Object Mesh Policy¶
UI family |
Canonical keys |
|---|---|
presets |
|
element size |
|
topology/layers |
|
interface |
|
edge |
|
corner |
|
backend |
|
quality |
|
boundary layer |
count, thickness, stretching, semantic selectors or raw entity tags |
advanced |
complete object policy JSON |
Transition distance accepts a positive SI length or the sentinel airbox_boundary in the object,
edge, and corner structured editors.
Region Mesh¶
UI label |
Meaning |
|---|---|
Enable mesh policy |
activate/deactivate the regional override |
Max element size |
regional upper target in metres |
Min element size |
regional lower target in metres |
Transition distance |
distance over which the region target blends to its parent policy |
Order |
regional finite-element order where supported |
Region quality distributions are read from the realized region membership and quality resources, not synthesized from the authored policy.
Explicit size fields¶
Manual Box field¶
The object inspector can author one explicit box size field with:
x/y/z minimum and maximum bounds in metres;
VIn, the target inside the box;VOut, the target outside the box;a source marker distinguishing the structured object-policy editor from unmarked advanced JSON.
Object-core relaxation field¶
ObjectCoreRelaxation can grade from fine surface/edge targets toward a coarser object core. The UI
exposes geometry name, core maximum size, surface and edge distances, surface and edge maximum
sizes, and sampling controls. The field is valid only when its geometry/selector resolution is
published in the realization report.
Ordered mesh operations¶
Operation |
Intended effect |
Qualification boundary |
|---|---|---|
|
unstructured volume fill |
general FEM path |
|
layered elements on selected surfaces/curves |
selector/topology dependent |
|
uniform h-refinement pass |
operation status must confirm execution |
|
adaptive refinement intent |
no universal production solve–estimate–remesh loop is claimed |
|
structured extrusion |
geometry and capability dependent |
|
inject an additional size field |
field kind and selectors must resolve |
The operation schema is representable, but the current public build boundary rejects every authored
operation with mesh operation executor unavailable before mesh generation, including entries with
enabled=False. Therefore no operation is currently classified as applied, ignored, skipped,
degraded, or failed in a build report. The table above describes intended families, not executable
public capability.
ProblemIR and provenance¶
A reproducible mesh record contains:
study, universe, object, and region authored policies with revisions;
backend-effective values and inheritance source;
geometry and material digests;
requested and actual algorithms, topology, order, layers, and transitions;
ordered size fields and operations with realization status;
selector-to-native-tag resolution;
build mode, fallback list, degradation flag, and exact failure reason;
nodes/elements/facets by family, order, region, and boundary role;
bounds, volumes, surfaces, connected components, and periodic pairs;
Jacobian, SICN, gamma/radius, volume, edge-size, and histogram statistics;
Gmsh/native versions, deterministic inputs, mesh/submesh digests;
current versus latest-successful mesh identity.
Validation and failure semantics¶
Structured Python/UI controls reject invalid numeric values, unsupported vocabulary, inconsistent hmin/hmax, invalid layer tuples, and unresolved FEM/FDM lane selection before build. The mesh build then rejects or explicitly degrades:
nonconformal or failed CAD assembly;
empty magnetic or air partitions;
inverted, collapsed, orphan, duplicate, or nonmanifold entities;
missing material/boundary attributes;
invalid periodic pairing;
unresolved semantic selectors;
unsupported family/order/device combinations;
requested-versus-realized topology mismatch in strict mode.
A failed build must not overwrite the latest successful mesh. A green policy request without a green mesh build is not a usable solver discretization.
Round-trip contract¶
The exported Python preserves requested intent. ProblemIR and the build report preserve resolved execution separately. Invalid values produce explicit validation errors, while unsupported combinations are rejected before meshing rather than silently degraded.
Discrete realization¶
FEM mesh generation is normally host/Gmsh work. CPU and GPU solvers must consume the same content-addressed extracted asset when parity is claimed. FDM uses a different structured-grid contract and exposes object/region mesh membership read-only in the Control Room.
Implementation mapping¶
Responsibility |
Repository path |
Stable symbol |
|---|---|---|
reusable size policy |
|
|
shared assembly policy |
|
|
public normalization and validation |
|
|
resolved preset values and quality schemas |
|
|
size-field composition |
|
size-field plan owner |
target precedence |
|
|
operation/fallback reporting |
|
|
object UI transaction |
|
|
object request |
|
|
airbox UI transaction |
|
|
airbox request |
|
|
region UI |
|
|
Scientific mesh-convergence workflow¶
choose a target observable and physical parameter range;
make temporal, equilibrium, algebraic, and airbox errors smaller than the expected spatial change;
retain the exact authored/effective policy and realized mesh for at least three controlled levels where possible;
compare geometry volume and marker topology independently of field error;
compare fields on a common space and modes by complex overlap;
refine thickness layers, geometry order, airbox extent, and h/p independently;
inspect worst elements and lower quality percentiles, not only averages;
verify CPU/GPU on the identical mesh digest;
archive every build report and acceptance decision.
Limitations¶
presets are convenience policies, not accuracy grades;
advanced JSON can contain keys not consumed by the active backend;
raw Gmsh tags are not stable geometry identifiers;
region/object requests may be altered by conformity and shared-domain constraints;
exact prism, boundary-layer, swept, and adaptive operations have bounded support scopes;
this contract does not claim universal automatic adaptive remeshing.
Scientific bibliography¶
C. Geuzaine and J.-F. Remacle, “Gmsh: a three-dimensional finite element mesh generator with built-in pre- and post-processing facilities,” International Journal for Numerical Methods in Engineering 79, 1309–1331 (2009), doi:10.1002/nme.2579.
P. G. Ciarlet, The Finite Element Method for Elliptic Problems, SIAM Classics, 2002, doi:10.1137/1.9780898719208.
R. Anderson et al., “MFEM: a modular finite element methods library,” Computers & Mathematics with Applications 81, 42–74 (2021), doi:10.1016/j.camwa.2020.06.009.
Exhaustive public-API and Python-to-ProblemIR mapping¶
Python |
Type |
Default |
SI unit |
Validation |
Meaning |
Backend support |
ProblemIR |
|---|---|---|---|---|---|---|---|
MeshSizeControls.calibrate_for |
str | None |
None |
\(1\) |
Standalone compatibility payload; no authoring facade attaches it to ProblemIR. |
Recorded calibration-family data. |
Unattached |
none |
MeshSizeControls.size_preset |
str | None |
None |
\(1\) |
Standalone compatibility payload; no authoring facade attaches it to ProblemIR. |
Named size-policy data. |
Unattached |
none |
MeshSizeControls.maximum_element_size |
float | None |
None |
\(\mathrm{m}\) |
Standalone compatibility payload; constructor does not validate it. |
Upper element-size data. |
Unattached |
none |
MeshSizeControls.minimum_element_size |
float | None |
None |
\(\mathrm{m}\) |
Standalone compatibility payload; constructor does not validate it. |
Lower element-size data. |
Unattached |
none |
MeshSizeControls.maximum_element_growth_rate |
float | None |
None |
\(1\) |
Standalone compatibility payload; constructor does not validate it. |
Element-growth data. |
Unattached |
none |
MeshSizeControls.curvature_factor |
float | None |
None |
\(1\) |
Standalone compatibility payload; constructor does not validate it. |
Curvature-sizing data. |
Unattached |
none |
MeshSizeControls.narrow_region_resolution |
float | None |
None |
\(1\) |
Standalone compatibility payload; constructor does not validate it. |
Narrow-region data. |
Unattached |
none |
SharedMeshAssemblyPolicy.interface_hmax_factor |
float |
0.5 |
\(1\) |
Strictly greater than zero and no greater than one. |
Preserved compatibility value; not consumed by the current builder. |
Inert compatibility data |
shared_mesh_assembly_policy.interface_hmax_factor |
SharedMeshAssemblyPolicy.enforce_conforming |
bool |
True |
\(1\) |
Boolean. |
Preserved compatibility value; not consumed by the current builder. |
Inert compatibility data |
shared_mesh_assembly_policy.enforce_conforming |
SharedMeshAssemblyPolicy.airbox_hmax_factor |
float |
3.0 |
\(1\) |
Finite and positive. |
Preserved compatibility value; not consumed by the current builder. |
Inert compatibility data |
shared_mesh_assembly_policy.airbox_hmax_factor |
Python API¶
The complete runnable example is in the numbered example section below; the exact callable fields and arguments are in the numbered API section. These values are copied from the current Python contract, not inferred from the UI.
Source-code index¶
Claim |
Lane |
Path |
Stable symbol |
Evidence |
Evidence status |
Immutable revision |
|---|---|---|---|---|---|---|
unattached compatibility payload |
Python data model only |
|
|
repository-wide attachment audit |
limitation documented |
|
UI object lifecycle |
Control Room, FEM |
|
|
component tests |
source-backed |
|
UI airbox lifecycle |
Control Room, FEM |
|
|
panel/model tests |
source-backed |
|
UI region controls |
Control Room, FEM |
|
|
component tests |
source-backed |
|
final provenance |
FEM CPU/GPU shared mesh |
|
|
fallback/report tests |
source-backed |