-
Notifications
You must be signed in to change notification settings - Fork 104
Non-uniform boundary conditions #165
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
Changes from 25 commits
111c8f7
81724f0
31086c2
e97d012
2766de4
d451f1c
633b6d9
cde7299
ab62bbc
05336b5
3653bbf
5226d1a
247c1a8
f4f4697
be9e85f
24aa6b7
a932639
404ddab
2e6a49b
05a989d
35c1b23
c9a4db2
5cb8752
3026334
341f046
c80d198
311b5b1
9a7753d
8c55457
561db0d
957aed0
bbbc15a
01d9a24
399061a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,7 +40,7 @@ Constructor for a WaterLily.jl simulation: | |
|
|
||
| - `dims`: Simulation domain dimensions. | ||
| - `u_BC`: Simulation domain velocity boundary conditions, either a | ||
| tuple `u_BC[i]=uᵢ, i=eachindex(dims)`, or a time-varying function `f(i,t)` | ||
| tuple `u_BC[i]=uᵢ, i=eachindex(dims)`, or a time and space-varying function `u_BC(i,x,t)` | ||
| - `L`: Simulation length scale. | ||
| - `U`: Simulation velocity scale. | ||
| - `Δt`: Initial time step. | ||
|
|
@@ -69,9 +69,12 @@ mutable struct Simulation <: AbstractSimulation | |
| T=Float32, mem=Array) where N | ||
| @assert !(isa(u_BC,Function) && isa(uλ,Function)) "`u_BC` and `uλ` cannot be both specified as Function" | ||
|
||
| @assert !(isnothing(U) && isa(u_BC,Function)) "`U` must be specified if `u_BC` is a Function" | ||
| isa(u_BC,Function) && @assert all(typeof.(ntuple(i->u_BC(i,zero(T)),N)).==T) "`u_BC` is not type stable" | ||
| uλ = isnothing(uλ) ? ifelse(isa(u_BC,Function),(i,x)->u_BC(i,0.),(i,x)->u_BC[i]) : uλ | ||
| U = isnothing(U) ? √sum(abs2,u_BC) : U # default if not specified | ||
| isa(g,Function) && @assert first(methods(g)).nargs==4 "g::Function needs to be defined as g(i,x,t)" | ||
marinlauber marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| isa(g,Function) && @assert all(typeof.(ntuple(i->g(i,zeros(SVector{N}),zero(T)),N)).==T) "`g` is not type stable" | ||
| isa(u_BC,Function) && @assert first(methods(u_BC)).nargs==4 "u_BC::Function needs to be defined as u_BC(i,x,t)" | ||
b-fg marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| isa(u_BC,Function) && @assert all(typeof.(ntuple(i->u_BC(i,zeros(SVector{N}),zero(T)),N)).==T) "`u_BC` is not type stable" | ||
| isnothing(uλ) && (uλ = isa(u_BC, Function) ? uλ = (i,x)->u_BC(i,x,0) : uλ = (i,_)->u_BC[i]) | ||
| isnothing(U) && (U = √sum(abs2,u_BC)) | ||
| flow = Flow(dims,u_BC;uλ,Δt,ν,g,T,f=mem,perdir,exitBC) | ||
| measure!(flow,body;ϵ) | ||
| new(U,L,ϵ,flow,body,MultiLevelPoisson(flow.p,flow.μ₀,flow.σ;perdir)) | ||
|
|
@@ -94,18 +97,20 @@ sim_time(sim::AbstractSimulation) = time(sim)*sim.U/sim.L | |
| Integrate the simulation `sim` up to dimensionless time `t_end`. | ||
| If `remeasure=true`, the body is remeasured at every time step. | ||
| Can be set to `false` for static geometries to speed up simulation. | ||
| A user-defined function `udf` can be passed to arbitrarily modify the `::Flow` during the predictor and corrector steps. | ||
| If the `udf` user keyword arguments, these needs to be included in the `sim_step!` call as well. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably want to add something in the documentation here about the type returned by these functions needing to match |
||
| """ | ||
| function sim_step!(sim::AbstractSimulation,t_end;remeasure=true,max_steps=typemax(Int),verbose=false) | ||
| function sim_step!(sim::AbstractSimulation,t_end;remeasure=true,max_steps=typemax(Int),udf=nothing,verbose=false,kwargs...) | ||
| steps₀ = length(sim.flow.Δt) | ||
| while sim_time(sim) < t_end && length(sim.flow.Δt) - steps₀ < max_steps | ||
| sim_step!(sim; remeasure) | ||
| sim_step!(sim; remeasure, udf, kwargs...) | ||
| verbose && println("tU/L=",round(sim_time(sim),digits=4), | ||
| ", Δt=",round(sim.flow.Δt[end],digits=3)) | ||
| end | ||
| end | ||
| function sim_step!(sim::AbstractSimulation;remeasure=true) | ||
| function sim_step!(sim::AbstractSimulation;remeasure=true,udf=nothing,kwargs...) | ||
| remeasure && measure!(sim) | ||
| mom_step!(sim.flow,sim.pois) | ||
| mom_step!(sim.flow, sim.pois; udf, kwargs...) | ||
| end | ||
|
|
||
| """ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems redundant given
udf.