Workbench¶
The workbench is a browser app for looking at runs: a dock of panels that shows solved fields in 3D and 2D, browses the run and artifact indexes, and follows runs and sweeps while they solve. It runs as a local trame server that you start from a script or from the femforge-workbench command, and it reads the same telemetry root and run bundles as the rest of femforge. You can also build your own dock from the same panels and list it beside the built-in ones.

Install¶
The workbench is a separate package, femforge-workbench, that the workbench extra installs:
ff.workbench raises an ImportError that names this command when the extra is missing. The package has extras of its own, listed on the install page, among them app for the --webview window and pty for an interactive terminal on Windows.
Open the field viewer from a script¶
import femforge as ff
display = ff.DisplaySpec(
field="magnetic flux density",
mode=ff.DisplayMode.MAGNITUDE,
colormap="plasma",
hidden_bodies=("air",),
body_styles=(ff.BodyStyle(body="mover", paint=ff.BodyPaint.SOLID, color="#c0c0c0", opacity=0.5),),
streamlines=ff.FieldLineOptions(seed_placement=ff.SeedPlacement.CENTER_PLANE, line_count=16),
)
viewer = ff.workbench.field_viewer(display=display, telemetry="telemetry")
ff.workbench.show(viewer, title="Field viewer")
field_viewer builds the viewer dock. Its run picker lists the indexed runs of the telemetry root, FEMFORGE_TELEMETRY when you pass none. Pass run= a Result, a Run, a run id or a bundle directory to open that run once the server starts. Without one, the viewer opens the newest indexed run as soon as one lands. The DisplaySpec sets where the controls start; Results covers it. A DisplaySpec without a field opens each run on default_display.
show serves a workbench and returns when its window closes:
show(workbench) |
Opens |
|---|---|
a dock Split |
that dock, as built |
a module-level function that returns a Split or a Renderable |
its result, rebuilt on every save of a .py file under its source roots |
any of these, with tasks= a module-level function listing Tasks |
the same, while the tasks run in the background, one at a time |
a WorkbenchSpec |
that catalogue card, as the command opens it by name |
| nothing | the launcher |
window= |
Opens in |
|---|---|
Window.APP, the default |
a Chrome or Edge app window; closing it stops the server |
Window.BROWSER |
a tab in the default browser |
Window.WEBVIEW |
pywebview, from the app extra |
show also takes port, telemetry, persist and watch, which match the command's flags below, and tasks, which the next section covers.
Solve in the background¶
from functools import partial
import femforge as ff
GAPS = (0.5, 1.0, 2.0)
def solve(gap: float) -> None:
"""Solves one gap."""
def solves() -> list[ff.workbench.Task]:
"""One task per gap."""
return [ff.workbench.Task(f"Gap {gap:g} mm", partial(solve, gap)) for gap in GAPS]
def viewer() -> ff.workbench.Split:
"""The field viewer, which opens each run as it lands."""
return ff.workbench.field_viewer(telemetry="runs-index")
if __name__ == "__main__":
ff.workbench.show(viewer, tasks=solves)
tasks takes a module-level function that lists Tasks; the workbench runs them one at a time in child processes while it serves, shows each in the task strip, and lists them again on every save. A Task pairs a label, unique in the list, with a function that takes no arguments; Task(export) labels a named function Export, and a partial or a lambda needs a label of its own. Each child imports the script by module name, from the script's own directory with the server's sys.path behind it, calls the function again and runs the task with the same label, so a partial or a lambda works, nothing is pickled, and the sys.path edits the script makes hold in the child. Guard the show call under if __name__ == "__main__":, or every child serves a workbench of its own.
| The strip shows | When |
|---|---|
Queued, with its place in line |
the task waits for the one before it |
Starting, Preparing Geometry, Meshing, Solving, Finishing |
the stage its child reports; Meshing · Cached when the artifact cache served the mesh. Solving names the solver, its place in a stack of several such as 2/3, and the percent converged once known, or Direct for a solver that factorizes; the sheet adds the linear iteration |
Running |
the task's own code runs between or after its runs |
Waiting · Another Process Is Solving It |
another process holds the claim on the same run; the task reuses that run once it lands |
Done, Reused |
the task returned; Reused when every run it asked for was solved before, Reused · From Cache when the artifact cache served it. The summary counts each apart, and while other tasks still run the strip shows ↺ N Reused beside it |
Failed, with the error |
the task raised, or its child died; Details shows the traceback |
Stalled, with the reason |
the watchdog stopped a linear solve of the task, residual flat at 3.14e-08 since it 1000 or residual not improving; Log shows the child's last log lines |
Cancelling |
Cancel, pressed twice, is stopping the task; it gets up to 10 s to release its run |
Cancelled |
Cancel, pressed twice within the 3 s it counts down, stopped it |
Script Error |
a save broke the script; the strip and the sheet show why, and the rows of the last good save stay |
- A save while a task runs lets it finish on its old code, then runs it once more. A task the save dropped finishes, then leaves the strip.
- Retry runs a failed, stalled or cancelled task again; a done one runs again on the next save. Click the summary line or Tasks to open the sheet, and press
Escapeanywhere in the page to close it. - When a task finishes on a newer run while the viewer shows the run it finished on before, the viewer opens the newer one and says so in the status line.
- An unchanged task re-runs in about 3 s, the start of a child process: the Driver reuses its finished runs.
- The child stores its own records in the telemetry root, and the server only relays them to its terminal.
The femforge-workbench command¶
femforge-workbench # the launcher
femforge-workbench field-viewer --telemetry telemetry
femforge-workbench -m lab.workbenches:gap_study --app
| Argument | Does |
|---|---|
name |
Open the catalogue card with this name, such as demo or field-viewer. Without a name or -m, open the launcher. |
-m pkg.module:attr |
Open the module attribute, a function that returns a dock Split or a Renderable. |
-m pkg.module |
Open the module's main(), which returns a Renderable. |
--app |
Open a Chrome or Edge app window; closing it stops the server. |
--webview |
Open in pywebview, from the app extra. |
--dev |
Run the server as a child that restarts after every save to the shell's own modules; the page reloads itself. |
--port N |
Serve on port N, 8080 by default. |
--watch DIR |
Also rebuild the open workbench when a .py file under DIR is saved. Repeatable. |
--telemetry DIR |
The telemetry root the panels read. It also sets FEMFORGE_TELEMETRY for the process, so a card opened later reads the same root. |
--persist DIR |
Where layouts and choices are saved, the per-user config directory by default. |
Without --app or --webview, the command opens a browser tab. An unknown name, or the browsers or monitors card without a telemetry root, exits with code 2 and a message. CLI lists the command beside femforge.
The built-in cards¶
| Card | Opens |
|---|---|
launcher |
Every catalogue card: open and close docks, open previews, run scripts and browse what they produced. |
demo |
A sphere, a line figure and a grouped table, to try the shell without data. |
browsers |
The run browser over the run detail, beside the artifact browser over the artifact detail. |
field-viewer |
A solved run's fields: the view, the symmetry expansion, colormaps, bodies and field lines. |
monitors |
A run's heartbeat, stages, convergence and logs; a sweep's progress and failures; the log browser; a terminal. |
The browsers and monitors cards read the telemetry root; the Telemetry page covers what it holds. The artifact panels read the store at FEMFORGE_ARTIFACTS when it is set, else the store the index rows name.
The field viewer¶
The field viewer puts its controls and the Setup tab beside one view, which draws every run, flat or solid. The app bar holds the run picker, which lists the 200 newest indexed runs that have fields, are still solving or failed, newest first, and shows the open run's bundle path beside it. Each run reads as its description, with its run id muted beside it. A run that is still solving reads Solving and opens once its solve ends; one whose solve failed reads Failed. The list follows the run index every second and holds still while its dropdown is open, so a run that lands never moves the row under the pointer and never replaces the open run. With no run given, the viewer opens the newest run with fields as soon as one lands, else the newest one still solving, else the newest failed one. The camera stays put when the next run frames alike.
Each run opens on its own field. A run colors the primary field of its solver stack: the flux density of a magnetostatics run, the temperature of a thermal or Joule heating run, the displacement of an elasticity run. A displacement opens on the component its surface forces share, such as Y under a pull along Y, and on Magnitude when they point several ways. Show Field Lines and Opacity Mapping start on for a flux density, a field strength, an electric field or a current, and off otherwise. A Quantity, Mode, Show Field Lines or Opacity Mapping choice you make carries over to the next run that has the quantity shown, and a run without it opens on its own field. The other controls carry over from the run before. A DisplaySpec that names a field opens each run on that field, mode, field lines and opacity mapping instead. The workbench keeps the panel layout, the open cards and each view's mode between sessions, never the field display.
The first time a run opens, a short tour points out the run picker, each section of the controls and the view's toolbar. Skip or Esc ends it, and it stays closed on later starts. The help button at the right of the app bar replays it.
The controls come in five sections:
| Section | Controls |
|---|---|
| Symmetry | Solved As, Show As, Sweep |
| Deformation | Deformed Shape, Scale |
| Field | Quantity, Mode, Colormap, Invert Colormap, Log Scale, Outline, Auto Range with the color range slider, Legend, Opacity Mapping |
| Field Lines | Show Field Lines, Seeds, Integrate Within, the seed count, Length |
| Bodies | An All Bodies row, whose look sets every body and the overall opacity, then one row per body and per material that owns several bodies, each a look swatch and its name |
Symmetry expands a run solved on a section. Solved As names the solve frame. For an axisymmetric run, Show As shows the r–z half-plane as solved, mirrors it into the full plane, or revolves it around the axis into a solid in the frame the model was authored in. Revolve is the default, at a full Sweep of 360°; a smaller sweep cuts the solid open so the cut faces show the field inside the bodies. Only the surfaces are revolved, so a section costs about as much to draw revolved as flat. The field lines of a revolved run are seeded as in a solid run, on the center plane, the gap line or through the volume of the swept solid, integrated in the section and swept back to their seeds. A run solved in 3D or on a planar Cartesian 2D section has nothing to expand. DisplaySpec holds the choice as expansion and sweep.
Deformation draws the bodies displaced by the solved displacement. For a run with a displacement, such as a linear elasticity run, Deformed Shape starts on and moves every point by the displacement times the scale. The scale starts where the largest displacement moves a tenth of the diagonal of the solved bodies' bounding box, and its slider reaches five times that. A new scale is drawn when the thumb is released and keeps the view. A scale of zero, or the switch off, draws the bodies as solved. The colors and the color range keep the solved values, and the field lines run through the displaced bodies. A section is displaced after it is mirrored or revolved, and an elemental displacement is first averaged onto each body's points. A run without a displacement reads No Displacement. DisplaySpec holds the choice as warp, the vector array or None, and warp_scale, None for the automatic scale.
The legend starts hidden. The range slider wears the colormap between its thumbs, so the controls read as the legend. Set Legend to Vertical or Horizontal to draw a color bar in the view, titled with the field's unit, before a screenshot. Field lines share that bar while they map like the field, and get a bar of their own only when their colormap or range differs. A vertical pair stacks at the right, and a long title wraps onto two lines. Moving a thumb of the range slider pins the range and turns Auto Range off. Color bars and scene labels keep their size on a high-density display, in both the Client and Server views.
The Quantity picker lists every scalar, vector and principal-value array of the run. The stress and strain tensors are left out, with the stress_xx and strain_xx columns Elmer splits them into; read them with Run.mesh(). The Mode picker offers what the quantity supports:
| DisplayMode | Colors by | Offered for |
|---|---|---|
MAGNITUDE |
the vector magnitude | vectors, the default |
X, Y, Z |
one component | vectors |
POLAR_XY |
the in-plane direction as hue, brightened by the in-plane magnitude | vectors |
VALUE |
the value | scalars, the default |
ABSVALUE |
the absolute value | scalars |
MAX_PRINCIPAL |
the largest principal value | principal stresses and strains, the default |
MID_PRINCIPAL, MIN_PRINCIPAL |
the middle or the smallest principal value | principal stresses and strains |
A body's swatch opens its look. The popover shows or hides the body and sets its opacity on its top row, then where its color comes from, its BodyPaint:
| Mode | Paint | Color | The swatch |
|---|---|---|---|
| Field | FIELD |
the field colormap, by the displayed value | a diagonal gradient of the field colormap |
| Colormap | COLORMAP |
one color of the body colormap, spread evenly over every body that takes it; the colormap is shared, so picking one recolors every such body | that color, with a corner dot of the body colormap |
| Fixed | SOLID |
a color picked on the square, the hue strip or a palette chip | that color |
A hidden body's swatch is an outline with an eye-off, and its popover folds to the top row until the body shows again; moving the dimmed opacity slider shows it. The All Bodies swatch sets every body at once.
The automatic color range spans every body. With Auto range on, the range is the union of each body's own range, over every body whether it is shown, hidden or painted another way, so hiding a body never rescales the rest. Each body is clamped to its 2nd to 98th percentile, so a small body keeps its range beside a large one. Log scale keeps only the positive values and starts at their 1st percentile. Turn Auto range off to pin the range with the slider.
Field lines follow the shown vector field. While a scalar or a principal value is shown, they follow the magnetic flux density, else the first vector field, such as the displacement of an elasticity run. The switch stays off for a run without a vector field. They start on, from 18 × 18 seeds on the center plane. Seeds sit on a grid in the domain's bounding box: a volume, the center plane or a line along X through the center. A run shown flat moves volume seeds to the center plane. Length is the fraction of the domain diagonal a line may run, and each line ends at its first sharp reversal. Integrate Within limits the lines to one body.
The Setup tab¶
Setup shows what the solver received. The second tab beside the controls lists every body and boundary group with its material or measure and each condition in the solve frame, beside the authored value: a 100 N pull along X on a 20 mm × 10 mm face reads Surface Force 100 N Along (1, 0, 0) over Traction (500, 0) kPa, the signed traction in solve order, with expr in place of a component the sif holds as an expression. A fixed displacement reads the authored axes X, Y and Z in order, each as the value its solve coordinate received, Free, or – when the frame drops it, so a clamp with Y free on a section normal to X reads X – · Y Free · Z 0; the dash's tooltip and the row's spoken name say which solve axes the frame keeps. The values come from the run's conditions.json, the record of what each sif block got, so a condition the frame mapped differently from how it was authored reads as solved. A run from before that record lists its groups without conditions and says so.
| Section | Shows |
|---|---|
| Frame | The solve frame's kind, which way its plane faces, where it sits and how its axes run in the authored model, the thickness and plane state of a Cartesian 2D run, how a revolved section is shown, and the geometry check. A 2D run adds the Section Outline and Authored Body Ghost switches. |
| Glyphs | One row per glyph kind the run draws, with how many groups draw it and a switch for the kind. It sits above the tables, so it stays in reach on a model with many groups. |
| Bodies | One row per body, under a row for a material several bodies share, with its material and its conditions. |
| Boundaries | One row per boundary group, named faces first, with its measure and its conditions. With Conditions lists only the groups that received one, the default above 12 groups; a run without conditions.json lists every group. |
- Glyphs show only while the tab does. The scene then draws each condition as a shape on a neutral fill with its value, and Show Glyphs turns them all off. A row's icon toggles its own glyph.
- Plain Bodies paints every body grey while it is on, so the glyphs read clearly.
- Select a row to highlight its group in the accent. Click it again or press
Escto clear the selection, and double-click it, pressFor use the fit button that shows on the row to fit the camera to it. A row whose group has no cells to draw is dimmed, and a body hidden in the Field Viewer offers Show, orS. - Search matches names, Elmer group names, materials and condition kinds. Press
/to reach it from the tab, andEscto clear it. - A run without fields opens on the Setup tab: one still solving or one that failed after meshing draws its glyphs on the mesh, and one that failed before meshing lists its authored tags. A run whose mesh was purged lists its rows without glyphs. Show Glyphs, Plain Bodies, the 2D switches and the legend switches act only while the view draws the run, and hide or disable otherwise.
- A new run resets the row and kind toggles, the selection and the filter. A solving run that reopens with its fields keeps them, and the search carries over either way.
Runs and figures¶
| Panel | Shows |
|---|---|
| RunBrowserPanel | The run index as a table, refreshed every 5 s, with text, status, tag and physics filters and the runs claimed right now marked. A row click selects the run. |
| RunDetailPanel | The selected run: its manifest summary, stage timeline, results, artifact inputs, files and retention history, re-read every second while it solves. Fields opens the run in the field viewer, Folder opens its directory, Rehydrate fetches its store inputs back and Purge opens a dialog that removes bundle files by a retention plan. |
| FigurePanel | One plotly figure; update() swaps it, a figure with a uirevision keeps its zoom and selections, and bind() routes plotly events to a handler. |
| TablePanel | A polars frame that the browser sorts, filters, groups and hides columns of, with its layout saved per panel. |
The dock¶
A dock is a tree of three nodes:
| Node | Holds |
|---|---|
| Panel | One tab: a title, a builder that makes the component once the shell exists, a weight and an optional id. |
| Tabs | Panels sharing one tab group, the first one shown. |
| Split | Panels, tab groups and splits along one axis, shared by weight. The root is horizontal and the axis alternates with depth. |
A panel's id is its id, else its title in lower case with dashes. The builder receives the shell, the id and the title.
The workbench saves its layout and its open cards when they change, and restores the layout on the next start when it names exactly the panels the dock defines; a changed dock starts from its authored layout. Popped-out and floating groups come back docked. The reset button in the app bar rebuilds the authored layout. Each table saves its column layout and each 3D view its render mode.
The documents live in the per-user config directory, such as %LOCALAPPDATA%\femforge-workbench on Windows or ~/.config/femforge-workbench on Linux, as <user>/<workbench>/<key>.json. Pass --persist DIR to keep them elsewhere.
Write your own workbench¶
A workbench is a module-level function that returns a Split. Register it as a card through the femforge.workbenches entry point group:
import femforge as ff
import plotly.graph_objects as go
import polars as pl
from femforge_workbench.registry import WorkbenchSpec, panel
def force_curve(app: ff.workbench.Workbench, id: str, title: str) -> ff.workbench.FigurePanel:
"""The force against the gap."""
figure = go.Figure(go.Scatter(x=[1.0, 2.0, 3.0], y=[8.7, 6.1, 4.4], name="force"))
return ff.workbench.FigurePanel(app, id, title, figure)
def points(app: ff.workbench.Workbench, id: str, title: str) -> ff.workbench.TablePanel:
"""The solved points."""
frame = pl.DataFrame({"gap": [1.0, 2.0, 3.0], "force": [8.7, 6.1, 4.4]})
return ff.workbench.TablePanel(app, id, title, frame, filterable=True)
def gap_study() -> ff.workbench.Split:
"""The force curve beside its points."""
return ff.workbench.Split([ff.workbench.Panel("Force", force_curve, weight=2), ff.workbench.Panel("Points", points)])
WORKBENCHES: list[WorkbenchSpec] = [
panel("gap-study", "Gap Study", target=gap_study, description="Force against air gap.", group="Lab"),
]
if __name__ == "__main__":
ff.workbench.show(gap_study)
An entry point provides one WorkbenchSpec or a sequence of them. Three functions in femforge_workbench.registry declare one:
| Function | Card | Opens |
|---|---|---|
panel |
dock | the dock its target returns |
renderable |
viewer | the Renderable its target returns, in one 3D panel |
script |
script | its module, run with python -m in a subprocess; the launcher shows the files it lists in outputs |
A target is the function itself or its pkg.module:attr name, and its module is imported only when the card opens, so listing the catalogue imports nothing heavy. Two different specs under one name raise an error. A dock or viewer card rebuilds in place when you save a .py file under its source roots or a --watch directory, keeping the layout; a builder that raises leaves the old panels and names the error in the status line.
Limits¶
- One VTK.wasm mirror per page. The newest 3D panel mirrors its scene in the browser; older ones stream rendered frames from the server and say so in their status line.
- A scene whose geometry exceeds 64 MB streams from the server instead of mirroring.
--appandWindow.APPlook for Chrome and Edge at their default Windows install paths. Without either, the workbench opens a browser tab, and closing it leaves the server running.- The terminal panel is interactive on Windows with the
ptyextra. Elsewhere it shows the live log stream, read-only. - A
Splitpassed toshowis served as built. Pass the function that builds it to rebuild on save. - The
browsersandmonitorscards need a telemetry root. - Scene picking does not select a Setup row yet.
- Ctrl+C or closing the window stops the running task and waits up to 10 s for it to release its run. A task stuck in a long CAD or meshing call past that is killed, and its claim on the run is broken so the next start need not wait.