This is the experimental repository for SFEM, a C++ finite element framework, primarily developed for the solution of problems in solid mechanics and heat transfer. It supports distributed memory parallelism via the MPI protocol. SFEM utilizes PETSc for sparse linear algebra computations, and METIS for mesh partitioning. SLEPc is an optional dependency, which enables the computation of eigenvalues of discretized operators.
- C++ 23 and above
- Python 3.8 and above
- CMake 3.16 and above
- MPI
- PETSc
- SLEPc (optional)
- METIS
Start by cloning the repository to your machine:
git clone https://github.com/dlmpal/sfem-dev.git
Then, inside of the SFEM directory, execute the installation script (install.py). The script can be configured with several options, which are shown by executing:
python install.py --help
The installation script is able to download and build all required dependencies of SFEM (--download-all). Alternatively, the user must provide some relevant info (e.g. --petsc-dir or petsc-arch). The user can also select whether to build the applications (--with-apps). The simplest way to install the package is by executing:
python install.py --download-all --build-all
By default, the downloaded dependencies are installed at ${HOME}/local/sfem-deps and the library is installed at ${HOME}/local/sfem. These locations can be changed by setting --third-party-dir and --install-dir respectively.
After successfully running the script, a summary is printed and saved to file (summary.log). At the end of the summary several lines are printed, which should be copied and appended at the end of the user's .bashrc or equivalent file.
The easiest way to build a program with SFEM is by using CMake. Start by creating a CMakeLists.txt as follows:
cmake_minimum_required(VERSION 3.16)
project(my_sfem_solver)
set(CMAKE_CXX_COMPILER $ENV{MPICXX})
set(sfem_DIR ${SFEM_INSTALL_DIR}/lib/cmake/sfem)
find_package(sfem REQUIRED)
add_executable(my_sfem_solver /path/to/my_sfem_solver.cc)
target_link_libraries(my_sfem_solver sfem::sfem)
The user should verify that the MPI compiler MPICXX used to compile my_sfem_solver.cc is the same one that was used to compile SFEM (and PETSc).
SFEM can read and convert meshes in Gmsh format using the gmshToSfem application. SFEM can also produce VTK files for visualization (e.g. via ParaView) with the sfemToVTK application. Application binaries are located under ${SFEM_INSTALL_DIR}/bin.