Skip to content

FEniCS Elasticity Problem

This exercise connects the geometry and mesh you created earlier in Salome with the solver implementation in FEniCS. You’ll first convert the exported .med file into .xdmf format using the provided Jupyter Notebook converter, then use the main elasticity notebook to perform a linear elasticity analysis on a single-material cantilever beam. Finally, you’ll visualize the computed displacement and stress fields in ParaView.

Time: 30–45 minutes Deliverables: 5–6 screenshots (listed below)

Step 1 — Prepare the working directory

  1. Copy your exported .med mesh file (from the Salome Geometry & Mesh Exercise) into a folder called mesh/, for example:

    project_root/
      mesh/
        cantilever_marked.med
      post-processing/output/
      meshio_converter.ipynb
      main_elasticity.ipynb
  2. Download or copy the two provided notebooks:

    • meshio_converter.ipynb — converts .med.xdmf
    • main_elasticity.ipynb — runs the FEniCS elasticity solver

    Download link for the notebooks: Download notebooks (Google Drive) — main_elasticity.ipynb, meshio_converter.ipynb

Place both notebooks in your project_root/ folder.

Step 2 — Run the mesh conversion notebook

Open Jupyter Notebook (inside your WSL Ubuntu or Conda environment) and navigate to your folder.

  1. Launch and open meshio_converter.ipynb.
  2. Run all cells sequentially (Cell → Run All).

This notebook uses meshio to read your .med mesh file, extract solid and surface markers, and save multiple .xdmf files for use in FEniCS.

After running, you should see new files inside mesh/output/:

mesh.xdmf
surface.xdmf
solid.xdmf
markers.json

The printed JSON lists all markers detected from your Salome file (e.g., Fixed, Forced).

Screenshot A: Notebook cell output showing the printed markers.json summary (e.g., Fixed, Forced).

Screenshot B: Explorer or terminal view showing the generated .xdmf and .json files in mesh/output/.

Step 3 — Review and run the main elasticity notebook

Next, open main_elasticity.ipynb. This notebook automatically loads:

  • The mesh (mesh/output/mesh.xdmf)
  • The surface and solid markers (surface.xdmf, solid.xdmf)
  • The marker JSON file for boundary IDs

It defines material properties, sets Fixed and Forced faces, applies a downward surface traction, and solves the linear elasticity equations for a single material cantilever beam.

Run all cells sequentially.

After execution, you’ll see printed analysis results such as:

=== ANALYSIS RESULTS ===
Mesh: 1234 vertices, 5678 cells
Material: E = 2.1e11 Pa, nu = 0.3
Maximum displacement: 3.12e-05 m
Maximum von Mises stress: 2.45e07 Pa
Results saved to: post-processing/output/cantilever_results.xdmf
=== ANALYSIS COMPLETE ===

Screenshot C: Notebook output cell showing solver progress and final printed statistics.

Screenshot D: File explorer showing cantilever_results.xdmf inside post-processing/output/.

Step 4 — Visualize in ParaView

  1. Open ParaViewFile → Open → post-processing/output/cantilever_results.xdmf

  2. Click Apply to load the dataset.

  3. In the Color By dropdown, select:

    • Displacement → for the deformation field
    • or VonMisesStress → for stress visualization
  4. Change Representation to Surface with Edges for clarity.

  5. Optionally apply filters:

    • Slice (view cross-section of stress field)
    • Warp by Vector (show exaggerated deformation)

Screenshot E: ParaView visualization showing stress contours (Von Mises) and scalar bar.

Screenshot F (optional): Warped displacement view showing deformation pattern.

Acceptance Checklist (pass/fail)

  • .med mesh converted successfully using meshio_converter.ipynb
  • Boundary and material markers saved correctly to markers.json
  • Elasticity notebook executed successfully with solver outputs printed
  • cantilever_results.xdmf generated in the output directory
  • ParaView visualization showing displacement or stress fields clearly

This exercise completes the simulation pipeline — from geometry creation in Salome, mesh conversion via Jupyter notebooks, solving elasticity equations in FEniCS, to visualization in ParaView.