Trilinos is a software package that provides lots of functionality for linear algebra, among other things. For example, it includes implementations of a variety of linear solvers, as well as various different sparse and dense matrix and vector formats. Trilinos also has many subpackages that deal with problems that go far beyond linear algebra, for example nonlinear solvers, automatic differentiation packages, uncertainty propagation engines, etc. Of particular interest to deal.II is their ability to provide this functionality both on sequential and parallel (using MPI) computers. Compared to PETSc, which is written in C, Trilinos is written in C++ and can be considered to be a more modern version of PETSc though both packages are under continuing development at their respective national laboratories.
deal.II has wrapper classes to the linear algebra parts of Trilinos that provide almost the same interfaces as the built-in deal.II linear algebra classes. We use these interfaces for parallel computations based on MPI since the native deal.II linear algebra classes lack this ability. They are used, among other programs, in step-31 and step-32.
While building deal.II with Trilinos is covered in the ReadMe file, we here give an introduction to building Trilinos in such a way that it contains everything that we need from the deal.II side.
Note: Trilinos versions older than 10.12.2 can cause problems and are therefore not recommended. The newest version tested to work is 11.4.1. Major releases after this version may cause problems, so we recommend sticking to this version if at all possible.
Trilinos uses cmake to configure and build. The following slightly longish set of commands will set up a reasonable configuration:
cd trilinos-11.4.1 mkdir build cd build cmake -D Trilinos_ENABLE_Sacado=ON \ -D Trilinos_ENABLE_Stratimikos=ON \ -D CMAKE_BUILD_TYPE=RELEASE \ -D CMAKE_CXX_FLAGS="-g -O3" \ -D CMAKE_C_FLAGS="-g -O3" \ -D CMAKE_FORTRAN_FLAGS="-g -O5" \ -D Trilinos_EXTRA_LINK_FLAGS="-lgfortran" \ -D CMAKE_VERBOSE_MAKEFILE=FALSE \ -D Trilinos_VERBOSE_CONFIGURE=FALSE \ -D TPL_ENABLE_MPI=ON \ -D BUILD_SHARED_LIBS=ON \ -D CMAKE_INSTALL_PREFIX:PATH=$HOME/share/trilinos \ .. make installYou will need to adjust the path into which you want to install Trilinos in the CMAKE_INSTALL_PREFIX line.
Parallel builds:
If your computer has more than one processor core, use
make -jN
instead of make
in the last line
above, where N
is the number of processors you have.
Trilinos sometimes searches for other libraries but can't find
them if they are not in the usual directories or have other
names. A common example are BLAS or LAPACK. In a case like
this, you may have to specifically pass the directories and/or
library names under which they can be found
to cmake
. For example, this may mean to add the
following flags to the call above:
-D BLAS_LIBRARY_NAMES:STRING=goto \ -D BLAS_LIBRARY_DIRS:STRING=/apps/GotoBLAS/lib64 \ -D LAPACK_LIBRARY_NAMES:STRING=lapack \ -D LAPACK_LIBRARY_DIRS:STRING=/apps/lapack-3.2.1/lib64