-
Notifications
You must be signed in to change notification settings - Fork 1
/
run_complete_MGP.sh
129 lines (79 loc) · 2.45 KB
/
run_complete_MGP.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
#!/bin/bash
#SBATCH --time=01:00:00
#SBATCH --job-name=run_P-multigrid
#SBATCH --output=%x_%j.out
#SBATCH --error=%x_%j.err
#SBATCH --partition=medium
#SBATCH --account=project_2001628
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=128
export OMP_NUM_THREADS=1
module load elmer/latest
# THIS IS A FULLY AUTOMATED BASH SCRIPT FOR RUNNING
# A CASE WITH GIVEN SET OF SOLVERS, MESH LEVELS
# AND P VALUES
# USER NEEDS TO FILL THE FOLLOWING CONSTANTS:
# Define the path to the case folder
CASE_PATH=Electrostatics/CapacitanceOfTwoBallsP
# Define the problem type
PROBLEM=P-MutliGrid
# Define the mesh levels to loop over
MESH_LEVELS=(1 2 3)
# Define the P values to loop over
P_VALUES=(2 3 4 5 6 7)
# USER CAN IF WANTED CHANGE FOLLOWING CONSTANTS:
# Define the number of partitions (no need to change)
PARTITIONS=$SLURM_NPROCS
# Define the path where resulting .dat files are stored (no need to change)
RET_PATH=$PWD/$CASE_PATH/results
# Define the resulting .dat file (no need to change)
RET_FILE=f$PARTITIONS.dat
ORG_DIR=$PWD
###################### RUN THE SCRIPTS #######################
# CHECK FOR PARTITIONINGS AND AS REQUIRED PARTITION THE MESH TO NEEDED AMOUNT
cd $CASE_PATH
# Find all folders with files of form mesh.*
MESH_DIRS=$(find . -type f -name "mesh.*" | sed -r 's|/[^/]+$||' |sort |uniq)
for mesh_dir in "${MESH_DIRS[@]}"; do
# Check if proper partitioning already exists
if [ -f "$mesh_dir/partitioning.$PARTITIONS" ]; then
continue
# Otherwise call ElmerGrid
else
ElmerGrid 2 2 $mesh_dir -partdual -metiskway $PARTITIONS
fi
done
cd $ORG_DIR
# RUN THE ELMERSOLVER
echo "Running ElmerSolver..."
for mesh_level in "${MESH_LEVELS[@]}"; do
for p_value in "${P_VALUES[@]}"; do
for solver in linsys/*.sif; do
if grep -Fxq "$solver" solver-lists/$PROBLEM-Solvers.txt
then
cp $solver $CASE_PATH/linsys.sif
cd $CASE_PATH
echo
echo
echo "-----------------------------------"
echo "Starting $solver with mesh level $mesh_level and p-value $p_value"
echo
start=$(date +%s)
srun ElmerSolver case.sif -ipar 3 $mesh_level $PARTITIONS $p_value
end=$(date +%s)
echo
echo "Ending $solver with mesh level $mesh_level and p-value $p_value"
echo "Elapsed time: $(($end-$start)) s"
echo "-----------------------------------"
echo
cd $ORG_DIR
else
echo
echo "Solver $solver not recommended for given problem. Ignoring it"
echo
fi
done
done
done
cd $ORG_DIR
echo "DONE"