|
2 | 2 |
|
3 | 3 | # Flow visualization |
4 | 4 |
|
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. |
8 | 7 |
|
9 | | -### Visualizing with Paraview |
| 8 | +--- |
10 | 9 |
|
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 images and videos directly from post-processed output — no external GUI tools needed. |
| 13 | + |
| 14 | +### Basic usage |
| 15 | + |
| 16 | +```bash |
| 17 | +# Launch the terminal UI (default mode) |
| 18 | +./mfc.sh viz case_dir/ |
| 19 | + |
| 20 | +# Launch with a specific variable pre-selected |
| 21 | +./mfc.sh viz case_dir/ --var pres |
| 22 | +``` |
| 23 | + |
| 24 | +The command auto-detects the output format (binary or Silo-HDF5) and dimensionality (1D, 2D, or 3D). |
| 25 | +By default it launches an interactive terminal UI that works over SSH. |
| 26 | +Use `--interactive` for a browser-based UI (supports 3D), `--png` to save images, or `--mp4` for video. |
| 27 | + |
| 28 | +### Exploring available data |
| 29 | + |
| 30 | +Before plotting, you can inspect what data is available: |
| 31 | + |
| 32 | +```bash |
| 33 | +# List all available timesteps |
| 34 | +./mfc.sh viz case_dir/ --list-steps |
| 35 | + |
| 36 | +# List all available variables at a given timestep |
| 37 | +./mfc.sh viz case_dir/ --list-vars --step 0 |
| 38 | +``` |
| 39 | + |
| 40 | +### Timestep selection |
| 41 | + |
| 42 | +The `--step` argument accepts several formats: |
| 43 | + |
| 44 | +| Format | Example | Description | |
| 45 | +|--------|---------|-------------| |
| 46 | +| Single | `--step 1000` | One timestep | |
| 47 | +| Range | `--step 0:10000:500` | Start:end:stride (inclusive) | |
| 48 | +| Last | `--step last` | Most recent available timestep | |
| 49 | +| All | `--step all` | Every available timestep | |
| 50 | + |
| 51 | +### Rendering options |
| 52 | + |
| 53 | +Customize the appearance of plots: |
| 54 | + |
| 55 | +```bash |
| 56 | +# Custom colormap and color range |
| 57 | +./mfc.sh viz case_dir/ --var rho --step 1000 --png --cmap RdBu --vmin 0.5 --vmax 2.0 |
| 58 | + |
| 59 | +# Higher resolution |
| 60 | +./mfc.sh viz case_dir/ --var pres --step 500 --png --dpi 300 |
| 61 | + |
| 62 | +# Logarithmic color scale |
| 63 | +./mfc.sh viz case_dir/ --var pres --step 1000 --png --log-scale |
| 64 | +``` |
| 65 | + |
| 66 | +| Option | Description | Default | |
| 67 | +|--------|-------------|---------| |
| 68 | +| `--cmap` | Matplotlib colormap name | `viridis` | |
| 69 | +| `--vmin` | Minimum color scale value | auto | |
| 70 | +| `--vmax` | Maximum color scale value | auto | |
| 71 | +| `--dpi` | Image resolution (dots per inch) | 150 | |
| 72 | +| `--log-scale` | Use logarithmic color scale | off | |
| 73 | +| `--output` | Output directory for images | `case_dir/viz/` | |
| 74 | + |
| 75 | +### 3D slicing |
| 76 | + |
| 77 | +For 3D simulations, `viz` extracts a 2D slice for plotting. |
| 78 | +By default, it slices at the midplane along the z-axis. |
| 79 | + |
| 80 | +> [!NOTE] |
| 81 | +> To limit memory use, 3D batch rendering is capped at 500 timesteps and |
| 82 | +> `--interactive` mode at 50. Use `--step start:end:stride` to stay within |
| 83 | +> these limits when processing many steps. |
| 84 | +
|
| 85 | +```bash |
| 86 | +# Default z-midplane slice |
| 87 | +./mfc.sh viz case_dir/ --var pres --step 500 --png |
| 88 | + |
| 89 | +# Slice along the x-axis at x=0.25 |
| 90 | +./mfc.sh viz case_dir/ --var pres --step 500 --png --slice-axis x --slice-value 0.25 |
| 91 | + |
| 92 | +# Slice by array index |
| 93 | +./mfc.sh viz case_dir/ --var pres --step 500 --png --slice-axis y --slice-index 50 |
| 94 | +``` |
| 95 | + |
| 96 | +### Video generation |
| 97 | + |
| 98 | +Generate MP4 videos from a range of timesteps: |
| 99 | + |
| 100 | +```bash |
| 101 | +# Basic video (10 fps) |
| 102 | +./mfc.sh viz case_dir/ --var pres --step 0:10000:100 --mp4 |
| 103 | + |
| 104 | +# Custom frame rate |
| 105 | +./mfc.sh viz case_dir/ --var rho --step all --mp4 --fps 24 |
| 106 | + |
| 107 | +# Video with fixed color range |
| 108 | +./mfc.sh viz case_dir/ --var rho --step 0:5000:50 --mp4 --vmin 0.1 --vmax 1.0 |
| 109 | +``` |
| 110 | + |
| 111 | +Videos are saved as `case_dir/viz/<varname>.mp4`. |
| 112 | +The color range is automatically computed from the first, middle, and last frames unless `--vmin`/`--vmax` are specified. |
| 113 | + |
| 114 | +### Tiled 1D rendering |
| 115 | + |
| 116 | +For 1D cases, omitting `--var` (or passing `--var all`) renders all variables in a single tiled figure: |
| 117 | + |
| 118 | +```bash |
| 119 | +# Tiled plot of all variables at the last timestep |
| 120 | +./mfc.sh viz case_dir/ --step last --png |
| 121 | + |
| 122 | +# Equivalent explicit form |
| 123 | +./mfc.sh viz case_dir/ --var all --step last --png |
| 124 | +``` |
| 125 | + |
| 126 | +Each variable gets its own subplot with automatic LaTeX-style axis labels. |
| 127 | +Tiled mode is available for 1D and 2D data. For 3D data, omitting `--var` auto-selects the first variable. |
| 128 | + |
| 129 | +### Interactive mode |
| 130 | + |
| 131 | +Launch a browser-based interactive viewer with `--interactive`: |
| 132 | + |
| 133 | +```bash |
| 134 | +./mfc.sh viz case_dir/ --interactive |
| 135 | + |
| 136 | +# Custom port |
| 137 | +./mfc.sh viz case_dir/ --interactive --port 9000 |
| 138 | +``` |
| 139 | + |
| 140 | +The interactive viewer provides a Dash web UI with: |
| 141 | +- Variable and timestep selection |
| 142 | +- Live plot updates |
| 143 | +- Pan, zoom, and hover inspection |
| 144 | + |
| 145 | +> [!NOTE] |
| 146 | +> Interactive mode requires the `dash` Python package. |
| 147 | +
|
| 148 | +### Terminal UI (TUI) |
| 149 | + |
| 150 | +The default mode launches a live terminal UI that works over SSH with no browser or port-forwarding needed: |
| 151 | + |
| 152 | +```bash |
| 153 | +./mfc.sh viz case_dir/ |
| 154 | + |
| 155 | +# Start with a specific variable pre-selected |
| 156 | +./mfc.sh viz case_dir/ --var pres |
| 157 | +``` |
| 158 | + |
| 159 | +The TUI loads all timesteps and renders plots directly in the terminal using Unicode block characters. |
| 160 | +It supports 1D and 2D data only (use `--interactive` for 3D). |
| 161 | + |
| 162 | +**Keyboard shortcuts:** |
| 163 | + |
| 164 | +| Key | Action | |
| 165 | +|-----|--------| |
| 166 | +| `.` / `→` | Next timestep | |
| 167 | +| `,` / `←` | Previous timestep | |
| 168 | +| `Space` | Toggle autoplay | |
| 169 | +| `l` | Toggle logarithmic scale | |
| 170 | +| `f` | Freeze / unfreeze color range | |
| 171 | +| `↑` / `↓` | Select variable (in sidebar) | |
| 172 | +| `c` | Cycle colormap | |
| 173 | +| `q` | Quit | |
| 174 | + |
| 175 | +### Plot styling |
| 176 | + |
| 177 | +Axis labels use LaTeX-style math notation — for example, `pres` is labeled as \f$p\f$, `vel1` as \f$u\f$, and `alpha1` as \f$\alpha_1\f$. |
| 178 | +Plots use serif fonts and the Computer Modern math font for consistency with publication figures. |
| 179 | + |
| 180 | +### Format selection |
| 181 | + |
| 182 | +The output format is auto-detected from the case directory. |
| 183 | +To override: |
| 184 | + |
| 185 | +```bash |
| 186 | +./mfc.sh viz case_dir/ --var pres --step 0 --format binary |
| 187 | +./mfc.sh viz case_dir/ --var pres --step 0 --format silo |
| 188 | +``` |
| 189 | + |
| 190 | +> [!NOTE] |
| 191 | +> Reading Silo-HDF5 files requires the `h5py` Python package. |
| 192 | +> If it is not installed, you will see a clear error message with installation instructions. |
| 193 | +> Alternatively, use `format=2` (binary) in your case file to produce binary output, which has no extra dependencies. |
| 194 | +
|
| 195 | +### Complete option reference |
| 196 | + |
| 197 | +Run `./mfc.sh viz -h` for a full list of options. |
| 198 | + |
| 199 | +--- |
| 200 | + |
| 201 | +## Visualizing with ParaView |
| 202 | + |
| 203 | +ParaView is an open-source interactive parallel visualization and graphical analysis tool for viewing scientific data. |
| 204 | +Post-processed data in Silo-HDF5 format (`format=1`) can be opened directly in ParaView. |
12 | 205 | Paraview 5.11.0 has been confirmed to work with the MFC databases for some parallel environments. |
13 | 206 | Nevertheless, the installation and configuration of Paraview can be environment-dependent and are left to the user. |
14 | 207 |
|
|
0 commit comments