neuralop.layers.spectral_projection.spectral_projection_divergence_free

neuralop.layers.spectral_projection.spectral_projection_divergence_free(u, domain_size, constraint_modes)[source]

Apply spectral projection layer to make a velocity field divergence-free.

Parameters:
utorch.Tensor

Input velocity field [batch, 2, height, width] where the last two dimensions represent the 2D velocity components (u_x, u_y)

domain_sizefloat or tuple of float

Physical domain size. If float, assumes square domain with same size for height and width. If tuple, should be (height_size, width_size) for non-square domains.

constraint_modestuple

Number of modes to use for constraint resolution (height_modes, width_modes). If larger than input dimensions, they are truncated to the input dimensions.

Returns:
torch.Tensor

Divergence-free projected velocity field with [batch, 2, height, width] shape. The output maintains the same shape as the input while satisfying ∇·u = 0.