# Using Trilinos and/or Petsc in Windows with Visual Studio?

I am currently working on a project of building a simulator. Up till now I have mostly played around with very simple examples, but with regards to the future I have been thinking that it might be a good idea to use an external library for numerical computations, especially since I might also want to look into the possibility for parallelization.

So far I have used the Eigen library, which is very simple since you only need to include the appropriate header files and you are good to go. However, I am a bit uncertain about whether it is good enough in the long run? (versatility, speed etc.) Please correct me if you have used Eigen extensively and know I'm wrong! ;)

But anyway, my idea was to maybe learn to use one of the "big guns", Trilinos or Petsc, as I understand they are the most well regarded libraries. However, it seems like it might be a bit problematic to get everything to work on Windows? (using Visual Studio) From what I've found by googling and reading here, it seems there is an option compiling for Visual Studio using CMAKE, but I've found most of the user guides a bit confusing with regards to how well it will work, what possible ugly issues might turn up etc.

I guess my main question is: How easy will it be to set-up e.g. Trilinos for my current project? I mostly need code for doing linear algebra computations (vectors, sparse matrices etc.), possibly in parallel. There is also the issue of choosing the "right" mesh data structure, but maybe I should get those from elsewhere (or build my own, as I have so far).

• Just use PETSc in Cygwin or (even better) virtualbox running a minimal install of Debian that you can ssh into. Trilinos is much more than just a linear algebra package and installing it is a pain even in Linux. – stali Sep 20 '14 at 20:51
• Ok, but would it be possible to get this (e.g. PETSc) to work with Visual Studio? – Axiom Sep 23 '14 at 11:25

Trilinos (and PETSc) will definitely work on windows, but it does have quite a few dependencies. How easy that will be depends on you. I'd suggest just starting up the CMake visual studio build and let it tell you what you're missing and just pick those up one at a time. In e.g. ubuntu it's a lot easier, just apt-get install trilinos.

As for if it's appropriate, it depends on the particulars of your program. If you definitely need parallelism, then it's a good idea to use trilinos or PETSc. But if you don't, I do find working with Eigen to be much more pleasant. I personally actually use a mix, where I have PETSc vectors for global, parallel data and use its linear/nonlinear solvers, but locally I use a lot of small matrix manipulation where it makes more sense to use Eigen.

• Ok I'll see what I find out. Maybe I should try installing it on my private laptop first when I get the time to test it out! – Axiom Sep 23 '14 at 11:24
• +1 for using Eigen for small local computations; it could actually work better than established BLAS and LAPACK libraries when used this way, because of kernel fusion etc. I use PETSc and Eigen in the same way. – Aditya Kashi Mar 1 '18 at 17:59

Here is something that works for me to build Trilinos. Put it in a batch file on a single line aftery modifying it for your file locations. Also install the third party software. Not all options below are strictly necessary. You can install clapack using cmake for (a slow) blas and lapack. See more here http://trilinos.sandia.gov/Trilinos10CMakeQuickstart.txt

"c:\Program Files (x86)\CMake 2.8\bin\cmake"
-G "Visual Studio 11 Win64"
-DTrilinos_ENABLE_TESTS:BOOL=ON
-DTrilinos_ENABLE_EXAMPLES:BOOL=ON
-DTrilinos_ENABLE_Fortran=OFF
-DPYTHON_EXECUTABLE:FILEPATH=C:/Python26/python
-DTrilinos_ENABLE_Teuchos:BOOL=ON
-DTrilinos_ENABLE_Epetra:BOOL=ON
-DTrilinos_ENABLE_Triutils:BOOL=ON
-DTrilinos_ENABLE_Galeri:BOOL=ON
-DTrilinos_ENABLE_Amesos:BOOL=ON
-DTrilinos_ENABLE_Ifpack:BOOL=ON
-DTrilinos_ENABLE_AztecOO:BOOL=ON
-DTrilinos_ENABLE_ML:BOOL=ON
-DTPL_ENABLE_MPI:BOOL=ON
-DMPI_BASE_DIR:PATH="c:/Program Files/Microsoft HPC Pack 2008 SDK"
-DLAPACK_LIBRARY_DIRS:PATH="C:\blas_lapack\x64\Debug"
-DLAPACK_LIBRARY_NAMES:STRING="lapack"
-DBLAS_LIBRARY_DIRS:PATH="C:\blas_lapack\x64\Debug"
-DBLAS_LIBRARY_NAMES:STRING="blas;f2c"
C:/Trilinos_master/