Spectral Convolution#

class SpectralConvBlock1D(input_numb_fields, output_numb_fields, n_modes)[source]#

Bases: Module

PINA implementation of Spectral Convolution Block for one dimensional tensors.

The module computes the spectral convolution of the input with a linear kernel in the fourier space, and then it maps the input back to the physical space.

The block expects an input of size [batch, input_numb_fields, N] and returns an output of size [batch, output_numb_fields, N].

Parameters:
  • input_numb_fields (int) – The number of channels for the input.

  • output_numb_fields (int) – The number of channels for the output.

  • n_modes (int) – Number of modes to select, it must be at most equal to the floor(N/2)+1.

forward(x)[source]#

Forward computation for Spectral Convolution.

Parameters:

x (torch.Tensor) – The input tensor, expect of size [batch, input_numb_fields, x].

Returns:

The output tensor obtained from the spectral convolution of size [batch, output_numb_fields, x].

Return type:

torch.Tensor

class SpectralConvBlock2D(input_numb_fields, output_numb_fields, n_modes)[source]#

Bases: Module

PINA implementation of spectral convolution block for two dimensional tensors.

The module computes the spectral convolution of the input with a linear kernel in the fourier space, and then it maps the input back to the physical space.

The block expects an input of size [batch, input_numb_fields, Nx, Ny] and returns an output of size [batch, output_numb_fields, Nx, Ny].

Parameters:
  • input_numb_fields (int) – The number of channels for the input.

  • output_numb_fields (int) – The number of channels for the output.

  • n_modes (list | tuple) – Number of modes to select for each dimension. It must be at most equal to the floor(Nx/2)+1 and floor(Ny/2)+1.

forward(x)[source]#

Forward computation for Spectral Convolution.

Parameters:

x (torch.Tensor) – The input tensor, expect of size [batch, input_numb_fields, x, y].

Returns:

The output tensor obtained from the spectral convolution of size [batch, output_numb_fields, x, y].

Return type:

torch.Tensor

class SpectralConvBlock3D(input_numb_fields, output_numb_fields, n_modes)[source]#

Bases: Module

PINA implementation of spectral convolution block for three dimensional tensors.

The module computes the spectral convolution of the input with a linear kernel in the fourier space, and then it maps the input back to the physical space.

The block expects an input of size [batch, input_numb_fields, Nx, Ny, Nz] and returns an output of size [batch, output_numb_fields, Nx, Ny, Nz].

Parameters:
  • input_numb_fields (int) – The number of channels for the input.

  • output_numb_fields (int) – The number of channels for the output.

  • n_modes (list | tuple) – Number of modes to select for each dimension. It must be at most equal to the floor(Nx/2)+1, floor(Ny/2)+1 and floor(Nz/2)+1.

forward(x)[source]#

Forward computation for Spectral Convolution.

Parameters:

x (torch.Tensor) – The input tensor, expect of size [batch, input_numb_fields, x, y, z].

Returns:

The output tensor obtained from the spectral convolution of size [batch, output_numb_fields, x, y, z].

Return type:

torch.Tensor