How to use the PaStiX solver in Kratos

From KratosWiki
Revision as of 09:52, 3 January 2017 by Andreas (Talk | contribs)
Jump to: navigation, search


How to use the PaStiX solver in Kratos

The PaStiX (Parallel Sparse matriX package) is a open-source scientific library that provides a high performance parallel solver for very large sparse linear systems based on direct methods. Numerical algorithms are implemented in single or double precision (real or complex) using LLt, LDLt and LU with static pivoting (for non symmetric matrices having a symmetric pattern). This solver provides also an adaptive blockwise iLU(k) factorization that can be used as a parallel preconditioner using approximated supernodes to build a coarser block structure of the incomplete factors ([1]).

It can be linked to the Kratos by the ExternalSolversApplication. The following steps have to be made in order to use be able to use it in Ubuntu version 14.04 LTS 64 bit or 16.04 LTS 64 bit.

Compile the Scotch library

PaStiX needs the Scotch library as a prerequisite to work.

You can download version 6.0.4 here:

Copy it to a folder of your choice. In the following we are using "~/compiled_libraries" as a reference.

Extract the files by the command:

tar -xf scotch_6.0.4.tar.gz

Navigate into the source directory by:

cd scotch_6.0.4/src

Copy the correct for the version of your system to the source directory. Ín the case of the Ubuntu versions mentioned above it is the

cp ./

Additional libraries are necessary, which can be installed by:

sudo apt-get install flex bison zlib1g-dev

In order to install scotch locally the install path has to be set. Since the "prefix" command is not working this has to be done manually in the Makefile, which is also located in the /src folder. You can see an example for the part of the file to be modified below:

...some code...
prefix		?= ~/software/scotch_6.0.4-install
bindir		?= $(prefix)/bin
includedir	?= $(prefix)/include
libdir		?= $(prefix)/lib
datarootdir	?= $(prefix)/share
mandir		?= $(datarootdir)/man
...some code...

Now scotch can be compiled by (we are still in the /src directory):

make scotch

And can be installed to the directory specified in the MakeFile by:

make install

Add the following line in the file CMakeLists.txt of your application:


Export your variables

In order to make your variables visible, you will need to change its declaration with the define name from the step 1. We provide a couple of replacements for do that:


will become:


For example:


will become


Export your classes

Finally you will also need to indicate which classes are available to be used from other applications. In order to do it you will need to use the KRATOS_API() macro with the define name of your applications in the declaration of the class.

For example

 class myclass() {

will become:

 class KRATOS_API(FOO_APPLICATION) myclass() {

If your class depends on a template parameter, you will also need to instantiate such class, as no code exists in compile time and otherwise will be impossible to export:

For instance, if you want to use class myclass with double:

 temaplte<class T>
 class myclass() {


 temaplte<class T>
 class KRATOS_API(FOO_APPLICATION) myclass() {
 template class KRATOS_API(FOO_APPLICATION) myclass<double>;
Personal tools