-
Notifications
You must be signed in to change notification settings - Fork 78
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
Adjusts velocity boundary conditions for accelerated flows #108
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #108 +/- ##
==========================================
+ Coverage 96.44% 96.55% +0.11%
==========================================
Files 12 12
Lines 450 465 +15
==========================================
+ Hits 434 449 +15
Misses 16 16 ☔ View full report in Codecov by Sentry. |
That's indeed required for the GPU. We cannot have a small |
This comment was marked as outdated.
This comment was marked as outdated.
Have a look here: https://juliaarrays.github.io/StaticArrays.jl/stable/pages/api/#Mutable-arrays:-MVector,-MMatrix-and-MArray I think |
Shouldn't we just use functions instead of arrays? @TzuYaoHuang's |
Yes, we can, but this will mean that the boundary condition function will now call these functions every time. |
Maybe we can dispatch to the tuple for static conditions and dispatch to the functions for dynamic ones. |
…nd updated documentation in src/Waterlily
I think this is ready to merge? @weymouth @marinlauber |
This is ready! The tests are passing on CPU/GPU Test Summary: | Pass Total Time
util.jl | 34 34 20.8s
Test Summary: | Pass Total Time
Poisson.jl | 14 14 18.8s
Test Summary: | Pass Total Time
MultiLevelPoisson.jl | 13 13 6.2s
Test Summary: | Pass Total Time
Flow.jl | 18 18 9.4s
Test Summary: | Pass Total Time
Body.jl | 3 3 0.1s
Test Summary: | Pass Total Time
AutoBody.jl | 11 11 5.3s
Test Summary: | Pass Total Time
Flow.jl periodic TGV | 2 2 5.1s
Test Summary: | Pass Total Time
Flow.jl with increasing body force | 2 2 10.0s
Test Summary: | Pass Total Time
Metrics.jl | 17 17 6.8s
Test Summary: | Pass Total Time
WaterLily.jl | 34 34 6.4s
Test Summary: | Pass Total Time
VTKExt.jl | 28 28 14.2s
Testing WaterLily tests passed And the benchmark results compared to --------------------------------------
Running benchmark tests for:
- Julia: 1.10.0
- Backends: Array CuArray
- CPU threads: 1 6
- Cases: tgv jelly
- Size: 6,7 5,6
- Sim. steps: 100 100
- Data type: Float32 Float32
--------------------------------------
Julia 1.10.0 benchmaks
Updating environment to Julia 1.10.0
Resolving package versions...
No Changes to `~/Workspace/WaterLily.jl/benchmark/Project.toml`
No Changes to `~/Workspace/WaterLily.jl/benchmark/Manifest.toml`
Updating registry at `/scratch/marinlauber/.julia/registries/General.toml`
No Changes to `~/Workspace/WaterLily.jl/benchmark/Project.toml`
No Changes to `~/Workspace/WaterLily.jl/benchmark/Manifest.toml`
Running: julia --project --startup-file=no -t 1 benchmark.jl --backend=Array --cases=["tgv","jelly"] --log2p=[(6,7),(5,6)] --max_steps=[100,100] --ftype=[Float32,Float32]
Benchmarking: tgv
(1/2) benchmarking "6"...
(1/1) benchmarking "sim_step!"...
done (took 9.153122932 seconds)
done (took 9.664080328 seconds)
(2/2) benchmarking "7"...
(1/1) benchmarking "sim_step!"...
done (took 55.775909505 seconds)
done (took 56.219365421 seconds)
Benchmarking: jelly
(1/2) benchmarking "5"...
(1/1) benchmarking "sim_step!"...
done (took 10.31607692 seconds)
done (took 10.762646285 seconds)
(2/2) benchmarking "6"...
(1/1) benchmarking "sim_step!"...
done (took 48.866873048 seconds)
done (took 49.323129197 seconds)
Running: julia --project --startup-file=no -t 6 benchmark.jl --backend=Array --cases=["tgv","jelly"] --log2p=[(6,7),(5,6)] --max_steps=[100,100] --ftype=[Float32,Float32]
Benchmarking: tgv
(1/2) benchmarking "6"...
(1/1) benchmarking "sim_step!"...
done (took 3.224376419 seconds)
done (took 3.562162138 seconds)
(2/2) benchmarking "7"...
(1/1) benchmarking "sim_step!"...
done (took 15.920800915 seconds)
done (took 16.161406035 seconds)
Benchmarking: jelly
(1/2) benchmarking "5"...
(1/1) benchmarking "sim_step!"...
done (took 3.995909223 seconds)
done (took 4.262310484 seconds)
(2/2) benchmarking "6"...
(1/1) benchmarking "sim_step!"...
done (took 18.140882184 seconds)
done (took 18.3939807 seconds)
Running: julia --project --startup-file=no benchmark.jl --backend=CuArray --cases=["tgv","jelly"] --log2p=[(6,7),(5,6)] --max_steps=[100,100] --ftype=[Float32,Float32]
Benchmarking: tgv
(1/2) benchmarking "6"...
(1/1) benchmarking "sim_step!"...
done (took 1.097216626 seconds)
done (took 1.657903387 seconds)
(2/2) benchmarking "7"...
(1/1) benchmarking "sim_step!"...
done (took 1.639622323 seconds)
done (took 2.123524882 seconds)
Benchmarking: jelly
(1/2) benchmarking "5"...
(1/1) benchmarking "sim_step!"...
done (took 1.510458438 seconds)
done (took 2.007634304 seconds)
(2/2) benchmarking "6"...
(1/1) benchmarking "sim_step!"...
done (took 2.660584546 seconds)
done (took 3.166380567 seconds) Benchmark environment: tgv sim_step! (max_steps=100)
▶ log2p = 6
┌─────────┬───────────┬────────┬───────────┬─────────────┬────────┬──────────┬──────────┐
│ Backend │ WaterLily │ Julia │ Precision │ Allocations │ GC [%] │ Time [s] │ Speed-up │
├─────────┼───────────┼────────┼───────────┼─────────────┼────────┼──────────┼──────────┤
│ CPUx1 │ afa03a3 │ 1.10.0 │ Float32 │ 1271464 │ 0.09 │ 8.67 │ 1.00 │
│ CPUx1 │ d0ec1d2 │ 1.10.0 │ Float32 │ 1357166 │ 0.23 │ 8.95 │ 0.97 │
│ CPUx6 │ afa03a3 │ 1.10.0 │ Float32 │ 4677363 │ 1.00 │ 2.92 │ 2.97 │
│ CPUx6 │ d0ec1d2 │ 1.10.0 │ Float32 │ 4999132 │ 0.94 │ 3.13 │ 2.77 │
│ GPU │ afa03a3 │ 1.10.0 │ Float32 │ 2304525 │ 1.56 │ 0.57 │ 15.17 │
│ GPU │ d0ec1d2 │ 1.10.0 │ Float32 │ 2467970 │ 1.58 │ 0.60 │ 14.57 │
└─────────┴───────────┴────────┴───────────┴─────────────┴────────┴──────────┴──────────┘
▶ log2p = 7
┌─────────┬───────────┬────────┬───────────┬─────────────┬────────┬──────────┬──────────┐
│ Backend │ WaterLily │ Julia │ Precision │ Allocations │ GC [%] │ Time [s] │ Speed-up │
├─────────┼───────────┼────────┼───────────┼─────────────┼────────┼──────────┼──────────┤
│ CPUx1 │ afa03a3 │ 1.10.0 │ Float32 │ 1145360 │ 0.09 │ 55.34 │ 1.00 │
│ CPUx1 │ d0ec1d2 │ 1.10.0 │ Float32 │ 1329041 │ 0.14 │ 57.37 │ 0.96 │
│ CPUx6 │ afa03a3 │ 1.10.0 │ Float32 │ 3994709 │ 0.40 │ 15.65 │ 3.54 │
│ CPUx6 │ d0ec1d2 │ 1.10.0 │ Float32 │ 4683048 │ 0.67 │ 16.54 │ 3.35 │
│ GPU │ afa03a3 │ 1.10.0 │ Float32 │ 1918194 │ 0.38 │ 1.16 │ 47.86 │
│ GPU │ d0ec1d2 │ 1.10.0 │ Float32 │ 2263519 │ 0.68 │ 1.31 │ 42.10 │
└─────────┴───────────┴────────┴───────────┴─────────────┴────────┴──────────┴──────────┘ Benchmark environment: jelly sim_step! (max_steps=100)
▶ log2p = 5
┌─────────┬───────────┬────────┬───────────┬─────────────┬────────┬──────────┬──────────┐
│ Backend │ WaterLily │ Julia │ Precision │ Allocations │ GC [%] │ Time [s] │ Speed-up │
├─────────┼───────────┼────────┼───────────┼─────────────┼────────┼──────────┼──────────┤
│ CPUx1 │ afa03a3 │ 1.10.0 │ Float32 │ 2263424 │ 0.15 │ 9.86 │ 1.00 │
│ CPUx1 │ d0ec1d2 │ 1.10.0 │ Float32 │ 2701319 │ 0.17 │ 10.94 │ 0.90 │
│ CPUx6 │ afa03a3 │ 1.10.0 │ Float32 │ 8318725 │ 1.44 │ 3.72 │ 2.65 │
│ CPUx6 │ d0ec1d2 │ 1.10.0 │ Float32 │ 9932893 │ 1.35 │ 4.29 │ 2.30 │
│ GPU │ afa03a3 │ 1.10.0 │ Float32 │ 4202842 │ 1.23 │ 1.00 │ 9.87 │
│ GPU │ d0ec1d2 │ 1.10.0 │ Float32 │ 5081193 │ 1.40 │ 1.18 │ 8.34 │
└─────────┴───────────┴────────┴───────────┴─────────────┴────────┴──────────┴──────────┘
▶ log2p = 6
┌─────────┬───────────┬────────┬───────────┬─────────────┬────────┬──────────┬──────────┐
│ Backend │ WaterLily │ Julia │ Precision │ Allocations │ GC [%] │ Time [s] │ Speed-up │
├─────────┼───────────┼────────┼───────────┼─────────────┼────────┼──────────┼──────────┤
│ CPUx1 │ afa03a3 │ 1.10.0 │ Float32 │ 3192831 │ 0.19 │ 48.40 │ 1.00 │
│ CPUx1 │ d0ec1d2 │ 1.10.0 │ Float32 │ 4208670 │ 0.22 │ 53.38 │ 0.91 │
│ CPUx6 │ afa03a3 │ 1.10.0 │ Float32 │ 11729531 │ 0.84 │ 17.86 │ 2.71 │
│ CPUx6 │ d0ec1d2 │ 1.10.0 │ Float32 │ 15448298 │ 0.88 │ 20.85 │ 2.32 │
│ GPU │ afa03a3 │ 1.10.0 │ Float32 │ 5958203 │ 0.89 │ 2.15 │ 22.48 │
│ GPU │ d0ec1d2 │ 1.10.0 │ Float32 │ 7945566 │ 1.02 │ 2.69 │ 17.99 │
└─────────┴───────────┴────────┴───────────┴─────────────┴────────┴──────────┴──────────┘ |
Looks fine to me. |
I have adjusted the velocity boundary conditions to allow for either a
Tuple
or aFunction(i,t)
. This is required if we have an accelerated flow without periodic BC in the forced direction. The resulting body force is computed withForwardDiff
on the body velocity function.Either boundary condition type is dispatched to a
BCTuple
function that generates a Tuple that is then passed to theBC!()
function.I added an example,
examples/TwoD_SlowStartCircle.jl
, that demonstrates how to use the time-varying velocity boundary conditions.I have added some tests (not run on the GPU yet) for the new functions.