1% How to build and use `TFEL` and `MFront` on `Windows` with the `MinGW` compiler delivered with `Cast3M` `2017` 2% Thomas Helfer 3% 1/09/2017 4 5Building and using `MFront` on `Windows` is more complex than on other 6systems for the following reasons: 7 8- There is no default compiler on this platform. 9- The usage of command line is less common. 10 11This page is dedicated to show how this issues can be overcome and 12ease the `MFront` experience on `Windows`. We will focus on coupling 13with `Cast3M` `2017` which is packaged with a version of the `MinGW` 14compiler suite. **This tutorial makes the assumption that the user 15have installed the developer version of `Cast3M`**. 16 17This tutorial will show that: 18 19- The installation does not require any administrator privileges. 20- The main trick is to appropriately update the `PATH` variable so 21 that the `MinGW` and `TFEL` libraries are found when needed. This 22 can be done by creating small wrapper scripts as discussed bellow. 23 24This tutorial is mostly based on `bat` scripts that can be downloaded 25[here](downloads/windows-install-scripts.tar.bz2). 26 27## Notes on the installation directory 28 29For information, the author use the following convention: the scripts 30are decompressed in `C:\tfel-master\src`. 31 32By default, the previous scripts will install `TFEL` and `MFront` in 33`C:\tfel-master\install-castem2017`. The user is, of course, free to 34choose another installation location: he simply has to edit the 35scripts accordingly. 36 37## Notes on `bat` scripts 38 39Executing `bat` scripts is fairly easy: in `Windows` `Explorer`, 40right-click on the script and select `Open`. 41 42Modifying `bat` scripts is also easy: in `Windows` `Explorer`, 43right-click on the script and select `Modify`. By default, this action 44will open the script in `Notepad`, but any text editor will do. 45 46## About binary packages 47 48Various binary packages can be downloaded on the `sourceforge` 49website. Those binary packages are built against specific versions of 50`Cast3M`. When installing thoses packages, the user have the choice to 51modify the `PATH` variable globally. 52 53This tutorial can nevertheless be usefull: small scripts wrapping 54calls to `MFront` can be a viable choice in the `Windows` environment, 55rather than relying on the command line. Be careful that modify the 56examples appropriately to reflect where `TFEL` and `MFront` have been 57installed. 58 59# Decompressing the archive 60 61As said before, this tutorial is mostly based on `bat` scripts that 62can be downloaded [here](downloads/windows-install-scripts.tar.bz2). 63 64The archive contains the following files: 65 66- `git.bat`: a script used to fetch the latest source from the 67 `github` repository. 68- `git-update.bat`: a script used to update the sources to the latest 69 version. 70- `compil-castem2017.bat`: a script used to compile `TFEL` and 71 `MFront` using the compiler delivered with `Cast3M` `2017`. 72 73The two first scripts are not mandatory: the user can directly 74download an archive from the sourceforge website 75(<https://sourceforge.net/projects/tfel/files/>). 76 77It also contains a directory called `test`. The usage is those scripts 78is fully detailed in the following sections. 79 80The other files contained in the archive will not be used in this 81tutorial. 82 83# Prerequisites 84 85In the following, we will suppose that: 86 87- `git` is installed. This is not mandatory. Users that do not want to 88 follow the latest developments of `TFEL` and `MFront` can download a 89 packaged version on the sourceforge website. The tutorial will 90 mostly apply, but the name of the directory containing the sources 91 must be changed. `git` for `Windows` can be downloaded 92 [here](https://git-scm.com/download/win) 93- `cmake` is installed. `cmake` can be downloaded 94 [here](https://cmake.org/download/). 95- `Cast3M` `2017` **developer version** is installed. `Cast3M` can be 96 downloaded [here](http://www-cast3m.cea.fr/index.php?xml=download1). 97 98> **Notes** 99> 100> In the following, it is expected that those prerequisites are 101> located in directories listed in the `PATH` variables. If this is 102> not the case, the scripts must be modified to update this variable 103> appropriately. 104 105# Getting the sources using `git` 106 107This section can be skipped if the user wants to use a packaged 108version of tfel (<https://sourceforge.net/projects/tfel/files/>). 109 110## Cloning the repository 111 112The `git.bat` will clone the `git` repository on your machine in the 113current directory. The directory containing the repository is called 114`tfel`. 115 116## Updating the repository 117 118After the `git` repository has been cloned, the `git-update.bat` 119script can be used to synchronize our local repository with the 120official repository and follow the latest developments. 121 122# Compiling `MFront` 123 124The `compil-castem2017.bat` can now be used to compile and install 125`TFEL` using the `MinGW` compiler delivered with `Cast3M` `2017`. 126 127## Changing the location of `Cast3M` `2017` 128 129The script assumes that `Cast3M` `2017` is installed in 130`C:\Cast3M\PCW_17`. If this is not the case, edit the script and 131change the following line appropriately: 132 133~~~~{.bash} 134set PATH=C:\Cast3M\PCW_17\MinGW\x86_64-6.3.0-posix-sjlj-rt_v5-rev1\mingw64\bin;%PATH% 135~~~~ 136 137## Changing the location of the sources 138 139By default, the script assumes that the sources are in the `tfel` 140subdirectory. This is the case if the user cloned the `git` repository 141as explained before. 142 143If the user has downloaded an archive from the `sourceforge` website, 144the name of the directory can be different and the user must update 145the following line: 146 147~~~~{.bat} 148cmake.exe ..\tfel -G "MinGW Makefiles" ... 149~~~~ 150 151For example, if you have downloaded version `3.0.1`, the name of the 152archive is `tfel-3.0.1.tar.bz2`. Assuming that this archive is 153decompressed in the same directory than the scripts, the name of the 154directory containing the sources will be `tfel-3.0.1`. The previous 155line can thus be udpated as follows: 156 157~~~~{.bat} 158cmake.exe ..\tfel-3.0.1 -G "MinGW Makefiles" ... 159~~~~ 160 161## Changing the installation directory 162 163The installation directory is passed to `cmake` through the 164`CMAKE_INSTALL_PREFIX` variable. The default install directory is 165`C:\tfel-master\install-castem-2017`. The user can modify this value 166to fit its needs. 167 168# A simple test showing how to perform `Cast3M` `2017` simulations with a `MFront` behaviour 169 170The `test` directory contains an example showing how to perform 171`Cast3M` `2017` simulations with a `MFront` behaviour. It contains: 172 173- a `mfront.bat` script. 174- a `launch-castem.bat` script. 175- a `MFront` behaviour called `LogarithimcStrainPlasticity`. 176- a `Gibiane` script called `LogarithimcStrainPlasticity-ssna303.dgibi`. 177 178## Compilation the `MFront` behaviour 179 180Launch the `mfront.bat` script. This script is basically a wrapper 181around the following call to `MFront`: 182 183~~~~{.bash} 184mfront.exe --obuild --interface=castem LogarithmicStrainPlasticity.mfront 185~~~~ 186 187This command: 188 189- generates `C++` sources from the 190 `LogarithmicStrainPlasticity.mfront` file and a `Makefile.mfront` 191 file. 192- calls the `make` utility to compile the sources an generate the 193 `libUmatBehaviour.dll` library. 194 195There is one trick here: the name of `make` utility in the `MinGW` 196compiler suite is `mingw32-make`. For `MFront` to call the appropriate 197program, the `MAKE` environment variable must be set. This is done in 198the script at the following line: 199 200~~~~{.bash} 201set MAKE=mingw32-make 202~~~~ 203 204## Launch the `Cast3M` `2017` simulation 205 206The `Cast3M` solver can be used directly because it can't find the 207`TFEL` libraries automatically. The `launch-castem.bat` script thus 208first updates the `PATH` variable and then launches the `Cast3M` 209solver script. 210 211Launch the `launch-castem.bat` script to perform the simulation. 212 213<!-- Local IspellDict: english --> 214