Kratos Multiphysics uses several components of the Trilinos project for its MPI capabilities. The most relevant of these are the distributed-memory matrix and vector classes from the Epetra module and the linear solvers provided by the AztecOO, Amesos and ML packages. In addition, it also contains the MPI version of the AMGCL solver.
TrilinosLinearSolverAztecSolverAmesosSolverAmesos2SolverMultiLevelSolverAMGCL Mpi-based Solver
The TrilinosApplication also provides MPI versions of most of the core classes of Kratos, adapted to work with Epetra distributed matrices where necessary. Hence it provide its own version of the following Kratos classes:
TrilinosResidualBasedBuilderAndSolverTrilinosEliminationBuilderAndSolverTrilinosBlockBuilderAndSolverTrilinosBlockBuilderAndSolverPeriodic
TrilinosDisplacementCriteriaTrilinosResidualCriteriaTrilinosAndCriteriaTrilinosOrCriteriaTrilinosMixedGenericCriteria
TrilinosSolvingStrategyTrilinosLinearStrategyTrilinosNewtonRaphsonStrategy
For more information about these please refer to their serial version (without Trilinos prefix) in the main Kratos documentation.
Building the TrilinosApplication requires the Trilinos libraries and their dependencies already installed on the system.
The easiest way to get them is by the package manager of the GNU/Linux distribution. For example, in Ubuntu GNU/Linux:
sudo apt install trilinos-all-devHowever, there may be situations where downloading the packages may not be possible.
In this case, other (potentially trickier) option is to download the source code and build the libraries. For more detailed and updated instructions for compiling Trilinos and other necessary packages, refer to Compiling Kratos with MPI support, in the wiki.
Assuming that the dependencies are installed, the following steps are:
- Add the
TrilinosApplicationto the list of applications to be compiled in the building script for Kratos, as described in the install instructions.
export KRATOS_APPLICATIONS=
...
add_app ${KRATOS_APP_DIR}/TrilinosApplication- Tell cmake where are located the libraries and headers of Trilinos.
If Trilinos was compiled (instead of downloaded with a package manager), it is usually enough to point the
TRILINOS_ROOTvariable to the build directory. For example:
cmake -H"${KRATOS_SOURCE}" -B"${KRATOS_BUILD}" \
...
-DTRILINOS_ROOT="${HOME}/Projects/Trilinos/build"Or, if Trilinos is installed with a package manager, then libraries and headers may be in different locations.
Moreover, the name of the libraries may not be standard.
In this case, instead of setting TRILINOS_ROOT, set -DTRILINOS_INCLUDE_DIR=String with the path to the include dir, -DTRILINOS_LIBRARY_DIR=String with the path to the library dir, and set -DTRILINOS_LIBRARY_PREFIX=String with the prefix to use when looking for the Trilinos libraries, i.e.,
libepetra.so # No need to set TRILINOS_PREFIX
libtrilinos_epetra.so # -DTRILINOS_PREFIX="trilinos_"For example, in the case of Ubuntu with Trilinos installed by sudo apt install trilinos-all-dev:
-DTRILINOS_INCLUDE_DIR="/usr/include/trilinos"
-DTRILINOS_LIBRARY_DIR="/usr/lib/x86_64-linux-gnu"
-DTRILINOS_LIBRARY_PREFIX="trilinos_"Notes:
-Trilinos is a large project and not all of its packages are being used in Kratos. Check the docker of the CI to see which packages are necessary in order to compile the TrilinosApplication.
At the moment, the list of required packages is:
sudo apt install \
libtrilinos-amesos-dev \
libtrilinos-amesos2-dev \
libtrilinos-aztecoo-dev \
libtrilinos-epetra-dev \
libtrilinos-epetraext-dev \
libtrilinos-ifpack-dev \
libtrilinos-ml-dev \
libtrilinos-teuchos-dev \
libtrilinos-tpetra-dev \
libtrilinos-kokkos-dev \
libtrilinos-kokkos-kernels-dev \
libtrilinos-shylu-dev-It is possible to do a minimal installation of the TrilinosApplication only using the Epetra package. Other packages can be disabled with the following flags:
-DTRILINOS_EXCLUDE_ML_SOLVER=ON # exclude the interface to the Trilinos ML solver package
-DTRILINOS_EXCLUDE_AZTEC_SOLVER=ON # exclude solvers from the Trilinos AztecOO package
-DTRILINOS_EXCLUDE_AMESOS_SOLVER=ON # exclude solvers using features of the Trilinos Amesos package
-DTRILINOS_EXCLUDE_AMESOS2_SOLVER=ON # exclude solvers using features of the Trilinos Amesos2 packageSpack is a multi-platform package manager that builds and installs multiple versions and configurations of software. It works on GNU/Linux, macOS, and many supercomputers. Spack is non-destructive: installing a new version of a package does not break existing installations, so many configurations of the same package can coexist.
To install Spack you just need to run the following command:
git clone -c feature.manyFiles=true https://github.com/spack/spack.gitTo use it you will need to add the corresponding environment variables (or call spack_location/spack/bin/spack):
. spack_location/spack/share/spack/setup-env.shThen in order to install Trilinos:
spack install trilinosIn case we want to use MUMPS and SuperLUDist with Trilinos, you can install them all together and properly liked with:
spack install trilinos+mumps+superlu-distIf you want that the libraries are added automatically to LD_LIBRARY_PATH to run the following commands before loading the modules:
spack config add modules:prefix_inspections:lib64:[LD_LIBRARY_PATH]
spack config add modules:prefix_inspections:lib:[LD_LIBRARY_PATH]Now you just need to load Trilinos:
spack load trilinosor (if installed):
spack load trilinos+mumps+superlu-distOnce to compile TrilinosApplication just remember to add the application to the configure bash script:
export KRATOS_APPLICATIONS=
...
add_app ${KRATOS_APP_DIR}/TrilinosApplicationWhen building the TrilinosApplication that depends on a library compiled with Fortran (such as a manually compiled version of MUMPS, SuperLU_DIST, or another third-party solver), you may encounter linker errors during the final linking stage.
This is because the Fortran compiler, typically Gfortran, links in several runtime libraries (like libgfortran, libquadmath, etc.) that are essential for the Fortran code to execute. If your TrilinosApplication is primarily being linked by the C++ compiler (like
To ensure that these required Fortran runtime libraries are correctly included during the linking process, you must enable the following CMake flag:
TRILINOS_APPLICATION_LINK_GFORTRAN
Set this flag to ON in your CMake configuration:
-DTRILINOS_APPLICATION_LINK_GFORTRAN=ON \