Skip to content

Commit

Permalink
Merge pull request #117 from henryleberre/merge
Browse files Browse the repository at this point in the history
  • Loading branch information
sbryngelson authored Mar 8, 2023
2 parents d929c4b + be76f43 commit 64dbf1f
Show file tree
Hide file tree
Showing 26 changed files with 1,019 additions and 633 deletions.
9 changes: 5 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ __pycache__
/tests/*/**
!/tests/golden.txt

# NVIDIA Nsight Compute
*.nsys-rep
*.sqlite

examples/*batch/*/
examples/*/D/*
examples/*/p*
Expand All @@ -34,8 +38,5 @@ examples/*/restart*
examples/*/*.out
examples/*/binary
examples/*/fort.1
examples/*/pre_process.sh
examples/*/simulation.sh
examples/*/post_process.sh
examples/*/fort.1
examples/*/*.sh
examples/*/*.err
554 changes: 554 additions & 0 deletions docs/documentation/case.md

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions docs/documentation/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
## User Documentation

- [Getting Started](getting-started.md)
- [Running MFC](running.md)
- [Testing MFC](testing.md)
- [Case Files](case.md)
- [Running MFC](running.md)
- [Flow Visualisation](visualisation.md)
- [MFC's Authors](authors.md)
- [References](references.md)
Expand All @@ -13,7 +14,7 @@

MFC's three codes have their own documentation:

- [Pre Process](../pre_process/)
- [Pre-Process](../pre_process/)
- [Simulation](../simulation/)
- [Post Process](../post_process/)
- [Post-Process](../post_process/)

537 changes: 4 additions & 533 deletions docs/documentation/running.md

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions docs/documentation/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ To (re)generate *golden files*, append the `-g` (i.e `--generate`) option:
$ ./mfc.sh test -g -j 8
```

It is recommended that a range be specified when generating golden files for new test cases, as described in the previous section, in an effort not to regenerate the golden files of existing test cases.

Adding a new test case can be done by modifying [cases.py](toolchain/mfc/tests/cases.py). The function `generate_cases` is responsible for generating the list of test cases. Loops and conditionals are used to vary parameters, whose defaults can be found in the `BASE_CFG` case object within [case.py](toolchain/mfc/tests/case.py). The function operates on two variables:

- `stack`: A stack that holds the variations to the default case parameters. By pushing and popping the stack inside loops and conditionals, it is easier to nest test case descriptions, as it holds the variations that are common to all future test cases within the same indentation level (in most scenarios).
Expand Down
24 changes: 24 additions & 0 deletions examples/3D_weak_scaling/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 3D Weak Scaling

The [**3D_weak_scaling**](case.py) case depends on two parameters:

- **The number of MPI ranks** (_procs_): As _procs_ increases, the problem
size per rank remains constant. _procs_ is determined using information provided
to the case file by `mfc.sh run`.

- **GPU memory usage per rank** (_gbpp_): As _gbpp_ increases, the problem
size per rank increases and the number of timesteps decreases so that wall times
consistent. _gbpp_ is a user-defined optional argument to the [case.py](case.py)
file. It can be specified right after the case filepath when invoking `mfc.sh run`.

Weak scaling benchmarks can be produced by keeping _gbpp_ constant and varying _procs_.

For example, to run a weak scaling test that uses ~4GB of GPU memory per rank
on 8 2-rank nodes with case optimization, one could:

```console
./mfc.sh run examples/3D_weak_scaling/case.py 4 -t pre_process simulation \
-e batch -p mypartition -N 8 -n 2 -w "01:00:00" -# "MFC Weak Scaling" \
--case-optimization -j 32
```

287 changes: 287 additions & 0 deletions examples/3D_weak_scaling/case.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,287 @@
#!/usr/bin/env python3

# Case file contributed by Anand Radhakrishnan and modified by Henry Le Berre
# for integration as a weak scaling benchmark for MFC.

import json, math, argparse

parser = argparse.ArgumentParser(
prog="3D_weak_scaling",
description="This MFC case was created for the purposes of weak scaling.",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)

parser.add_argument("dict", type=str, metavar="DICT", help=argparse.SUPPRESS)
parser.add_argument("gbpp", type=int, metavar="MEM", default=16, help="Adjusts the problem size per rank to fit into [MEM] GB of GPU memory per GPU.")

ARGS = vars(parser.parse_args())
DICT = json.loads(ARGS["dict"])

ppg = 8000000 / 16.0
procs = DICT["nodes"] * DICT["tasks_per_node"]
ncells = math.floor(ppg * procs * ARGS["gbpp"])
s = math.floor((ncells / 2.0) ** (1/3))
Nx, Ny, Nz = 2*s, s, s

# athmospheric pressure - Pa (used as reference value)
patm = 101325

# Initial Droplet Diameter / Reference length - m
D0 = 1.0E-3

# cavity to droplet ratio
CtD = 0.06

# cavity relative eccentricity (distance between radii)
ecc = 0.564

# initial shock distance from the y axis. Note that the droplet center is located at y = 0. Thus, the distance from the shock to
# the droplet is about D0/8
ISD = 5.0/8 * D0

## pre-shock properties - AIR

# pressure - Pa
p0a = patm

# density - kg/m3
rho0a = 1.204

# gamma
gama = 1.40

# pi infinity - Pa
pia = 0

# speed of sound - M/s
c_a = math.sqrt( gama * ( p0a + pia ) / rho0a )

## Droplet - WATER

# surface tension - N / m
st = 0.00E+0

# Delta Pressure - Pa
DP = -st * 4 / D0

# initial pressure inside the droplet - Pa
p0w = p0a - DP

# density - kg/m3
rho0w = 1000

# gama
gamw = 6.12

# pi infty - Pa
piw = 3.43E+08

# speed of sound - m/s
c_w = math.sqrt( gamw * ( p0w + piw ) / rho0w )

# Shock Mach number of interest. Note that the post-shock properties can be defined in terms of either
# Min or psOp0a. Just comment/uncomment appropriatelly
Min = 2.4

## Pos to pre shock ratios - AIR

# pressure
psOp0a = ( Min ** 2 -1 ) * 2 * gama / ( gama + 1 ) + 1
# psOp0a = 4.5

# density
rhosOrho0a = ( 1 + ( gama + 1 ) / ( gama - 1) * psOp0a ) / ( ( gama + 1 ) / ( gama - 1) + psOp0a )

# Mach number of the shocked region - just a checker, as it must return "Min"
Ms = math.sqrt( ( gama + 1. ) / ( 2. * gama ) * ( psOp0a - 1. ) * ( p0a / ( p0a + pia ) ) + 1. )

# shock speed of sound - m/s
ss = Ms * c_a

## post-shock - AIR

# pressure - Pa
ps = psOp0a * p0a

# density - kg / m3
rhos = rhosOrho0a * rho0a

# post shock speed of sound - m/s
c_s = math.sqrt( gama * (ps + pia) / rhos )

# velocity at the post shock - m/s
vel = c_a/gama * (psOp0a - 1.) * p0a / ( p0a + pia ) / Ms

## Domain boundaries - m

# x direction
xb = -8.4707 * D0
xe = 9.6226 * D0

#xb = -10 * D0
#xe = 10 * D0

# y direction
yb = 0 * D0
ye = 10 * D0

# y direction
zb = 0 * D0
ze = 10 * D0

# Stretching factor, to make sure the domaing is sufficiently large after the mesh strecth
StF = 4.0

# grid delta x if mesh were uniform in x direction - m. Note that I do not need a measure for dy
dx = ( xe - xb ) / Nx

# I calculate tend twice; first is an estimate, second is
# the actual value used. This is because I am getting errors in the
# post process part every time I approximate the actual Nt by an integer
# number (think of a smarter way).

# dimensionless time
ttilde = 1.92

# auxiliary simulation physical time - s. This is not YET the total simulation time, as it will be corrected so as to avoid
# mismatches in simulation and post_process parts. Note that I wrote it this way so I have better control over the # of autosaves
tendA = ttilde * D0 / vel

cfl = 0.1

# time-step - s
dt = dx * cfl/ ss

# Save Frequency. Note that the number of autosaves will be SF + 1, as th IC (0.dat) is also saved
SF = 400

## making Nt divisible by SF
# 1 - ensure NtA goes slightly beyond tendA
NtA = int( tendA//dt + 1 )

# Array of saves. It is the same as Nt/Sf = t_step_save
AS = int( NtA // SF + 1 )

# Nt = total number of steps. Note that Nt >= NtA (so at least tendA is completely simulated)
Nt = AS * SF

# total simulation time - s. Note that tend >= tendA
tend = Nt * dt

# Configuring case dictionary
print(json.dumps({
# Logistics ================================================
'run_time_info' : 'T',
# ==========================================================

# Computational Domain Parameters ==========================
'x_domain%beg' : xb,
'x_domain%end' : xe,
'y_domain%beg' : yb,
'y_domain%end' : ye,
'z_domain%beg' : zb,
'z_domain%end' : ze,
'm' : Nx,
'n' : Ny,
'p' : Nz,
'cyl_coord' : 'F',
'dt' : dt,
't_step_start' : 0,
't_step_stop' : int(5000*16.0/ARGS["gbpp"]),
't_step_save' : int(1000*16.0/ARGS["gbpp"]),
# ==========================================================

# Simulation Algorithm Parameters ==========================
'num_patches' : 3,
'model_eqns' : 2,
'alt_soundspeed' : 'F',
'num_fluids' : 2,
'adv_alphan' : 'T',
'mpp_lim' : 'T',
'mixture_err' : 'T',
'time_stepper' : 3,
'weno_vars' : 2,
'weno_order' : 3,
'weno_eps' : 1.0E-16,
'mapped_weno' : 'T',
'riemann_solver' : 2,
'wave_speeds' : 1,
'avg_state' : 2,
'bc_x%beg' : -6,
'bc_x%end' : -6,
'bc_y%beg' : -2,
'bc_y%end' : -3,
'bc_z%beg' : -2,
'bc_z%end' : -3,
# ==========================================================

# Formatted Database Files Structure Parameters ============
'format' : 1,
'precision' : 2,
'prim_vars_wrt' :'T',
'parallel_io' :'T',
# ==========================================================
# I will use 1 for WATER properties, and 2 for AIR properties
# Patch 1: Background (AIR - 2) =============================
'patch_icpp(1)%geometry' : 9,
'patch_icpp(1)%x_centroid' : (xb+xe) / 2 * StF,
'patch_icpp(1)%y_centroid' : (yb+ye) / 2 * StF,
'patch_icpp(1)%z_centroid' : (yb+ye) / 2 * StF,
'patch_icpp(1)%length_x' : (xe-xb) * StF,
'patch_icpp(1)%length_y' : (ye-yb) * StF,
'patch_icpp(1)%length_z' : (ze-zb) * StF,
'patch_icpp(1)%vel(1)' : 0.0E+00,
'patch_icpp(1)%vel(2)' : 0.0E+00,
'patch_icpp(1)%vel(3)' : 0.0E+00,
'patch_icpp(1)%pres' : p0a,
'patch_icpp(1)%alpha_rho(1)' : 0.0E+00,
'patch_icpp(1)%alpha_rho(2)' : rho0a,
'patch_icpp(1)%alpha(1)' : 0.0E+00,
'patch_icpp(1)%alpha(2)' : 1.0E+00,
# ==========================================================

# Patch 2: Shocked state (AIR - 2) =========================
'patch_icpp(2)%geometry' : 9,
'patch_icpp(2)%alter_patch(1)' : 'T',
'patch_icpp(2)%x_centroid' : -ISD - ( xe - xb ) / 2 * StF,
'patch_icpp(2)%y_centroid' : ( yb + ye ) / 2 * StF,
'patch_icpp(2)%z_centroid' : ( zb + ze ) / 2 * StF,
'patch_icpp(2)%length_x' : ( xe - xb ) * StF,
'patch_icpp(2)%length_y' : ( ye - yb ) * StF,
'patch_icpp(2)%length_z' : ( ze - zb ) * StF,
'patch_icpp(2)%vel(1)' : vel,
'patch_icpp(2)%vel(2)' : 0.0E+00,
'patch_icpp(2)%vel(3)' : 0.0E+00,
'patch_icpp(2)%pres' : ps,
'patch_icpp(2)%alpha_rho(1)' : 0.0E+00,
'patch_icpp(2)%alpha_rho(2)' : rhos,
'patch_icpp(2)%alpha(1)' : 0.0E+00,
'patch_icpp(2)%alpha(2)' : 1.0E+00,
# ==========================================================

# Patch 3: Droplet (WATER - 1) =============================
'patch_icpp(3)%geometry' : 8,
'patch_icpp(3)%x_centroid' : 0.0E+00,
'patch_icpp(3)%y_centroid' : 0.0E+00,
'patch_icpp(3)%z_centroid' : 0.0E+00,
'patch_icpp(3)%radius' : D0/2,
'patch_icpp(3)%alter_patch(1)' : 'T',
'patch_icpp(3)%vel(1)' : 0.0E+00,
'patch_icpp(3)%vel(2)' : 0.0E+00,
'patch_icpp(3)%vel(3)' : 0.0E+00,
'patch_icpp(3)%pres' : p0w,
'patch_icpp(3)%alpha_rho(1)' : rho0w,
'patch_icpp(3)%alpha_rho(2)' : 0.0E+00,
'patch_icpp(3)%alpha(1)' : 1.0E+00,
'patch_icpp(3)%alpha(2)' : 0.0E+00,
# ==========================================================

# Fluids Physical Parameters ===============================
'fluid_pp(1)%gamma' : 1.0E+00/(gamw-1),
'fluid_pp(1)%pi_inf' : gamw*piw/(gamw-1),
'fluid_pp(2)%gamma' : 1.0E+00/(gama-1),
'fluid_pp(2)%pi_inf' : gama*pia/(gama-1),
# ==========================================================
}))

# ==============================================================================

8 changes: 4 additions & 4 deletions mfc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ if [ "$1" == "load" ]; then
if [ "$u_cg" == "c" ]; then
MODULES=("gcc/12.1.0")
elif [ "$u_cg" == "g" ]; then
MODULES=("nvhpc/22.5" "cuda/nvhpc")
MODULES=("nvhpc/22.11" "cuda/nvhpc")
fi

MODULES=("${MODULES[@]}" "python/3.8.10" "darshan-runtime/3.3.1-lite"
"hsi/5.0.2.p5" "xalt/1.2.1" "lsf-tools/2.0"
"cmake/3.23.1" "ninja/1.10.2" "spectrum-mpi/10.4.0.3-20210112")
"cmake/3.23.2" "ninja/1.10.2" "spectrum-mpi/10.4.0.3-20210112")
elif [ "$u_computer" == "b" ]; then # Bridges2
if [ "$u_cg" == "c" ]; then
MODULES=("allocations/1.0" "gcc/10.2.0" "python/3.8.6"
Expand Down Expand Up @@ -115,10 +115,10 @@ if [ "$1" == "load" ]; then
if [ "$u_cg" == "c" ]; then
MODULES=("gcc/11.1.0" "openmpi/4.0.5_gcc")
elif [ "$u_cg" == "g" ]; then
MODULES=("cuda/11.5.1" "/sw/wombat/Nvidia_HPC_SDK/modulefiles/nvhpc/22.1")
MODULES=("nvhpc/22.11")
fi

MODULES=("${MODULES[@]}" "cmake/3.22.1" "python/3.9.9")
MODULES=("${MODULES[@]}" "cmake/3.25.1" "python/3.10.8")
elif [ "$u_computer" == "e" ]; then # Expanse
if [ "$u_cg" == "c" ]; then
warn "Please set CC=icc, CXX=icx, and FC=ifort."
Expand Down
Loading

0 comments on commit 64dbf1f

Please sign in to comment.