# How to use the PaStiX solver in Kratos

(Difference between revisions)
 Revision as of 08:49, 3 January 2017 (view source)Andreas (Talk | contribs) (Created page with "= How to use the PaStiX solver in Kratos = It has been always possible to make applications use code from other applications in Linux without further modification. Although, whe...") Revision as of 08:52, 3 January 2017 (view source)Andreas (Talk | contribs) (→How to use the PaStiX solver in Kratos)Newer edit → Line 1: Line 1: = How to use the PaStiX solver in Kratos = = How to use the PaStiX solver in Kratos = − It has been always possible to make applications use code from other applications in Linux without further modification. + The PaStiX (Parallel Sparse matriX package) is a 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. (reference: [http://pastix.gforge.inria.fr/files/README-txt.html]) − Although, when compiling under windows environments this can be a little bit tricky since by default MSVC compiler does not export any symbol. In other words your applications are black boxes and no one can access its contents. + − KratosMultiphysics provides a method to automate as much as possible the process of make your application derivable in windows. + 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. − + − There are only a couple small things that you need to take into account: + == Define you application name == == Define you application name ==

# How to use the PaStiX solver in Kratos

The PaStiX (Parallel Sparse matriX package) is a 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. (reference: [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.

## Define you application name

The first thing you need to do is to indicate the compiler that you are going to allow the application to be derived. This is done by defining the name of your application with the value "EXPORT,API" in the CMakeLists.txt file. This is step is also mandatory if you want to make derivable any class in your application, even though it is not the application itself.

``` set_target_properties(KratosFooApplication PROPERTIES COMPILE_DEFINITIONS "FOO_APPLICATION=EXPORT,API")
```

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:

```KRATOS_DEFINE_VARIABLE
KRATOS_DEFINE_3D_VARIABLE_WITH_COMPONENTS
```

will become:

```KRATOS_DEFINE_APPLICATION_VARIABLE
KRATOS_DEFINE_3D_APPLICATION_VARIABLE_WITH_COMPONENTS
```

For example:

```KRATOS_DEFINE_VARIABLE(int, VAR_1)
```

will become

```KRATOS_DEFINE_APPLICATION_VARIABLE(FOO_APPLICATION, int, VAR_1)
```

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() {
...
};
```

becomes

``` temaplte<class T>
class KRATOS_API(FOO_APPLICATION) myclass() {
...
};

...

template class KRATOS_API(FOO_APPLICATION) myclass<double>;
```