Skip to content

A solid imported from geometry

Demonstrates meshing an imported solid, running a static analysis, and recovering displacements from the default results database.

The model before it is solved: parts, supports and loads

The model before it is solved: its parts, supports (red) and loads (blue).

The result: the model coloured by stress (vonMises [MPa])

The model, coloured by stress (vonMises [MPa]), in xfea’s 3D viewer.

Open in 3D turn it, cut it, pick any field: in xfea's viewer, in your browser

examples/scripts/01_getting_started/04_solid_from_geometry.py. Run it from the repository with uv run python examples/scripts/01_getting_started/04_solid_from_geometry.py, or, with xfea-examples installed, xfea-examples run 01_getting_started/04_solid_from_geometry.py.

from xfea.problem import Problem
from xfea.problem import StaticStep
from xfea.results import DisplacementFieldResults
from xfea.results import StressFieldResults
from xfea_examples import out_dir
from xfea_examples import viewer_wanted
from xfea_examples.models import solid_box_model
from xfea.viewers.viewer import Viewer
total_top_load = -10_000 # [N] total downward load on top face (-10 kN)
model, _, top_nodes, _, _, = solid_box_model(name="getting_started_solid")
problem = model.add_problem(Problem(name="solid_problem"))
step = problem.add_step(StaticStep(name="service"))
step.add_uniform_forcefield(
nodes=top_nodes,
z=total_top_load / max(1, len(top_nodes)),
load_case="service",
)
disp = DisplacementFieldResults()
stress = StressFieldResults()
step.add_field_outputs([disp, stress])
problem.analyse_and_extract(path=out_dir(model.name), verbose=True)
print(f"Maximum vertical displacement: {disp.get_min_result('z').z}")
# Via plugin registry
viewer = Viewer(plugin="browser")
viewer.add_model(model)
viewer.add_results({stress: "principal_stress_min"}, units="MPa")
viewer.add_results({stress: "principal_stress_max"}, units="MPa")
viewer.add_results({disp: "z"}, units="mm")
if viewer_wanted(): # XFEA_EXAMPLES_SHOW_VIEWER=1, or `xfea-examples config set-show-viewer on`
viewer.run()

© 2026 Francesco Ranaudo · Text and pictures CC BY 4.0 · Code Elastic License 2.0 · how to reuse them