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_stateMethod.
julia
get_state(
    stepper
) -> NamedTuple{(:u, :temp, :t, :n), <:NTuple{4, Any}}

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

source


# IncompressibleNavierStokes.solve_unsteadyMethod.
julia
solve_unsteady(
;
    setup,
    tlims,
    ustart,
    tempstart,
    method,
    psolver,
    Δt,
    cfl,
    n_adapt_Δt,
    docopy,
    processors,
    θ
)

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 .

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.animatorMethod.
julia
animator(
;
    setup,
    path,
    plot,
    nupdate,
    framerate,
    visible,
    screen,
    kwargs...
)

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_plotMethod.
julia
energy_history_plot(state; setup)

Create energy history plot.

source


# IncompressibleNavierStokes.energy_spectrum_plotMethod.
julia
energy_spectrum_plot(state; setup, npoint, a)

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 [13].

source


# IncompressibleNavierStokes.fieldplotMethod.
julia
fieldplot(state; setup, kwargs...)

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.fieldsaverMethod.
julia
fieldsaver(; setup, nupdate)

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

source


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

Observe field fieldname at pressure points.

source


# IncompressibleNavierStokes.processorFunction.
julia
processor(
    initialize
) -> NamedTuple{(:initialize, :finalize), <:Tuple{Any, IncompressibleNavierStokes.var"#311#312"}}
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.realtimeplotterMethod.
julia
realtimeplotter(
;
    setup,
    plot,
    nupdate,
    displayfig,
    screen,
    displayupdates,
    sleeptime,
    kwargs...
)

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_vtkMethod.
julia
save_vtk(state; setup, filename, kwargs...)

Save fields to vtk file.

The kwargs are passed to snapshotsaver.

source


# IncompressibleNavierStokes.snapshotsaverMethod.
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.timeloggerMethod.
julia
timelogger(
;
    showmax,
    showdt,
    nupdate
) -> @NamedTuple{initialize::IncompressibleNavierStokes.var"#314#316"{Bool, Bool, Int64}, finalize::IncompressibleNavierStokes.var"#311#312"}

Create processor that logs time step information.

source


# IncompressibleNavierStokes.vtk_writerMethod.
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