Skip to content

Interacive simulation of PDEs with the Finite Element Method

License

Notifications You must be signed in to change notification settings

tvumcc/fea-visualizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

a03bdbf · · Jul 21, 2025

History

44 Commits
Jul 19, 2025
Jul 19, 2025
Jul 17, 2025
Jul 19, 2025
Jul 19, 2025
Jul 21, 2025
Jun 23, 2025
Jul 12, 2025
Jul 13, 2025
Jul 21, 2025
Jul 19, 2025
Jul 20, 2025

Repository files navigation

Finite Element Visualizer

Hackatime Counter

This project aims to showcase the time propogation of solutions to partial differential equations on triangularly meshed surfaces in 3D space by use of the Finite Element Method. Users can adjust parameters with sliders, set initial conditions with the mouse, and create surfaces from line drawings or .obj files.

In particular, this project currently provides solvers for the following equations:

Demo Video

The link to the demo video can be found here.

Screenshots

Screenshot of Finite Element Visualizer: Reaction-Diffusion Screenshot of Finite Element Visualizer: Wave

Usage

Initializing a Surface

Before any solver can be used, a valid surface must be initialized. There are two ways to initialize said surface:

Draw a PSLG (Planar Straight Line Graph)

  1. By clicking the Draw PSLG button, the user enters into the PSLG drawing mode where left mouse clicks define a series of points connected by lines.
  2. To close a loop with the final segment press Enter (to finish the whole PSLG and exit drawing) or Ctrl+Enter (to finish just that loop and continue drawing).
  3. Once there is at least one closed loop and none that are incomplete, holes can be designated in a region by clicking Add Hole.
  4. Triangulate the PSLG using the Init from PSLG button to generate a valid surface. Regions containing a hole indicator will not be triangulated.

Import from a .obj

Click the Import from .obj button and select a .obj file that contains vertex positions and normals. Some example meshes are provided in the assets/fem_meshes directory. In general, you need to use a mesh that does not have sharp edges like a cube does as that causes numerical instability. Tools like Blender can be used to smooth out vertices and possibly circumvent this issue.

Using the Solver

Once a surface is initialized, the application switches to brush mode where the user can hold left click and drag on the surface to set the values of the nodes in that region. Parameters for each equation's solver can be adjusted using the sliders at the bottom of the side panel.

Be wary, however, of numerical instability that could arise when setting these parameters to be too extreme; this will trigger a pop up and clear the solver of its nodal values. In some cases, if using the brush causes numerical instability almost immediately, then try lowering the brush strength. Meshes with sharp edges and turns (around 90 degrees) can also cause problems so try to stick to those that are relatively smooth.

Installation

Builds for Windows and Linux are available in the Releases tab.

Building from Source

This project uses CMake for compilation, so make sure CMake is installed before proceeding.

git clone https://github.com/tvumcc/fea-visualizer.git --recursive

cd fea-visualizer
cmake -S  . -B build -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release
cmake --build buildd

Be sure to use the appropriate generator for the OS you are compiling on. Run cmake -G to see a list of generators. If you are using a multi-configuration generator like MSVC or Xcode, use the argument --config Release when calling the build command to compile in Release mode.

When running the executable, make sure it is run from the same directory that contains the shaders and assets directories otherwise shaders and images will not be able to load.

Attribution

Libraries Used

  • glfw - windowing and input handling
  • glad - OpenGL function and enum loading
  • glm - linear algebra library for use with OpenGL
  • eigen - linear algebra library for solving linear systems
  • imgui - drawing the GUI
  • stb_image.h - image file loading
  • tinyobjloader - .obj file loading
  • nativefiledialog - cross platform interface to a file dialog
  • triangle - Delaunay triangulation for PSLGs

Online References Used

Inspiration

This project is largely inspired by the brilliant work done on VisualPDE, an interactive sandbox for various PDEs that uses Finite Differences for spatial discretization instead of Finite Elements.