Skip to content

Operators

All discrete operators are built using KernelAbstractions.jl and Cartesian indices, similar to WaterLily.jl. This allows for dimension- and backend-agnostic code. See this blog post for how to write kernels. IncompressibleNavierStokes previously relied on assembling sparse operators to perform the same operations. While being very efficient and also compatible with CUDA (CUSPARSE), storing these matrices in memory is expensive for large 3D problems.

IncompressibleNavierStokes.Offset Type
julia
struct Offset{D}

Cartesian index unit vector in D = 2 or D = 3 dimensions. Calling Offset(D)(α) returns a Cartesian index with 1 in the dimension α and zeros elsewhere.

See https://b-fg.github.io/2023/05/07/waterlily-on-gpu.html for writing kernel loops using Cartesian indices.

Fields

source

IncompressibleNavierStokes.Dfield! Method
julia
Dfield!(d, G, p, setup; ϵ) -> Any

Compute the D-field (in-place version).

source

IncompressibleNavierStokes.Dfield Method
julia
Dfield(p, setup; kwargs...) -> Any

Compute the D-field [5] given by

D=2|p|2p.

Differentiable version.

source

IncompressibleNavierStokes.Qfield! Method
julia
Qfield!(Q, u, setup) -> Any

Compute the Q-field (in-place version).

source

IncompressibleNavierStokes.Qfield Method
julia
Qfield(u, setup) -> Any

Compute Q-field [6] given by

Q=12α,βuαxβuβxα.

Differentiable version.

source

IncompressibleNavierStokes.applybodyforce! Method
julia
applybodyforce!(F, u, t, setup) -> Any

Compute body force (in-place version). Add the result to F.

source

IncompressibleNavierStokes.applybodyforce Method
julia
applybodyforce(u, t, setup) -> Any

Compute body force (differentiable version).

source

IncompressibleNavierStokes.applypressure! Method
julia
applypressure!(u, p, setup) -> Any

Subtract pressure gradient (in-place version).

source

IncompressibleNavierStokes.avg Method
julia
avg(ϕ, Δ, I, α) -> Any

Average scalar field ϕ in the α-direction.

source

IncompressibleNavierStokes.convection! Method
julia
convection!(F, u, setup) -> Any

Compute convective term (in-place version). Add the result to F.

source

IncompressibleNavierStokes.convection Method
julia
convection(u, setup) -> Any

Compute convective term (differentiable version).

source

IncompressibleNavierStokes.convection_diffusion_temp! Method
julia
convection_diffusion_temp!(c, u, temp, setup) -> Any

Compute convection-diffusion term for the temperature equation. (in-place version). Add result to c.

source

IncompressibleNavierStokes.convection_diffusion_temp Method
julia
convection_diffusion_temp(u, temp, setup) -> Any

Compute convection-diffusion term for the temperature equation. (differentiable version).

source

IncompressibleNavierStokes.convectiondiffusion! Method
julia
convectiondiffusion!(F, u, setup) -> Any

Compute convective and diffusive terms (in-place version). Add the result to F.

source

IncompressibleNavierStokes.diffusion! Method
julia
diffusion!(F, u, setup) -> Any

Compute diffusive term (in-place version). Add the result to F.

source

IncompressibleNavierStokes.diffusion Method
julia
diffusion(u, setup) -> Any

Compute diffusive term (differentiable version).

source

IncompressibleNavierStokes.dissipation! Method
julia
dissipation!(diss, diff, u, setup) -> Any

Compute dissipation term for the temperature equation (in-place version). Add result to diss.

source

IncompressibleNavierStokes.dissipation Method
julia
dissipation(u, setup) -> Any

Compute dissipation term for the temperature equation (differentiable version).

source

IncompressibleNavierStokes.dissipation_from_strain! Method
julia
dissipation_from_strain!(ϵ, u, setup) -> Any

Compute dissipation term from strain-rate tensor (in-place version).

source

IncompressibleNavierStokes.dissipation_from_strain Method
julia
dissipation_from_strain(u, setup) -> Any

Compute dissipation term 2νSijSij from strain-rate tensor (differentiable version).

source

IncompressibleNavierStokes.divergence! Method
julia
divergence!(div, u, setup) -> Any

Compute divergence of velocity field (in-place version).

source

IncompressibleNavierStokes.divergence Method
julia
divergence(u, setup) -> Any

Compute divergence of velocity field (differentiable version).

source

IncompressibleNavierStokes.divoftensor! Method
julia
divoftensor!(s, σ, setup) -> Any

Compute divergence of a tensor with all components in the pressure points (in-place version). The stress tensors should be precomputed and stored in σ.

source

IncompressibleNavierStokes.eig2field! Method
julia
eig2field!(λ, u, setup) -> Any

Compute the second eigenvalue of S2+R2 (in-place version).

source

IncompressibleNavierStokes.eig2field Method
julia
eig2field(u, setup) -> Any

Compute the second eigenvalue of S2+R2, as proposed by Jeong and Hussain [6].

Differentiable version.

source

IncompressibleNavierStokes.get_scale_numbers Method
julia
get_scale_numbers(
    u,
    setup
) -> NamedTuple{(:uavg, , , , :Reλ, :L, ), <:Tuple{Any, Any, Any, Any, Any, Nothing, Nothing}}

Get the following dimensional scale numbers [7]:

  • Velocity uavg=uiui1/2

  • Dissipation rate ϵ=2νSijSij

  • Kolmolgorov length scale η=(ν3ϵ)1/4

  • Taylor length scale λ=(5νϵ)1/2uavg

  • Taylor-scale Reynolds number Reλ=λuavg3ν

  • Integral length scale L=3π2uavg20E(k)kdk

  • Large-eddy turnover time τ=Luavg

source

IncompressibleNavierStokes.gravity! Method
julia
gravity!(F, temp, setup) -> Any

Compute gravity term (in-place version). add the result to F.

source

IncompressibleNavierStokes.gravity Method
julia
gravity(temp, setup) -> Any

Compute gravity term (differentiable version).

source

IncompressibleNavierStokes.interpolate_u_p! Method
julia
interpolate_u_p!(up, u, setup) -> Any

Interpolate velocity to pressure points (in-place version).

source

IncompressibleNavierStokes.interpolate_u_p Method
julia
interpolate_u_p(u, setup) -> Any

Interpolate velocity to pressure points (differentiable version).

source

IncompressibleNavierStokes.interpolate_ω_p! Method
julia
interpolate_ω_p!(ωp, ω, setup) -> Any

Interpolate vorticity to pressure points (in-place version).

source

IncompressibleNavierStokes.interpolate_ω_p Method
julia
interpolate_ω_p(ω, setup) -> Any

Interpolate vorticity to pressure points (differentiable version).

source

IncompressibleNavierStokes.kinetic_energy! Method
julia
kinetic_energy!(ke, u, setup; interpolate_first) -> Any

Compute kinetic energy field (in-place version).

source

IncompressibleNavierStokes.kinetic_energy Method
julia
kinetic_energy(u, setup; kwargs...) -> Any

Compute kinetic energy field k (in-place version). If interpolate_first is true, it is given by

kI=18α(uI+hαα+uIhαα)2.

Otherwise, it is given by

kI=14α((uI+hαα)2+(uIhαα)2),

as in [8].

Differentiable version.

source

IncompressibleNavierStokes.laplacian! Method
julia
laplacian!(L, p, setup) -> Any

Compute Laplacian of pressure field (in-place version).

source

IncompressibleNavierStokes.laplacian Method
julia
laplacian(p, setup) -> Any

Compute Laplacian of pressure field (differentiable version).

source

IncompressibleNavierStokes.momentum! Method
julia
momentum!(F, u, temp, t, setup) -> Any

Right hand side of momentum equations, excluding pressure gradient (in-place version).

source

IncompressibleNavierStokes.momentum Method
julia
momentum(u, temp, t, setup) -> Any

Right hand side of momentum equations, excluding pressure gradient (differentiable version).

source

IncompressibleNavierStokes.pressuregradient! Method
julia
pressuregradient!(G, p, setup) -> Any

Compute pressure gradient (in-place version).

source

IncompressibleNavierStokes.pressuregradient Method
julia
pressuregradient(p, setup) -> Any

Compute pressure gradient (differentiable version).

source

IncompressibleNavierStokes.scalewithvolume! Method
julia
scalewithvolume!(p, setup) -> Any

Scale scalar field with volume sizes (in-place version).

source

IncompressibleNavierStokes.scalewithvolume Method
julia
scalewithvolume(p, setup) -> Any

Scale scalar field p with volume sizes (differentiable version).

source

IncompressibleNavierStokes.smagorinsky_closure Method
julia
smagorinsky_closure(
    setup
) -> IncompressibleNavierStokes.var"#closure#181"

Create Smagorinsky closure model m. The model is called as m(u, θ), where the Smagorinsky constant θ should be a scalar between 0 and 1 (for example θ = 0.1).

source

IncompressibleNavierStokes.smagtensor! Method
julia
smagtensor!(σ, u, θ, setup) -> Any

Compute Smagorinsky stress tensors σ[I] (in-place version). The Smagorinsky constant θ should be a scalar between 0 and 1.

source

IncompressibleNavierStokes.tensorbasis! Method
julia
tensorbasis!(B, V, u, setup) -> Tuple{Any, Any}

Compute symmetry tensor basis B[1]-B[11] and invariants V[1]-V[5], as specified in [9] in equations (9) and (11). Note that B[1] corresponds to T0 in the paper, and V to I.

source

IncompressibleNavierStokes.tensorbasis Method
julia
tensorbasis(u, setup) -> Tuple{Tuple, Tuple}

Compute symmetry tensor basis (differentiable version).

source

IncompressibleNavierStokes.total_kinetic_energy Method
julia
total_kinetic_energy(u, setup; kwargs...) -> Any

Compute total kinetic energy. The velocity components are interpolated to the volume centers and squared.

source

IncompressibleNavierStokes.unit_cartesian_indices Method
julia
unit_cartesian_indices(D) -> Any

Get tuple of all unit vectors as Cartesian indices.

source

IncompressibleNavierStokes.vorticity! Method
julia
vorticity!(ω, u, setup) -> Any

Compute vorticity field (in-place version).

source

IncompressibleNavierStokes.vorticity Method
julia
vorticity(u, setup) -> Any

Compute vorticity field (differentiable version).

source

IncompressibleNavierStokes.laplacian_mat Method
julia
laplacian_mat(setup) -> Any

Get matrix for the Laplacian operator.

source