A Guide Through Feel++
User Manual
Feel++ Book Contributors https://github.com/feelpp/book.feelpp.org/graphs/contributors
The Feel++ User Manual
Feel++ Book Contributors https://github.com/feelpp/book.feelpp.org/graphs/contributors
This document is under active development and discussion!
If you find errors or omissions in this document, please don’t hesitate to submit an issue or open a pull request with a fix. We also encourage you to ask questions and discuss any aspects of the project on the Feel++ Gitter forum. New contributors are always welcome! |
2. Conventions used in this book
The following typographical conventions are used in the book
Italic indicates new terms
typewriter
is used on program listings as well as when referring to
programming elements, e.g. functions, variables, statements, data types,
environment variables or keywords.
\$ typewriter
or > typewriter
displays commands that the user types literally without the \$
or >
.
this is a general note. |
this is a general warning. |
be cautious |
3. Mathematical Notations
3.1. Geometry and Meshes
-
\(d=1,2,3\) geometrical dimension
-
\(\Omega \subset \mathbb{R}^d\)
-
\(K\) a cell or element of a mesh
-
\(h\) characteristic mesh size
-
\(k_{\mathrm{geo}}\) polynomial order of the geometrical transformation
-
\(\delta=(h,k_{\mathrm{geo}})\) discretization parameter pair for the geometrical transformation, default value \(k_{\mathrm{geo}}=1\) (straight cells or elements)
-
\(\varphi^K_\delta: \hat{K} \rightarrow K\), geometrical transformation
-
\(\mathcal{T}_{\delta}\) a triangulation, \(\mathcal{T}_\delta = \{ K\; | \; K=\varphi^K_\delta (\hat{K}) \} \)
-
\(\Omega_h \equiv \cup_K {K}\)
3.2. Spaces
-
\(P^k_{c,h} = \{ v_h \in C^0(\bar{\Omega}); \forall K \in \mathcal{T}_h,\ v_h \circ T_K \in \mathbb{P}^k\}\) Space of continuous piecewise polynomial of total degree \(\leq k\).
Introduction to Feel++
Discuss and Contribute
Use Issue 858 to drive development of this
section. Your contributions make a difference. No contribution is too small.
|
4. What is Feel++?
Feel++ is a unified C++ implementation of Galerkin methods (finite and spectral element methods) in 1D, 2D and 3D to solve partial differential equations.
Feel++ is
-
a versatile mathematical kernel solving easily problems using different techniques thus allowing testing and comparing methods, e.g. cG versus dG.
-
a small and manageable library which nevertheless encompasses a wide range of numerical methods and techniques and in particular reduced order methods such as the reduced basis method.
-
a software that follows closely the mathematical abstractions associated with partial differential equations (PDE) and in particular the finite element mathematical framework and variational formulations.
-
a library that offers solving strategies that scales up to thousands and even tens of thousands of cores.
-
a library entirely in C++ allowing to create C++ complex and typically non-linear multi-physics applications currently in industry, physics and health-care.
Quick Starts
5. Installation Quick Start
Using Feel++ inside Docker is the recommended and fastest way to use Feel++. The Docker chapter is dedicated to Docker and using Feel++ in Docker.
We strongly encourage you to follow these steps if you begin with Feel++ in particular as an end-user.
People who would like to develop with and in Feel++ should read through the remaining sections of this chapter.
6. Usage Start
Start the Docker container feelpp/feelpp-base
or feelpp/feelpp-toolboxes
as follows
> docker run -it -v $HOME/feel:/feel feelpp/feelpp-toolboxes
these steps are explained in the chapter on Feel++ containers. |
Then run e.g. the Quickstart Laplacian that solves the Laplacian problem in Quickstart Laplacian sequential or in Quickstart Laplacian on 4 cores in parallel.
> feelpp_qs_laplacian_2d --config-file Testcases/quickstart/laplacian/feelpp2d/feelpp2d.cfg
The results are stored in Docker in
/feel/qs_laplacian/feelpp2d/np_1/exports/ensightgold/qs_laplacian/
and on your computer
$HOME/feel/qs_laplacian/feelpp2d/np_1/exports/ensightgold/qs_laplacian/
The mesh and solutions can be visualized using e.g. Parariew or Visit.
|
> mpirun -np 4 feelpp_qs_laplacian_2d --config-file Testcases/quickstart/laplacian/feelpp2d/feelpp2d.cfg
The results are stored in a simular place as above: just replace np_1
by np_4
in the paths above. The results should look like
Solution |
Mesh |
7. Syntax Start
Here are some excerpts from Quickstart Laplacian that solves the Laplacian problem. It shows some of the features of Feel++ and in particular the domain specific language for Galerkin methods.
First we load the mesh, define the function space define some expressions
tic();
auto mesh = loadMesh(_mesh=new Mesh<Simplex<FEELPP_DIM,1>>);
toc("loadMesh");
tic();
auto Vh = Pch<2>( mesh );
auto u = Vh->element("u");
auto mu = expr(soption(_name="functions.mu")); // diffusion term
auto f = expr( soption(_name="functions.f"), "f" );
auto r_1 = expr( soption(_name="functions.a"), "a" ); // Robin left hand side expression
auto r_2 = expr( soption(_name="functions.b"), "b" ); // Robin right hand side expression
auto n = expr( soption(_name="functions.c"), "c" ); // Neumann expression
auto solution = expr( checker().solution(), "solution" );
auto g = checker().check()?solution:expr( soption(_name="functions.g"), "g" );
auto v = Vh->element( g, "g" );
toc("Vh");
Second we define the linear and bilinear forms to solve the problem
tic();
auto l = form1( _test=Vh );
l = integrate(_range=elements(mesh),
_expr=f*id(v));
l+=integrate(_range=markedfaces(mesh,"Robin"), _expr=r_2*id(v));
l+=integrate(_range=markedfaces(mesh,"Neumann"), _expr=n*id(v));
toc("l");
tic();
auto a = form2( _trial=Vh, _test=Vh);
tic();
a = integrate(_range=elements(mesh),
_expr=mu*inner(gradt(u),grad(v)) );
toc("a");
a+=integrate(_range=markedfaces(mesh,"Robin"), _expr=r_1*idt(u)*id(v));
a+=on(_range=markedfaces(mesh,"Dirichlet"), _rhs=l, _element=u, _expr=g );
//! if no markers Robin Neumann or Dirichlet are present in the mesh then
//! impose Dirichlet boundary conditions over the entire boundary
if ( !mesh->hasAnyMarker({"Robin", "Neumann","Dirichlet"}) )
a+=on(_range=boundaryfaces(mesh), _rhs=l, _element=u, _expr=g );
toc("a");
More explanations are available in Learning by examples.
Installing Feel++
8. Getting Started
This section describes the available ways to to download, compile and install Feel++.
8.1. Docker
Using Feel++ inside Docker is the recommended and fastest way to use Feel++. The Docker chapter is dedicated to Docker and Feel++ containers chapter is dedicated to Feel++ in Docker.
We strongly encourage you to follow these steps if you begin with Feel++ in particular as an end-user.
People who would like to develop with and in Feel++ should read through the remaining sections of this chapter.
8.2. System requirements
8.2.1. Compilers
Feel++ uses C++14 compilers such as GCC6 and Clang. Currently it is not mandatory to have a C++14 stantard library but it will be soon.
There used to be a major compatibility issue between llvm/clang and GCC compilers since GCC5 released the ABI tag which makes it impossible to compile Feel++ using llvm/clang with GCC5 or GCC6 standard libraries for a time. Please see the following table to understand the working C++ compiler / C++ standard library combinations. |
Compiler | Standard Library |
---|---|
clang (3.6, 3.7, 3.8) |
libstdc++ 4.9 |
clang |
libc++ (corresponding clang version) |
clang (3.8(requires patches), 3.9) |
libstdc++ 6 |
GCC 6 |
libstdc++ 6 |
GCC 6.2.1 seems to be problematic on debian/testing — the tests in the testsuite fail. — GCC 6.3.1 or GCC 6.2.0 don’t have any problems. |
8.2.2. Required tools and libraries
Other than C++14 compilers, Feel++ requires only a few tools and libraries, namely CMake, Boost C++ libraries and an MPI implementation such as open-mpi or mpich. The table below provides information regarding the minimum and maximum version supported. A — means it has not necessarily been tested with the latest version but we do not expect any issues. Note that for MPI, an implementation with MPI-IO support would be best.
Name | Minimum Version | Maximum Version | Notes |
---|---|---|---|
CMake |
3.0 |
— |
|
MPI |
— |
— |
openmpi or mpich |
Boost |
1.55 |
1.63 |
8.2.3. Recommended libraries
Here is a list of libraries that we recommend to use jointly with Feel++.
Library | Minimum Version | Maximum Version | Notes |
---|---|---|---|
HDF5 |
1.8.6 |
1.8.16 |
Enables high performance I/O; Enables MED Support; Be careful on Debian/sid a more recent version of HDF5 breaks MED support |
PETSc |
3.2 |
3.7 |
Last is best; a requirement for parallel and high performance computing |
SLEPc |
3.2 |
3.7 |
last is best; a requirement for eigenvalue problem; depends on PETSc |
Gmsh |
2.8.7 |
2.16 |
last is best; a requirement if you want to be able to read many file formats; HDF5 version in Debian/sid currently breaks MED format support. |
Superlu |
superlu and superlu_dist |
||
Suitesparse |
umfpack (colamd,amd) |
||
OpenTURNS |
2.0 |
Uncertainty quantification |
8.2.4. Recommended tools
Here is a list of tools that we recommend to use jointly with Feel++.
Tool | License | Notes |
---|---|---|
Computer Aided Design |
||
Gmsh |
Open Source |
|
Mesh Generation |
||
Gmsh |
Open Source |
|
MeshGems |
Commercial |
|
Post-Processing |
||
Paraview |
Open Source |
|
Ensight |
Commercial |
|
Octave |
Open Source |
|
Gmsh |
Open Source |
Note that all these packages are available under Debian GNU/Linux and Ubuntu. Once you have installed those dependencies, you can go to Compiling.
8.2.5. Suggested tools
Here is a list of tools that we suggest to use jointly with Feel++.
Tool | License | Notes |
---|---|---|
Computer Aided Design (CAD) |
||
Freecad |
Open Source |
|
Salome |
Open Source |
HDF5 version in Debian/sid currently breaks MED format support. |
Modeling, Compilation and Simulation Environment |
||
Open Modelica |
Open Source |
|
Debugging and Profiling |
||
Google perftools |
Open Source |
|
Valgrind |
Open Source |
8.3. Feel++ on Linux
We now turn to the installation of the Feel++ dependencies on Linux. Feel++ is currently support on Ubuntu (16.04, 16.10) and Debian (Sid, Testing).
8.3.1. Ubuntu
Ubuntu 16.10 Yaketti Yak
Here is the suggested installation of the Feel++ dependencies on Ubuntu 16.10
$ sudo apt-get -qq update
$ sudo apt-get install automake autoconf libtool libboost-all-dev\
bash-completion emacs24 gmsh libgmsh-dev libopenturns-dev \
libbz2-dev libhdf5-openmpi-dev libeigen3-dev libcgal-dev \
libopenblas-dev libcln-dev libcppunit-dev libopenmpi-dev \
libann-dev libglpk-dev libpetsc3.7-dev libslepc3.7-dev \
liblapack-dev libmpfr-dev paraview python-dev libhwloc-dev \
libvtk6-dev libpcre3-dev python-h5py python-urllib3 xterm tmux \
screen python-numpy python-vtk6 python-six python-ply wget \
bison sudo xauth cmake flex gcc-6 g++-6 clang-3.9 \
clang++-3.9 git ipython openmpi-bin pkg-config
Ubuntu 16.04
Here is the suggested installation of the Feel++ dependencies on Ubuntu LTS 16.04
$ sudo apt-get install autoconf automake bash-completion bison\
clang++-3.8 clang-3.8 cmake emacs24 flex g++-6 gcc-6 git gmsh\
ipython libann-dev libbz2-dev libcgal-dev libcln-dev \
libcppunit-dev libeigen3-dev libglpk-dev libgmsh-dev \
libhdf5-openmpi-dev libhwloc-dev liblapack-dev libmpfr-dev\
libopenblas-dev libopenmpi-dev libopenturns-dev libpcre3-dev \
libpetsc3.6.2-dev libproj-dev libslepc3.6.1-dev libtool \
libvtk6-dev openmpi-bin paraview pkg-config python-dev \
python-h5py python-numpy python-ply python-six \
python-urllib3 python-vtk6 screen sudo tmux wget xauth xterm
We are unfortunately stung by the ABI change in GCC 6 when using clang. You need to recompile the Boost C++ libraries to be able to use clang, see the section in the Annexes on Compiling Boost. |
8.3.2. Debian
Debian Sid and Testing
At the time of writing there is little difference between Sid and Testing, here is the recommend dependencies installation command line:
$ apt-get -y install \
autoconf automake bash-completion bison cmake emacs24 \
flex git gmsh ipython libann-dev libboost-all-dev \
libbz2-dev libcgal-dev libcln-dev libcppunit-dev \
libeigen3-dev libglpk-dev libgmsh-dev \
libhdf5-openmpi-dev libhwloc-dev liblapack-dev \
libmpfr-dev libopenblas-dev libopenmpi-dev \
libopenturns-dev libpcre3-dev libtool libvtk6-dev \
openmpi-bin paraview petsc-dev pkg-config python-dev \
python-h5py python-numpy python-ply python-six \
python-urllib3 python-vtk6 screen slepc-dev sudo \
tmux wget xauth xterm zsh
Older distributions
Unfortunately the older distributions have the ABI GCC issue with clang, e.g. Debian/jessie, or they are too old to support a simple installation procedure.
8.4. Mac OS X
Feel++ is supported on Mac OSX, starting from OS X 10.9 Mavericks to OS X 10.12 Sierra using Homebrew or MacPorts.
8.4.1. First step
Xcode is required on Mac OSX to install Feel++.
The easiest way to do so is to go through the Apple Store application and to search for Xcode. Xcode will provide the programming environment, e.g clang, for the next steps.
8.4.2. Homebrew
Introduction to HomeBrew
Homebrew is a free/open source software introduced to simplify the installation of other free/open source software on MacOS X. Homebrew is distributed under the BSD 2 Clause (NetBSD) license. For more information, visit their website.
Installation
To install the latest version of Homebrew, simply visit their website and follow the instructions. Each new package Homebrew installs is built into an intermediate place called the Cellar (usually /usr/local/Cellar) and then the packages are symlinked into /usr/local (default).
Key commands
Homebrew base command is brew
. Here is a list of base available commands:
-
brew doctor
: Check if the system has any problem with the current installation of Homebrew; -
brew install mypackage
: This command installs the package mypackage; -
brew install [--devel|--HEAD] mypackage
: These options respectively installs either the development version or the HEAD version of the package mypackage, if such versions are specified in the Formula file; -
brew uninstall mypackage
: This command allows to uninstall the package mypackage.
Formulas
A Formula is a Ruby script format specific to Homebrew. It allows to describe the installation process of a package. Feel++ uses specific Formulae that you can get in the Feel++ github repository: feelpp/homebrew-feelpp.
Installation
This section is aimed at users that do not have Homebrew already installed.
In order to build Feel++ from Homebrew, you have to do the following steps:
First install Homebrew
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
then check your Homebrew installation and fix warnings/errors if necessary
$ brew doctor
Install Homebrew-science tap to get the scientific software recommended or suggested for Feel++.
$ brew tap homebrew/homebrew-science
you should see something like
==> Tapping homebrew/science
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-science'...
remote: Counting objects: 661, done.
remote: Compressing objects: 100% (656/656), done.
remote: Total 661 (delta 0), reused 65 (delta 0), pack-reused 0
Receiving objects: 100% (661/661), 591.93 KiB | 0 bytes/s, done.
Tapped 644 formulae (680 files, 1.9M)
Next you install Feel++ tap with
brew tap feelpp/homebrew-feelpp
you should read something like
==> Tapping feelpp/feelpp
Cloning into '/usr/local/Homebrew/Library/Taps/feelpp/homebrew-feelpp'...
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 5 (delta 0), reused 4 (delta 0), pack-reused 0
Unpacking objects: 100% (5/5), done.
Tapped 1 formula (30 files, 60.7K)
The final step is to either install Feel++
$ brew install feelpp
or just Feel++ dependencies if you plan to build Feel++ from sources yourself
$ brew install --only-dependencies feelpp
Note If you encounter problems, you can fix them using
brew doctor
. A frequent issue is to forceopen-mpi
withbrew link --overwrite open-mpi
Advanced usage
If Homebrew is already installed on your system, you might want to customize your installation for the correct dependencies to be met for Feel++.
Feel++ Dependencies
You can browse Feel++ dependencies using the following command:
$ brew deps feelpp | column
you get the list of formulas Feel++ depends on for its installation
ann fftw libtool slepc
arpack gcc metis suite-sparse
autoconf glpk mumps sundials
automake gmp netcdf superlu
boost gmsh open-mpi superlu_dist
cln hdf5 parmetis szip
cmake hwloc petsc tbb
eigen hypre scalapack veclibfort
Customizing builds
If you want to customize the compilation process for a dependency (Set debug mode, Remove checking steps, Remove the link with certain libraries, etc.), you can access to the building options with the info
flag. For exemple, with open-mpi:
$ brew info open-mpi
You get various information about the open-mpi
formula
open-mpi: stable 2.0.1 (bottled), HEAD
High performance message passing library
https://www.open-mpi.org/
Conflicts with: lcdf-typetools, mpich
/usr/local/Cellar/open-mpi/2.0.1 (688 files, 8.6M) *
Built from source on 2016-09-26 at 10:36:46 with: --c++11 --with-mpi-thread-multiple
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/open-mpi.rb
==> Dependencies
Required: libevent ✔
==> Requirements
Recommended: fortran ✔
Optional: java ✔
==> Options
--c++11
Build using C++11 mode
--with-cxx-bindings
Enable C++ MPI bindings (deprecated as of MPI-3.0)
--with-java
Build with java support
--with-mpi-thread-multiple
Enable MPI_THREAD_MULTIPLE
--without-fortran
Build without fortran support
--HEAD
Install HEAD version
Then, you then just have to pass the needed flags, when installing the dependency.
Important:
boost
has to be installed with mpi and c++11 support andmumps
needs to be installed with the following scotch5 support.
8.4.3. MacPorts
Introduction
MacPorts is an open-source community projet which aims to design an easy-to-use system for compiling, installing and upgrading open-source software on Mac OS X operating system. It is distributed under BSD License and facilitate the access to thousands of ports (software) without installing or compiling open-source software. MacPorts provides a single software tree which includes the latest stable releases of approximately 17700 ports targeting the current Mac OS X release (10.9). If you want more information, please visit their website.
MacPorts Installation
To install the latest version of MacPorts, please go
to Installing
MacPorts page and follow the instructions. The simplest way is to
install it with the Mac OS X Installer using the pkg
file
provided on their website. It is recommended that you install X11 (X Window System) which is normally used to display X11 applications.
If you have installed with the package installer (MacPorts-2.x.x.pkg
) that means MacPorts will be installed in
/opt/local
. From now on, we will suppose that macports has
been installed in /opt/local
which is the default MacPorts
location. Note that from now on, all tools installed by MacPorts will be installed in /opt/local/bin
or /opt/local/sbin
for example (that’s here you’ll find gcc4.7 or later e.g
/opt/local/bin/g++-mp-4.7
once being installed).
Key commands
In your command-line, the software MacPorts is called by the command port
. Here is a list of key commands for using MacPorts, if you want more informations please go to MacPorts Commands.
-
sudo port -v selfupdate
: This action should be used regularly to update the local tree with the global MacPorts ports. The option-v
enables verbose which generates verbose messages. -
port info mypackage
: This action is used to get information about a port. (description, license, maintainer, etc.) -
sudo port install mypackage
: This action install the port mypackage. -
sudo port uninstall mypackage
: This action uninstall the port mypackage. -
port installed
: This action displays all ports installed and their versions, variants and activation status. You can also use the-v
option to also display the platform and CPU architecture(s) for which the ports were built, and any variants which were explicitly negated. -
sudo port upgrade mypackage
: This action updgrades installed ports and their dependencies when aPortfile
in the repository has been updated. To avoid the upgrade of a port’s dependencies, use the option-n
.
Portfile
A Portfile is a TCL script which usually contains simple
keyword values and TCL expressions. Each package/port has a
corresponding Portfile but it’s only a part of a port description.
Feel++ provides some mandatory Portfiles for its compilation which are either not available in MacPorts or are buggy but Feel++ also provides some Portfiles which are already available in MacPorts such as gmsh or petsc. They usually provide either some fixes to ensure Feel++ works properly or new version not yet available in MacPorts. These Portfiles are installed in ports/macosx/macports
.
Installation
To be able to install Feel++, add the following line in
/opt/local/etc/macports/source.conf
at the top of the file
before any other sources:
file:///<path to feel top directory>/ports/macosx/macports
Once it’s done, type in a command-line:
$ cd <your path to feel top directory>/ports/macosx/macports
$ sudo portindex -f
You should have an output like this:
Reading port index in $<$your path to feel top directory$>$/ports/macosx/macports
Adding port science/feel++
Adding port science/gmsh
Adding port science/petsc
Total number of ports parsed: 3
Ports successfully parsed: 3
Ports failed: 0
Up-to-date ports skipped: 0
Your are now able to type
$ sudo port install feel++
It might take some time (possibly an entire day) to compile all the requirements for Feel++ to compile properly. If you have several cores on your MacBook Pro, iMac or MacBook, we suggest that you configure macports to use all or some of them.
To do that uncomment the following line in the file
/opt/local/etc/macports/macports.conf
buildmakejobs 0 $\#$ all the cores
At the end of the sudo port install feel++
, you have all
dependencies installed. To build all the Makefile, \cmake
is
automatically launched but can have some libraries may not be found but they are not mandatory for build Feel++, only the features related to the missing libraries will be missing.
Missing ports
|
8.5. Building Feel++
Once the steps to install on Linux or MacOS X has been followed, we explain, in this section, how to download and build Feel++ from source.
8.5.1. For the impatient
First retrieve the source
$ git clone https://github.com/feelpp/feelpp.git
Create a build directory
$ mkdir build
$ cd build
Configure Feel++
$ CXX=clang++ ../feelpp/configure -r
Compile the Feel++ library
$ make feelpp
you can speed up the make process by passing the option -j<N> where N is the number of concurrent make sub-processes. It compiles N files at a time and respect dependencies. For example -j4 compiles 4 C++ files at a time.
|
Be aware that Feel++ consumes memory. The Feel++ library compile with 2Go of RAM. But to be more comfortable, 4Go or more would be best. The more, the better. |
Compile your first Feel++ applications
$ make quickstart
Execute your first Feel++ application in sequential
$ cd quickstart
$ ./feelpp_qs_laplacian_2d --config-file qs_laplacian_2d.cfg
Execute your first Feel++ application using 4 mpi processes
$ mpirun -np 4 feelpp_qs_laplacian_2d --config-file qs_laplacian_2d.cfg
8.5.2. Downloading sources
Using Tarballs
Feel is distributed as tarballs following each major release. The tarballs are available on the link:https://github.com/feelpp/feelpp/releases[Feel Releases] web page.
Download the latest tarball, then uncompress it with:
$ tar -xzf feelpp-X.YY.0.tar.gz
$ cd feelpp-X.YY.0
You can now move to the section Using cmake.
Using Git
Alternatively, you can download the sources of Feel++ directly from the Git repository.
$ git clone https://github.com/feelpp/feelpp.git
You should read something like
Cloning into 'feelpp'...
remote: Counting objects: 129304, done.
remote: Compressing objects: 100% (18/18), done.
remote: Total 129304 (delta 6), reused 0 (delta 0), pack-reused 129283
Receiving objects: 100% (129304/129304), 150.52 MiB | 1.69 MiB/s, done.
Resolving deltas: 100% (94184/94184), done.
Checking out files: 100% (7237/7237), done.
$ cd feelpp
The first level directory tree is as follows
$ tree -L 1 -d | column
. ├── databases ├── research
├── applications ├── doc ├── testsuite
├── benchmarks ├── feel └── tools
├── cmake ├── ports 14 directories
├── contrib ├── projects
├── data ├── quickstart
8.5.3. Configuring Feel++
For now on, we assume that clang++
has been installed in /usr/bin
. Yor mileage
may vary depending on your installation of course.
It is not allowed to build the library in the top source directory. |
It is recommended to have a directory (e.g.
|
Using cmake
The configuration step with cmake
is as follows
$ cd FEEL/feel.opt
$ cmake ../feelpp -DCMAKE_CXX_COMPILER=/usr/bin/clang++-3.6 -DCMAKE_C_COMPILER=/usr/bin/clang-3.6 -DCMAKE_BUILD_TYPE=RelWithDebInfo
CMake supports different build type that you can set with |
Using configure
Alternatively you can use the configure
script which calls cmake
. configure --help
will provide the following help.
Options:
-b, --build build type: Debug, Release, RelWithDebInfo
-d, --debug debug mode
-rd, --relwithdebinfo relwithdebinfo mode
-r, --release release mode
--std=c++xx c++ standard: c++14, c++1z (default: c++14)
--stdlib=libxx c++ standard library: stdc++(GCC), c++(CLANG) (default: stdc++)
--max-order=x maximum polynomial order to instantiate(default: 3)
--cxxflags override cxxflags
--cmakeflags add extra cmake flags
--prefix=PATH define install path
-v, --verbose enable verbose output
-h, --help help page
--<package>-dir=PACKAGE_PATH define <package> install directory
--disable-<package> disable <package>
--generator=GENERATOR cmake generator
We display below a set of possible configurations:
Compile using Release build type, default c compiler and libstdc
$ ../feelpp/configure -r
Compile using Release build type, clang compiler and libstdc
$ CXX=clang++ ../feelpp/configure -r
Compile using Debug build type, clang compiler and libc
CXX=clang++ ../feelpp/configure -d -stdlib=c++
8.5.4. Compiling Feel++
Once cmake
or configure
have done their work successfully, you are ready to compile Feel++
$ make
You can speed up the compilation process, if you have a multicore processor by specifying the number of parallel jobs make
will be allowed to spawn using the -j
flag:
$ make -j4 feelpp
From now on, all commands should be typed in build directory (e.g feel.opt ) or its subdirectories.
|
8.5.5. Running the Feel++ Testsuite
If you encounter issues with Feel++, you can run the testsuite and send the resulting report. Feel++ has more than 300 tests running daily on our servers. Most of the tests are run both in sequential and in parallel.
The testsuite is in the testsuite
directory.
$ cd testsuite
The following command will compile 10 tests at a time
$ make -j10
$ ctest -j4 -R .
It will run 4 tests at a time thanks to the option -j4
.
9. Docker
Docker is the recommended way if you are beginning using Feel++.
This chapter explains step by step how to get the Feel++ Container System(FCS), how to execute a precompiled application, how to parameter and run models.
9.1. Introduction
Container based technologies are revolutionizing development, deployment and execution of softwares. Containers encapsulate a software and allow to run seamlessly on different platforms — clusters, workstations, laptops — The developer doesn’t have to worry about specific environments and users spend less time in configuring and installing the software. Containers appear to be lightweight virtual machines (VMs) — they are started in a fraction of a second — but they, in fact, have important differences.
One of the differences is the isolation process. The VMs share only the hypervisor, the OS and hardware whereas containers may share, between each other, large parts of filesystems rather than having copies. Another difference is that, unlike in VMs, processes in a container are similar to native processes and they do not incur the overhead due to the VM hypervisor. The figure below illustrates these fundamental differences. We see in particular that the applications 2 and 3 are sharing lib 2 without redundancy.

Docker is a container technology providing:
-
an engine to start and stop containers,
-
a user friendly interface from the creation to the distribution of containers and
-
a hub — cloud service for container distribution — that provides publicly a huge number of containers to download and avoid duplicating work.
9.2. Installation
This section covers briefly the installation of Docker. It should be a relatively simple smooth process to install Docker.
9.2.1. Channels
Docker offers two channels: the stable and beta channels.
- stable channel
-
is fully baked and tested software providing a reliable platform to work with. Releases are not frequent.
- beta channel
-
offers cutting edge features and experimental versions of the Docker Engine. This is a continuation of the initial Beta program of Docker to experiment with the latest features in development. It incurs far more instabilities than the stable channel but releases are done frequently — possibly several releases per month.
In the latter we shall consider only installing and using the stable channel.
9.2.2. Installing Docker
At the time of writing this section, Docker is available on Linux, Mac and Windows.
Mac and Windows
The support for Mac and Windows as Host OS was recently released and Docker Inc provides installation processes Docker For Mac and Docker for Windows which are the recommended way of installing Docker on these platforms.
Linux
Most Linux distributions have their own packages but they tend to lag behind the stable releases of Docker which could be a serious issue considering the development speed of Docker.
To follow Docker releases, it is probably best to use the packages distributed by Docker.
Installing Binaries
The last possibility is to use Docker Binaries to install Docker. This should be used at the last resort if packages are provided neither by your distribution nor by Docker Inc.
Tested with Docker 1.12
At the time of writing this book, the Docker version we used is Docker 1.12. All commands have been tested with this version.
9.2.3. Running without sudo
On Linux, Docker is a priviledged binary, you need to prefix all your commands with sudo
, e.g. on Ubuntu. You need first to belong to the docker
group with the following command on Ubuntu
$ sudo usermod -aG docker
It creates the docker
group if it doesn’t already exist and adds the current user to the docker
group. Then you need to log out and log in again. Similar process is available on other distributions. You need also to restart the docker
service
$ sudo service docker restart
From now on, we omit the sudo command when using Docker for the sake of brevity.
|
Adding a user to the docker group has security implications. On a shared machine, you should consider reading the Docker security page.
|
9.2.4. Checking Docker
We now check your installation by running docker version
To make sure everything is installed correctly and working, try running the docker version command. You should see something like the following on Linux or Mac.
docker version
on Linux> docker version Client: Version: 1.12.1 API version: 1.24 Go version: go1.6.3 Git commit: 23cf638 Built: Mon, 10 Oct 2016 21:38:17 +1300 OS/Arch: linux/amd64 Server: Version: 1.12.1 API version: 1.24 Go version: go1.6.3 Git commit: 23cf638 Built: Mon, 10 Oct 2016 21:38:17 +1300 OS/Arch: linux/amd64
docker version
on Mac> docker version Client: Version: 1.12.6 API version: 1.24 Go version: go1.6.4 Git commit: 78d1802 Built: Wed Jan 11 00:23:16 2017 OS/Arch: darwin/amd64 Server: Version: 1.12.6 API version: 1.24 Go version: go1.6.4 Git commit: 78d1802 Built: Wed Jan 11 00:23:16 2017 OS/Arch: linux/amd64
If so, you are ready for the next step. If instead you get something like
docker version
on Linux> docker version Client: Version: 1.12.1 API version: 1.24 Go version: go1.6.3 Git commit: 23cf638 Built: Mon, 10 Oct 2016 21:38:17 +1300 OS/Arch: linux/amd64 Cannot connect to the Docker daemon. Is the docker daemon running on this host?
docker version
on Mac> docker version Client: Version: 1.12.6 API version: 1.24 Go version: go1.6.4 Git commit: 78d1802 Built: Wed Jan 11 00:23:16 2017 OS/Arch: darwin/amd64 Error response from daemon: Bad response from Docker engine
then it means that the Docker daemon is not running or that the client cannot access it.
To investigate the problem you can try running the daemon manually — e.g. sudo docker daemon
. This should give you some informations of
what might have gone wrong with your installation.
10. Feel++ Containers
Feel++ leverages the power of Docker and provides a stack of container images.
10.1. First steps
To test Docker is installed properly, try
$ docker run feelpp/feelpp-env echo 'Hello World!'
We have called the docker run
command which takes care of executing
containers. We passed the argument feelpp/feelpp-env
which is a
Feel++ Ubuntu 16.10 container with the required programming
and execution environment for Feel++.
|
This may take a while depending on your internet connection but eventually you should see something like
Unable to find image 'feelpp/feelpp-env:latest' locally (1) latest: Pulling from feelpp/feelpp-env 8e21f82d32cf: Pull complete [...] 0a8dee947f9b: Pull complete Digest: sha256:457539dbd781594eccd4ddf26a7aefdf08a2fff9dbeb1f601a22d9e7e3761fbc Status: Downloaded newer image for feelpp/feelpp-env:latest Hello World!
1 | The first line tells us that there is no local copy of this Feel++ image. Docker checks automatically online on the Docker Hub if an image is available. |
Once the image is downloaded, Docker launches the container and
executes the command we provided echo 'Hello World!'
from inside the
container. The result of the command is showed on the last line of the
output log above.
If you run the command again, you won’t see the download part and the command will be executed very fast.
We can ask Docker to give us a shell using the following command
$ docker run -it feelpp/feelpp-env
It provides a shell prompt from inside the container which is very
similar to what you obtain when login with ssh
on a remote
machine. The flags -i
and -t
tell Docker to provide an interactive
session (-i
) with a TTY attached (-t
).
10.1.1. Feel++ Container System
The Feel++ Container System (FCS) is organized in layers and provides a set of images.
10.1.2. Naming
The naming convention of the FCS allows the user to know where they come from and where they are stored on the Docker Hub. The name of the images is built as follows
feelpp/feelp-<component>[:tag]
where
-
feelpp/
is the namespace of the image and organization name -
feelpp-<component>
the image name and Feel++ component -
[:tag]
an optional tag for the image, by default set to:latest
Feel++ images(components) are defined as layers in the FCS in the table below.
Component | Description | Built From |
---|---|---|
|
Execution and Programming environment |
<OS> |
|
Feel++ libraries and tools |
|
|
Feel++ base applications |
|
|
Feel++ toolboxes |
|
| Note: feelpp-env
depends on an operating system image <OS>
, the recommended and default <OS>
is Ubuntu 16.10. In the future, we will build upon the next Ubuntu LTS or Debian Stable releases.
10.1.3. Tags
By default, the :latest
tag is assumed in the name of the images, for example when running
$ docker run -it feelpp/feelpp-base
it is in fact feelpp/feelpp-base:latest
which is being launched.
The following table displays how the different images depend from one another.
Image | Built from |
---|---|
|
Ubuntu 16.10 |
|
|
|
|
|
|
10.1.4. Host OS
As we said before the default Host OS is Ubuntu 16.10.
However Docker shines in continuous integration. It provides a large set of operating system to build upon and allows to check the software in various contexts. The FCS takes advantage of Docker to build feelpp-libs
for several operating systems provided by feelpp-env
and with different compilers any time a commit in the Feel++ repository is done.
Operating system | version | feelpp-env Tags |
Compilers |
---|---|---|---|
Ubuntu |
16.10 |
|
GCC 6.x, Clang 3.9 |
Ubuntu |
16.04 |
|
GCC 6.x, Clang 3.8 |
Debian |
sid |
|
GCC 6.x, Clang 3.9,4.0 |
Debian |
testing |
|
GCC 6.x, Clang 3.9 |
If you are interested in testing Feel++ in these systems, you can run these flavors.
10.1.5. Containers
feelpp-libs
feelpp-libs
builds from feelpp-env
and provides:
-
the Feel++ libraries
-
the Feel++ mesh partitioner application
$ docker run feelpp/feelpp-libs
feelpp-base
feelpp-base
builds from feelpp-libs
and provides two basic applications:
-
feelpp_qs_laplacian_*
: 2D and 3D laplacian problem -
feelpp_qs_stokes_*
: 2D stokes problem
$ docker run feelpp/feelpp-base
feelpp-toolboxes
feelpp-toolboxes
builds from feelpp-base
and provides
$ docker run feelpp/feelpp-toolboxes
10.2. Running Feel++ Applications
To run Feel++ applications in docker, you need first to create a directory where you will store the Feel++ simulation files. For example, type
> mkdir $HOME/feel
and then type the following docker command
> docker run -it -v $HOME/feel:/feel feelpp/feelpp-libs
The previous command will execute the latest feelpp/feelpp-libs
docker
image in interactive mode in a terminal (-ti
) and mount $HOME/feel
in the directory /feel
of the docker image.
Running the command df
inside the Docker container launched by the previous command
feelpp@4e7b485faf8e:~$ df
will get you this kind of output
Filesystem 1K-blocks Used Available Use% Mounted on none 982046716 505681144 426457452 55% / tmpfs 132020292 0 132020292 0% /dev tmpfs 132020292 0 132020292 0% /sys/fs/cgroup /dev/sda2 982046716 505681144 426457452 55% /feel shm 65536 0 65536 0% /dev/shm
You see on the last but one line the directory $HOME/feel
mounted on /feel
in the Docker image.
Note that mouting a host sub-directory on /feel is
mandatory. If you don’t, the Feel++ applications will exit due to lack
of permissions. If you prefer running inside the docker environment
you can type unset FEELPP_REPOSITORY and then all results from
Feel++ applications will be store in $HOME/feel. But then
you will have to use `rsync or ssh to copy your results out of the
docker image if needed.
|
Using Feel++
11. Reduced Basis Methods
11.1. Introduction
This section assumes two things:
-
you have downloaded the CRBDB database
-
you are running the applications from a standard installation of Feel++ such as in the
feelpp/feelpp-crb
Docker container.hello {feelppdb} .
To download the CRBDB database, do as follows
cd {feelppdb}
git clone https://github.com/feelpp/crbdb.git
it creates the crbdb
sub-directory in the $HOME/feel directory.
To start the feelp/feelpp-crb
container
docker run --rm -it -v $HOME/feel:/feel feelpp/feelpp-crb
11.3. C++ online interface
feelpp_crb_onlinerun --plugin.name <name of the application>
For example consider the Heat3D reduced basis application,
feelpp_crb_onlinerun --plugin.name heat3d
It runs by default the lastest modified reduced basis online code on a random sampling set of 10 parameters
The output of the previous command looks like
[ Starting Feel++ ] application crbonlinerun version 0.104.0-alpha.10 date 2017-Jul-09 . crbonlinerun files are stored in /home/prudhomm/feel/crbonlinerun/np_1 .. exports :/home/prudhomm/feel/crbonlinerun/np_1/exports .. logfiles :/home/prudhomm/feel/crbonlinerun/np_1/logs Loaded the plugin heat3d Last modified db: /home/prudhomm/feel/crbdb/heat3d/4c5148a6-7b1e-4543-a2f1-56d895afc71c/heat3d.crb.json dimension of parameter space : 8 min element in parameter space : 100 100 100 100 29300 29300 29300 -1000 max element in parameter space : 200 200 200 200 62000 62000 62000 1000 -------------------------------------- mu[0] : 177.066 173.107 144.201 190.168 32628.5 61114.9 42897.3 156.468 output 277.092 err 1.27319e-06 -------------------------------------- mu[1] : 105.221 173.036 181.216 180.088 36958.6 42264.7 39575.6 236.381 output 222.797 err 5.75982e-07 -------------------------------------- mu[2] : 173.66 189.698 189.316 108.457 47668.8 41861.8 33056.6 523.555 output 258.181 err 6.65526e-07 -------------------------------------- mu[3] : 117.927 115.727 105.98 119.009 38330.6 42099.7 54722.5 -906.339 output 393.676 err 2.23366e-07 -------------------------------------- mu[4] : 166.036 121.946 105.149 123.785 35591.2 46718.9 50869.5 719.639 output 383.395 err 2.38611e-06 -------------------------------------- mu[5] : 180.233 184.746 166.07 103.653 47252.9 50670.7 42979.8 -428.772 output 320.723 err 1.18664e-06 -------------------------------------- mu[6] : 175.656 131.15 162.982 131.829 59624.2 45161.5 47498 -496.144 output 361.513 err 1.70618e-06 -------------------------------------- mu[7] : 167.221 138.369 155.798 160.396 36653.7 54823.5 40719.2 129.049 output 290.629 err 5.33121e-07 -------------------------------------- mu[8] : 143.892 159.93 119.762 136.868 33615.8 46892.9 36772.1 -868.616 output 286.007 err 1.74971e-06 -------------------------------------- mu[9] : 169.055 111.08 197.084 123.957 37006.3 42026.3 44826.5 -41.7794 output 298.901 err 4.09352e-07 [env] Time : 0.0684201s [ Stopping Feel++ ] application crbonlinerun execution time 0.0684201s
Learning Feel++
12. The Laplacian
12.1. Problem statement
We are interested in this section in the conforming finite element approximation of the following problem:
\(\partial \Omega_D\), \(\partial \Omega_N\) and \(\partial \Omega_R\) can be empty sets. In the case \(\partial \Omega_D =\partial \Omega_R = \emptyset\), then the solution is known up to a constant. |
In the implementation presented later, \(\partial \Omega_D =\partial \Omega_N = \partial \Omega_R = \emptyset\), then we set Dirichlet boundary conditions all over the boundary. The problem then reads like a standard laplacian with inhomogeneous Dirichlet boundary conditions: |
12.2. Variational formulation
We assume that \(f, h, l \in L^2(\Omega)\). The weak formulation of the problem then reads:
12.3. Conforming Approximation
We now turn to the finite element approximation using Lagrange finite element. We assume \(\Omega\) to be a segment in 1D, a polygon in 2D or a polyhedron in 3D. We denote \(V_\delta \subset H^1(\Omega)\) an approximation space such that \(V_{g,\delta} \equiv P^k_{c,\delta}\cap H^1_{g,\Gamma_D}(\Omega)\).
The weak formulation reads:
from now on, we omit \(\delta\) to lighten the notations. Be careful that it appears both the geometrical and approximation level. |
12.4. Feel++ Implementation
In Feel++, \(V_{g,\delta}\) is not built but rather \(P^k_{c,\delta}\).
The Dirichlet boundary conditions can be treated using different techniques and we use from now on the elimination technique. |
We start with the mesh
auto mesh = loadMesh(_mesh=new Mesh<Simplex<FEELPP_DIM,1>>);
the keyword auto enables type inference, for more details see Wikipedia C++11 page.
|
Next the discretization setting by first defining Vh=Pch<k>(mesh)
\(\equiv P^k_{c,h}\), then elements of Vh
and expressions f
, n
and g
given by command line options or configuration file.
auto Vh = Pch<2>( mesh );
auto u = Vh->element("u");
auto mu = doption(_name="mu");
auto f = expr( soption(_name="functions.f"), "f" );
auto r_1 = expr( soption(_name="functions.a"), "a" ); // Robin left hand side expression
auto r_2 = expr( soption(_name="functions.b"), "b" ); // Robin right hand side expression
auto n = expr( soption(_name="functions.c"), "c" ); // Neumann expression
auto g = expr( soption(_name="functions.g"), "g" );
auto v = Vh->element( g, "g" );
at the following line
|
the variational formulation is implemented below, we define the
bilinear form a
and linear form l
and we set strongly the
Dirichlet boundary conditions with the keyword on
using
elimination. If we don’t find Dirichlet
, Neumann
or Robin
in the
list of physical markers in the mesh data structure then we impose
Dirichlet boundary conditions all over the boundary.
auto l = form1( _test=Vh );
l = integrate(_range=elements(mesh),
_expr=f*id(v));
l+=integrate(_range=markedfaces(mesh,"Robin"), _expr=r_2*id(v));
l+=integrate(_range=markedfaces(mesh,"Neumann"), _expr=n*id(v));
toc("l");
tic();
auto a = form2( _trial=Vh, _test=Vh);
a = integrate(_range=elements(mesh),
_expr=mu*gradt(u)*trans(grad(v)) );
a+=integrate(_range=markedfaces(mesh,"Robin"), _expr=r_1*idt(u)*id(v));
a+=on(_range=markedfaces(mesh,"Dirichlet"), _rhs=l, _element=u, _expr=g );
//! if no markers Robin Neumann or Dirichlet are present in the mesh then
//! impose Dirichlet boundary conditions over the entire boundary
if ( !mesh->hasAnyMarker({"Robin", "Neumann","Dirichlet"}) )
a+=on(_range=boundaryfaces(mesh), _rhs=l, _element=u, _expr=g );
toc("a");
tic();
//! solve the linear system, find u s.t. a(u,v)=l(v) for all v
if ( !boption( "no-solve" ) )
a.solve(_rhs=l,_solution=u);
toc("a.solve");
cout << "||u_h-g||_L2=" << normL2(_range=elements(mesh), _expr=idv(u)-g) << std::endl;
tic();
auto e = exporter( _mesh=mesh );
e->addRegions();
e->add( "u", u );
e->add( "g", v );
e->save();
toc("Exporter");
return 0;
}
We have the following correspondance:
|
next we solve the algebraic problem
//! solve the linear system, find u s.t. a(u,v)=l(v) for all v
if ( !boption( "no-solve" ) )
a.solve(_rhs=l,_solution=u);
next we compute the \(L^2\) norm of \(u_\delta-g\), it could serve as an \(L^2\) error if \(g\) was manufactured to be the exact solution of the Laplacian problem.
cout << "||u_h-g||_L2=" << normL2(_range=elements(mesh), _expr=idv(u)-g) << std::endl;
and finally we export the results, by default it is in the ensight gold format and the files can be read with Paraview and Ensight. We save both \(u\) and \(g\).
auto e = exporter( _mesh=mesh );
e->addRegions();
e->add( "u", u );
e->add( "g", v );
e->save();
12.5. Testcases
The Feel++ Implementation comes with testcases in 2D and 3D.
12.5.1. circle
circle
is a 2D testcase where \(\Omega\) is a disk whose boundary
has been split such that \(\partial \Omega=\partial \Omega_D \cup
\partial \Omega_N \cup \partial \Omega_R\).
Here are some results we can observe after use the following command
cd Testcases/quickstart/circle
mpirun -np 4 /usr/local/bin/feelpp_qs_laplacian_2d --config-file circle.cfg
This give us some data such as solution of our problem or the mesh used in the application.
Solution \(u_\delta\) |
Mesh |
12.5.2. feelpp2d and feelpp3d
This testcase solves the Laplacian problem in \(\Omega\) an quadrangle or hexadra containing the letters of Feel++
feelpp2d
After running the following command
cd Testcases/quickstart/feelpp2d
mpirun -np 4 /usr/local/bin/feelpp_qs_laplacian_2d --config-file feelpp2d.cfg
we obtain the result \(u_\delta\) and also the mesh
/images/Laplacian/TestCases/Feelpp2d/meshfeelpp2d.png[] |
|
Solution \(u_\delta\) |
Mesh |
feelpp3d
We can launch this application with the current line
cd Testcases/quickstart/feelpp3d
mpirun -np 4 /usr/local/bin/feelpp_qs_laplacian_3d --config-file feelpp3d.cfg
When it’s finish, we can extract some informations
Solution \(u_\delta\) |
Mesh |
13. Ressources
13.1. Licenses
Copyright © 2010-2017 by Feel++ Consortium
Copyright © 2005-2015 by Université Joseph Fourier (Grenoble, France)
Copyright © 2005-2015 by University of Coimbra (Portugal)
Copyright © 2011-2015 by Université de Strasbourg (France)
Copyright © 2011-2015 by CNRS (France)
Copyright © 2005-2006 by Ecole Polytechnique Fédérale de Lausanne (EPFL, Switzerland)
Free use of this software is granted under the terms of the L License.
See the LICENSE file for details
13.2. Authors
Feel++ is actively developed by Christophe Prud’homme, Vincent Chabannes, Christophe Trophime, Cécile Daversin, Thibaut Métivet, Guillaume Dollé, Jean-Baptiste Wahl, Romain Hild, Lorenzo Sala, and Thomas Lantz.
There are many other contributors.
Feel++ is currently managed by Christophe Prud’homme, Professor in applied mathematic and scientific computing at the University of Strasbourg, France.
13.3. Funding
Feel++ has been funded by various sources and especially
13.3.1. Current funding
13.4. Contributors
Feel++ benefits from the many discussions and close research collaborations with the following persons: Mourad Ismail, Zakaria Belhachmi, Silvia Bertoluzza, Micol Pennacchio, Marcela Szopos, Giovanna Guidoboni, Riccardo Sacco, Gonçalo Pena.
Finally Feel++ also benefits from discussions within collaborative projects with many people (in no particular order):
Yannick Hoarau, Philippe Gilotte, Benjamin Surowiec, Yoann Eulalie, Stephie Edwige, Marion Spreng, Benjamin Vanthong, Thomas Lantz, Mamadou Camara, Camille Boulard, Pierre Gerhard, Frédéric Hecht, Michel Fouquembergh, Denis Barbier, Jean-Marc Gratien, Daniele Di Pietro.
13.5. Consortium
Feel++ was initially developed at École Polytechnique Fédérale de Lausanne(Suisse) and is now a joint effort between Université de Strasbourg, Université Grenoble-Alpes, CNRS, LNCMI and Cemosis.
Glossary
Unresolved directive in /mnt/irma-data/var/lib/buildkite/builds/feelpp-1/feelpp/www-dot-feelpp-dot-org/docs/man/README.adoc - include::GLOSSARY.adoc[]