![]() |
LehrFEM++ 1.0.0
A simple Finite Element Library for teaching
|
This tutorial shows you how you can call LehrFEM++ from your own code in a few simple steps. We will make a very simple program that calls LehrFEM++ and prints the number of nodes of a triangle to the console.
You can find a minimal working example here: LehrFEM++ Project Scaffold Github.
You only need a recent version of CMake (>= 3.10) and one of the supported compilers:
getting_started
somewhere on your system and create the subfolder cmake
in it, e.g. getting_started/main.cc
. Later on, we will add the main()
function to this file and call LehrFEM++ from there.HunterGate.cmake
file into getting_started/cmake
getting_started/CMakeLists.txt
with the following content CMakeLists.txt
links only with the lf.base
module of LehrFEM++. Because we only want to print the number of nodes of a triangle, it suffices to link to the lf.base
module. However, if you want to use more functionality, you will probably need to link to other LehrFEM++ modules as well. See Modules for more info about LehrFEM++ modules and list of namespaces for a list of all LehrFEM++ modules.getting_started
. E.g. on linux: Here we will write a very simple program that prints the number of nodes of a triangle to the console. For this we write the following code into the previously created main.cc
:
Afterwards compile your program and run it. Example on linux:
The LehrFEM++ team releases new versions of LehrFEM++ on hunter when important changes happen. These releases are tagged on github and you can see all releases here.
It's important to understand that the concrete HunterGate
command that you use in your CMakeLists will determine the versions of LehrFEM++ that you can use in your code. If you want to use the latest version of LehrFEM++, you should also use the latest HunterGate
command. Hunter allows you to select the LehrFEM++ version explictly, see here. If you don't specify a version explicitly, the most recent version which is available with your current HunterGate
command, is used.
Hunter also allows you to manually use any commit from the LehrFEM++ github repository. This can be useful if you want to use a version of LehrFEM++ that has not yet been officially released via hunter. We show here how you can use the commit with hash 41fe4560d5f56612059c3f919ec1a83093116984 in your own project.
1) Determine the SHA1 hash of the commit:
2) create the file cmake/Hunter/config.cmake
in your own project and fill it with the following content (see here for more information), adapt it accordingly if you want to use another commit(!):
3) modify the HunterGate command in your top-level CMakeLists.txt
so that it includes the local config file:
4) build your project as before. Note that the commit that the build can fail depending on whether the commit you have selected built LehrFEM++ correctly.