76 lines
1.4 KiB
Markdown
76 lines
1.4 KiB
Markdown
# Lab 3: Stencil-Based Grid Subdivision
|
|
|
|
Author: Zhe Yuan
|
|
|
|
## How to Build
|
|
|
|
### Windows
|
|
|
|
Use Visual Studio (Developer Command Prompt) to compile the code.
|
|
|
|
```bat
|
|
.\make.bat
|
|
```
|
|
|
|
> **Note:** `cl` is only available in the Developer Command Prompt, change the path of `VsDevCmd.bat` in `make.bat` first.
|
|
|
|
### Linux / macOS — GCC via Makefile
|
|
|
|
```
|
|
make
|
|
```
|
|
|
|
This compiles all targets including `subdivide_grid`.
|
|
|
|
## How to Run
|
|
|
|
### Windows
|
|
|
|
```bat
|
|
subdivide_grid.exe {num_iter} {input_file}
|
|
```
|
|
|
|
### Linux / macOS
|
|
|
|
```bash
|
|
./subdivide_grid {num_iter} {input_file}
|
|
```
|
|
|
|
- `{num_iter}`: integer number of subdivision iterations (>= 0)
|
|
- `{input_file}`: a `.grid2D` file
|
|
|
|
The output file is written to the same directory as the input, with the suffix
|
|
`-subdiv.grid2D` appended (replacing the `.grid2D` extension).
|
|
|
|
### Optional `-off` flag
|
|
|
|
```bash
|
|
./subdivide_grid -off {num_iter} {input_file}
|
|
```
|
|
|
|
With `-off`, the program additionally writes a Geomview `.off` file named
|
|
`{basename}-subdiv.off`.
|
|
|
|
### Examples
|
|
|
|
```bash
|
|
./subdivide_grid 1 "Lab3 simple grids/grid2D-2x3-A.grid2D"
|
|
./subdivide_grid 3 "Lab3 grids/wave-A.grid2D"
|
|
./subdivide_grid -off 3 "Lab3 grids/sphere-A.grid2D"
|
|
```
|
|
|
|
## Visualization
|
|
|
|
Convert a `.grid2D` file to Geomview `.off` format:
|
|
|
|
```bash
|
|
./grid2off {input.grid2D}
|
|
```
|
|
|
|
## AI Tools Used
|
|
|
|
**GitHub Copilot** (via VS Code) was used for:
|
|
|
|
- Auto generating `Makefile` and this `README.md`.
|
|
- Auto completing during writing code.
|