-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathconfig.sh
executable file
·107 lines (81 loc) · 4.44 KB
/
config.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
#!/bin/bash
#*********************************************************************************#
# Simulation Configuration Script
#*********************************************************************************#
#
#--------------------------------------- PATH ---------------------------------------------
# absolute or relative paths of corresponding files or directories
template_directory="../../../multiphase_3D/run_template/"
exec_location="../../../multiphase_3D/1.exec/MF_LBM.gpu"
# if external geometry is used (external_geometry_read_cmd = 1)
geometry_file="../../../MF-LBM-extFiles/geometry_files/sample_rock_geometry_wallarray/bentheimer_in10_240_240_240_out10.dat"
# if pre-computed boundary info is used (geometry_preprocess_cmd = 2)
geometry_boundary_info_file="../../../preprocessing/3.wall_boundary_preprocess/output/indirect_addressing_walls_boundary.dat"
#------------------------ choose Linux or OSX system --------------------------------------
# sed command is slightly different between Linux and OSX.
# Uncomment OSX below if you are using a MAC
# OS="OSX"
# --- Linux
sed_option="-i"
# --- OSX sed -i.bak should be used. One can delete .bak files afterwards
if [[ "$OS" == "OSX" ]]
then
sed_option="-i.bak"
fi
# -------------------------------------- modify path --------------------------------------
# write above paths to path_info.txt
cp $template_directory/template-path_info.txt path_info.txt
sed $sed_option "s|exec_path_holder|$exec_location|" path_info.txt
sed $sed_option "s|geometry_file_path_holder|$geometry_file|" path_info.txt
sed $sed_option "s|geometry_boundary_file_path_holder|$geometry_boundary_info_file|" path_info.txt
cp $template_directory/clean.sh ./
#---------------------- copy and modify the control file template --------------------------
cp $template_directory/template-simulation_control.txt simulation_control.txt
initial_fluid_distribution_option=6
sed $sed_option "s|initial_fluid_distribution_option .*|initial_fluid_distribution_option $initial_fluid_distribution_option|g" ./simulation_control.txt
benchmark_cmd=1
sed $sed_option "s|benchmark_cmd .*|benchmark_cmd $benchmark_cmd|g" ./simulation_control.txt
external_geometry_read_cmd=1
sed $sed_option "s|external_geometry_read_cmd .*|external_geometry_read_cmd $external_geometry_read_cmd|g" ./simulation_control.txt
geometry_preprocess_cmd=1
sed $sed_option "s|geometry_preprocess_cmd .*|geometry_preprocess_cmd $geometry_preprocess_cmd|g" ./simulation_control.txt
nx=240
ny=240
nz=260
sed $sed_option "s|lattice_dimensions .*|lattice_dimensions $nx,$ny,$nz|g" ./simulation_control.txt
periodic_x=0
periodic_y=0
periodic_z=1
sed $sed_option "s|periodic_indicator .*|periodic_indicator $periodic_x,$periodic_y,$periodic_z|g" ./simulation_control.txt
mpi_npx=1 # x-axis domain decomposition currently disabled, keep using mpi_npx=1
mpi_npy=1
mpi_npz=1
sed $sed_option "s|MPI_process_num .*|MPI_process_num $mpi_npx,$mpi_npy,$mpi_npz|g" ./simulation_control.txt
body_force_0=200d-6
sed $sed_option "s|body_force_0 .*|body_force_0 $body_force_0|g" ./simulation_control.txt
target_fluid1_saturation=0.4
sed $sed_option "s|target_fluid1_saturation .*|target_fluid1_saturation $target_fluid1_saturation|g" ./simulation_control.txt
# -------------------------- modify interactive run script ----------------------------------
MPI_process_num=1 # MPI_process_num must be equal to mpi_npx * mpi_npy * mpi_npz
run_command="mpirun -n $MPI_process_num $exec_location"
################# sample run command #################
# ~~~~~ typical CPU computing nodes with two NUMAs per node
# mpirun -n $MPI_process_num --map-by ppr:2:node --bind-to numa $exec_location
# ~~~~~ consumer-grade desktop or laptop
# mpirun -n $MPI_process_num $exec_location
# ~~~~~ GPU nodes with 4 GPUs per node
# mpirun -n $MPI_process_num --map-by ppr:4:node --bind-to socket $exec_location
# ~~~~~ use srun
# srun -n $MPI_process_num $exec_location
# Intel Xeon Phi 'KNL' node
# export KMP_AFFINITY=noverbose,warnings,respect,granularity=fine,duplicates,scatter,0,0
# mpirun -n $MPI_process_num numactl --membind=1 $exec_location
################# sample run command #################
# Interactive run script. Slurm job scripts can be generated easily based on irun.sh
cp $template_directory/template-irun.sh irun.sh
sed $sed_option "s|run_command|$run_command|" irun.sh
# -------------------------- clean up ----------------------------------
if [[ "$OS" == "OSX" ]]
then
rm *.bak
fi