Skip to content

Commit 9da51cd

Browse files
committed
update a lid-driven cavity example
1 parent 5a7c9df commit 9da51cd

File tree

6 files changed

+320
-14
lines changed

6 files changed

+320
-14
lines changed

examples/Kolmogrov2d_rk4_fvm_forced_turbulence.ipynb

Lines changed: 16 additions & 6 deletions
Large diffs are not rendered by default.

examples/Kolmogrov2d_rk4_spectral_forced_turbulence.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 2,
5+
"execution_count": null,
66
"metadata": {},
77
"outputs": [],
88
"source": [
99
"import torch\n",
1010
"import torch.fft as fft\n",
1111
"\n",
1212
"from torch_cfd.grids import Grid\n",
13-
"from torch_cfd.initial_conditions import vorticity_field\n",
13+
"from torch_cfd.initial_conditions import filtered_vorticity_field\n",
1414
"from torch_cfd.forcings import KolmogorovForcing\n",
1515
"from torch_cfd.spectral import *\n",
1616
"from torch_cfd.equations import *\n",
@@ -26,7 +26,7 @@
2626
},
2727
{
2828
"cell_type": "code",
29-
"execution_count": 4,
29+
"execution_count": null,
3030
"metadata": {},
3131
"outputs": [],
3232
"source": [
@@ -53,7 +53,7 @@
5353
"\n",
5454
"grid = Grid(shape=(n, n), domain=((0, diam), (0, diam)), device=device)\n",
5555
"\n",
56-
"vort_init = vorticity_field(grid, peak_wavenumber, random_state=random_state, batch_size=batch_size).data\n",
56+
"vort_init = filtered_vorticity_field(grid, peak_wavenumber, random_state=random_state, batch_size=batch_size).data\n",
5757
"vort_hat = fft.rfft2(vort_init).to(device)\n",
5858
"\n",
5959
"\n",

examples/Lid-driven_cavity_rk4_fvm.ipynb

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

fno/data_gen/data_gen_Kolmogorov2d.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import torch
1313
import torch.fft as fft
14+
import torch.nn.functional as F
1415
from torch_cfd.finite_differences import curl_2d
1516
from torch_cfd.forcings import KolmogorovForcing
1617

fno/data_gen/data_gen_McWilliams2d.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111

1212
import torch
1313
import torch.fft as fft
14+
import torch.nn.functional as F
1415

1516
from torch_cfd.grids import Grid
16-
from torch_cfd.initial_conditions import vorticity_field
17+
from torch_cfd.initial_conditions import filtered_vorticity_field
1718
from torch_cfd.equations import *
1819

1920
from solvers import get_trajectory_imex
@@ -131,7 +132,7 @@ def main(args):
131132

132133
vort_init = torch.stack(
133134
[
134-
vorticity_field(
135+
filtered_vorticity_field(
135136
grid, peak_wavenumber, random_state=random_state + idx + k
136137
).data
137138
for k in range(batch_size)

torch_cfd/grids.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -933,9 +933,9 @@ def data(self, values: Tuple[torch.Tensor, ...]):
933933
v.data = value
934934

935935
@property
936-
def array(self) -> Tuple[GridVariable, ...]:
936+
def array(self) -> GridVariableVector:
937937
"""Returns a tuple of GridVariables without boundary conditions."""
938-
return tuple(v.array for v in self)
938+
return GridVariableVector(tuple(v.array for v in self))
939939

940940
@array.setter
941941
def array(self, values: Tuple[GridVariable, ...]):

0 commit comments

Comments
 (0)