Skip to content

Commit 1e28b9c

Browse files
committed
added fvm
1 parent 4fc7924 commit 1e28b9c

File tree

13 files changed

+3919
-865
lines changed

13 files changed

+3919
-865
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Data generation instructions are available in the [SFNO folder](./fno).
4242
## Examples
4343
- Demos of different simulation setups:
4444
- [2D simulation with a pseudo-spectral solver](./examples/Kolmogrov2d_rk4_cn_forced_turbulence.ipynb)
45+
- [2D simulation with a finite volume solver](./examples/Kolmogrov2d_rk4_fvm_forced_turbulence.ipynb)
4546
- Demos of Spatiotemporal FNO's training and evaluation using the neural operator-assisted fluid simulation pipelines
4647
- [Training of SFNO for only 15 epochs for the isotropic turbulence example](./examples/ex2_SFNO_train.ipynb)
4748
- [Training of SFNO for only ***10*** epochs with 1k samples and reach `1e-2` level of relative error](./examples/ex2_SFNO_train_fnodata.ipynb) using the data in the FNO paper, which to our best knowledge no operator learner can do this in <100 epochs in the small data regime.
@@ -56,6 +57,7 @@ The Apache 2.0 License in the root folder applies to the `torch-cfd` folder of t
5657
## Contributions
5758
PR welcome. Currently, the port of `torch-cfd` currently includes:
5859
- The pseudospectral method for vorticity uses anti-aliasing filtering techniques for nonlinear terms to maintain stability.
60+
- The finite volume method on a MAC grid for velocity, and using the projection scheme to impose the divergence free condition.
5961
- Temporal discretization: Currently only RK4 temporal discretization uses explicit time-stepping for advection and either implicit or explicit time-stepping for diffusion.
6062
- Boundary conditions: only periodic boundary conditions.
6163

examples/Kolmogrov2d_rk4_fvm_forced_turbulence.ipynb

Lines changed: 222 additions & 0 deletions
Large diffs are not rendered by default.

torch_cfd/README.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
## TODO
22

3-
- [ ] add native PyTorch implementation for applying `torch.linalg` and `torch.fft` function directly on `GridArray`.
3+
- [x] add native PyTorch implementation for applying `torch.linalg` and `torch.fft` function directly on `GridArray`.
44
- [x] add discrete Helmholtz decomposition in both spatial and spectral domains.
55
- [x] adjust the function to act on `(batch, time, *spatial)` tensor, currently only `(*spatial)` is supported.
66
- [x] add native vorticity computation, instead of taking FDM for pseudo-spectral.
77

88
## Changelog
99

1010
### 0.1.0
11-
- Added a native PyTorch implementation of `scipy.linalg.circulant`: for a 1d array `column`
12-
```python
13-
# scipy version
14-
mat = scipy.linalg.circulant(column)
15-
16-
# torch version
17-
idx = (n - torch.arange(n)[None].T + torch.arange(n)[None]) % n
18-
mat = torch.gather(column[None, ...].expand(n, -1), 1, idx)
19-
```
11+
- Implemented the FVM method on a staggered MAC grid (pressure on cell centers).
12+
- Added native PyTorch implementation for applying `torch.linalg` and `torch.fft` functions directly on `GridArray` and `GridVariable`.
13+
- Added native implementation of arithmetic manipulation directly on `GridVariableVector`.
14+
- Added several helper functions `consistent_grid` to replace `consistent_grid_arrays`.
15+
- Removed dependence of `from torch.utils._pytree import register_pytree_node`
16+
- Minor notes:
17+
- Added native PyTorch dense implementation of `scipy.linalg.circulant`: for a 1d array `column`
18+
```python
19+
# scipy version
20+
mat = scipy.linalg.circulant(column)
21+
22+
# torch version
23+
idx = (n - torch.arange(n)[None].T + torch.arange(n)[None]) % n
24+
mat = torch.gather(column[None, ...].expand(n, -1), 1, idx)
25+
```
2026

2127

2228
### 0.0.8

0 commit comments

Comments
 (0)