iTranslated by AI
[Extra Edition] Building an Open-Source CAE Environment on WSL2 (Elmer FEM + Gmsh + ParaView + Python)
Introduction
In this series, I share my studies on open-source CAE using tools like Elmer on Windows.
As a change of pace, and with an eye toward future analysis automation and server-based progress management, I have set up an Ubuntu environment on Windows using WSL2.
This document summarizes the steps for building a "Full-OSS CAE Platform" that integrates a mesher (Gmsh), solver (Elmer FEM), post-processor (ParaView), and automation/data processing tools (Python).
Installing Elmer was more time-consuming than I expected. Please forgive me if a pure Linux environment would have been better suited to a different approach.
System Configuration & Toolchain
My goal is a configuration where computationally heavy solvers run on WSL2, while graphics-heavy GUI tools run natively on Windows.
- Geometry & Mesh Creation: Free CAD, Gmsh (Windows native)
- Format Conversion: ElmerGrid (WSL2 / Ubuntu)
- Numerical Analysis: ElmerSolver / ElmerGUI (WSL2 / Ubuntu)
- Visualization: ParaView (Windows native)
- Automation & Data Processing: Python 3 (WSL2 / Ubuntu)
1. WSL2 Resource Optimization
To fully utilize multi-core CPUs and large amounts of memory in WSL2, I will expand the resource allocation.
Write the following to C:\Users\<username>\.wslconfig on Windows, then restart WSL by running wsl --shutdown in PowerShell to apply the changes.
[wsl2]
memory=12GB # Adjust according to your RAM (e.g., 12GB for a 16GB system)
swap=4GB
processors=8 # Specify the number of logical cores to use
2. Preparing the WSL2 (Ubuntu 22.04) Environment
Install the build tools and dependency libraries required to compile Elmer all at once.
sudo apt update && sudo apt upgrade -y
sudo apt install -y git cmake build-essential gfortran libblas-dev liblapack-dev \
libopenmpi-dev openmpi-bin libqwt-qt5-dev qtscript5-dev libqt5xmlpatterns5-dev \
qtbase5-dev libqt5svg5-dev
3. Building and Installing Elmer FEM
Get the source code from the official repository and build it. For the sake of file access speed, please be sure to work under your Linux home directory (~/).
mkdir -p ~/projects && cd ~/projects
git clone https://github.com/ElmerCSC/elmerfem.git
cd elmerfem
mkdir build && cd build
# Create build configuration with CMake
cmake .. \
-DWITH_ELMERGUI:BOOL=TRUE \
-DWITH_OCC:BOOL=FALSE \
-DWITH_QWT:BOOL=TRUE \
-DWITH_MPI:BOOL=TRUE
# Parallel compile and install using all cores
make -j$(nproc)
sudo make install
Once complete, if you run ElmerSolver --version and the version information is displayed, the installation is successful.
4. Building a Python Virtual Environment for Analysis Automation
To automate parameter studies and process analysis results, we will set up a Python environment specialized for scientific computing.
# Create and activate a virtual environment named "cae_env"
python3 -m venv ~/cae_env
source ~/cae_env/bin/activate
# Install essential libraries
pip install --upgrade pip
pip install numpy scipy matplotlib pandas pyvista
5. Setting Up Windows Tools (Gmsh & ParaView)
For pre- and post-processing tools that involve heavy 3D rendering, we use Windows-native versions to benefit from GPU acceleration.
ParaView: Download and install the Windows 64-bit installer from the official website.
Gmsh: Download the Windows 64-bit version from the official website and extract it to a folder of your choice. It is convenient to add the folder path to your environment variable (Path).
6. Standard Analysis Workflow
The basic analysis cycle in the constructed environment is as follows:
[Windows] Gmsh: Create geometry → Generate mesh → Export as model.msh (v2 format).
[WSL2] ElmerGrid: Convert to an Elmer-format folder by executing the following in the terminal:
ElmerGrid 14 2 model.msh -autoclean
[WSL2] ElmerSolver: Create an analysis condition file (.sif) and run the simulation.
[Windows] ParaView: Open the output case.vtu from the Windows side and evaluate the results.
With this, your flexible CAE simulation environment is complete.
Discussion
ElmerのWSLディストロ(Debin 13, Alma Linux 9:SolverはほぼElmer Virtual Machineの機能、ElmerGUI付き)をElmer フォーラムに投稿しています。
Ubuntu 24.04・Ubuntu 22.04であれば、Debian 13用のスクリプトで動作すると思います。(Zoltan用の設定:Ubuntu 24.04 gcc-12系、Ubuntu 22.04はデフォルトのgccでOK)。
ご参考まで。