Skip to content

Solvers

Solvers

IncompressibleNavierStokes.get_cfl_timestep! Method
julia
get_cfl_timestep!(buf, u, setup) -> Any

Get proposed maximum time step for convection and diffusion terms.

source

IncompressibleNavierStokes.get_state Method
julia
get_state(
    stepper
) -> NamedTuple{(:u, :temp, :t, :n), <:NTuple{4, Any}}

Get state (; u, temp, t, n) from stepper.

source

IncompressibleNavierStokes.solve_unsteady Method
julia
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.

source

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.

source

IncompressibleNavierStokes.energy_history_plot Function

Create energy history plot.

source

IncompressibleNavierStokes.energy_spectrum_plot Function

Create energy spectrum plot. The energy at a scalar wavenumber level κN is defined by

e^(κ)=κk2<κ+1|e^(k)|dk,

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 to observespectrum.

source

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 types for 2D are:

  • heatmap (default),

  • image,

  • contour,

  • contourf.

Available plot types for 3D are:

  • contour (default).

The alpha value gets passed to contour in 3D.

source

IncompressibleNavierStokes.fieldsaver Method
julia
fieldsaver(; setup, nupdate)

Create processor that stores the solution and time every nupdate time step.

source

IncompressibleNavierStokes.observefield Method
julia
observefield(state; setup, fieldname, logtol, psolver)

Observe field fieldname at pressure points.

source

IncompressibleNavierStokes.observespectrum Method
julia
observespectrum(state; setup, npoint, a)

Observe energy spectrum of state.

source

IncompressibleNavierStokes.processor Function
julia
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:

julia
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

source

IncompressibleNavierStokes.realtimeplotter Function

Processor for plotting the solution in real time.

Keyword arguments:

  • plot: Plot function.

  • nupdate: Show solution every nupdate time step.

  • displayfig: Display the figure at the start.

  • screen: If nothing, use default display. If GLMakie.screen() multiple plots can be displayed in separate windows like in MATLAB (see also GLMakie.closeall()).

  • displayupdates: Display the figure at every update (if using CairoMakie).

  • sleeptime: The sleeptime is slept at every update, to give Makie time to update the plot. Set this to nothing to skip sleeping.

Additional kwargs are passed to the plot function.

source

IncompressibleNavierStokes.save_vtk Method
julia
save_vtk(state; setup, filename, kwargs...)

Save fields to vtk file.

The kwargs are passed to snapshotsaver.

source

IncompressibleNavierStokes.snapshotsaver Method
julia
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.

source

IncompressibleNavierStokes.timelogger Method
julia
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.

source

IncompressibleNavierStokes.vtk_writer Method
julia
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.

source