Solvers
Solvers
IncompressibleNavierStokes.get_cfl_timestep! Method
get_cfl_timestep!(buf, u, setup) -> Any
Get proposed maximum time step for convection and diffusion terms.
IncompressibleNavierStokes.get_state Method
get_state(
stepper
) -> NamedTuple{(:u, :temp, :t, :n), <:NTuple{4, Any}}
Get state (; u, temp, t, n)
from stepper.
IncompressibleNavierStokes.solve_unsteady Method
solve_unsteady(
;
setup,
tlims,
ustart,
tempstart,
method,
psolver,
Δt,
Δt_min,
cfl,
n_adapt_Δt,
docopy,
processors,
θ,
cache
)
Solve unsteady problem using method
.
If Δt
is a real number, it is rounded such that (t_end - t_start) / Δt
is an integer. If Δt = nothing
, the time step is chosen every n_adapt_Δt
iteration with CFL-number cfl
. If Δt_min
is given, the adaptive time step never goes below it.
The processors
are called after every time step.
Note that the state
observable passed to the processor.initialize
function contains vector living on the device, and you may have to move them back to the host using Array(u)
in the processor.
Return (; u, t), outputs
, where outputs
is a named tuple with the outputs of processors
with the same field names.
Processors
Processors can be used to process the solution in solve_unsteady
after every time step.
IncompressibleNavierStokes.animator Function
Animate a plot of the solution every update
iteration. The animation is saved to path
, which should have one of the following extensions:
".mkv"
".mp4"
".webm"
".gif"
The plot is determined by a plotter
processor. Additional kwargs
are passed to plot
.
IncompressibleNavierStokes.energy_spectrum_plot Function
Create energy spectrum plot. The energy at a scalar wavenumber level
as in San and Staples [12].
Keyword arguments:
sloperange = [0.6, 0.9]
: Percentage (between 0 and 1) of x-axis where the slope is plotted.slopeoffset = 1.3
: How far above the energy spectrum the inertial slope is plotted.kwargs...
: They are passed toobservespectrum
.
IncompressibleNavierStokes.fieldplot Function
Plot state
field in pressure points. If state
is Observable
, then the plot is interactive.
Available fieldnames are:
:velocity
,:vorticity
,:streamfunction
,:pressure
.
Available plot type
s for 2D are:
heatmap
(default),image
,contour
,contourf
.
Available plot type
s for 3D are:
contour
(default).
The alpha
value gets passed to contour
in 3D.
IncompressibleNavierStokes.fieldsaver Method
fieldsaver(; setup, nupdate)
Create processor that stores the solution and time every nupdate
time step.
IncompressibleNavierStokes.observefield Method
observefield(state; setup, fieldname, logtol, psolver)
Observe field fieldname
at pressure points.
IncompressibleNavierStokes.observespectrum Method
observespectrum(state; setup, npoint, a)
Observe energy spectrum of state
.
IncompressibleNavierStokes.processor Function
processor(
initialize
) -> NamedTuple{(:initialize, :finalize), <:Tuple{Any, IncompressibleNavierStokes.var"#281#282"}}
processor(
initialize,
finalize
) -> NamedTuple{(:initialize, :finalize), <:Tuple{Any, Any}}
Process results from time stepping. Before time stepping, the initialize
function is called on an observable of the time stepper state
, returning initialized
. The observable is updated every time step.
After timestepping, the finalize
function is called on initialized
and the final state
.
See the following example:
function initialize(state)
s = 0
println("Let's sum up the time steps")
on(state) do (; n, t)
println("The summand is $n, the time is $t")
s = s + n
end
s
end
finalize(i, state) = println("The final sum (at time t=$(state.t)) is $s")
p = processor(initialize, finalize)
When solved for 6 time steps from t=0 to t=2 the displayed output is
Let's sum up the time steps
The summand is 0, the time is 0.0
The summand is 1, the time is 0.4
The summand is 2, the time is 0.8
The summand is 3, the time is 1.2
The summand is 4, the time is 1.6
The summand is 5, the time is 2.0
The final sum (at time t=2.0) is 15
IncompressibleNavierStokes.realtimeplotter Function
Processor for plotting the solution in real time.
Keyword arguments:
plot
: Plot function.nupdate
: Show solution everynupdate
time step.displayfig
: Display the figure at the start.screen
: Ifnothing
, use default display. IfGLMakie.screen()
multiple plots can be displayed in separate windows like in MATLAB (see alsoGLMakie.closeall()
).displayupdates
: Display the figure at every update (if using CairoMakie).sleeptime
: Thesleeptime
is slept at every update, to give Makie time to update the plot. Set this tonothing
to skip sleeping.
Additional kwargs
are passed to the plot
function.
IncompressibleNavierStokes.save_vtk Method
save_vtk(state; setup, filename, kwargs...)
Save fields to vtk file.
The kwargs
are passed to snapshotsaver
.
IncompressibleNavierStokes.snapshotsaver Method
snapshotsaver(state; setup, fieldnames, psolver)
In the case of a 2D setup, the velocity field is saved as a 3D vector with a z-component of zero, as this seems to be preferred by ParaView.
IncompressibleNavierStokes.timelogger Method
timelogger(
;
showiter,
showt,
showdt,
showmax,
showspeed,
nupdate
) -> @NamedTuple{initialize::IncompressibleNavierStokes.var"#284#286"{Bool, Bool, Bool, Bool, Bool, Int64}, finalize::IncompressibleNavierStokes.var"#281#282"}
Create processor that logs time step information.
IncompressibleNavierStokes.vtk_writer Method
vtk_writer(; setup, nupdate, dir, filename, kwargs...)
Create processor that writes the solution every nupdate
time steps to a VTK file. The resulting Paraview data collection file is stored in "$dir/$filename.pvd"
. The kwargs
are passed to snapshotsaver
.