SpECTRE  v2024.04.12
Spectral::filtering Namespace Reference

Matrices for filtering spectral coefficients. More...

Functions

Matrix exponential_filter (const Mesh< 1 > &mesh, double alpha, unsigned half_power)
 Returns a Matrix by which to multiply the nodal coefficients to apply a stable exponential filter. More...
 
const Matrixzero_lowest_modes (const Mesh< 1 > &mesh, size_t number_of_modes_to_zero)
 Zeros the lowest number_of_modes_to_zero modal coefficients. Note that the matrix must be applied to a nodal representation. More...
 

Detailed Description

Matrices for filtering spectral coefficients.

Function Documentation

◆ exponential_filter()

Matrix Spectral::filtering::exponential_filter ( const Mesh< 1 > &  mesh,
double  alpha,
unsigned  half_power 
)

Returns a Matrix by which to multiply the nodal coefficients to apply a stable exponential filter.

The exponential filter rescales the modal coefficients according to:

\begin{align*} c_i\to c_i \exp\left[-\alpha \left(\frac{i}{N}\right)^{2m}\right] \end{align*}

where \(c_i\) are the zero-indexed modal coefficients, \(N\) is the basis degree (number of grid points per element per dimension minus one), \(\alpha\) determines how much the coefficients are rescaled, and \(m\) determines how aggressive/broad the filter is (lower values means filtering more coefficients). Setting \(\alpha=36\) results in setting the highest coefficient to machine precision, effectively zeroing it out.

Note
The filter matrix is not cached by the function because it depends on a double, an integer, and the mesh, which could make caching very memory intensive. The caller of this function is responsible for determining whether or not the matrix should be cached.

◆ zero_lowest_modes()

const Matrix & Spectral::filtering::zero_lowest_modes ( const Mesh< 1 > &  mesh,
size_t  number_of_modes_to_zero 
)

Zeros the lowest number_of_modes_to_zero modal coefficients. Note that the matrix must be applied to a nodal representation.

Given a function \(u\)

\begin{align} u(x)=\sum_{i=0}^N c_i P_i(x), \end{align}

where \(c_i\) are the modal coefficients and \(P_i(x)\) is the basis (e.g. Legendre polynomials), the filter matrix will take the nodal representation of \(u\) and zero out the lowest number_of_modes_to_zero modal coefficients. That is, after the filter is applied \(u\to\bar{u}\) is

\begin{align} \bar{u}(x)=\sum_{i=k}^N c_i P_i(x), \end{align}

where \(k\) is the number of modes set to zero. The output \(\bar{u}\) is also in the nodal representation.