Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kernel formulation #43

Merged
merged 393 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
393 commits
Select commit Hold shift + click to select a range
140ba47
fix: wrong name
agdestein Nov 25, 2023
7b7e69a
Add projection option
agdestein Nov 25, 2023
c0ca54b
Update processors
agdestein Nov 25, 2023
87a8fc5
Add smoother in energy spectrum
agdestein Nov 25, 2023
90a9da5
Add Laplace matrix
agdestein Nov 25, 2023
0d4b636
Format files
agdestein Nov 25, 2023
e2261be
Update files
agdestein Nov 26, 2023
2b5df9a
Fix docs
agdestein Nov 26, 2023
2fd779a
Add bound
agdestein Nov 26, 2023
9cb4853
fix: typo
agdestein Nov 26, 2023
9c31c13
Add bounds
agdestein Nov 26, 2023
1cf9c44
fix broadcast
agdestein Nov 26, 2023
c7db791
Fix broadcast
agdestein Nov 26, 2023
5bbbeb8
Put loops inside kernels
agdestein Nov 27, 2023
b26a606
Rename kernels
agdestein Nov 27, 2023
dd594e1
Siplify zeros
agdestein Nov 27, 2023
1ce8839
Remove sqrt from kinetic energy
agdestein Nov 27, 2023
2201e4f
Project by default
agdestein Nov 27, 2023
27a22e2
Rename function
agdestein Nov 27, 2023
80752cb
Rename files
agdestein Nov 27, 2023
c7cf262
Rename function
agdestein Nov 27, 2023
17d2e27
Update files
agdestein Nov 27, 2023
7f328bf
Make manual solver default
agdestein Nov 27, 2023
4f5db30
Add operator
agdestein Nov 27, 2023
513b548
Fix tests
agdestein Nov 27, 2023
e67faaf
Format files
agdestein Nov 27, 2023
6b995ab
Remove wrong name
agdestein Nov 27, 2023
a2d3d07
Merge loops
agdestein Nov 27, 2023
5a92fa9
Fix allocation
agdestein Nov 28, 2023
2e989c1
Update force
agdestein Nov 28, 2023
c07cb7f
Update syntax
agdestein Nov 28, 2023
1e11285
Add workgroupsize to setup
agdestein Nov 28, 2023
90c4055
Factorize functions
agdestein Nov 29, 2023
edf648f
Fix typo
agdestein Nov 29, 2023
21268aa
docs: Add docstrings
agdestein Nov 29, 2023
b8d5174
Do not assume 0
agdestein Nov 29, 2023
a42f6b5
Fix interpolation
agdestein Dec 1, 2023
e707a1a
Fix BC in matrix
agdestein Dec 1, 2023
7dd6b47
Use multithreading for CI
agdestein Dec 1, 2023
e16b2a5
Put examples back
agdestein Dec 1, 2023
593f5ca
Fix: Wrong cell separators
agdestein Dec 1, 2023
312ba17
Skip save steps
agdestein Dec 2, 2023
8ea03af
Correct size info
agdestein Dec 2, 2023
7643be3
Add missing RNG
agdestein Dec 2, 2023
2c46a41
Update format
agdestein Dec 2, 2023
45d7bdd
Add plot for individual components
agdestein Dec 2, 2023
d3cc3e5
Create dataloader
agdestein Dec 3, 2023
7331833
Rename
agdestein Dec 3, 2023
ef91710
Add Smagorinsky model
agdestein Dec 4, 2023
08fbc47
Add multigrid training
agdestein Dec 4, 2023
88316bc
Add fixed length solver loop
agdestein Dec 4, 2023
a04205a
Add multigrid experiments
agdestein Dec 4, 2023
a729855
fix: Missing reference
agdestein Dec 5, 2023
e282113
Add plot
agdestein Dec 5, 2023
9212199
Merge branch 'main' into kernel
agdestein Dec 6, 2023
bb72225
Update forcing
agdestein Dec 11, 2023
c83e204
Make sure to preserve "unified memory" trait
agdestein Dec 11, 2023
c27ba65
Add rng
agdestein Dec 12, 2023
91dc185
Update spectra
agdestein Dec 12, 2023
d326336
Update files
agdestein Dec 12, 2023
67ab42f
Rename function
agdestein Dec 13, 2023
343e769
Add toggle option
agdestein Dec 13, 2023
b126366
Fix wrong variable
agdestein Dec 13, 2023
7ba29e2
Add kinetic energy
agdestein Dec 13, 2023
7674d33
docs: Add docstrings
agdestein Dec 13, 2023
e5fe5c7
Siplify expression
agdestein Dec 13, 2023
bfe98c8
Fill DOFs only in divergence
agdestein Dec 13, 2023
83450d8
Remove unused args
agdestein Dec 13, 2023
54cadc7
Add log to plots
agdestein Dec 13, 2023
78062a4
Add adjoint prototype
agdestein Dec 13, 2023
ed335bc
Add methods
agdestein Dec 14, 2023
0ccd83c
Add adjoints
agdestein Dec 15, 2023
3b66c65
Add projector
agdestein Dec 15, 2023
3eee0ab
Add missing import
agdestein Dec 15, 2023
b4a6c46
Add differentiable stepper
agdestein Dec 15, 2023
44bfd0d
Remove debugger
agdestein Dec 15, 2023
f3d1a4f
Minor changes
agdestein Dec 15, 2023
8bb30bb
Update pullbacks
agdestein Dec 18, 2023
a8a91f4
Enforce tuple
agdestein Dec 18, 2023
85ae27c
Add trajectory loss
agdestein Dec 19, 2023
0db88cd
Merge branch 'main' into kernel
agdestein Dec 19, 2023
919a770
Rename solver
agdestein Dec 20, 2023
f3e235a
Hide pressure
agdestein Dec 20, 2023
00c78da
Add missing function
agdestein Dec 20, 2023
2e5a47f
Minor changes
agdestein Dec 20, 2023
6b04f1d
Minor fixes
agdestein Dec 20, 2023
f1d8151
Add missing BC
agdestein Dec 20, 2023
7665b11
Add different setup
agdestein Dec 21, 2023
0e11e84
Some fixes
agdestein Dec 22, 2023
b1a89f7
Add some sketches
agdestein Dec 22, 2023
8e61bcc
Add volume averaging filter
agdestein Jan 9, 2024
d37206f
fix: Volume average
agdestein Jan 16, 2024
025ff5e
Add script
agdestein Jan 16, 2024
90ae4ac
Create filter structs
agdestein Jan 18, 2024
da341d4
Update script
agdestein Jan 18, 2024
0ecedd8
Update script
agdestein Jan 19, 2024
eec3781
Update IC expression
agdestein Jan 20, 2024
083dcbc
fix: image plot type
agdestein Jan 20, 2024
947ca11
Update spectra
agdestein Jan 22, 2024
cd19ad8
Update script
agdestein Jan 22, 2024
f74cb29
Add reference
agdestein Jan 22, 2024
15ea58d
Add different LES models
agdestein Jan 24, 2024
832eb13
Update spectral plot
agdestein Jan 25, 2024
5ceb387
Add dyadic binning
agdestein Jan 25, 2024
25f0aba
Update plot
agdestein Jan 28, 2024
501a327
Update and rename loss/error
agdestein Jan 28, 2024
cd6efc6
Add missing kwargs
agdestein Jan 28, 2024
c3982a9
Update scripts
agdestein Jan 28, 2024
346ec8b
fix: Add missing zero in BC pullback and do chain
agdestein Jan 28, 2024
1e00222
Update files
agdestein Jan 29, 2024
1750abf
fix: Possible bug in IC
agdestein Jan 30, 2024
6928420
Merge branch 'main' into kernel
agdestein Feb 5, 2024
248dce6
Update files
agdestein Feb 8, 2024
d3c743e
Add linear stuff
agdestein Feb 22, 2024
3c6dfa8
Update script
agdestein Feb 22, 2024
8c1b4ab
Update script
agdestein Feb 22, 2024
6963f1f
Format
agdestein Feb 23, 2024
5594960
Rename scripts
agdestein Feb 23, 2024
680a635
Add low memory Poisson solver
agdestein Feb 23, 2024
5fd38c3
Add prior errors
agdestein Feb 29, 2024
e9b8857
Fix typos
agdestein Feb 29, 2024
f7eda50
Up
agdestein Mar 7, 2024
091dc08
Up
Mar 18, 2024
39d104f
Add energy
agdestein Mar 18, 2024
21d43f9
Fix energy
agdestein Mar 18, 2024
aecb1d2
Update paths
agdestein Mar 20, 2024
5412a8e
Up
agdestein Mar 21, 2024
ee68ce7
Update script
agdestein Mar 25, 2024
b279950
Add script
agdestein Mar 29, 2024
502d566
Up
agdestein Mar 29, 2024
c1de80b
Add CUDA pressure solver
agdestein Apr 3, 2024
d672d11
Add low memory spectrum generator
agdestein Apr 3, 2024
d1fc5fa
Add test case
agdestein Apr 3, 2024
ee54904
Merge branch 'main' into kernel
agdestein Apr 3, 2024
d069fe9
Fix bound
agdestein Apr 4, 2024
53a5da4
Add reconstructor
agdestein Apr 4, 2024
ca5e355
Up
agdestein Apr 5, 2024
f9acf4d
Add tensor basis
agdestein Apr 15, 2024
5164efd
Add functions
agdestein Apr 17, 2024
df42e7e
Old updates
agdestein Apr 19, 2024
3c3725e
Split out neural stuff in a sub-package
agdestein Apr 19, 2024
dbe8458
Add README
agdestein Apr 19, 2024
eb670c6
Update project files
agdestein Apr 19, 2024
56188f4
Remove trailing package
agdestein Apr 19, 2024
f8fc824
Put paper scripts in subfolder
agdestein Apr 19, 2024
ce962c3
Add sub-tests
agdestein Apr 19, 2024
2f7e81e
Add project file
agdestein Apr 19, 2024
a0a1980
Remove LSP trick
agdestein Apr 19, 2024
d6514e2
Update docs environment
agdestein Apr 19, 2024
062ec9a
chore: Format files
agdestein Apr 19, 2024
0f3578f
Add README
agdestein Apr 19, 2024
127eabe
Add missing package
agdestein Apr 19, 2024
ce69650
Fix script
agdestein Apr 19, 2024
fbdd8ad
Add missing rng
agdestein Apr 19, 2024
e971cfd
Clean up script
agdestein Apr 19, 2024
3d11e24
Fix docs
agdestein Apr 20, 2024
e460d57
Fix make
agdestein Apr 20, 2024
5f66af2
Up
agdestein Apr 20, 2024
026b76b
Fix make
agdestein Apr 20, 2024
83302cc
Fix make
agdestein Apr 20, 2024
e3aa518
Up
agdestein Apr 20, 2024
5d4bcfa
Fix make
agdestein Apr 20, 2024
7c8822e
Fix make
agdestein Apr 21, 2024
049ac3a
Fix examples
agdestein Apr 21, 2024
04c48ff
chore: Format files
agdestein Apr 21, 2024
badd0eb
Add 2D invariants
agdestein Apr 22, 2024
8f4e919
Add missing conditios
agdestein Apr 22, 2024
6a26d73
Bump version
agdestein Apr 22, 2024
f4d29e5
Update basis
agdestein Apr 22, 2024
e300aad
Add script
agdestein Apr 22, 2024
e2b6602
Move weird integrator to paper only
agdestein Apr 25, 2024
30b2bba
Fix naming conflict
agdestein Apr 25, 2024
07779a8
chore: Format
agdestein Apr 25, 2024
2c42dbb
refactor(PaperDC): Split into file
agdestein Apr 25, 2024
08d41f5
Move subprojects
agdestein Apr 25, 2024
dc8f4f9
Update READMEs
agdestein Apr 25, 2024
4f07f1d
Update gitignore
agdestein Apr 25, 2024
1ef6969
Update READMEs
agdestein Apr 25, 2024
800eddc
Fix tests
agdestein Apr 25, 2024
379ba6d
chore: Format
agdestein Apr 25, 2024
3ee9d9b
Rename variable
agdestein Apr 25, 2024
c6b55e1
Fix dimension in definite case
agdestein Apr 25, 2024
9f1482d
fix(NeuralClosure): Missing dependencies
agdestein Apr 25, 2024
64979ac
feat(PaperDC): Clean up script
agdestein Apr 25, 2024
ebc27a1
feat(PaperDC): Structure RNGs transparently
agdestein Apr 25, 2024
fea03e9
Fix typo
agdestein Apr 25, 2024
c0cb20f
chore: Format
agdestein Apr 25, 2024
c049672
Update old code
agdestein Apr 29, 2024
e30a0bc
Force zero average
agdestein Apr 29, 2024
e61d33d
Minor change
agdestein Apr 29, 2024
063bd0f
docs(PaperDC): Add title
agdestein Apr 29, 2024
eada869
Add old changes
agdestein Apr 29, 2024
6fabace
docs(PaperDC): Remove statement
agdestein Apr 29, 2024
28dc31e
clean(PaperDC): Remove duplicate names
agdestein Apr 29, 2024
16197cc
docs(NeuralClosure): Update README
agdestein Apr 29, 2024
94c97e8
Fix averaging weights in non-uniform case
agdestein May 2, 2024
d911d04
Fill with zero
agdestein May 2, 2024
9684ef6
Update test
agdestein May 3, 2024
0cfc799
Move functions
agdestein May 3, 2024
e19f8ba
Do not assemble unused fields
agdestein May 3, 2024
d5ac8fa
Add operator tests
agdestein May 3, 2024
dce6ea7
Add rule test outline
agdestein May 3, 2024
f3c64e4
Remove unused code
agdestein May 3, 2024
246c91d
Put RK methods in module
agdestein May 3, 2024
54757c9
Fix setup
agdestein May 3, 2024
547b61e
Fix tests
agdestein May 3, 2024
bbd86f0
Fix dependency
agdestein May 3, 2024
00509d1
chore: Format files
agdestein May 3, 2024
a34e2ee
Update format options
agdestein May 3, 2024
ef8e758
Add 3D tests
agdestein May 3, 2024
303ccc4
Add and fix chain rule tests
agdestein May 3, 2024
197517c
Remove undefined rule
agdestein May 3, 2024
2516dee
chore: Format
agdestein May 3, 2024
b08fd11
Rename symbols
agdestein May 3, 2024
6f08a37
Add load path
agdestein May 3, 2024
0a8494d
Rename symbol
agdestein May 4, 2024
e4fc097
Add rrule tests
agdestein May 4, 2024
e8c4dd6
Add rrule test for Poisson
agdestein May 4, 2024
d7761dc
Add comment
agdestein May 4, 2024
08a7837
Move filters to NeuralClosure
agdestein May 4, 2024
be3d713
Update README
agdestein May 4, 2024
4a110bd
Add missing dependency
agdestein May 4, 2024
a91fa29
docs: Fix reference
agdestein May 4, 2024
13ce4e4
Add tests
agdestein May 5, 2024
4d91755
Simplify docs environment
agdestein May 5, 2024
a5bc363
Move files
agdestein May 5, 2024
d794ca7
Put CUDA specific solver in extension
agdestein May 5, 2024
ecf5776
refactor: Simplify psolvers
agdestein May 5, 2024
5b5b80a
docs: Remove old line
agdestein May 5, 2024
9a3fe13
Add missing file
agdestein May 5, 2024
1a4d6e2
Add missing extension
agdestein May 5, 2024
02cb6c6
Rename file
agdestein May 5, 2024
f9da7cf
Add default psolver
agdestein May 5, 2024
5321608
Minor fixes
agdestein May 5, 2024
0a8ee43
Merge files
agdestein May 5, 2024
426357a
Merge files
agdestein May 5, 2024
d5d930e
Add info
agdestein May 5, 2024
195b6e0
Add temperature equation
agdestein May 6, 2024
dea771c
Update README.md
agdestein May 6, 2024
e5f305a
Add some missing temps
agdestein May 6, 2024
1169234
Merge branch 'kernel' of github.com:agdestein/IncompressibleNavierSto…
agdestein May 6, 2024
0fcc1fa
docs: Document temperature
agdestein May 6, 2024
42290e4
Add doc script
agdestein May 6, 2024
ce4fb37
docs: Minor changes
agdestein May 6, 2024
350b4d5
Fix: Update signatures
agdestein May 6, 2024
a3664ce
Minor fixes
agdestein May 6, 2024
2907b3c
fix(docs): dois
agdestein May 6, 2024
0dab32f
Fix signatures
agdestein May 6, 2024
80654d5
Update docs
agdestein May 6, 2024
38f627f
Fix test
agdestein May 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .JuliaFormatter.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
whitespace_in_kwargs = true
remove_extra_newlines = true
trailing_comma = true
separate_kwargs_with_semicolon = true
long_to_short_function_def = true
5 changes: 4 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- main
tags: ['*']
pull_request:
workflow_dispatch:

concurrency:
# Skip intermediate builds: always.
Expand Down Expand Up @@ -51,10 +52,12 @@ jobs:
version: '1'
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-docdeploy@v1
with:
install-package: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: |
julia --project=docs -e '
julia --project=docs -t auto -e '
using Documenter: DocMeta, doctest
using IncompressibleNavierStokes
DocMeta.setdocmeta!(
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/FormatCheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- "main"
pull_request:
workflow_dispatch:

jobs:
build:
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/SpellCheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Spell Check

on: [pull_request]

jobs:
typos-check:
name: Spell Check with Typos
runs-on: ubuntu-latest
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v4
- name: Check spelling
uses: crate-ci/typos@master
17 changes: 16 additions & 1 deletion .github/workflows/TagBot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,22 @@ on:
types:
- created
workflow_dispatch:

inputs:
lookback:
default: 3
permissions:
actions: read
checks: read
contents: write
deployments: read
issues: read
discussions: read
packages: read
pages: read
pull-requests: read
repository-projects: read
security-events: read
statuses: read
jobs:
TagBot:
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
Expand Down
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
.vscode
*.jl.*.cov
*.jl.cov
*.jl.mem
*Manifest.toml
/docs/build/
/docs/src/generated/
*output/
*notebooks/
examples/test.jl
scratch/*
test.jl
toto.jl
tata.jl

# Vim swap
*.swp
Expand Down
35 changes: 28 additions & 7 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,50 @@ version = "0.4.1"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
IterativeSolvers = "42fd0dbc-a981-5370-80f2-aaf504508153"
KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
NNlib = "872c559c-99b0-510c-b3b7-b6c96a88d5cd"
Observables = "510215fc-4207-5dde-b226-833fc4488ee2"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
WriteVTK = "64499a7a-5c06-52f2-abe2-ccb03c286192"

[weakdeps]
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
CUDSS = "45b445bb-4962-46a0-9369-b4df9d0f772e"

[extensions]
IncompressibleNavierStokesCUDAExt = ["CUDA", "CUDSS"]

[compat]
Adapt = "3, 4"
CairoMakie = "0.11"
ChainRulesCore = "1"
CUDA = "5"
CUDSS = "0.2"
FFTW = "1"
GLMakie = "0.9"
IterativeSolvers = "0.9"
Makie = "0.19, 0.20"
KernelAbstractions = "0.9"
LinearAlgebra = "1"
Makie = "0.20"
NNlib = "0.9"
Observables = "0.5"
Printf = "1"
Random = "1"
SparseArrays = "1"
StaticArrays = "1"
Statistics = "1"
WriteVTK = "1"
julia = "1.7"
julia = "1.9"

[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Aqua", "CairoMakie", "Test"]
148 changes: 77 additions & 71 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,33 @@

This package implements energy-conserving solvers for the incompressible Navier-Stokes
equations on a staggered Cartesian grid. It is based on the Matlab package
[INS2D](https://github.com/bsanderse/INS2D)/[INS3D](https://github.com/bsanderse/INS3D).
[INS2D](https://github.com/bsanderse/INS2D)/[INS3D](https://github.com/bsanderse/INS3D). The simulations can be run on the single/multithreaded CPUs or Nvidia GPUs.

This package also provides experimental support for neural closure models for
large eddy simulation.

## Installation

To install IncompressibleNavierStokes, open up a Julia-REPL, type `]` to get
into Pkg-mode, and type:

```
add IncompressibleNavierStokes
```julia-repl
(v1.10) pkg> add IncompressibleNavierStokes
```

which will install the package and all dependencies to your local environment.
Note that IncompressibleNavierStokes requires Julia version `1.7` or above.
Note that IncompressibleNavierStokes requires Julia version `1.9` or above.

See the
[Documentation](https://agdestein.github.io/IncompressibleNavierStokes.jl/dev/generated/LidDrivenCavity2D/)
for examples of some typical workflows. More examples can be found in the
[`examples`](examples) directory.

## Source code for paper

See [here](./lib/PaperDC) for the source code used in the paper
[Discretize first, filter next: learning divergence-consistent closure models for large-eddy simulation](https://arxiv.org/abs/2403.18088).

## Gallery

The velocity and pressure fields may be visualized in a live session using
Expand All @@ -37,97 +44,96 @@ The velocity and pressure fields may be visualized in a live session using
snapshot files using the `save_vtk` function, or the full time series using the
`VTKWriter` processor.

| ![](assets/examples/Actuator2D.png) | ![](assets/examples/BackwardFacingStep2D.png) | ![](assets/examples/DecayingTurbulence2D.png) | ![](assets/examples/TaylorGreenVortex2D.png) |
|:---------------------------------------:|:-------------------------------------------------------------:|:------------------------------------------------------------:|:-----------------------------------------------------------:|
| ![](assets/examples/Actuator2D.png) | ![](assets/examples/BackwardFacingStep2D.png) | ![](assets/examples/DecayingTurbulence2D.png) | ![](assets/examples/TaylorGreenVortex2D.png) |
|:-:|:-:|:-:|:-:|
| [Actuator (2D)](examples/Actuator2D.jl) | [Backward Facing Step (2D)](examples/BackwardFacingStep2D.jl) | [Decaying Turbulence (2D)](examples/DecayingTurbulence2D.jl) | [Taylor-Green Vortex (2D)](examples/TaylorGreenVortex2D.jl) |
| ![](assets/examples/Actuator3D.png) | ![](assets/examples/BackwardFacingStep3D.png) | ![](assets/examples/DecayingTurbulence3D.png) | ![](assets/examples/TaylorGreenVortex3D.png) |
| ![](assets/examples/Actuator3D.png) | ![](assets/examples/BackwardFacingStep3D.png) | ![](assets/examples/DecayingTurbulence3D.png) | ![](assets/examples/TaylorGreenVortex3D.png) |
| [Actuator (3D)](examples/Actuator3D.jl) | [Backward Facing Step (3D)](examples/BackwardFacingStep3D.jl) | [Decaying Turbulence (3D)](examples/DecayingTurbulence3D.jl) | [Taylor-Green Vortex (3D)](examples/TaylorGreenVortex3D.jl) |

IncompressibleNavierStokes also supports adding a temperature equation.

https://github.com/agdestein/IncompressibleNavierStokes.jl/assets/40632532/e4894d97-d890-4d4a-a43a-8eb2772d5130

## Demo

The following example code using a negative body force on a small rectangle
The following example code using a negative body force on a small rectangle
with an unsteady inflow. It simulates a wind turbine (actuator) under varying
wind conditions.

Make sure to have the `GLMakie` and `IncompressibleNavierStokes` installed:

```julia
using Pkg
Pkg.add(["GLMakie", "IncompressibleNavierStokes"])
```

Then run run the following code to make a short animation:

```julia
using GLMakie
using IncompressibleNavierStokes

# Viscosity model
viscosity_model = LaminarModel(; Re = 100.0)

# Boundary conditions: Unsteady BC requires time derivatives
u_bc(x, y, t) = x ≈ 0.0 ? cos(π / 6 * sin(π / 6 * t)) : 0.0
v_bc(x, y, t) = x ≈ 0.0 ? sin(π / 6 * sin(π / 6 * t)) : 0.0
dudt_bc(x, y, t) = x ≈ 0.0 ? -(π / 6)^2 * cos(π / 6 * t) * sin(π / 6 * sin(π / 6 * t)) : 0.0
dvdt_bc(x, y, t) = x ≈ 0.0 ? (π / 6)^2 * cos(π / 6 * t) * cos(π / 6 * sin(π / 6 * t)) : 0.0
bc_type = (;
u = (; x = (:dirichlet, :pressure), y = (:symmetric, :symmetric)),
v = (; x = (:dirichlet, :symmetric), y = (:pressure, :pressure)),
# A 2D grid is a Cartesian product of two vectors
n = 40
x = LinRange(0.0, 10.0, 5n + 1)
y = LinRange(-2.0, 2.0, 2n + 1)

# Boundary conditions
boundary_conditions = (
# Inlet, outlet
(
# Unsteady BC requires time derivatives
DirichletBC(
(dim, x, y, t) -> sin(π / 6 * sin(π / 6 * t) + π / 2 * (dim() == 1)),
(dim, x, y, t) ->
(π / 6)^2 *
cos(π / 6 * t) *
cos(π / 6 * sin(π / 6 * t) + π / 2 * (dim() == 1)),
),
PressureBC(),
),

# Sides
(PressureBC(), PressureBC()),
)

# A 2D grid is a Cartesian product of two vectors
x = LinRange(0.0, 10.0, 200)
y = LinRange(-2.0, 2.0, 80)

# Actuator body force: A thrust coefficient `Cₜ` distributed over a thin rectangle
xc, yc = 2.0, 0.0 # Disk center
D = 1.0 # Disk diameter
δ = 0.11 # Disk thickness
Cₜ = 5e-4 # Thrust coefficient
cₜ = Cₜ / (D * δ)
inside(x, y) = abs(x - xc) ≤ δ / 2 && abs(y - yc) ≤ D / 2
bodyforce_u(x, y) = -cₜ * inside(x, y)
bodyforce_v(x, y) = 0.0
# Actuator body force: A thrust coefficient distributed over a thin rectangle
inside(x, y) = abs(x - 2.0) ≤ 0.055 && abs(y) ≤ 0.5
bodyforce(dim, x, y, t) = dim() == 1 && inside(x, y) ? -1.82 : 0.0

# Build setup and assemble operators
setup = Setup(
x,
y;
viscosity_model,
u_bc,
v_bc,
dudt_bc,
dvdt_bc,
bc_type,
bodyforce_u,
bodyforce_v,
);

# Time interval
t_start, t_end = tlims = (0.0, 40.0)
setup = Setup(x, y; Re = 100.0, boundary_conditions, bodyforce);

# Initial conditions (extend inflow)
initial_velocity_u(x, y) = 1.0
initial_velocity_v(x, y) = 0.0
initial_pressure(x, y) = 0.0
V₀, p₀ = create_initial_conditions(
setup,
initial_velocity_u,
initial_velocity_v,
t_start;
initial_pressure,
);

# Time step processors
processors = (
# Record solution every fourth time step
animator(setup, "vorticity.mp4"; nupdate = 4),

# Log time step information
step_logger(),
)
ustart = create_initial_conditions(setup, (dim, x, y) -> dim() == 1 ? 1.0 : 0.0);

# Solve unsteady Navier-Stokes equations
V, p, outputs = solve_unsteady(
setup, V₀, p₀, tlims;
method = RK44P2(),
Δt = 0.05,
processors,
solve_unsteady(;
setup, ustart, tlims = (0.0, 48.0), Δt = 0.05,
processors = (
anim = animator(; setup, path = "vorticity.mp4", nupdate = 4),
log = timelogger(),
),
)
```

The resulting animation is shown below.

https://github.com/agdestein/IncompressibleNavierStokes.jl/assets/40632532/6ee09a03-1674-46e0-843c-000f0b9b9527

## Similar projects

- [WaterLily.jl](https://github.com/weymouth/WaterLily.jl/)
Incompressible solver with immersed boundaries
- [Oceananigans.jl](https://github.com/CliMA/Oceananigans.jl):
Ocean simulations
- [ClimaCore.jl](https://github.com/CliMA/ClimaCore.jl):
Atmospheric simulations
- [Trixi.jl](https://github.com/trixi-framework/Trixi.jl):
High order solvers for various hyperbolic equations
- [Ferrite.jl](https://github.com/Ferrite-FEM/Ferrite.jl):
Finite element discretizations
- [Gridap.jl](https://github.com/gridap/Gridap.jl):
Finite element discretizations
- [FourierFlows.jl](https://github.com/FourierFlows/FourierFlows.jl):
Pseudo-spectral discretizations
6 changes: 2 additions & 4 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
[deps]
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
DocumenterCitations = "daee34ce-89f3-4625-b898-19384cb65244"
FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a"
Examples = "318dbb63-4243-420f-99f2-d56058123f9d"
IncompressibleNavierStokes = "5e318141-6589-402b-868d-77d7df8c442e"
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
NeuralClosure = "099dac27-d7f2-4047-93d5-0baee36b9c25"
9 changes: 9 additions & 0 deletions docs/liveserve.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
push!(LOAD_PATH, "@live-server")

using LiveServer

servedocs(;
foldername = @__DIR__,
literate = joinpath(@__DIR__, "..", "examples"),
skip_dir = joinpath(@__DIR__, "src", "generated"),
)
Loading
Loading