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:
The link to the demo video can be found here.
Before any solver can be used, a valid surface must be initialized. There are two ways to initialize said surface:
- By clicking the
Draw PSLGbutton, the user enters into the PSLG drawing mode where left mouse clicks define a series of points connected by lines. - 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).
- Once there is at least one closed loop and none that are incomplete, holes can be designated in a region by clicking
Add Hole. - Triangulate the PSLG using the
Init from PSLGbutton to generate a valid surface. Regions containing a hole indicator will not be triangulated.
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.
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.
Builds for Windows and Linux are available in the Releases tab.
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 builddBe 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.
- 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
- Professor Qiqi Wang's Lectures on the Finite Element Method on his channel AerodynamicCFD
- mbn010/Gray-Scott-reaction-diffusion-on-a-sphere
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.