-
Notifications
You must be signed in to change notification settings - Fork 248
Windows Install (MinGW)
In this section we are going to go through the process of compiling a basic version of Kratos Multiphysics under Windows environments with MinGW. The process is something in between the compilation in Linux and in Windows using Visual Studio.
Please notice that this guide is introductory and many of the steps and software used here can be customized. The only hard restriction is to use a C++11 compatible compiler.
First we download MSYS2 in the following link. This will install MinGW, which allows to easiy install packages a la Arch-Linux (Pacman package manager). We install it, and with it the first thing we do is to update as follows:
pacman -Syu
- Objectives:
- Install git
- Get Kratos Multiphysics source code
The first thing you will need is the Kratos Multiphysics source code. To download the code you will have to use a git. You can install the default git by using this command:
pacman -S git
Once git is installed you can fetch the code by using these commands:
git clone https://github.com/KratosMultiphysics/Kratos Kratos
- Objectives:
- Get G++
- Get Fortran compiler
- Get LIBBLAS and LIBLAPACK
You will need a series of packages with some Kratos dependencies. The command below will install all the packages needed. It will allow you to compile with python2 or python3 so you will be able to chose later ( we recommend python3 )
pacman -S mingw64/mingw-w64-x86_64-lapack mingw64/mingw-w64-x86_64-openblas mingw-w64-x86_64-cotire mingw64/mingw-w64-x86_64-cmake mingw64/mingw-w64-x86_64-clang mingw64/mingw-w64-x86_64-gcc mingw64/mingw-w64-x86_64-gcc-fortran mingw-w64-x86_64-make
- Objectives:
- Install Python3
You will need any version of python in your computer in order to compile Kratos. We strongly recommend Python 3, at least 3.3.4 or higher. You can download python from its official webpage:
Please, take special care to download a installer that suits your desired architecture x86 for 32 bits compilations and x86_64 for 64 bits compilations. Otherwise it won't work.
Unfortunately we cannot use right now MSYS2 directly, as the development files are not available (python3-dev equivalent to Linux).
- Objectives:
- Download Boost
The next step will consist in downloading Boost. For that we will use pacman again:
pacman -S mingw64/mingw-w64-x86_64-boost
- Objectives:
- Configure Kratos for the first time compilation
In order to compile Kratos for the first time you will need to configure the project. First, navigate to your Kratos/cmake_build folder and make a copy of the template files:
copy example_configure_mingw.sh.do_not_touch configure.sh
copy example_configure_mingw.bat.do_not_touch configure.bat
We only execute the configure.bat, but we need to edit both. The configure.bat you just need to specify the location of your msys2 folder so it can find the sh.exe (unfortunately sh.exe cannot be in the PATH, so the two files are required).
Then, open configure.sh with any text editor and modify the lines that tell cmake where some components are located. You will need to provide at least '''BOOST_ROOT'' and '''PYTHON_EXECUTABLE'''.
Kratos has moved to C++11 recently, Please mind to add the "-std=c++11" to your compiler of choice. If you follow the example below, it is already present ( notice the flag in CMAKE_CXX_FLAGS, highlighted in bold)
For example, in ubuntu it will look something like:
cmake .. \
-G "MinGW Makefiles" \
-DCMAKE_BUILD_TYPE=Release \
-DWIN32=TRUE \
-DCMAKE_EXE_LINKER_FLAGS="-s" \
-DCMAKE_SHARED_LINKER_FLAGS="-s" \
-DCMAKE_INSTALL_RPATH="../libs" \
-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE \
-DCMAKE_C_COMPILER="gcc" \
-DCMAKE_CXX_COMPILER="g++" \
-DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} -msse3" \
-DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -msse3 -std=c++11" \
-DPYTHON_EXECUTABLE="your_python_folder/Python/Python37/python.exe" \
-DLAPACK_LIBRARIES="your_msys_folder/msys64/mingw64/lib/liblapack.dll.a" \
-DBLAS_LIBRARIES="your_msys_folder/msys64/mingw64/lib/libblas.dll.a" \
-DMESHING_APPLICATION=ON \
-DEXTERNAL_SOLVERS_APPLICATION=ON \
// More options ( do not include this line )
Note that the \
must be the last character in the line. Even an space after it will cause an error! (and the returned message is completely misleading, so be careful with this!!)
Notice that you can also turn ON/OFF parts of the code according to your necessities:
-DSTRUCTURAL_MECHANICS_APPLICATION=ON/OFF
\
therefore MUST NOT be followed by any whitespace in the same line as this would prevent the cmake from running the lines below
- Objectives:
- Compile Kratos.
If you followed all the steps correctly, compiling Kratos should be as easy as executing the configure script:
configure.bat
Please, notice that Kratos is big and the compilation process can easily take 1 or 2 hours, depending on which applications are being compiled. A typical compilation process with the default configuration takes approximately 45 minutes with a i7 / 8GB Ram computer.
- Objectives:
- Tell Windows how to execute Kratos
Once Kratos is compiled, you will have to tell the OS where to find the libraries. You need to add to PYTHONPATH (environment variables) the Kratos folder, and to PATH (environment variables) the libs folder (usually the kratos_folder/libs).
If you have enabled the embedded python option -DINSTALL_EMBEDDED_PYTHON=ON, you can also add to PATH (environment variables) the Kratos folder in order to have the "runkratos" available as a regular command.
- Objectives:
- Tests kratos
To to tests the compilation, you can execute a simple python script containing this line:
from KratosMultiphysics import *
We strongly recommend you to run kratos scripts with the "runkratos" binary that will be generated inside your Kratos installation folder. You can also run them by using python (if you have compiled with python version 2.x.x), or python3 (if you have compiled with python version 3.x.x)
- runkratos test.py
- python test.py
- python3 test.py
If everething was ok you will see this message:
| / |
' / __| _` | __| _ \ __|
. \ | ( | | ( |\__ \
_|\_\_| \__,_|\__|\___/ ____/
Multi-Physics 3.3.11016
- Getting Kratos (Last compiled Release)
- Compiling Kratos
- Running an example from GiD
- Kratos input files and I/O
- Data management
- Solving strategies
- Manipulating solution values
- Multiphysics
- Video tutorials
- Style Guide
- Authorship of Kratos files
- Configure .gitignore
- How to configure clang-format
- How to use smart pointer in Kratos
- How to define adjoint elements and response functions
- Visibility and Exposure
- Namespaces and Static Classes
Kratos structure
Conventions
Solvers
Debugging, profiling and testing
- Compiling Kratos in debug mode
- Debugging Kratos using GDB
- Cross-debugging Kratos under Windows
- Debugging Kratos C++ under Windows
- Checking memory usage with Valgind
- Profiling Kratos with MAQAO
- Creating unitary tests
- Using ThreadSanitizer to detect OMP data race bugs
- Debugging Memory with ASAN
HOW TOs
- How to create applications
- Python Tutorials
- Kratos For Dummies (I)
- List of classes and variables accessible via python
- How to use Logger
- How to Create a New Application using cmake
- How to write a JSON configuration file
- How to Access DataBase
- How to use quaternions in Kratos
- How to do Mapping between nonmatching meshes
- How to use Clang-Tidy to automatically correct code
- How to use the Constitutive Law class
- How to use Serialization
- How to use GlobalPointerCommunicator
- How to use PointerMapCommunicator
- How to use the Geometry
- How to use processes for BCs
- How to use Parallel Utilities in futureproofing the code
- Porting to Pybind11 (LEGACY CODE)
- Porting to AMatrix
- How to use Cotire
- Applications: Python-modules
- How to run multiple cases using PyCOMPSs
- How to apply a function to a list of variables
- How to use Kratos Native sparse linear algebra
Utilities
Kratos API
Kratos Structural Mechanics API