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)(α) 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
sourceIncompressibleNavierStokes.Dfield! Method
Dfield!(d, G, p, setup; ϵ) -> AnyCompute the
IncompressibleNavierStokes.Dfield Method
Dfield(p, setup; kwargs...) -> AnyCompute the
Differentiable version.
sourceIncompressibleNavierStokes.Qfield! Method
Qfield!(Q, u, setup) -> AnyCompute the
IncompressibleNavierStokes.Qfield Method
Qfield(u, setup) -> AnyCompute
Differentiable version.
sourceIncompressibleNavierStokes.applybodyforce! Method
applybodyforce!(F, u, t, setup) -> AnyCompute body force (in-place version). Add the result to F.
IncompressibleNavierStokes.applybodyforce Method
applybodyforce(u, t, setup) -> AnyCompute body force (differentiable version).
sourceIncompressibleNavierStokes.applypressure! Method
applypressure!(u, p, setup) -> AnySubtract pressure gradient (in-place version).
sourceIncompressibleNavierStokes.applypressure Method
applypressure(u, p, setup) -> AnySubtract pressure gradient (differentiable version).
sourceIncompressibleNavierStokes.avg Method
avg(ϕ, Δ, I, α) -> AnyAverage scalar field ϕ in the α-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) -> 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) -> AnyCompute convection-diffusion term for the temperature equation. (differentiable version).
sourceIncompressibleNavierStokes.convectiondiffusion! Method
convectiondiffusion!(F, u, setup) -> AnyCompute convective and diffusive terms (in-place version). Add the result to F.
IncompressibleNavierStokes.diffusion! Method
diffusion!(F, u, setup; use_viscosity) -> AnyCompute diffusive term (in-place version). Add the result to F.
Keyword arguments:
with_viscosity = true: Include viscosity in the operator.
IncompressibleNavierStokes.diffusion Method
diffusion(u, setup; kwargs...) -> AnyCompute diffusive term (differentiable version).
sourceIncompressibleNavierStokes.dissipation! Method
dissipation!(diss, diff, u, setup) -> AnyCompute dissipation term for the temperature equation (in-place version). Add result to diss.
IncompressibleNavierStokes.dissipation Method
dissipation(u, setup) -> AnyCompute dissipation term for the temperature equation (differentiable version).
sourceIncompressibleNavierStokes.dissipation_from_strain! Method
dissipation_from_strain!(ϵ, u, setup) -> AnyCompute dissipation term from strain-rate tensor (in-place version).
sourceIncompressibleNavierStokes.dissipation_from_strain Method
dissipation_from_strain(u, setup) -> AnyCompute dissipation term
IncompressibleNavierStokes.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.divoftensor! Method
divoftensor!(s, σ, setup) -> AnyCompute divergence of a tensor with all components in the pressure points (in-place version). The stress tensors should be precomputed and stored in σ.
IncompressibleNavierStokes.eig2field! Method
eig2field!(λ, u, setup) -> AnyCompute the second eigenvalue of
IncompressibleNavierStokes.eig2field Method
eig2field(u, setup) -> AnyCompute the second eigenvalue of
Differentiable version.
sourceIncompressibleNavierStokes.get_scale_numbers Method
get_scale_numbers(
u,
setup
) -> NamedTuple{(:uavg, :ϵ, :η, :λ, :Reλ, :L, :τ, :Re_int), <:NTuple{8, Any}}Get the following dimensional scale numbers [7]:
Velocity
Dissipation rate
Kolmolgorov length scale
Taylor length scale
Taylor-scale Reynolds number
Integral length scale
Large-eddy turnover time
IncompressibleNavierStokes.gravity! Method
gravity!(F, temp, setup) -> AnyCompute gravity term (in-place version). add the result to F.
IncompressibleNavierStokes.gravity Method
gravity(temp, setup) -> AnyCompute gravity term (differentiable version).
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 [8].
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.momentum! Method
momentum!(F, u, temp, t, setup) -> AnyRight hand side of momentum equations, excluding pressure gradient (in-place version).
sourceIncompressibleNavierStokes.momentum Method
momentum(u, temp, t, setup) -> AnyRight hand side of momentum equations, excluding pressure gradient (differentiable version).
sourceIncompressibleNavierStokes.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.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.smagorinsky_closure Method
smagorinsky_closure(
setup
) -> IncompressibleNavierStokes.var"#closure#182"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).
IncompressibleNavierStokes.smagtensor! Method
smagtensor!(σ, u, θ, setup) -> AnyCompute Smagorinsky stress tensors σ[I] (in-place version). The Smagorinsky constant θ should be a scalar between 0 and 1.
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.lastdimcontract Method
lastdimcontract(a, b, setup) -> AnyCompute c[I] = sum_i a[I, i] * b[I, i], where c[:, i] and b[:, i] are tensor fields (elements are SMatrixes), a[:, i] is a scalar field, and the i dimension is contracted (multiple channels).
IncompressibleNavierStokes.tensorbasis! Method
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 V to
IncompressibleNavierStokes.tensorbasis Method
tensorbasis(u, setup) -> Tuple{Any, Any}Compute symmetry tensor basis (differentiable version).
source