forked from deepmodeling/deepflame-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.sh
203 lines (175 loc) · 5.24 KB
/
configure.sh
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#!/bin/sh
unset USE_LIBTORCH
unset USE_PYTORCH
unset LIBTORCH_DIR
unset LIBCANTERA_DIR
unset PYTORCH_INC
unset PYTORCH_LIB
unset USE_GPUSOLVER
unset AMGX_DIR
unset ODE_GPU_SOLVER
print_usage() {
echo "Usage: . install.sh --libtorch_no (default) | --libtorch_dir _path_to_libtorch | --libtorch_autodownload | --use_pytorch | --libcantera_dir _path_to_libcantera
| --amgx_dir _path_to_amgx | --use_ode_gpu_solver"
}
# default
LIBTORCH_AUTO=false
USE_LIBTORCH=false
USE_PYTORCH=false
USE_GPUSOLVER=false
USE_ODE_GPU_SOLVER=false
while test $# -gt 0; do
case "$1" in
-h|--help)
print_usage
return
;;
--libtorch_dir)
shift
if test $# -gt 0; then
LIBTORCH_DIR=$1
USE_LIBTORCH=true
else
print_usage
return
fi
shift
;;
--libtorch_autodownload)
USE_LIBTORCH=true
LIBTORCH_AUTO=true
LIBTORCH_DIR="$PWD/thirdParty/libtorch"
shift
;;
--libtorch_no)
shift
USE_LIBTORCH=false
shift
;;
--use_pytorch)
shift
USE_PYTORCH=true
shift
;;
--libcantera_dir)
shift
if test $# -gt 0; then
LIBCANTERA_DIR=$1
else
print_usage
return
fi
shift
;;
--amgx_dir)
shift
if test $# -gt 0; then
AMGX_DIR=$1
USE_GPUSOLVER=true
else
print_usage
return
fi
shift
;;
--use_ode_gpu_solver)
shift
USE_ODE_GPU_SOLVER=true
;;
-h|--help)
shift
print_usage
shift
;;
*)
echo "$1 is not a recognized flag!"
print_usage
return
;;
esac
done
# if LIBCANTERA_DIR empty and CONDA_PREFIX empty
if [ -z "$LIBCANTERA_DIR" ] && [ -z "$CONDA_PREFIX" ]; then
echo "ERROR! either offer libcantera dir or ensure in the conda enviorment including libcantera-devel!"
return
fi
# if LIBCANTERA_DIR not empty and CONDA_PREFIX not empty
# --libcantera_dir _path_to_libcantera has a higher priority than the path from conda enviornment
if [ ! -z "$LIBCANTERA_DIR" ] && [ ! -z "$CONDA_PREFIX" ]; then
echo "duplicate libcantera dir from args and from conda!"
echo "from args: "$LIBCANTERA_DIR
echo "from args: "$CONDA_PREFIX
echo "we are going to use the dir from args: "$LIBCANTERA_DIR
fi
# if LIBCANTERA_DIR empty and CONDA_PREFIX not empty
if [ -z "$LIBCANTERA_DIR" ] && [ ! -z "$CONDA_PREFIX" ]; then
LIBCANTERA_DIR=$CONDA_PREFIX
fi
# if LIBCANTERA_DIR not empty and CONDA_PREFIX empty
# just use LIBCANTERA_DIR
if [ $USE_LIBTORCH = true ] && [ $USE_PYTORCH = true ]; then
echo "ERROR! either use libtorch or pytorch!"
return
fi
if [ $LIBTORCH_AUTO = true ]; then
if [ -d "thirdParty/libtorch" ]; then
echo "libtorch already exist."
else
if [ -e libtorch-cxx11-abi-shared-with-deps-1.11.0+cpu.zip ]
then
echo "libtorch.zip exist."
else
wget https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-1.11.0%2Bcpu.zip
fi
unzip libtorch-cxx11-abi-shared-with-deps-1.11.0+cpu.zip -d thirdParty
fi
fi
if [ $USE_PYTORCH = true ]; then
PYTORCH_INC=`python3 -m pybind11 --includes`
if [ -z "$PYTORCH_INC" ]; then
return
fi
PYTORCH_LIB=`pkg-config --libs python3-embed`
fi
echo "setup for deepflame bashrc:"
echo LIBCANTERA_DIR=$LIBCANTERA_DIR
if [ $USE_LIBTORCH = true ]; then
echo LIBTORCH_DIR=$LIBTORCH_DIR
echo PYTORCH_INC=""
echo PYTORCH_LIB=""
fi
if [ $USE_PYTORCH = true ]; then
echo PYTORCH_INC=$PYTORCH_INC
echo PYTORCH_LIB=$PYTORCH_LIB
echo LIBTORCH_DIR=""
fi
if [ $USE_GPUSOLVER = true ]; then
echo AMGX_DIR=$AMGX_DIR
fi
if [ $USE_ODE_GPU_SOLVER = true ]; then
echo ODE_GPU_SOLVER=$OPENCC_PATH
fi
cp bashrc.in bashrc
sed -i "s#pwd#$PWD#g" ./bashrc
sed -i "s#LIBTORCH_DIR#$LIBTORCH_DIR#g" ./bashrc
sed -i "s#PYTORCH_INC#$PYTORCH_INC#g" ./bashrc
sed -i "s#PYTORCH_LIB#$PYTORCH_LIB#g" ./bashrc
sed -i "s#LIBCANTERA_DIR#$LIBCANTERA_DIR#g" ./bashrc
sed -i "s#@AMGX_DIR@#$AMGX_DIR#g" ./bashrc
sed -i "s#@ODE_GPU_SOLVER@#$OPENCC_PATH#g" ./bashrc
if [ -d "src_orig" ]; then
echo "src_orig exist."
else
mkdir -p src_orig/TurbulenceModels
mkdir -p src_orig/thermophysicalModels
mkdir -p src_orig/lagrangian
mkdir -p src_orig/regionModels
mkdir -p src_orig/functionObjects
cp -r $FOAM_SRC/TurbulenceModels/compressible src_orig/TurbulenceModels
cp -r $FOAM_SRC/thermophysicalModels/basic src_orig/thermophysicalModels
cp -r $FOAM_SRC/thermophysicalModels/thermophysicalProperties src_orig/thermophysicalModels
cp -r $FOAM_SRC/lagrangian/intermediate src_orig/lagrangian
cp -r $FOAM_SRC/lagrangian/turbulence src_orig/lagrangian
cp -r $FOAM_SRC/regionModels/surfaceFilmModels src_orig/regionModels
cp -r $FOAM_SRC/functionObjects/field src_orig/functionObjects
fi