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
struct Offset{D}Cartesian index unit vector in D = 2 or D = 3 dimensions. Calling Offset(D)(i) returns a Cartesian index with 1 in the dimension i and zeros elsewhere.
See https://b-fg.github.io/research/2023-07-05-waterlily-on-gpu.html for writing kernel loops using Cartesian indices.
Fields
sourceIncompressibleNavierStokes.apply! Method
apply!(kernel, setup, args...; ndrange, offset)Apply kernel to args with offset offset. By default, it is applied everywhere except for at the outermost boundary.
IncompressibleNavierStokes.applygravity! Method
applygravity!(f, temp, setup, gdir, gravity) -> AnyCompute gravity term (in-place version). add the result to F.
IncompressibleNavierStokes.applygravity Method
applygravity(temp, setup, gdir, gravity) -> AnyCompute gravity term (differentiable version).
sourceIncompressibleNavierStokes.applypressure! Method
applypressure!(u, p, setup) -> AnySubtract pressure gradient (in-place version).
sourceIncompressibleNavierStokes.avg Method
avg(ϕ, Δ, I, i) -> AnyAverage scalar field ϕ in the i-direction.
IncompressibleNavierStokes.convection! Method
convection!(f, u, setup) -> AnyCompute convective term (in-place version). Add the result to F.
IncompressibleNavierStokes.convection Method
convection(u, setup) -> AnyCompute convective term (differentiable version).
sourceIncompressibleNavierStokes.convection_diffusion_temp! Method
convection_diffusion_temp!(
c,
u,
temp,
setup,
conductivity
) -> AnyCompute convection-diffusion term for the temperature equation. (in-place version). Add result to c.
IncompressibleNavierStokes.convection_diffusion_temp Method
convection_diffusion_temp(
u,
temp,
setup,
conductivity
) -> AnyCompute convection-diffusion term for the temperature equation. (differentiable version).
sourceIncompressibleNavierStokes.convectiondiffusion! Method
convectiondiffusion!(f, u, setup, viscosity) -> AnyCompute diffusive term (in-place version). Add the result to F.
IncompressibleNavierStokes.diffusion! Method
diffusion!(f, u, setup, viscosity) -> AnyCompute diffusive term (in-place version). Add the result to F.
IncompressibleNavierStokes.diffusion Method
diffusion(u, setup, viscosity) -> AnyCompute diffusive term (differentiable version).
sourceIncompressibleNavierStokes.dissipation! Method
dissipation!(diss, u, setup, coeff) -> AnyCompute dissipation term for the temperature equation (in-place version). Add result to diss.
IncompressibleNavierStokes.dissipation Method
dissipation(u, setup, coeff) -> AnyCompute dissipation term for the temperature equation (differentiable version).
sourceIncompressibleNavierStokes.divergence! Method
divergence!(div, u, setup) -> AnyCompute divergence of velocity field (in-place version).
sourceIncompressibleNavierStokes.divergence Method
divergence(u, setup) -> AnyCompute divergence of velocity field (differentiable version).
sourceIncompressibleNavierStokes.get_scale_numbers Method
get_scale_numbers(
u,
setup,
viscosity
) -> NamedTuple{(:uavg, :ϵ, :η, :λ, :Reλ, :L, :τ, :Re_int), <:NTuple{8, Any}}Get the following dimensional scale numbers [3]:
Velocity
Dissipation rate
Kolmolgorov length scale
Taylor length scale
Taylor-scale Reynolds number
Integral length scale
Large-eddy turnover time
IncompressibleNavierStokes.gridsize Method
gridsize(setup, I::CartesianIndex{2}) -> AnyGridsize based on the length of the diagonal of the cell.
sourceIncompressibleNavierStokes.gridsize_vol Method
gridsize_vol(setup, I::CartesianIndex{2}) -> AnyGrid size based on the volume of the cell.
sourceIncompressibleNavierStokes.interpolate_u_p! Method
interpolate_u_p!(up, u, setup) -> AnyInterpolate velocity to pressure points (in-place version).
sourceIncompressibleNavierStokes.interpolate_u_p Method
interpolate_u_p(u, setup) -> AnyInterpolate velocity to pressure points (differentiable version).
sourceIncompressibleNavierStokes.interpolate_ω_p! Method
interpolate_ω_p!(ωp, ω, setup) -> AnyInterpolate vorticity to pressure points (in-place version).
sourceIncompressibleNavierStokes.interpolate_ω_p Method
interpolate_ω_p(ω, setup) -> AnyInterpolate vorticity to pressure points (differentiable version).
sourceIncompressibleNavierStokes.kinetic_energy! Method
kinetic_energy!(ke, u, setup; interpolate_first) -> AnyCompute kinetic energy field (in-place version).
sourceIncompressibleNavierStokes.kinetic_energy Method
kinetic_energy(u, setup; kwargs...) -> AnyCompute kinetic energy field interpolate_first is true, it is given by
Otherwise, it is given by
as in [4].
Differentiable version.
sourceIncompressibleNavierStokes.laplacian! Method
laplacian!(L, p, setup) -> AnyCompute Laplacian of pressure field (in-place version).
sourceIncompressibleNavierStokes.laplacian Method
laplacian(p, setup) -> AnyCompute Laplacian of pressure field (differentiable version).
sourceIncompressibleNavierStokes.left Method
left(I::CartesianIndex{D}, i) -> Any
left(I::CartesianIndex{D}, i, n) -> AnyLeft index n times away in direction i.
IncompressibleNavierStokes.pressuregradient! Method
pressuregradient!(G, p, setup) -> AnyCompute pressure gradient (in-place version).
sourceIncompressibleNavierStokes.pressuregradient Method
pressuregradient(p, setup) -> AnyCompute pressure gradient (differentiable version).
sourceIncompressibleNavierStokes.qcrit Method
qcrit(u, setup) -> AnyCompute
IncompressibleNavierStokes.right Method
right(I::CartesianIndex{D}, i) -> Any
right(I::CartesianIndex{D}, i, n) -> AnyRight index n times away in direction i.
IncompressibleNavierStokes.scalewithvolume! Method
scalewithvolume!(p, setup) -> AnyScale scalar field with volume sizes (in-place version).
sourceIncompressibleNavierStokes.scalewithvolume Method
scalewithvolume(p, setup) -> AnyScale scalar field p with volume sizes (differentiable version).
IncompressibleNavierStokes.total_kinetic_energy Method
total_kinetic_energy(u, setup; kwargs...) -> AnyCompute total kinetic energy. The velocity components are interpolated to the volume centers and squared.
sourceIncompressibleNavierStokes.unit_cartesian_indices Method
unit_cartesian_indices(D) -> AnyGet tuple of all unit vectors as Cartesian indices.
sourceIncompressibleNavierStokes.vorticity! Method
vorticity!(ω, u, setup) -> AnyCompute vorticity field (in-place version).
sourceIncompressibleNavierStokes.vorticity Method
vorticity(u, setup) -> AnyCompute vorticity field (differentiable version).
sourceIncompressibleNavierStokes.δ Method
δ(setup, p, i, I) -> AnyDifferentiate scalar
IncompressibleNavierStokes.δ Method
δ(setup, u, i, j, I) -> AnyDifferentiate vector i and j are known at compile-time to remove the if-statement.