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.
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
Dfield!(d, G, p, setup; ϵ) -> Any
Compute the
Dfield(p, setup; kwargs...) -> Any
Compute the
Differentiable version.
Qfield!(Q, u, setup) -> Any
Compute the
Qfield(u, setup) -> Any
Compute
Differentiable version.
applybodyforce!(F, u, t, setup) -> Any
Compute body force (in-place version). Add the result to F
.
applybodyforce(u, t, setup) -> Any
Compute body force (differentiable version).
applypressure!(u, p, setup) -> Any
Subtract pressure gradient (in-place version).
avg(ϕ, Δ, I, α) -> Any
Average scalar field ϕ
in the α
-direction.
convection!(F, u, setup) -> Any
Compute convective term (in-place version). Add the result to F
.
convection(u, setup) -> Any
Compute convective term (differentiable version).
convection_diffusion_temp!(c, u, temp, setup) -> Any
Compute convection-diffusion term for the temperature equation. (in-place version). Add result to c
.
convection_diffusion_temp(u, temp, setup) -> Any
Compute convection-diffusion term for the temperature equation. (differentiable version).
convectiondiffusion!(F, u, setup) -> Any
Compute convective and diffusive terms (in-place version). Add the result to F
.
diffusion!(F, u, setup) -> Any
Compute diffusive term (in-place version). Add the result to F
.
diffusion(u, setup) -> Any
Compute diffusive term (differentiable version).
dissipation!(diss, diff, u, setup) -> Any
Compute dissipation term for the temperature equation (in-place version). Add result to diss
.
dissipation(u, setup) -> Any
Compute dissipation term for the temperature equation (differentiable version).
dissipation_from_strain!(ϵ, u, setup) -> Any
Compute dissipation term from strain-rate tensor (in-place version).
dissipation_from_strain(u, setup) -> Any
Compute dissipation term
divergence!(div, u, setup) -> Any
Compute divergence of velocity field (in-place version).
divergence(u, setup) -> Any
Compute divergence of velocity field (differentiable version).
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 σ
.
eig2field!(λ, u, setup) -> Any
Compute the second eigenvalue of
eig2field(u, setup) -> Any
Compute the second eigenvalue of
Differentiable version.
get_scale_numbers(
u,
setup
) -> NamedTuple{(:uavg, :ϵ, :η, :λ, :Reλ, :L, :τ), <:Tuple{Any, Any, Any, Any, Any, Nothing, Nothing}}
Get the following dimensional scale numbers [8]:
Velocity
Dissipation rate
Kolmolgorov length scale
Taylor length scale
Taylor-scale Reynolds number
Integral length scale
Large-eddy turnover time
gravity!(F, temp, setup) -> Any
Compute gravity term (in-place version). add the result to F
.
gravity(temp, setup) -> Any
Compute gravity term (differentiable version).
interpolate_u_p!(up, u, setup) -> Any
Interpolate velocity to pressure points (in-place version).
interpolate_u_p(u, setup) -> Any
Interpolate velocity to pressure points (differentiable version).
interpolate_ω_p!(ωp, ω, setup) -> Any
Interpolate vorticity to pressure points (in-place version).
interpolate_ω_p(ω, setup) -> Any
Interpolate vorticity to pressure points (differentiable version).
kinetic_energy!(ke, u, setup; interpolate_first) -> Any
Compute kinetic energy field (in-place version).
kinetic_energy(u, setup; kwargs...) -> Any
Compute kinetic energy field interpolate_first
is true, it is given by
Otherwise, it is given by
as in [9].
Differentiable version.
laplacian!(L, p, setup) -> Any
Compute Laplacian of pressure field (in-place version).
laplacian(p, setup) -> Any
Compute Laplacian of pressure field (differentiable version).
momentum!(F, u, temp, t, setup) -> Any
Right hand side of momentum equations, excluding pressure gradient (in-place version).
momentum(u, temp, t, setup) -> Any
Right hand side of momentum equations, excluding pressure gradient (differentiable version).
pressuregradient!(G, p, setup) -> Any
Compute pressure gradient (in-place version).
pressuregradient(p, setup) -> Any
Compute pressure gradient (differentiable version).
scalewithvolume!(p, setup) -> Any
Scale scalar field with volume sizes (in-place version).
scalewithvolume(p, setup) -> Any
Scale scalar field p
with volume sizes (differentiable version).
smagorinsky_closure(
setup
) -> IncompressibleNavierStokes.var"#closure#224"
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
).
smagtensor!(σ, u, θ, setup) -> Any
Compute Smagorinsky stress tensors σ[I]
(in-place version). The Smagorinsky constant θ
should be a scalar between 0
and 1
.
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 [10] in equations (9) and (11). Note that B[1]
corresponds to V
to
tensorbasis(u, setup) -> Tuple{Tuple, Tuple}
Compute symmetry tensor basis (differentiable version).
total_kinetic_energy(u, setup; kwargs...) -> Any
Compute total kinetic energy. The velocity components are interpolated to the volume centers and squared.
vorticity!(ω, u, setup) -> Any
Compute vorticity field (in-place version).
vorticity(u, setup) -> Any
Compute vorticity field (differentiable version).
laplacian_mat(setup) -> Any
Get matrix for the Laplacian operator.