Skip to content

Commit 0ea6360

Browse files
sbryngelsonclaude
andcommitted
Add documentation for ./mfc.sh viz command
Updates visualization.md with comprehensive CLI viz docs covering basic usage, timestep selection, rendering options, 3D slicing, video generation, and format selection. Adds viz references to getting-started, running, case, and troubleshooting pages. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9f39c7e commit 0ea6360

5 files changed

Lines changed: 194 additions & 6 deletions

File tree

docs/documentation/case.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ To restart the simulation from $k$-th time step, see @ref running "Restarting Ca
651651

652652
The table lists formatted database output parameters. The parameters define variables that are outputted from simulation and file types and formats of data as well as options for post-processing.
653653

654-
- `format` specifies the choice of the file format of data file outputted by MFC by an integer of 1 and 2. `format = 1` and `2` correspond to Silo-HDF5 format and binary format, respectively.
654+
- `format` specifies the choice of the file format of data file outputted by MFC by an integer of 1 and 2. `format = 1` and `2` correspond to Silo-HDF5 format and binary format, respectively. Both formats are supported by `./mfc.sh viz` (see @ref visualization "Flow Visualization"). Silo-HDF5 requires the h5py Python package; binary has no extra dependencies.
655655

656656
- `precision` specifies the choice of the floating-point format of the data file outputted by MFC by an integer of 1 and 2. `precision = 1` and `2` correspond to single-precision and double-precision formats, respectively.
657657

docs/documentation/getting-started.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,24 @@ MFC is **unit-agnostic**: the solver performs no internal unit conversions. What
204204

205205
The only requirement is **consistency** — all inputs must use the same unit system. Note that some parameters use **transformed stored forms** rather than standard physical values (e.g., `gamma` expects \f$1/(\gamma-1)\f$, not \f$\gamma\f$ itself). See @ref sec-stored-forms for details.
206206

207+
## Visualizing Results
208+
209+
After running post_process, visualize the output directly from the command line:
210+
211+
```shell
212+
# List available variables
213+
./mfc.sh viz examples/2D_shockbubble/ --list-vars --step 0
214+
215+
# Render a pressure snapshot
216+
./mfc.sh viz examples/2D_shockbubble/ --var pres --step 1000
217+
218+
# Generate a video
219+
./mfc.sh viz examples/2D_shockbubble/ --var pres --step all --mp4
220+
```
221+
222+
Output images and videos are saved to the `viz/` subdirectory of the case.
223+
For more options, see @ref visualization "Flow Visualization" or run `./mfc.sh viz -h`.
224+
207225
## Helpful Tools
208226

209227
### Parameter Lookup

docs/documentation/running.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ using 4 cores:
7373
./mfc.sh run examples/2D_shockbubble/case.py -t simulation post_process -n 4
7474
```
7575

76+
- Visualizing post-processed output:
77+
78+
```shell
79+
./mfc.sh viz examples/2D_shockbubble/ --var pres --step 1000
80+
```
81+
82+
See @ref visualization "Flow Visualization" for the full set of visualization options.
83+
7684
---
7785

7886
## Running on GPUs

docs/documentation/troubleshooting.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ This guide covers debugging tools, common issues, and troubleshooting workflows
3737
./mfc.sh run case.py -v # Run with verbose output
3838
./mfc.sh test --only <UUID> # Run a specific test
3939
./mfc.sh clean # Clean and start fresh
40+
./mfc.sh viz case_dir/ --list-vars --step 0 # Inspect post-processed data
4041
```
4142

4243
---
@@ -457,6 +458,47 @@ Common issues:
457458

458459
---
459460

461+
## Visualization Issues
462+
463+
### "No 'binary/' or 'silo_hdf5/' directory found"
464+
465+
**Cause:** Post-processing has not been run, or the case directory path is wrong.
466+
467+
**Fix:**
468+
1. Run post_process first:
469+
```bash
470+
./mfc.sh run case.py -t post_process
471+
```
472+
2. Verify the path points to the case directory (containing `binary/` or `silo_hdf5/`)
473+
474+
### "Variable 'X' not found"
475+
476+
**Cause:** The requested variable was not written during post-processing.
477+
478+
**Fix:**
479+
1. List available variables:
480+
```bash
481+
./mfc.sh viz case_dir/ --list-vars --step 0
482+
```
483+
2. Ensure your case file enables the desired output (e.g., ``prim_vars_wrt = 'T'``, ``cons_vars_wrt = 'T'``)
484+
485+
### "h5py is required to read Silo-HDF5 files"
486+
487+
**Cause:** The case was post-processed with `format=1` (Silo-HDF5) but `h5py` is not installed.
488+
489+
**Fix:**
490+
- Install h5py: `pip install h5py`
491+
- Or re-run post_process with `format=2` in your case file to produce binary output
492+
493+
### Visualization looks wrong or has artifacts
494+
495+
**Possible causes and fixes:**
496+
1. **Color range:** Try setting explicit `--vmin` and `--vmax` values
497+
2. **Wrong variable:** Use `--list-vars` to check available variables
498+
3. **3D slice position:** Adjust `--slice-axis` and `--slice-value` to view the correct plane
499+
500+
---
501+
460502
## Getting Help
461503

462504
If you can't resolve an issue:

docs/documentation/visualization.md

Lines changed: 125 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,133 @@
22

33
# Flow visualization
44

5-
A post-processed database in Silo-HDF5 format can be visualized and analyzed using Paraview and VisIt.
6-
After the post-processing of simulation data (see section @ref running "Running"), a directory named `silo_hdf5` contains a silo-HDF5 database.
7-
Here, `silo_hdf5/` includes a directory named `root/` that contains index files for flow field data at each saved time step.
5+
After running `post_process` on a simulation (see @ref running "Running"), MFC produces output in either Silo-HDF5 format (`format=1`) or binary format (`format=2`).
6+
These can be visualized using MFC's built-in CLI tool or external tools like ParaView and VisIt.
87

9-
### Visualizing with Paraview
8+
---
109

11-
Paraview is an open-source interactive parallel visualization and graphical analysis tool for viewing scientific data.
10+
## Quick visualization with `./mfc.sh viz`
11+
12+
MFC includes a built-in visualization command that renders PNG images and MP4 videos directly from post-processed output — no external GUI tools needed.
13+
14+
### Basic usage
15+
16+
```bash
17+
# Plot pressure at timestep 1000
18+
./mfc.sh viz case_dir/ --var pres --step 1000
19+
20+
# Plot density at all available timesteps
21+
./mfc.sh viz case_dir/ --var rho --step all
22+
```
23+
24+
The command auto-detects the output format (binary or Silo-HDF5) and dimensionality (1D, 2D, or 3D).
25+
Output images are saved to `case_dir/viz/` by default.
26+
27+
### Exploring available data
28+
29+
Before plotting, you can inspect what data is available:
30+
31+
```bash
32+
# List all available timesteps
33+
./mfc.sh viz case_dir/ --list-steps
34+
35+
# List all available variables at a given timestep
36+
./mfc.sh viz case_dir/ --list-vars --step 0
37+
```
38+
39+
### Timestep selection
40+
41+
The `--step` argument accepts several formats:
42+
43+
| Format | Example | Description |
44+
|--------|---------|-------------|
45+
| Single | `--step 1000` | One timestep |
46+
| Range | `--step 0:10000:500` | Start:end:stride |
47+
| All | `--step all` | Every available timestep |
48+
49+
### Rendering options
50+
51+
Customize the appearance of plots:
52+
53+
```bash
54+
# Custom colormap and color range
55+
./mfc.sh viz case_dir/ --var rho --step 1000 --cmap RdBu --vmin 0.5 --vmax 2.0
56+
57+
# Higher resolution
58+
./mfc.sh viz case_dir/ --var pres --step 500 --dpi 300
59+
60+
# Logarithmic color scale
61+
./mfc.sh viz case_dir/ --var schlieren --step 1000 --log-scale
62+
```
63+
64+
| Option | Description | Default |
65+
|--------|-------------|---------|
66+
| `--cmap` | Matplotlib colormap name | `viridis` |
67+
| `--vmin` | Minimum color scale value | auto |
68+
| `--vmax` | Maximum color scale value | auto |
69+
| `--dpi` | Image resolution (dots per inch) | 150 |
70+
| `--log-scale` | Use logarithmic color scale | off |
71+
| `--output` | Output directory for images | `case_dir/viz/` |
72+
73+
### 3D slicing
74+
75+
For 3D simulations, `viz` extracts a 2D slice for plotting.
76+
By default, it slices at the midplane along the z-axis:
77+
78+
```bash
79+
# Default z-midplane slice
80+
./mfc.sh viz case_dir/ --var pres --step 500
81+
82+
# Slice along the x-axis at x=0.25
83+
./mfc.sh viz case_dir/ --var pres --step 500 --slice-axis x --slice-value 0.25
84+
85+
# Slice by array index
86+
./mfc.sh viz case_dir/ --var pres --step 500 --slice-axis y --slice-index 50
87+
```
88+
89+
### Video generation
90+
91+
Generate MP4 videos from a range of timesteps:
92+
93+
```bash
94+
# Basic video (10 fps)
95+
./mfc.sh viz case_dir/ --var pres --step 0:10000:100 --mp4
96+
97+
# Custom frame rate
98+
./mfc.sh viz case_dir/ --var schlieren --step all --mp4 --fps 24
99+
100+
# Video with fixed color range
101+
./mfc.sh viz case_dir/ --var rho --step 0:5000:50 --mp4 --vmin 0.1 --vmax 1.0
102+
```
103+
104+
Videos are saved as `case_dir/viz/<varname>.mp4`.
105+
The color range is automatically computed from the first, middle, and last frames unless `--vmin`/`--vmax` are specified.
106+
107+
### Format selection
108+
109+
The output format is auto-detected from the case directory.
110+
To override:
111+
112+
```bash
113+
./mfc.sh viz case_dir/ --var pres --step 0 --format binary
114+
./mfc.sh viz case_dir/ --var pres --step 0 --format silo
115+
```
116+
117+
> [!NOTE]
118+
> Reading Silo-HDF5 files requires the `h5py` Python package.
119+
> If it is not installed, you will see a clear error message with installation instructions.
120+
> Alternatively, use `format=2` (binary) in your case file to produce binary output, which has no extra dependencies.
121+
122+
### Complete option reference
123+
124+
Run `./mfc.sh viz -h` for a full list of options.
125+
126+
---
127+
128+
## Visualizing with ParaView
129+
130+
ParaView is an open-source interactive parallel visualization and graphical analysis tool for viewing scientific data.
131+
Post-processed data in Silo-HDF5 format (`format=1`) can be opened directly in ParaView.
12132
Paraview 5.11.0 has been confirmed to work with the MFC databases for some parallel environments.
13133
Nevertheless, the installation and configuration of Paraview can be environment-dependent and are left to the user.
14134

0 commit comments

Comments
 (0)