-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
su2AdapterInstall
executable file
·65 lines (49 loc) · 2.87 KB
/
su2AdapterInstall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
# This auxiliary script simplifies the installation of the preCICE-adapter for SU2. It copies the adapted SU2-files to the correct locations based on the environment variable SU2_HOME.
# Copied from SU2 Adapter
# SU2 version: 7.5.1 "Blackbird"
# SU2 versions for which this adapter was made
VERSIONS="7.5.1 \"Blackbird\"|7.5.0 \"Blackbird\""
# Always run this script from current directory
cd "$(dirname "$0")"
# Check for environment variables
printf "\nChecking whether the necessary environment variables are set...\n"
"${SU2_HOME:?You need to set variable SU2_HOME non-empty. Aborting.}"
printf "Necessary environment variables are set.\n"
# Check for SU2 version
printf "\nChecking whether updated adapter and SU2 version are compatible..."
if sed '1,10!d' $SU2_HOME/SU2_CFD/src/SU2_CFD.cpp | grep -Eq "$VERSION"
then
printf " yes.\n"
else
printf " no.\nThis adapter was built using SU2 version $VERSION.\nAborting.\n"
exit 1;
fi
# Replace SU2 files
printf "Replacing files..."
cp replacement_files/python_wrapper_structure.cpp $SU2_HOME/SU2_CFD/src || { printf >&2 "\nCannot copy python_wrapper_structure.cpp over. Is variable SU2_HOME set correctly? Are you running the script from the correct directory?\nAborting.\n"; exit 1; }
cp replacement_files/CDriver.hpp $SU2_HOME/SU2_CFD/include/drivers || { printf >&2 "\nCannot copy CDriver.hpp over. Is variable SU2_HOME set correctly? Are you running the script from the correct directory?\nAborting.\n"; exit 1; }
# Output to guide the user
printf "\nPlease navigate to the SU2 home directory $SU2_HOME to re-configure and build SU2.\nNote that meson must be wiped for changes to take effect.\n\n"
# Check if SU2 has been built before, if so:
if [[ -f $SU2_HOME/build/meson-logs/meson-log.txt ]]
then
BUILD_LINE=$(grep -P "Build Options: " $SU2_HOME/build/meson-logs/meson-log.txt)
BUILD_OPTIONS=$(cut -d ":" -f2 <<< "$BUILD_LINE")
PYBUILD_OPTION="-Denable-pywrapper=true"
printf "Previous build options obtained.\n"
printf "To update the build and installation for the adapter, go to $SU2_HOME and run:\n\n\t\t./meson.py build --wipe$BUILD_OPTIONS"
if [[ "$BUILD_OPTIONS" != *"$PYBUILD_OPTION"* ]]
then
printf " $PYBUILD_OPTION"
fi
else
printf "No previous build detected. To configure with the Python wrapper, navigate to $SU2_HOME and run as follows:\n\n\t\t./meson.py build -Denable-pywrapper=true [insert other build options here]\n"
fi
printf "\n\t\t./ninja -C build install\n\n"
printf "Please ensure MPI is enabled.\n"
printf "Note that you must have swig and mpi4py installed for the SU2 Python wrapper.\n"
printf "Also note that you must have the preCICE Python bindings set up as well.\n"
printf "SU2 adapter successfully installed. To access the default/template FSI + CHT Python scripts, add to your ~/.bashrc:\n\n"
SCRIPT_DIR=$(pwd)
printf "\t\texport PATH=$SCRIPT_DIR/run:\$PATH\n"