Skip to content

Commit 3dd46e2

Browse files
committed
Github suggestions and bug fix
1 parent f1c26f9 commit 3dd46e2

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

examples/1D_convergence/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
This example case contains an automated convergence test using a 1D, two-component advection case.
2-
The case can be ran by executing the bash script `./submitJobs.sh` in a terminal after enabling
2+
The case can be run by executing the bash script `./submitJobs.sh` in a terminal after enabling
33
execution permissions with `chmod +x ./submitJobs.sh` and setting the `ROOT_DIR` and `MFC_DIR`
4-
variables. The default settings the script run the case for 6 different grid resolutions with 1st,
4+
variables. By default the script runs the case for 6 different grid resolutions with 1st,
55
3rd, and 5th, order spatial reconstructions. These settings can be modified by editing the variables
66
at the top of the script. You can also run different model equations by setting the `ME` variable
77
and different Riemann solvers by setting the `RS` variable.

examples/1D_convergence/plot.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,15 @@
1919
exact_a2 = pd.read_csv(f"N{N[i]}_O{Ord[j]}/D/cons.6.00.000000.dat", sep=r"\s+", header=None, names=["x", "y"])
2020

2121
## 2 norm
22-
errors[i, j, 0] = 1 / N[i] * np.sum(np.sqrt((sim_a1.y - exact_a1.y) ** 2))
23-
errors[i, j, 0] += 1 / N[i] * np.sum(np.sqrt((sim_a2.y - exact_a2.y) ** 2))
22+
errors[i, j, 0] = np.linalg.norm(sim_a1.y - exact_a1.y) / np.sqrt(N[i])
23+
errors[i, j, 0] += np.linalg.norm(sim_a2.y - exact_a2.y) / np.sqrt(N[i])
2424

2525
## 1 norm
2626
errors[i, j, 1] = 1 / N[i] * np.sum(np.abs(sim_a1.y - exact_a1.y))
2727
errors[i, j, 1] += 1 / N[i] * np.sum(np.abs(sim_a2.y - exact_a2.y))
2828

2929
## Inf norm
30-
errors[i, j, 2] = np.nanmax(np.abs(sim_a1.y - exact_a1.y))
31-
errors[i, j, 2] += np.nanmax(np.abs(sim_a2.y - exact_a2.y))
30+
errors[i, j, 2] = np.max([np.nanmax(np.abs(sim_a1.y - exact_a1.y)), np.nanmax(np.abs(sim_a2.y - exact_a2.y))])
3231

3332
fig, ax = plt.subplots(1, 3, figsize=(12, 8), sharex=True)
3433

examples/1D_convergence/submitJobs.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
#!/usr/bin/env sh
22
Nx=(32 64 128 256 512 1024)
33
Order=(1 3 5)
4+
45
ME=2 # Model equations = 2 for five-equation model
56
RS=2 # Riemann solver = 2 for HLLC
67

7-
#ROOT_DIR=<WORKING DIRECTORY>
8-
#MFC_DIR=<MFC ROOT DIR>
9-
ROOT_DIR="/Users/benwilfong/Documents/software/MFC-Wilfong/examples/1D_convergence"
10-
MFC_DIR="/Users/benwilfong/Documents/software/MFC-Wilfong"
8+
# Get the directory of the script itself
9+
ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
10+
# Assume the script is in examples/1D_convergence, so MFC_DIR is two levels up
11+
MFC_DIR="$(dirname "$(dirname "$ROOT_DIR")")"
1112

1213
for i in "${Nx[@]}"; do
1314
for j in "${Order[@]}"; do

toolchain/mfc/test/cases.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,8 @@ def foreach_example():
10211021
"3D_TaylorGreenVortex_analytical",
10221022
"3D_IGR_TaylorGreenVortex_nvidia",
10231023
"2D_backward_facing_step",
1024-
"2D_forward_facing_step"]
1024+
"2D_forward_facing_step",
1025+
"1D_convergence"]
10251026
if path in casesToSkip:
10261027
continue
10271028
name = f"{path.split('_')[0]} -> Example -> {'_'.join(path.split('_')[1:])}"

0 commit comments

Comments
 (0)