Skip to content

Commit aad787b

Browse files
authored
Merge pull request #176 from henryleberre/master
2 parents 85bf026 + 4c55fca commit aad787b

File tree

20 files changed

+668
-248
lines changed

20 files changed

+668
-248
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ __pycache__
2525
*.nsys-rep
2626
*.sqlite
2727

28+
docs/*/initial*
29+
docs/*/result*
30+
docs/documentation/examples.md
31+
2832
examples/*batch/*/
2933
examples/*/D/*
3034
examples/*/p*
@@ -40,4 +44,7 @@ examples/*/binary
4044
examples/*/fort.1
4145
examples/*/*.sh
4246
examples/*/*.err
47+
examples/*/viz/
48+
examples/*.jpg
49+
examples/*.png
4350
*.mod

CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,8 @@ if (MFC_DOCUMENTATION)
414414
set(DOXYGEN_HTML_OUTPUT "\"${CMAKE_CURRENT_BINARY_DIR}/${target}\"")
415415
set(DOXYGEN_MATHJAX_CODEFILE "\"${CMAKE_CURRENT_SOURCE_DIR}/docs/config.js\"")
416416
set(DOXYGEN_PROJECT_LOGO "\"${CMAKE_CURRENT_SOURCE_DIR}/docs/res/icon.ico\"")
417+
set(DOXYGEN_IMAGE_PATH "\"${CMAKE_CURRENT_SOURCE_DIR}/docs/res\"\
418+
\"${CMAKE_CURRENT_SOURCE_DIR}/docs/${target}\"")
417419

418420
file(MAKE_DIRECTORY "${DOXYGEN_OUTPUT_DIRECTORY}")
419421

@@ -425,8 +427,9 @@ if (MFC_DOCUMENTATION)
425427
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${target}/html/index.html"
426428
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${target}-Doxyfile"
427429
"${${target}_SRCs}"
428-
COMMAND "${DOXYGEN_EXECUTABLE}"
429-
"${target}-Doxyfile"
430+
COMMAND "bash" "${CMAKE_CURRENT_SOURCE_DIR}/docs/examples.sh"
431+
"${CMAKE_CURRENT_SOURCE_DIR}" &&
432+
"${DOXYGEN_EXECUTABLE}" "${target}-Doxyfile"
430433
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
431434
COMMENT "${target}: Generating documentation"
432435
)

docs/Doxyfile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@ EXAMPLE_RECURSIVE = NO
914914
# that contain images that are to be included in the documentation (see the
915915
# \image command).
916916

917-
IMAGE_PATH = ../res
917+
IMAGE_PATH = @DOXYGEN_IMAGE_PATH@
918918

919919
# The INPUT_FILTER tag can be used to specify a program that doxygen should
920920
# invoke to filter for each input file. Doxygen will invoke the filter program

docs/documentation/case.md

Lines changed: 55 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -139,27 +139,66 @@ the grid stretching funciton is applied and has a default value of one.
139139

140140
### 3. Patches
141141

142-
| Parameter | Type | Description |
143-
| ---: | :----: | :--- |
144-
| `num_patches` | Integer | Number of initial condition geometric patches. |
145-
| `num_fluids` | Integer | Number of fluids/components present in the flow. |
146-
| `geometry` * | Integer | Geometry configuration of the patch. |
147-
| `alter_patch(i)` * | Logical | Alter the $i$-th patch. |
148-
| `x[y,z]_centroid` * | Real | Centroid of the applied geometry in the $[x,y,z]$-direction. |
149-
| `length_x[y,z]` * | Real | Length, if applicable, in the $[x,y,z]$-direction. |
150-
| `radius` * | Real | Radius, if applicable, of the applied geometry. |
151-
| `smoothen` * | Logical | Smoothen the applied patch. |
152-
| `smooth_patch_id` * | Integer | A patch with which the applied patch is smoothened. |
153-
| `smooth_coeff` * | Real | Smoothen coefficient. |
154-
| `alpha(i)` * | Real | Volume fraction of fluid $i$. |
155-
| `alpha_rho(i)` * | Real | Partial density of fluid $i$. |
156-
| `pres` * | Real | Pressure. |
157-
| `vel(i)` * | Real | Velocity in direction $i$. |
142+
| Parameter | Type | Analytical Definition | Description |
143+
| ---: | :----: | :----: | :--- |
144+
| `num_patches` | Integer | Not Supported | Number of initial condition geometric patches. |
145+
| `num_fluids` | Integer | Not Supported | Number of fluids/components present in the flow. |
146+
| `geometry` * | Integer | Not Supported | Geometry configuration of the patch. |
147+
| `alter_patch(i)` * | Logical | Not Supported | Alter the $i$-th patch. |
148+
| `x[y,z]_centroid` * | Real | Not Supported | Centroid of the applied geometry in the $[x,y,z]$-direction. |
149+
| `length_x[y,z]` * | Real | Not Supported | Length, if applicable, in the $[x,y,z]$-direction. |
150+
| `radius` * | Real | Not Supported | Radius, if applicable, of the applied geometry. |
151+
| `smoothen` * | Logical | Not Supported | Smoothen the applied patch. |
152+
| `smooth_patch_id` * | Integer | Not Supported | A patch with which the applied patch is smoothened. |
153+
| `smooth_coeff` * | Real | Not Supported | Smoothen coefficient. |
154+
| `alpha(i)` * | Real | Supported | Volume fraction of fluid $i$. |
155+
| `alpha_rho(i)` * | Real | Supported | Partial density of fluid $i$. |
156+
| `pres` * | Real | Supported | Pressure. |
157+
| `vel(i)` * | Real | Supported | Velocity in direction $i$. |
158158

159159
*: These parameters should be prepended with `patch_icpp(j)%` where $j$ is the patch index.
160160

161161
The Table lists the patch parameters. The parameters define the geometries and physical parameters of fluid components (patch) in the domain at initial condition. Note that the domain must be fully filled with patche(s). The code outputs error messages when an empty region is left in the domain.
162162

163+
#### Analytical Definition of Primitive Variables
164+
165+
Some parameters, as described above, can be defined by analytical functions in the input file. For example, one can define the following patch:
166+
167+
```json
168+
'patch_icpp(2)%geometry' : 15,
169+
'patch_icpp(2)%x_centroid' : 0.25,
170+
'patch_icpp(2)%length_x' : 9.5,
171+
'patch_icpp(2)%vel(1)' : 0.,
172+
'patch_icpp(2)%pres' : 1.,
173+
'patch_icpp(2)%alpha_rho(1)': '1 + 0.1*sin(20*x*pi)',
174+
'patch_icpp(2)%alpha(1)' : 1.,
175+
```
176+
177+
where `alpha_rho` is defined with the `1 + 0.1*sin(20*x*pi)` function.
178+
179+
The expressions are interpreted as Fortran code, in the execution context and scope of the function that defines the patch.
180+
Additionally, the following variables are made available as shorthand:
181+
182+
| Shorthand | Expands To | Shorthand | Expands To | Shorthand | Expands To |
183+
| --------- | ------------------------ | --------- | ------------------------- | --------- | ------------------------ |
184+
| `x` | `x_cc(i)` | `lx` | The patch's `length_x` | `xc` | The patch's `x_centroid` |
185+
| `y` | `y_cc(j)` | `ly` | The patch's `length_y` | `yc` | The patch's `y_centroid` |
186+
| `z` | `z_cc(k)` | `lz` | The patch's `length_z` | `zc` | The patch's `z_centroid` |
187+
| `eps` | The patch's `epsilon` | `beta` | The patch's `beta` | `radii` | The patch's `radii` |
188+
| `tau_e` | The patch's `tau_e` | `r` | The patch's `radius` | `pi` and `e` | $\pi$ and $e$ |
189+
190+
where $(i,j,k)$ are the grid-indices of the current cell in each coordinate direction.
191+
192+
In the example above, the following code is generated:
193+
194+
```f90
195+
if (patch_id == 2) then
196+
q_prim_vf(contxb)%sf(i, 0, 0) = 1 + 0.1*sin(20*x_cc(i)*3.141592653589793)
197+
end if
198+
```
199+
200+
#### Parameter Descriptions
201+
163202
- `num_patches` defines the total number of patches defined in the domain. The number has to be a positive integer.
164203

165204
- `num_fluids` defines the total number of fluids defined in each of the patches. The number has to be a positive integer.

docs/documentation/readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- [Getting Started](getting-started.md)
66
- [Testing MFC](testing.md)
77
- [Case Files](case.md)
8+
- [Example Cases](examples.md)
89
- [Running MFC](running.md)
910
- [Flow Visualisation](visualisation.md)
1011
- [MFC's Authors](authors.md)

docs/examples.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
examples_md="$1/docs/documentation/examples.md"
6+
rm "$examples_md" || true
7+
8+
echo -e "# Example Cases\n" > "$examples_md"
9+
10+
for casedir in $(find "$1/examples/" -maxdepth 1 -type d); do
11+
casename="$(basename $casedir)"
12+
13+
if [ "$casename" == "examples" ]; then
14+
continue
15+
fi
16+
17+
if [ -f "$casedir/README.md" ]; then
18+
sed -e "s/\.png/-$casename\.png/g" "$casedir/README.md" | sed 's/^#/##/g' >> "$examples_md"
19+
echo "" >> "$examples_md"
20+
21+
for png in $(find "$casedir" -maxdepth 1 -name "*.png"); do
22+
cp "$png" "$1/docs/documentation/$(basename $png | sed s/\.png//g)-$casename.png"
23+
done
24+
fi
25+
done

examples/1D_shuosher/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Shu-Osher problem (1D)
2+
3+
Reference: C. W. Shu, S. Osher, Efficient implementation of essentially non-oscillatory shock-capturing schemes, Journal of Computational Physics 77 (2) (1988) 439–471. doi:10.1016/0021-9991(88)90177-5.
4+
5+
## Initial Condition
6+
7+
![Initial Condition](initial.png)
8+
9+
## Result
10+
11+
![Result](result.png)

examples/1D_shuosher/case.py

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!/usr/bin/env python3
2+
3+
import math
4+
import json
5+
6+
# Numerical setup
7+
Nx = 1000
8+
dx = 1./(1.*(Nx+1))
9+
10+
Tend, Nt = 1.8, 20000
11+
mydt = Tend/(1.*Nt)
12+
13+
# Configuring case dictionary
14+
print(json.dumps({
15+
# Logistics ================================================================
16+
'run_time_info' : 'T',
17+
# ==========================================================================
18+
19+
# Computational Domain Parameters ==========================================
20+
'x_domain%beg' : -5.,
21+
'x_domain%end' : 5. ,
22+
'm' : Nx,
23+
'n' : 0,
24+
'p' : 0,
25+
'dt' : mydt,
26+
't_step_start' : 0,
27+
't_step_stop' : int(Nt),
28+
't_step_save' : int(math.ceil(Nt/10.0)),
29+
# ==========================================================================
30+
31+
# Simulation Algorithm Parameters ==========================================
32+
'num_patches' : 2,
33+
'model_eqns' : 2,
34+
'alt_soundspeed' : 'F',
35+
'num_fluids' : 1,
36+
'adv_alphan' : 'T',
37+
'mpp_lim' : 'F',
38+
'mixture_err' : 'F',
39+
'time_stepper' : 3,
40+
'weno_order' : 5,
41+
'weno_eps' : 1.E-16,
42+
'mapped_weno' : 'T',
43+
'null_weights' : 'F',
44+
'mp_weno' : 'F',
45+
'riemann_solver' : 2,
46+
'wave_speeds' : 1,
47+
'avg_state' : 2,
48+
'bc_x%beg' : -3,
49+
'bc_x%end' : -3,
50+
# ==========================================================================
51+
52+
# Formatted Database Files Structure Parameters ============================
53+
'format' : 1,
54+
'precision' : 2,
55+
'prim_vars_wrt' :'T',
56+
'parallel_io' :'F',
57+
# ==========================================================================
58+
59+
60+
# Background to cover whole domain with basic line patch
61+
# Patch 1 Left (-5 < x < -4) ===============================================
62+
'patch_icpp(1)%geometry' : 1,
63+
'patch_icpp(1)%x_centroid' : -4.5,
64+
'patch_icpp(1)%length_x' : 1.,
65+
'patch_icpp(1)%vel(1)' : 2.629369,
66+
'patch_icpp(1)%pres' : 10.3333,
67+
'patch_icpp(1)%alpha_rho(1)' : 3.957143,
68+
'patch_icpp(1)%alpha(1)' : 1.,
69+
# ==========================================================================
70+
71+
72+
# One anlytic patch to take care of -4 < x < 5
73+
# Patch 2 Analytic =========================================================
74+
'patch_icpp(2)%geometry' : 15,
75+
'patch_icpp(2)%x_centroid' : 0.5,
76+
'patch_icpp(2)%length_x' : 9.,
77+
'patch_icpp(2)%vel(1)' : 0.,
78+
'patch_icpp(2)%pres' : 1.,
79+
'patch_icpp(2)%alpha_rho(1)' : '1 + 0.2*sin(5*x)',
80+
'patch_icpp(2)%alpha(1)' : 1.,
81+
# ==========================================================================
82+
83+
# Fluids Physical Parameters ===============================================
84+
'fluid_pp(1)%gamma' : 1.E+00/(1.4-1.E+00),
85+
'fluid_pp(1)%pi_inf' : 0.0,
86+
# ==========================================================================
87+
}))
88+
89+
# ==============================================================================

examples/1D_shuosher/initial.png

47 KB
Loading

examples/1D_shuosher/result.png

73.1 KB
Loading

0 commit comments

Comments
 (0)