SpECTRE  v2026.09.05
Loading...
Searching...
No Matches
PowerMonitors Namespace Reference

Items for assessing truncation error in spectral methods. More...

Classes

struct  ConvergenceInfo
 Holds convergence rate and pile up modes of a power monitor. More...

Functions

template<typename VectorType, size_t Dim>
std::array< double, Dim > relative_truncation_error (const VectorType &tensor_component, const Mesh< Dim > &mesh)
 The relative truncation error in each logical direction of the grid.
ConvergenceInfo convergence_rate_and_number_of_pile_up_modes (const DataVector &power_monitor, size_t number_of_filtered_modes=0)
 Returns the convergence rate and the number of pile up modes of a power monitor as a ConvergenceInfo.
template<typename TensorType>
DataVector spherical_shell_tensor_radial_power_monitor (const TensorType &tensor, const Mesh< 3 > &mesh)
 Return the RMS radial power monitor across all components of a tensor on a spherical shell.
size_t spherical_shell_number_of_angular_coefficients (size_t ell, int spin_weight, bool zero_m_is_real, size_t radial_extents)
 Number of independent TensorYlm coefficients contributing to angular degree ell, summed over radial_extents radial points.
template<typename TensorType>
void accumulate_spherical_shell_tensor_angular_power (const gsl::not_null< DataVector * > weighted_squared_power, const gsl::not_null< std::vector< size_t > * > counts, const TensorType &tensor, const Mesh< 3 > &mesh)
 Accumulate weighted-squared angular TensorYlm power and mode counts for all components of a tensor on a spherical shell.
void normalize_spherical_shell_angular_power (gsl::not_null< DataVector * > power, const std::vector< size_t > &counts)
 Normalize an angular power monitor accumulator in place.
void accumulate_b3_tensor_component_sums (gsl::not_null< DataVector * > sum_sq_radial, gsl::not_null< DataVector * > counts_radial, gsl::not_null< DataVector * > sum_sq_angular, gsl::not_null< DataVector * > counts_angular, const double *spec_buf, size_t n_r, size_t n_r_max, int spin_weight, const std::vector< std::vector< size_t > > &offsets_by_l, double *gathered, double *modal_buf)
 Accumulate squared ZernikeB3 Jacobi spectral coefficients for one TensorYlm component into radial and angular power bins.
template<typename TensorType>
void accumulate_b3_tensor_sums (gsl::not_null< DataVector * > sum_sq_radial, gsl::not_null< DataVector * > counts_radial, gsl::not_null< DataVector * > sum_sq_angular, gsl::not_null< DataVector * > counts_angular, const TensorType &tensor, size_t n_r, size_t n_r_max, const std::vector< std::vector< size_t > > &offsets_by_l_real, const std::vector< std::vector< size_t > > &offsets_by_l_complex, double *gathered, double *modal_buf)
 Accumulate squared ZernikeB3 spectral coefficients for all components of a TensorYlm tensor into radial and angular power bins.
void normalize_b3_power (gsl::not_null< DataVector * > result, const DataVector &sum_sq, const DataVector &counts)
 Normalize a B3 power monitor accumulator in place.
template<typename VectorType, size_t Dim>
void power_monitors (gsl::not_null< std::array< DataVector, Dim > * > result, const VectorType &u, const Mesh< Dim > &mesh)
 Returns array of power monitors in each spatial dimension.
template<typename VectorType, size_t Dim>
std::array< DataVector, Dim > power_monitors (const VectorType &u, const Mesh< Dim > &mesh)
 Returns array of power monitors in each spatial dimension.
double relative_truncation_error (const DataVector &power_monitor, size_t num_modes_to_use)
 Compute the relative truncation error.
template<typename VectorType, size_t Dim>
std::array< double, Dim > absolute_truncation_error (const VectorType &tensor_component, const Mesh< Dim > &mesh)
 Returns an estimate of the absolute truncation error in each dimension.
void spherical_shell_radial_power_monitor (gsl::not_null< DataVector * > result, const DataVector &tensor_component, const Mesh< 3 > &mesh)
 Return the radial power monitor for a tensor component on a spherical shell.
DataVector spherical_shell_radial_power_monitor (const DataVector &tensor_component, const Mesh< 3 > &mesh)
 Return the radial power monitor for a tensor component on a spherical shell.
void spherical_shell_angular_power_monitor (gsl::not_null< DataVector * > result, const DataVector &tensor_ylm_component, const Mesh< 3 > &mesh, int spin_weight, bool zero_m_is_real)
 Return the angular power monitor for one TensorYlm component on a spherical shell.
DataVector spherical_shell_angular_power_monitor (const DataVector &tensor_ylm_component, const Mesh< 3 > &mesh, int spin_weight, bool zero_m_is_real)
 Return the angular power monitor for one TensorYlm component on a spherical shell.

Detailed Description

Items for assessing truncation error in spectral methods.

Function Documentation

◆ accumulate_b3_tensor_component_sums()

void PowerMonitors::accumulate_b3_tensor_component_sums ( gsl::not_null< DataVector * > sum_sq_radial,
gsl::not_null< DataVector * > counts_radial,
gsl::not_null< DataVector * > sum_sq_angular,
gsl::not_null< DataVector * > counts_angular,
const double * spec_buf,
size_t n_r,
size_t n_r_max,
int spin_weight,
const std::vector< std::vector< size_t > > & offsets_by_l,
double * gathered,
double * modal_buf )

Accumulate squared ZernikeB3 Jacobi spectral coefficients for one TensorYlm component into radial and angular power bins.

spec_buf has layout spec_buf[s * n_r + i_r] where s is the SPHEREPACK offset and i_r is the radial collocation index. Modes are binned radially via radial_mode = (n_total + 1) / 2 where n_total = l + 2 * k_spec, and angularly by degree \(\ell\). Modes with l < |spin_weight| are skipped.

offsets_by_l must be pre-computed for the correct zero_m_is_real value of this component. gathered and modal_buf are caller-owned scratch buffers of size max_n_modes_l * n_r each, where max_n_modes_l = 2 * (l_max + 1).

◆ accumulate_b3_tensor_sums()

template<typename TensorType>
void PowerMonitors::accumulate_b3_tensor_sums ( gsl::not_null< DataVector * > sum_sq_radial,
gsl::not_null< DataVector * > counts_radial,
gsl::not_null< DataVector * > sum_sq_angular,
gsl::not_null< DataVector * > counts_angular,
const TensorType & tensor,
size_t n_r,
size_t n_r_max,
const std::vector< std::vector< size_t > > & offsets_by_l_real,
const std::vector< std::vector< size_t > > & offsets_by_l_complex,
double * gathered,
double * modal_buf )

Accumulate squared ZernikeB3 spectral coefficients for all components of a TensorYlm tensor into radial and angular power bins.

Selects offsets_by_l_real for rank-0 (scalar) tensors and offsets_by_l_complex for all higher-rank tensors. The spin weight for each component is determined from the tensor structure.

◆ accumulate_spherical_shell_tensor_angular_power()

template<typename TensorType>
void PowerMonitors::accumulate_spherical_shell_tensor_angular_power ( const gsl::not_null< DataVector * > weighted_squared_power,
const gsl::not_null< std::vector< size_t > * > counts,
const TensorType & tensor,
const Mesh< 3 > & mesh )

Accumulate weighted-squared angular TensorYlm power and mode counts for all components of a tensor on a spherical shell.

Adds to weighted_squared_power and counts in place, so this can be called repeatedly to combine several tensors into the same angular power monitor before calling normalize_spherical_shell_angular_power.

◆ normalize_b3_power()

void PowerMonitors::normalize_b3_power ( gsl::not_null< DataVector * > result,
const DataVector & sum_sq,
const DataVector & counts )

Normalize a B3 power monitor accumulator in place.

Sets result[i] = sqrt(sum_sq[i] / counts[i]), or 0 when counts[i] == 0.

◆ normalize_spherical_shell_angular_power()

void PowerMonitors::normalize_spherical_shell_angular_power ( gsl::not_null< DataVector * > power,
const std::vector< size_t > & counts )

Normalize an angular power monitor accumulator in place.

Sets power[ell] = sqrt(power[ell] / counts[ell]), or 0 when counts[ell] == 0.

◆ relative_truncation_error()

template<typename VectorType, size_t Dim>
std::array< double, Dim > PowerMonitors::relative_truncation_error ( const VectorType & tensor_component,
const Mesh< Dim > & mesh )

The relative truncation error in each logical direction of the grid.

This overload is intended for visualization purposes only. It takes a tensor component as input, so it can be used as a kernel to post-process volume data with Python bindings (see TransformVolumeData.py).

◆ spherical_shell_angular_power_monitor() [1/2]

DataVector PowerMonitors::spherical_shell_angular_power_monitor ( const DataVector & tensor_ylm_component,
const Mesh< 3 > & mesh,
int spin_weight,
bool zero_m_is_real )

Return the angular power monitor for one TensorYlm component on a spherical shell.

The mesh dimensions are assumed to be ordered (radial, theta, phi), with l_max == m_max. TensorYlm coefficients use the radial dimension as the fastest-moving extent. As reviewed in Sec. II of [31], spin-weighted spherical harmonics with l < |spin_weight| vanish, so these modes are omitted from both the sum and its normalization. Set zero_m_is_real for real scalar coefficients, which have no imaginary m=0 coefficients in Spherepack storage.

◆ spherical_shell_angular_power_monitor() [2/2]

void PowerMonitors::spherical_shell_angular_power_monitor ( gsl::not_null< DataVector * > result,
const DataVector & tensor_ylm_component,
const Mesh< 3 > & mesh,
int spin_weight,
bool zero_m_is_real )

Return the angular power monitor for one TensorYlm component on a spherical shell.

The mesh dimensions are assumed to be ordered (radial, theta, phi), with l_max == m_max. TensorYlm coefficients use the radial dimension as the fastest-moving extent. As reviewed in Sec. II of [31], spin-weighted spherical harmonics with l < |spin_weight| vanish, so these modes are omitted from both the sum and its normalization. Set zero_m_is_real for real scalar coefficients, which have no imaginary m=0 coefficients in Spherepack storage.

◆ spherical_shell_number_of_angular_coefficients()

size_t PowerMonitors::spherical_shell_number_of_angular_coefficients ( size_t ell,
int spin_weight,
bool zero_m_is_real,
size_t radial_extents )

Number of independent TensorYlm coefficients contributing to angular degree ell, summed over radial_extents radial points.

Returns 0 when ell < |spin_weight|, since spin-weighted spherical harmonics vanish there (such terms are then excluded from accumulate_spherical_shell_tensor_angular_power()'s sum and normalization). See SpherepackIterator for the meaning of zero_m_is_real.

◆ spherical_shell_radial_power_monitor() [1/2]

DataVector PowerMonitors::spherical_shell_radial_power_monitor ( const DataVector & tensor_component,
const Mesh< 3 > & mesh )

Return the radial power monitor for a tensor component on a spherical shell.

The mesh dimensions are assumed to be ordered (radial, theta, phi). The radial grid points are contiguous, so each angular point supplies one radial slice to the one-dimensional modal transform.

◆ spherical_shell_radial_power_monitor() [2/2]

void PowerMonitors::spherical_shell_radial_power_monitor ( gsl::not_null< DataVector * > result,
const DataVector & tensor_component,
const Mesh< 3 > & mesh )

Return the radial power monitor for a tensor component on a spherical shell.

The mesh dimensions are assumed to be ordered (radial, theta, phi). The radial grid points are contiguous, so each angular point supplies one radial slice to the one-dimensional modal transform.

◆ spherical_shell_tensor_radial_power_monitor()

template<typename TensorType>
DataVector PowerMonitors::spherical_shell_tensor_radial_power_monitor ( const TensorType & tensor,
const Mesh< 3 > & mesh )

Return the RMS radial power monitor across all components of a tensor on a spherical shell.

Combines spherical_shell_radial_power_monitor for each of tensor.size() components in quadrature, normalized by the number of components.